How to Connect Salesforce to Claude Code
Claude Code can look up a Salesforce account without holding the password. A sandbox org and the live company org are different logins, and Claude should not invent the API version.
Key takeaways
- -In this article we explore how to connect Salesforce to Claude Code without putting the Salesforce login in the chat.
- -To understand how a Salesforce sandbox org differs from production: a sandbox is a practice copy with its own login. The live company org is where real customer records sit.
- -Swytchcode's test mode, set with swy init --mode=sandbox, is a separate switch. It does not by itself point you at a Salesforce sandbox org.
- -Salesforce puts a version in the request path. Use the action swy discover prints. Do not let Claude invent a version number.
- -The Salesforce login is stored with swy auth connect salesforce, outside the chat. Downloading Salesforce does not turn every action on.
You want Claude Code to look up an account, see which deals have gone quiet, or add a note, without you clicking through Salesforce for every question. That is a good use of an assistant. The login should stay out of the chat.
Two mix-ups cause the real trouble. One is practicing in the live company org. The other is letting Claude guess which version of Salesforce's API to call.
If you have not used Swytchcode before, the next section is the definition. After that are five Salesforce agents you can start by pasting a prompt.
The same shape for a payments tool is in this article: How to Connect Stripe to Claude Code. Salesforce in the directory is here. The example prompts on that listing are ideas, not permissions. You still choose the actions in the steps below.
What Swytchcode is
Swytchcode is a production runtime for AI agents. Claude, or another model, decides which API call to make. Swytchcode runs that call. It is not the model, not the agent framework, and not a catalog standing in for Salesforce.
On every call it does eight checks:
- Allow list. Only an action you added with
swy add methodcan run. Anything you did not add cannot run, even if Claude asks. - Schema check. The inputs are checked against that action before the request is sent.
- Policy. Rules in
policies.jsoncan allow a call, deny it, or hold it for a person. A rule can read the arguments. - Credentials. The Salesforce login is added when the call runs. It is not put in the chat. You store it with
swy auth connect. There is no project env file for it. - Execution. The request goes from your machine straight to Salesforce.
- Retry. Swytchcode waits and tries again when Salesforce says you are going too fast. A create or an update is retried only when that call already has an idempotency key.
- Response check. A success status whose body says the action failed is not treated as success.
- Audit. The call and the policy decision are written to a local log.
You choose test or live once, with swy init. That choice is stored in .swytchcode/tooling.json. On Business and Enterprise, a held call can go to Slack or Telegram. If nobody approves within 48 hours, the call never runs.
Salesforce AI agents you can build
These five stay inside a sandbox org. Paste one prompt into Claude Code, Cursor, or Codex. The skills file has the setup the assistant should follow. It should search for the action with swy discover and use the name that command prints.
1. Pipeline summary agent
Reads open opportunities and groups them by stage. It does not edit the pipeline.
Set up https://www.swytchcode.com/skills.md and build a Salesforce pipeline agent. Connect the sandbox org only. Summarize my open opportunities by stage. Do not create, edit, or delete records.2. Stalled deal agent
Finds opportunities that have not moved, so a person can decide what to do next.
Set up https://www.swytchcode.com/skills.md and build a Salesforce stalled-deal agent. Use the sandbox org. List open opportunities with no recent activity. Do not change stage, owner, or amount.3. Meeting prep agent
Looks up one account and the open contacts on it before a call.
Set up https://www.swytchcode.com/skills.md and build a Salesforce meeting-prep agent. Use the sandbox org. When I give you an account name, look it up and list related contacts. Do not log a call unless I ask for that account by name.4. Call note agent
Writes one note on one account you name. It does not update a list.
Set up https://www.swytchcode.com/skills.md and build a Salesforce call-note agent. Use the sandbox org. Add a note only to the single account I name, and show me the text first. Do not bulk-update records.5. Duplicate lead agent
Searches before it creates, so a new lead is not a second copy of someone already there.
Set up https://www.swytchcode.com/skills.md and build a Salesforce duplicate-lead agent. Use the sandbox org. Before creating a lead, search by email. If a match exists, show it and stop. Do not merge records.Salesforce sandbox org versus Swytchcode test mode
Salesforce has orgs. A sandbox org is a practice copy. It has its own address and its own login. The production org is the one the company uses with real customers. They look similar on screen. They are not similar if the assistant edits a live account.
Connect the sandbox org while you are learning. swy auth connect salesforce is where that login is stored, on your machine, outside the project and outside the chat. When you are ready for the live org, connect that login on purpose. Do not reuse the sandbox password and hope the address is the practice one.
Swytchcode also has a test mode. You set it once with swy init --mode=sandbox, and it is saved in .swytchcode/tooling.json. That switch belongs to the Swytchcode project. It does not, by itself, select your Salesforce sandbox org. You still connect the org you mean. Claude cannot flip either choice in the middle of a chat, and there is no project env file for the Salesforce password.
How the Salesforce API version is chosen
Salesforce identifies a version in the path of the request. An old version and a new version can disagree about fields. If Claude types a version from memory, it can talk to the wrong shape of the API.
Do not put a version number in the prompt. Download Salesforce, search for the job in plain language, and use the action name the search prints. That name is the one in the manifest you downloaded. Names change, so do not copy one from an old note, including this article.
Start with a lookup, such as finding an account. Leave deletes and bulk updates off until a person should approve them. On the Business and Enterprise plans, Swytchcode can hold a call and send it to Slack or Telegram. If nobody approves within 48 hours, the call never runs. Free and Pro can allow or deny an action. They do not include that hold. The rules are in this article: Policy-as-Code for AI Agents.
Follow these steps to connect Salesforce
Do these from the project folder, in order. swy is the short name for the Swytchcode program.
1. Follow this step to install the CLI
If you already use Node.js:
npm install -g swytchcodeOn Windows, open PowerShell and run:
irm https://cli.swytchcode.com/install.ps1 | iexOn macOS or Linux:
curl -fsSL https://cli.swytchcode.com/install.sh | shThen check the install:
swy --versionA version number means the CLI is on your machine. The rest of the walkthrough is the CLI quickstart.
2. Follow this step to sign in
swy loginA browser opens so you can create a Swytchcode account or sign in. Your first two calls that actually reach a service can run before you have an account. This is not your Salesforce password. Service logins are in the authentication docs.
3. Follow this step to start Claude Code in test mode
swy init --editor=claude --mode=sandbox--mode=sandbox is Swytchcode's test mode. It is saved for this project. It does not choose which Salesforce org you connect in step 8. Cursor and Codex use the same program. Change claude to cursor or codex. What the command creates is in Set up a project.
4. Follow this step to download Salesforce
swy get salesforceThis downloads Salesforce into the project. It does not turn every Salesforce action on.
5. Follow this step to find a lookup
swy discover "find an account" --project salesforceThis searches Salesforce and prints the current name of that action. --project salesforce keeps the search inside Salesforce. Use the name it prints.
6. Follow this step to see what that action needs
swy info <id from discover>Replace <id from discover> with the name from step 5. Run this only after step 4.
7. Follow this step to turn that one action on
swy add method <id from discover>Until you add an action, Claude cannot run it. Leave deletes and mass updates off.
8. Follow this step to connect the sandbox org
swy auth connect salesforceSign in to the Salesforce sandbox org, the practice copy. The login stays on your machine. Explore this article for how that works: credential brokering.
FAQ
How do I connect Salesforce to Claude Code?
Follow the eight steps in this article. Connect a sandbox org first. Do not paste the Salesforce password into Claude Code.
Does Swytchcode test mode select my Salesforce sandbox?
No. Test mode is saved in the Swytchcode project. The Salesforce org is whichever login you connect. Practice in the sandbox org until a lookup looks right.
Can Claude choose the Salesforce API version?
Do not ask it to. Use the action name from swy discover. That name belongs to the manifest you downloaded.
Can Claude see my Salesforce password?
Not on this path. Swytchcode adds the login when it makes the call. Pasting the password into the chat would skip these rules.
Read next
- The install, from the first command through a test call, is the CLI quickstart.
- Explore this article for the same shape with payments: How to Connect Stripe to Claude Code.
- Explore this article if the CRM is HubSpot instead: How to Connect HubSpot to Claude Code.
Look up one account in the sandbox
If you have not installed the CLI yet, start at step 1 in this article. When the steps are done, ask Claude Code, in ordinary words, to find one account in the sandbox. Do not ask it to delete or to update a list of records.
You can also give Claude Code skills.md and ask it to follow the same steps in test mode.
If you are not sure which org you connected, stop before you edit anything. Discord is the quick place to ask. The contact form is better if the org is private. Tell us what you wanted Claude to do. That is enough.
More content
How to Log Every API Call an AI Agent Makes
Log the call where it is sent, not where it is described. Record the operation, the actor, the idempotency key, the policy decision and the outcome. Never record the credential. If the agent writes its own log, the calls that were blocked quietly disappear.
How to Connect GitHub to an AI Agent (2026)
Most of what you want an agent to do on GitHub needs no push access at all. Working that out first is the difference between a useful teammate and a token that can rewrite your main branch.
Composio Pricing Compared with Nango, Arcade, Pipedream, and Swytchcode
Composio is free for 100,000 tool calls a month, then $29. Nango is $50 pay-as-you-go. Arcade Team is $25 plus a cent a call. Pipedream Startup is $99 billed annually. Swytchcode is $149 for a million. The headline prices are the least useful part, so here is the arithmetic.
