On this page
- What can Claude Code do in a Salesforce project?
- How does Claude Code compare with and without Salesforce tools?
- How do you set up Claude Code with Salesforce, step by step?
- What does a worked example look like?
- What can go wrong, and how do you undo it?
- How do you keep Claude Code focused on Apex or LWC?
- What did Salesforce and Anthropic announce?
- When should you use Claude Code, and when something else?
- Sources
- Common questions about Claude Code and Salesforce
Claude Code for Salesforce development is a way to run Anthropic's coding agent in a DX project, for Apex and Lightning web component (LWC) developers. Since August 2026, an official Salesforce plugin lets it test and deploy through the Salesforce CLI (sf). Claude Pro and Max plans include Claude Code, per the Claude Help Center.
Working with Claude Code in a real org? Clientell AI, the AI Salesforce admin, gives Claude Code the org context it lacks: metadata, dependencies and safe deploys. The Clientell MCP server (MCP is Model Context Protocol, the standard that lets AI clients call org tools) reads your org in read-only mode, and you approve every change. Run the free read-only health check to see it on your own org.
Start the 14-day trial (no card) and connect a client sandbox.
What can Claude Code do in a Salesforce project?
Claude Code reads your project files, edits them and runs commands, as the Claude Code docs describe. In a DX project with sfdx-project.json and a force-app folder, that covers four jobs:
- Write code: Apex classes, triggers, test classes, and Lightning web components.
- Run the CLI:
sf project retrieve start,sf apex run testandsf project deploy start. - Query the org: SOQL (Salesforce Object Query Language) through the CLI or an MCP server.
- Add checks: hooks (scripts that run before or after a tool call) can block a deploy to any org but your sandbox.
The official plugin ties these together. The Salesforce development plugin for Claude Code bundles skills, the CLI, MCP servers, hooks and commands in one install. You approve installs and review changes before they apply.
Takeaway: Claude Code is a developer tool. It does not build Flows visually or manage permissions across an org.
How does Claude Code compare with and without Salesforce tools?
Claude Code alone sees only local files such as force-app/main/default/classes. Each tool you add shows it more of your org.
Swipe sideways to see all columns
| Setup | What Claude Code can see | Best for | Main gap |
|---|---|---|---|
| Claude Code alone | Local project files | Writing Apex and tests | No org data, so it guesses field names |
| With the Salesforce CLI | Org metadata and SOQL results through sf | Retrieve, test and deploy | Each fact needs a command you approve |
| With the Salesforce plugin | CLI plus Salesforce skills and hosted MCP servers | Guided development in a DX project | Built for developers, not admin tasks |
| With Clientell MCP | Org map: objects, fields, flows, permissions | Impact checks and admin work | Needs a Clientell AI account |
| Source | Salesforce plugin announcement |
The trade-off: more access means more to review. Start with sf alone. Add an MCP server once Claude Code guesses a field name wrong, such as Opportunity.NextStep__c for a field that does not exist.
Which setup should you pick? A decision rule
Pick the first row that matches your work.
Swipe sideways to see all columns
| If you mostly | Use | Stop signal |
|---|---|---|
| Write Apex classes and test classes | Claude Code with sf only | It guesses a field API name twice |
| Build Lightning web components against live data | Add the Salesforce plugin and hosted MCP servers | You need data from more than one org |
| Change flows, permission sets and validation rules | Clientell MCP, in Claude Code or another client | You need a full CI/CD (automated build and release) pipeline for many developers |
| Run releases for a dev team | Claude Code plus a DevOps tool | Deploys need a second approver |
| Source | Hosted MCP servers GA |
The limit to plan around: hosted MCP servers need Enterprise Edition or above in production, while every Developer Edition org includes them, per the Salesforce Developers blog.
How do you set up Claude Code with Salesforce, step by step?
Do this in a sandbox (Setup > Sandboxes) or a free Developer Edition org, never in production. Since 15-04-2026, every Developer Edition org includes Salesforce hosted MCP servers at no cost, per the Salesforce Developers blog.
-
Install the tools. Install Node.js LTS, Python 3 (the plugin's safety hooks use it), the Salesforce CLI and Claude Code, as the plugin announcement lists. Check them with
sf --versionandclaude --version. Ifsfis not found, restart the terminal so the path updates. -
Log in to a sandbox.
sf org login webopens a browser login for the sandbox and saves it asDevSandbox.sf org listthen shows the alias with a default marker.sf org login web --alias DevSandbox --set-default sf org list -
Open your DX project. No project yet? Run
sf project generate --name sf-claudeand open the folder in VS Code. Then runclaudein the project folder, the one withsfdx-project.json. Then ask it to runsf org listand name the default org. Expected result: it namesDevSandbox. If it names production, stop and fix the default withsf config set target-org DevSandbox. -
Add the Salesforce plugin. Inside Claude Code, run the
/plugin installcommand from the Salesforce announcement:/plugin install salesforce-development@claude-plugins-official -
Connect an MCP server. MCP (Model Context Protocol) is the open standard that lets Claude read your org. You have three choices:
- The Salesforce DX MCP Server, run locally with
npx -y @salesforce/mcp, as the plugin docs show. Its end-of-life date is 2 November 2026, per the salesforcecli/mcp README. Hosted MCP servers are a separate Salesforce product. See what the DX MCP end of life means. - Salesforce hosted MCP servers, generally available since 29-04-2026 per the Salesforce Developers blog. Each call runs as the signed-in user.
- Clientell MCP, which adds the org map and safe writes. It works in Claude Code, Cursor, Codex and VS Code.
- The Salesforce DX MCP Server, run locally with
The expected result: Claude Code can list your sandbox with sf org list and answer a SOQL question about Account without guessing.
Takeaway: the --set-default alias keeps Claude Code pointed at the sandbox, not production.
What does a worked example look like?
For example, a RevOps team wants a trigger that sets Opportunity.NextStep when Opportunity.StageName changes. Here is the loop in a sandbox.
-
Ask for the plan first. Prompt: "Read the Opportunity object in DevSandbox. Plan an Apex trigger that sets NextStep when StageName changes. Do not edit files yet."
-
Check the facts. Ask Claude Code to run
sf sobject describe --sobject Opportunity --target-org DevSandbox. It then uses real field API names. -
Let it write the code. It creates the trigger, a handler class and a test class.
-
Run the tests.
sf apex run test --target-org DevSandbox --test-level RunLocalTests --wait 10 -
Validate the deploy. A dry run checks the deploy and saves nothing:
sf project deploy start --source-dir force-app --target-org DevSandbox --dry-run -
Deploy to the sandbox, then review the diff. Remove
--dry-runonly after the check passes. If the dry run fails with a missing field error, fix the field name in the trigger and run it again. The expected result: the sandbox shows the trigger under Setup > Apex Triggers and the handler under Setup > Apex Classes, andOpportunity.NextStepupdates when you moveStageNamein the sandbox.
A Salesforce walkthrough, Build Production-Ready Apps in Claude Code with Salesforce Skills, builds an Account form with a Lightning web component, an Apex controller and test classes.
What can go wrong, and how do you undo it?
Claude Code can write a trigger that passes its own tests and still updates the wrong Opportunity records. Plan the undo before the first deploy.
Swipe sideways to see all columns
| Risk | How it shows up | Undo or prevent |
|---|---|---|
| Wrong target org | A deploy hits production | Use --target-org DevSandbox every time; keep production out of the CLI |
| Guessed field names | Deploy fails on Opportunity fields | Run sf sobject describe first |
| Tests pass, behavior is wrong | A trigger fires on every update | Review the diff; test with real Opportunity stage changes |
| Overwritten metadata | A retrieve replaces a local edit | Commit to git before each Claude Code session |
| Bad deploy | Metadata is live in the org | Redeploy the last good commit; deploys have no built-in one-step undo |
| Source | Salesforce plugin docs |
Three habits cover most of it. Work in a sandbox or scratch org (a short-lived org built from source). Use --dry-run before every real deploy. Commit to git so you can redeploy the last good version.
Clientell AI asks before it changes anything in production. See how Clientell AI security works. On the Clientell Platform, each deploy has an approval step and a rollback.
Try it in Clientell AI: "Using the Clientell MCP, show me every flow that writes to Opportunity.Amount, in read-only mode, and explain what each one does." Start the 14-day trial, no card. The Clientell MCP costs $249 a month for 1 org and 10 people. The Clientell Platform costs $500 a month. See pricing.
How do you keep Claude Code focused on Apex or LWC?
Give Claude Code a project instructions file next to sfdx-project.json, short enough to read in a minute. Four rules work well:
- Name the sandbox alias (
DevSandbox) and forbid any other--target-org. - Require a test class for every Apex class, with assertions on
Opportunity.StageNameor the field you changed. - Keep triggers thin: one trigger per object that calls a handler class.
- For Lightning web components, ask for files under
force-app/main/default/lwconly, and runsf project deploy start --dry-runbefore you commit.
For Apex, the common failure is a query inside a loop, which hits governor limits (Salesforce's per-transaction caps). Ask Claude Code to bulkify (handle many records at once) every trigger and test it with 200 Opportunity records, the standard trigger batch size per the Apex developer guide.
What did Salesforce and Anthropic announce?
The two companies announced Claudeforce on 26-08-2026. It is an expanded partnership that includes a Salesforce plugin for Claude, per the Salesforce press release. It targets sellers and agents who work inside Claude. Developers use the separate development plugin above. For how general AI compares with Salesforce-specific AI, read general AI vs Salesforce AI tools.
When should you use Claude Code, and when something else?
Claude Code fits a developer who writes Apex, LWC and tests in a DX project and has a deploy pipeline.
An admin tool fits Flow edits, data cleanup and permission changes across an org. See Clientell AI vs Claude Code and the best AI tools for Salesforce.
Many teams use both: Claude Code writes the Opportunity trigger, and Clientell AI checks which flows and reports it touches. Read how a Salesforce consultant sped up org diagnosis with Clientell AI.
Common questions about Claude Code and Salesforce
Can Claude Code connect to my Salesforce org?
Yes. Claude Code connects through the Salesforce CLI after sf org login web, or through an MCP server. Access follows the Salesforce user you log in as, so use a sandbox user first.
Which Claude plan do I need for Claude Code?
Pro and Max plans include Claude Code, per the Claude Help Center. The free plan does not. Usage limits are shared with the Claude app.
Is Claude Code safe for production Salesforce orgs?
Use a sandbox first and validate with sf project deploy start --dry-run. Claude Code does not add an approval trail or a one-step undo, so keep your own git history.
Can Claude Code build Salesforce Flows?
It can write Flow metadata as XML, but it does not use the visual Flow Builder. Review any Flow it generates before you deploy it.
What is the Salesforce development plugin for Claude Code?
It is the official plugin from Salesforce. It packages skills, the CLI, MCP servers, hooks and commands, per the plugin docs.
Does Claude Code replace a Salesforce admin?
No. It speeds up code work. Daily admin tasks such as flows, data and permissions still need an admin or an admin tool.
Start the 14-day trial (no card) and connect a client sandbox.
Sources
Salesforce documentation
- Headless Development with Skills and a Claude Code Plugin
- New in Developer Edition: Agentforce Vibes, Claude and MCP
- Hosted MCP Servers Are Now Generally Available
- Build Production-Ready Apps in Claude Code with Skills
- Apex Triggers and Bulk Requests, Apex Developer Guide
- Claudeforce announcement, Salesforce press release
Industry research
Last reviewed October 2026
Last updated: October 28, 2026




