Guide to Quickly Building Agentforce Agents in VS Code

Guide to Quickly Building Agentforce Agents in VS Code

In today’s fast-paced development landscape, efficiency and automation are key. If you’re working with Salesforce, you know that maximizing your productivity can make all the difference. That’s where Agentforce comes in – a powerful tool that can streamline your processes and enhance your development experience.

This blog post will walk you through the essential steps to get started with Agentforce, from updating your Salesforce DX to previewing and managing your agents. By following this guide, you’ll be well on your way to leveraging the full potential of Agentforce in your Salesforce projects.

Let’s dive in!

Agentforce DX VS Code extension help us to quickly create, test and also preview Agentforce Agents from the IDE.

Step 1: Keep Your Salesforce DX Up-to-Date

Before we begin, ensure your Salesforce DX is running the latest version. This guarantees you have access to the newest features and improvements, critical for a smooth Agentforce experience.

sf update

This simple command will update your Salesforce DX to the latest release, setting the stage for everything that follows.

Step 2: Install the Agentforce DX VS Code Extension

For an integrated and efficient development experience, the Agentforce DX VS Code extension is a must-have.

For most users:

https://marketplace.visualstudio.com/items?itemName=salesforce.salesforcedx-vscode-agents

If you are using Code Builder:

https://open-vsx.org/extension/salesforce/salesforcedx-vscode-agents

Installing this extension provides crucial tooling and a seamless interface within your VS Code environment.

Step 3: Generate Your Agentforce Agent Specification

The heart of your Agentforce agent lies in its specification. This step guides you through creating the foundational YAML file that defines your agent’s behaviour.

sf agent generate agent-spec

a. Enter all the details: Follow the prompts to provide the necessary information for your agent. Be thoughtful here, as these details will shape your agent’s functionality.

b. Verify the generated YAML file: After generation, take a moment to review the agent-spec.yaml file. Ensure that all the details are accurate and reflect your intended agent design. This verification step is crucial for preventing future issues.

Step 4: Create Your Agentforce Agent

With your agent specification defined, it’s time to bring your agent to life!

sf agent create

You’ll be prompted to enter additional details to finalize the creation of your agent. This command deploys your agent based on the specification you just generated.

Step 5: Open Your Created Agent in the Browser

Want to see your agent in action? This command allows you to open your newly created Agentforce agent directly in your browser.

sf org open agent --api-name <API NAME OF THE AGENT> -b chrome

Example:

sf org open agent --api-name MyAgent17 -b chrome

Replace <API NAME OF THE AGENT> with the actual API name you assigned to your agent. This is a great way to quickly interact with and test your agent.

Step 6: Preview Your Agent in VS Code

For a more integrated preview experience within your development environment, you can preview your agent directly in VS Code.

sf agent preview --api-name "<API NAME OF THE AGENT>" --target-org <SALESFORCE ORG ALIAS> --connected-app-user <SALESFORCE USERNAME>

Example:

sf agent preview --api-name "MyAgent17" --target-org AgentforceDE --connected-app-user [email protected]

This command provides a powerful way to interact with and debug your agent in a real-time, sandboxed environment, connected to your Salesforce org.

Step 7: Delete Your Agentforce Agent (If Needed)

There might come a time when you need to remove an Agentforce agent. This command provides a clean way to delete an agent from your Salesforce project.

sf project delete source --metadata Agent:<API NAME OF THE AGENT>

Example:

sf project delete source --metadata Agent:MyAgent17

Always ensure you’re deleting the correct agent by double-checking the API name.

Conclusion

By following these steps, you’ve gained a solid understanding of how to work with Agentforce, from initial setup to creation, preview, and even deletion. Agentforce offers an exciting avenue to enhance your Salesforce development, enabling you to build more efficient and powerful solutions.

Start experimenting with Agentforce today and discover how it can transform your Salesforce development journey! If you have any questions or run into any issues, feel free to leave a comment below. Happy coding!

For Agent commands, please check the following:
https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_agent_commands_unified.htm

Salesforce Article:
https://developer.salesforce.com/blogs/2025/05/introducing-agentforce-dx-pro-code-tools

Leave a Reply