Agentforce Vibes — AI 驱动的代码排查与重构搭档(练习操作步骤)

《Agentforce Vibes — AI 驱动的代码排查与重构搭档》的分步练习操作指南。...

📅 2026/10/2 ✍️ ponybai 🏷️ agentforce, salesforce, developer

本文是《Agentforce Vibes — AI 驱动的代码排查与重构搭档》的练习操作步骤。阅读原文请见:Agentforce Vibes — AI 驱动的代码排查与重构搭档。

1. Reproduce the Bug

  1. Return to your playground and open the App Launcher, then select Agentforce Adventure Tools.
  2. In the Quick Dice Roller, click a die button (for example, 1 D20).
  3. Notice the toast says the roll is saved, but the sum shows as undefined.

2. Confirm Your Connection

  1. In the Agentforce Vibes tab, click Start a New Task.
  2. Ask: What is the username of the Salesforce Org I'm currently connected to?
  3. Press enter/return (approve commands if prompted).
  4. Confirm the correct username appears.

3. Retrieve the Source

  1. Open the Files Explorer (Ctrl+Shift+E / Cmd+Shift+E).
  2. Ensure the manifest folder with package.xml exists (create both if missing).
  3. Replace manifest/package.xml with the provided contents and save.
  4. Click the Agentforce icon and Start a New Task.
  5. Ask: Please retrieve the source from my default org based on the manifest file.
  6. Confirm DiceRollService (in force-app/main/default/classes) and diceRoller (in force-app/main/default/lwc) are retrieved.

4. Format the Code

  1. In the search bar, enter DiceRollService.cls and select it.
  2. Click the Agentforce icon and Start a New Task.
  3. Ask: Please format the DiceRollService class using prettier-plugin-apex. If the plugin is not installed, install it using npm and then use the npx prettier --write command.
  4. Press enter/return (approve/allow commands as prompted).
  5. Review the suggestions, ignore the Problems tab, and save with Ctrl+S / Cmd+S.

5. Fix the Bug

  1. Click Start a New Task and paste the provided bug-fix prompt.
  2. Press enter/return and review what Agentforce returns.
  3. If the fix is correct, accept the change and click Save / Run Command as prompted.

6. Deploy and Test

  1. Click Start a New Task and ask: Deploy the DiceRollService.cls class to my default org.
  2. Approve commands as prompted.
  3. Refresh the Agentforce Adventure Tools page.
  4. Add a modifier and roll the dice a few times; confirm totals and sums now display correctly.
  5. (Optional) Open the Dice Rolls tab → All Rolls List View to see recent rolls.

7. Improve the Code (Remove @track)

  1. Open the diceRoller.js file (search diceRoller.js).
  2. Click Start a New Task and paste the provided @track-removal prompt.
  3. Press enter/return and review the suggestions.
  4. Click Save and confirm the variable is renamed and getter/setter created.
  5. Click Start a New Task and ask: Deploy the diceRoller LWC to my default org.
  6. Return to the app and retest the Quick Dice Roller.