AI Engineering t ≈ 12 min

How to Build Salesforce Agent Scripts with Claude Code in Zero Shots

Generate 200-line Salesforce agent scripts from a single prompt. No MCP tools. No manual YAML. Just skills and context efficiency.

yfx(m)

yfxmarketer

December 26, 2025

You can generate a complete Salesforce agent script from a single prompt. No manual YAML files. No MCP tool overhead. Just Claude Code with the right skills installed. This post walks through the exact workflow that produces 200-line agent scripts, validates them, deploys them, and activates them in one session.

The key is context efficiency. Salesforce metadata is massive. Load everything into memory and you exhaust your token budget before generating anything useful. The skill-based approach uses progressive disclosure to pull only what the agent needs, when it needs it.

TL;DR

Install the SF skills plugin for Claude Code. Use plan mode to get a fresh 200k token context window. Let Claude Code read the skill files progressively. The agent generates agent scripts, flows, and connected apps without manual intervention. Zero MCP tools required.

Key Takeaways

  • Plan mode gives you a fresh 200k token context window for complex tasks
  • Progressive disclosure prevents context pollution from massive Salesforce metadata
  • Claude Code generates agent scripts, validates, deploys, and activates in one session
  • Skills link together so flow generation happens automatically when scripts need it
  • The SF skills repo is open source and covers agent scripts, flows, connected apps, and deployments

Why Context Efficiency Matters for Salesforce

Salesforce metadata is enormous. The SF skills directory contains dozens of files and folders. Loading everything into memory exhausts your context budget before you write a single line of code.

The actual usable context is not 200,000 tokens. Claude Code reserves space for system instructions and compaction. Real working budget is closer to 120,000 to 130,000 tokens. Some configurations drop this to 60% of the advertised limit.

Progressive disclosure solves this. The skill files are structured so Claude Code reads only what it needs. When you request an FAQ agent, it loads the FAQ template. When you need a service agent with flows, it loads flow generation instructions. Nothing extra enters the context.

What This Means for Operators

Every complex Salesforce automation you build faces the same constraint. CRM workflows, data integrations, and agent configurations all compete for context space. The teams that master progressive disclosure will build more sophisticated automations than teams that dump everything into prompts.

The pattern applies beyond Salesforce. Any domain with extensive documentation benefits from skill-based progressive loading. Legal contracts, financial compliance, healthcare protocols. Structure your reference materials as skills and let the agent pull what it needs.

Action item: Audit your current Salesforce prompts. Identify any prompt that pastes entire documentation sections. Refactor those into separate skill files that load on demand.

The Zero-Shot Agent Script Workflow

Step 1: Install the SF Skills Plugin

The SF skills plugin installs through the Claude Code plugin directory. Once installed, you get skills for agent scripts, flows, connected apps, data operations, deployments, diagrams, integrations, and metadata handling.

Each skill is designed for the Salesforce ecosystem. The agent force skill handles agent script generation. The flow skill handles flow creation and deployment. The deploy skill manages metadata deployment. Skills link together so Claude Code invokes the right one based on your requirements.

Action item: Open Claude Code and navigate to the plugins directory. Search for SF skills or point to the open source SF skills repository. Install all available skills. Verify installation by checking the installed skills list.

Step 2: Start in Plan Mode

Plan mode is critical for context efficiency. When you invoke plan mode, Claude Code spawns a planning sub-agent with its own fresh 200,000 token context window. The planning work happens in isolation. Only the final plan returns to your main thread.

This prevents context pollution. Complex planning requires reading documentation, exploring options, and reasoning through decisions. Without plan mode, all of that exploration consumes your main context budget. With plan mode, you preserve your main context for actual code generation.

The plan gets saved as a markdown file under the plans directory. You can reference it later, share it with teammates, or use it as documentation for what the agent decided and why.

Action item: For your next complex Salesforce task, start with plan mode enabled. Compare the context consumption to running the same task without plan mode. Note how much context budget you preserve for actual generation.

Step 3: Provide Requirements

Give Claude Code your requirements in plain language. Specify the org alias and default username. Describe what the agent should do. You do not need to design individual topics or actions. Let the agent propose a structure based on your requirements.

Example prompt: “Create a new agent script to demonstrate a simple FAQ agent. Make up product details and necessary information. Use the SF AI agent force skill. Deploy to the agent-force-script-org.”

The agent reads your requirements, explores the skill documentation, and proposes topics like product information, shipping, warranty, compatibility, setup, and support. It decides when to use flows versus inline instructions. It determines variable structures and escalation paths.

Action item: Write a requirements prompt for an agent you need. Include the org alias, username, and high-level purpose. Do not specify topics or actions. Let Claude Code propose the structure. Review its suggestions before approving.

Step 4: Let Claude Code Execute

Once you approve the plan, Claude Code generates the agent script, validates it against Salesforce, deploys it, publishes it, and activates it. A 200-line agent script from zero to deployed in one session.

The agent creates the .agent file and the bundle metadata XML. It skips the traditional YAML intermediate step. Direct generation is faster and reduces potential syntax errors from format conversion.

If the script requires flows, Claude Code invokes the flow skill automatically. It creates the flow, validates it, and deploys it before generating the agent script. This handles metadata dependencies correctly. Agent scripts that reference flows will fail validation if the flows do not exist yet.

Action item: Run your first zero-shot agent generation. Use a simple FAQ agent as a test case. Watch the execution to understand the sequence: skill loading, plan generation, script creation, validation, deployment, activation.

How Progressive Disclosure Works

The SF skills directory contains extensive documentation. Templates for different agent types. Syntax references. Block ordering rules. Callback patterns. Lifecycle patterns. Common errors and fixes.

Claude Code does not load all of this at once. When you request an FAQ agent, it reads the FAQ template. When you request a service agent with case tracking, it reads the service agent template and the flow generation instructions.

The skill files use a structure that guides Claude Code to the right content. A main skill.md file provides an overview. Reference folders contain templates organized by use case. Claude Code navigates this structure based on your requirements.

This is reinforcement learning through human feedback applied to documentation. Each template encodes lessons learned from previous failures. Common spacing issues, variable linking problems, transition syntax errors. The templates teach Claude Code how to avoid these mistakes.

Action item: Explore the SF skills repository structure. Read the main skill.md for agent force. Browse the reference templates. Understand how the documentation is organized so you can extend it with your own patterns.

Why This Beats Stuffing Context

Traditional approaches paste entire documentation sets into prompts. This works for small domains. It fails for Salesforce-scale metadata.

Skill-based loading scales to any documentation size. Add new templates without increasing baseline context consumption. Update individual skills without rewriting your entire prompt library. Share skills across teams and projects.

The SF skills repo demonstrates this at scale. Agent scripts, flows, connected apps, deployments, diagrams, integrations, metadata handling. Each skill loads independently. Claude Code composes them based on task requirements.

Action item: Take one large documentation file you currently paste into prompts. Split it into a skill with a main overview and reference templates. Test whether the skill-based version produces equivalent outputs with lower context consumption.

What the Agent Actually Generates

A typical FAQ agent script includes system instructions, default configuration, linked variables, language settings, and a topic selector that routes conversations to the right topic.

Each topic contains reasoning instructions, actions, and transitions. The agent generates natural language instructions that guide the Salesforce agent’s behavior. It creates transitions that move users between topics based on their questions.

For the example FAQ agent, Claude Code generated topics for product information, shipping and returns, warranty support, and escalation. Each topic had appropriate instructions and transitions. The total output was 200 lines of properly formatted agent script.

The agent also handles technical requirements like spacing consistency. Salesforce agent scripts are sensitive to indentation. Mixed tabs and spaces cause parser errors. Claude Code maintains consistent formatting throughout the generated script.

Action item: After generating your first agent script, open the .agent file and review the structure. Identify the topic selector, individual topics, transitions, and variable definitions. Understanding the output helps you write better requirements.

Handling Complex Dependencies

Service agents need flows. Flows that create cases, retrieve customer information, or update records. These flows must exist before the agent script can reference them.

Claude Code handles this dependency chain automatically. When your requirements indicate flow needs, it invokes the SF flow skill. It generates the flow, validates it, and deploys it. Then it returns to agent script generation with the flow available for reference.

The flow generation is sophisticated. Input and output variables are configured correctly. Assignment elements set output variables so data returns to the agent script. The flow deploys successfully before the agent script attempts to reference it.

This is the linked skills pattern. The agent force skill links to the flow skill. The flow skill links to the deploy skill. Claude Code follows these links based on task requirements. You describe what you want. The agent figures out which skills to invoke and in what order.

Action item: Test the dependency chain by requesting a service agent that creates cases. Verify that Claude Code generates and deploys the flow before attempting to generate the agent script. Check that the flow’s output variables are correctly configured for the agent script to consume.

Testing the Generated Agent

Once deployed, the agent is available in Salesforce for testing. The preview mode lets you interact with the agent and verify topic transitions work correctly.

Test by asking questions that should trigger different topics. Ask about products to test the product information topic. Ask about shipping to verify the transition from product info to shipping. Ask about warranty to test another transition path.

Salesforce provides trace logs that show which topics activated and why. You can see the reasoning the agent used to select topics and the transitions it followed. This helps debug issues when the agent does not behave as expected.

The current workflow requires manual testing in Salesforce. Future iterations could add recursive testing loops where Claude Code reviews trace logs, identifies issues, and auto-fixes agent script problems.

Action item: Create a test script for your generated agent. List 10 questions that should trigger specific topics or transitions. Run through the test script in Salesforce preview mode. Document any failures for refinement.

The Open Source SF Skills Repo

The SF skills repository is open source. It covers the core Salesforce development workflows for AI-assisted generation.

Current skills include:

  • SF AI Agent Force: Agent script generation and management
  • SF Flow: Flow creation, validation, and deployment
  • SF Connected Apps: Connected app and external client app generation
  • SF Deploy: Metadata deployment orchestration
  • SF Data: Data operations and queries
  • SF Diagrams: Architecture and flow diagrams
  • SF Integrations: External system connections
  • SF Metadata: Metadata exploration and management

The skills link together through a sub-agent architecture. A DevOps architect sub-agent handles deployments. It invokes the SF deploy skill and manages the deployment sequence across multiple metadata types.

Action item: Clone the SF skills repository. Review the skill structure for one skill you plan to use frequently. Identify any gaps where your org has patterns not covered by the existing templates.

Extending the Skills

The repo includes a skill builder for creating new Salesforce-specific skills. If your org has custom patterns or specialized requirements, you can build skills that encode your team’s knowledge.

Each skill follows the same structure. A main skill.md overview. Reference templates organized by use case. Examples that demonstrate correct usage. Error patterns and fixes learned from real implementations.

Contributing back to the repo helps the entire Salesforce community. Your edge cases become templates that prevent others from hitting the same issues.

Action item: Identify one pattern your team uses repeatedly that is not in the SF skills repo. Create a skill for it following the existing structure. Test the skill on a real project. Consider contributing it back to the open source repo.

Practical Workflows for Salesforce Teams

Greenfield Agent Development

Start with requirements in plain language. Describe the agent’s purpose, the topics it should handle, and any integration requirements. Let Claude Code propose a structure. Review the plan. Approve and execute.

A complete agent from requirements to deployed in under 30 minutes. Traditional development takes days for the same scope.

Action item: Time your next greenfield agent development. Compare the duration to your previous manual approach. Document the time savings to justify further investment in skill development.

Modifying Existing Agents

Point Claude Code at an existing agent script. Describe the changes you want. The agent reads the current implementation, proposes modifications, and generates an updated script.

This works for adding topics, modifying transitions, updating instructions, or connecting new flows. The agent maintains consistency with existing patterns while implementing your changes.

Action item: Take an existing agent that needs updates. Point Claude Code at the current script and describe the changes. Compare the generated output to what you would have written manually.

Multi-Agent Architectures

Complex implementations need multiple agents with different specializations. A service agent for case management. A sales agent for product inquiries. A support agent for technical issues.

Claude Code can generate each agent following consistent patterns. Shared skills ensure the agents use compatible structures. Transitions between agents work because they follow the same conventions.

Action item: Map your org’s agent requirements. Identify which specializations need separate agents. Generate each agent using the same skills to ensure consistency across your multi-agent architecture.

Why This Matters for Growth Teams

Salesforce implementations gate revenue operations. Slow development means delayed campaigns, manual workarounds, and missed opportunities. Fast generation changes the economics of what you can automate.

An FAQ agent that took a week to build now takes an afternoon. A service agent with case integration that took a sprint now takes a day. The constraint shifts from development capacity to imagination.

Action item: List three Salesforce automations you have delayed due to development capacity. Estimate how long each would take with zero-shot generation. Prioritize the highest-impact automation for your first production use of this workflow.

Building Your Salesforce Skill Library

Start with the open source SF skills repo. Add skills for your org’s custom patterns. Encode your team’s knowledge about what works and what fails.

Every skill you build compounds. New team members inherit working patterns immediately. Consultants can generate org-specific implementations without learning your conventions from scratch. The gap between experienced developers and everyone else shrinks.

Action item: Schedule a team session to identify your org’s top five Salesforce patterns. Assign one pattern per team member to convert into a skill. Review and refine the skills together. Deploy them to your shared Claude Code configuration.

What Comes Next

The current workflow generates agent scripts, flows, and connected apps. Apex generation is in progress. Once complete, Claude Code will have full discretion to choose flows versus Apex based on requirements.

Recursive testing loops will close the feedback cycle. Claude Code reviews trace logs, identifies issues, and auto-fixes problems. The agent improves its own output without human intervention.

The broader pattern is clear. Skill-based progressive disclosure scales to any complex domain. Salesforce is one implementation. The same architecture works for any platform with extensive metadata and documentation.

Action item: Follow the SF skills repository for updates on Apex generation and recursive testing. Plan how you will integrate these capabilities into your workflow when they become available.

Final Takeaways

Plan mode gives you a fresh context window. Use it for any complex generation task. The planning sub-agent preserves your main context budget for actual code generation.

Progressive disclosure prevents context pollution. Structure your documentation as skills. Let Claude Code load what it needs based on task requirements.

Skills link together for complex workflows. Agent scripts that need flows invoke flow skills automatically. Dependency chains resolve without manual intervention.

Zero-shot generation is possible with good skills. The SF skills repo demonstrates this for Salesforce. The pattern generalizes to any domain with structured documentation.

Context efficiency determines what you can build. Master progressive disclosure and you can generate implementations that would exhaust traditional approaches.

yfx(m)

yfxmarketer

AI Growth Operator

Writing about AI marketing, growth, and the systems behind successful campaigns.

read_next(related)