Skip to main content

Seamlessly Interact with Agentforce as You Code

Learning Objectives

After completing this unit, you’ll be able to:

  • Access Agentforce.
  • Explain how Agentforce can help you write code.
  • Explain how to use Rules and Workflows for consistent development.

Get to Know Agentforce

Agentforce is your intelligent development partner that transforms how you build on Salesforce. Unlike traditional chatbots, Agentforce doesn't just provide information—it takes action. Through agentic chat powered by Model Context Protocol (MCP), Agentforce can execute commands and perform complex workflows automatically, right from within Visual Studio Code.

Agentforce represents the evolution of AI-powered development assistance. When you chat with Agentforce, you’re not just getting code suggestions—you’re getting a coding partner that can understand your project context, execute tools on your behalf, and help you complete entire development workflows through natural language conversations.

To get to the chat screen, click the Agentforce Vibes icon in the Activity Bar. Once you’re in, Agentforce knows what you're working on and keeps up with the conversation. It even suggests code based on what you write and the file you’re working on in your VS Code editor. If you need more help, just continue chatting with Agentforce to get an even better response.

VS Code window with Agentforce

Try These Sample Conversation Starters

Here are simple prompts that showcase how Agentforce uses the Salesforce DX MCP server to take action and understand your org context.

Org-Aware Development

  • “Create an Apex class for Account management that follows my org's existing patterns"
  • "Generate a Lightning web component for Contact search using my org's custom fields"
  • "Build a trigger for Opportunity that matches my org's naming conventions"

Smart Code Generation

  • "Create comprehensive unit tests for my AccountService class"
  • "Build an Apex method that validates data based on my org's validation rules"

Context-Aware Assistance

  • "Explain why this SOQL query might be slow in my org and suggest improvements"
  • "Review my Apex class and suggest security improvements based on my org's sharing model"
  • "Help me understand the relationships between my custom objects"

These prompts show how Agentforce uses your org's metadata and structure to provide intelligent, contextual assistance.

Use Rules and Workflows

Agentforce Rules allow you to establish consistent coding standards and project-specific preferences that Agentforce follows throughout your development sessions. Rules work as persistent instructions that help maintain consistency across your development work and ensure your team follows the same patterns.

Key Benefits

  • Enforce coding patterns and architectural decisions automatically.
  • Maintain consistent naming conventions and code structure.
  • Share development practices across your team.
  • Ensure adherence to security and documentation standards.

Example Rules

  • Use PascalCase for Apex class names (for example, AccountService, OpportunityTriggerHandler)
  • Use kebab-case for Lightning web component names (for example, account-detail, product-search)
  • Follow your org's specific trigger naming patterns and error handling approaches

You can create rules through Agentforce's interface or by using the /newrule command in chat.

Add Context for Better Results

To get the most out of Agentforce, provide relevant context about your project, requirements, and coding standards. You can reference existing code files, describe business logic, mention specific Salesforce features you’re working with, and explain the intended functionality. The more context you provide, the more accurate and relevant the generated code will be. Agentforce can understand your project structure and maintain consistency with your existing codebase when given proper context.

Resources

Compartilhe seu feedback do Trailhead usando a Ajuda do Salesforce.

Queremos saber sobre sua experiência com o Trailhead. Agora você pode acessar o novo formulário de feedback, a qualquer momento, no site Ajuda do Salesforce.

Saiba mais Continue compartilhando feedback