Salesforce CLI
$ sf Official High RiskSalesforce CLI (sf) is the modern unified command-line tool for managing Salesforce orgs, running SOQL queries, deploying metadata, and spinning up scratch orgs. Nearly every command accepts --json (or SF_CONTENT_TYPE=JSON) and deployments support --dry-run validation.
brew install --cask salesforce-cli Prefer sf CLI over thin API wrappers because it handles Apex test execution, --dry-run metadata deployment checks, and scratch org lifecycles natively.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Global --json flag and SF_CONTENT_TYPE=JSON env var make nearly every sf subcommand machine-parseable and non-interactive.
--jsonworks consistently acrossorg,data, andprojectnamespacesSF_CONTENT_TYPE=JSONenforces JSON globally
Supports --dry-run metadata validation, explicit --target-org scoping, and ephemeral scratch org isolation.
sf project deploy start --dry-runvalidates without mutating state- Scratch orgs isolate experimental changes from production CRM data
Available via npm, Homebrew cask, and standalone OS installers across macOS, Linux, and Windows.
npm install -g @salesforce/cliandbrew install --cask salesforce-cli
Covers the entire Salesforce DX lifecycle including SOQL, Apex tests, metadata diffing, and CI/CD.
- Replaces legacy
sfdxwith unified, well-structured command trees
Official Salesforce tool (salesforcecli/cli) under BSD-3-Clause with weekly releases.
- Official Salesforce GitHub organization and active release cadence
Extensive official Salesforce CLI Command Reference and --help introspection.
- Official unified CLI reference docs and consistent oclif help schemas
Security, Auth & Guardrails
Stores encrypted org auth files under ~/.sfdx/ and ~/.sf/, or accepts SFDX_AUTH_URL / JWT bearer flows for headless CI.
CLI is free (BSD-3-Clause); Salesforce Developer Edition and Scratch Orgs via Dev Hub are free within edition limits.
# Salesforce CLI Agent Rules - Always pass `--target-org` pointing to a scratch org or sandbox; NEVER target production orgs autonomously. - Run `sf project deploy start --dry-run --json` before any real deployment. - Require explicit human approval for `sf data delete`, `sf org delete`, or production deploys.
Agent-Ready Command Recipes
Safe Read-Only Queries
sf org list --json
Enumerates connected Dev Hubs, sandboxes, and scratch orgs with alias and status metadata.
sf data query --query "SELECT Id, Name FROM Account LIMIT 5" --target-org my-sandbox --json
Queries up to 5 records from a designated sandbox org in structured JSON.
Controlled Writes & Previews
sf project deploy start --dry-run --target-org my-sandbox --json
Runs server-side metadata compilation and validation without committing changes to the org.
Strengths for Agents
- + Pervasive
--jsonsupport plusSF_CONTENT_TYPE=JSONmakes output parsing deterministic. - + First-class
--dry-rundeployment validation and scratch-org isolation protect production CRM data. - + oclif-based command structure is self-describing and consistent across dozens of plugins.
Caveats & Pitfalls
- ! Large plugin surface and Node.js runtime make cold startup noticeably slower than native Go/Rust CLIs.
- ! Headless CI authentication requires setting up
SFDX_AUTH_URLor JWT connected apps ahead of time.