Setting Up Claude Code for Salesforce Development: A Practical Guide
说明与用途
完成逐步指南后,开发人员可以安全地使用 Claude Code 在沙箱中自动化 Salesforce 任务,遵守守护规则并确认命令。
问题
Developers need a quick, secure way to use Claude Code with Salesforce, but must first install and configure several tools and interfaces.
结果
After following the guide, developers can securely use Claude Code to automate Salesforce development tasks in a sandbox environment, with guardrails and command approvals in place.
工作流
- Install Node.js LTS from nodejs.org and verify with
node --version - Install Salesforce CLI globally with
npm install -g @salesforce/cli sf --versionand verify output - Install Git and verify with
git --version - Create a Salesforce DX project:
sf project generate --name claude-sf-lab && cd claude-sf-lab && git init - Log in to sandbox:
sf org login web --alias my-sandbox --instance-url https://test.salesforce.com - Set sandbox as default org:
sf config set target-org my-sandbox - Test connection:
sf org displayandsf data query --query "SELECT COUNT() FROM Account" - Choose interface: (A) Terminal – install via curl or npm, run
claude; (B) Desktop App – download, sign in, open Code tab, point to folder; (C) VS Code – install Salesforce Extension Pack, install Claude Code extension, open folder, sign in - Run connection-test prompt in chosen interface and approve commands
- Create CLAUDE.md guardrail file with rules such as default org and no production target
- Keep command approvals on and commit clean starting point with
git add . && git commit -m "Initial Salesforce DX project"
证据
Claude Code — Anthropic's agentic coding tool — can retrieve metadata, write Apex and SOQL, and deploy changes, all through the Salesforce CLI you already know.
Do this once. Every option below relies on it.
Run sf org display and tell me which org this project is connected to. Then run a SOQL query to count Accounts.
- 记录日期: 2026-10-04T12:55:49.453Z