Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

Salesforce CLI

$ sf Official High Risk
Salesforce · Workspace & SaaS · BSD-3-Clause · macos / linux / windows

Salesforce 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.

FCRS-1.0 Score
90 /100
Excellent
Medium Confidence
Zero-Friction Install
brew install --cask salesforce-cli
CLI vs MCP Decision CLI Preferred vs MCP

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

✓ JSON Output
— Field Filtering
✓ Non-Interactive
✓ Dry-Run
— Read-Only Mode
✓ NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 23 / 25

Global --json flag and SF_CONTENT_TYPE=JSON env var make nearly every sf subcommand machine-parseable and non-interactive.

  • --json works consistently across org, data, and project namespaces
  • SF_CONTENT_TYPE=JSON enforces JSON globally
Trust & Safety 22 / 25

Supports --dry-run metadata validation, explicit --target-org scoping, and ephemeral scratch org isolation.

  • sf project deploy start --dry-run validates without mutating state
  • Scratch orgs isolate experimental changes from production CRM data
Setup & Portability 13 / 15

Available via npm, Homebrew cask, and standalone OS installers across macOS, Linux, and Windows.

  • npm install -g @salesforce/cli and brew install --cask salesforce-cli
Utility & Efficiency 14 / 15

Covers the entire Salesforce DX lifecycle including SOQL, Apex tests, metadata diffing, and CI/CD.

  • Replaces legacy sfdx with unified, well-structured command trees
Maintenance & Lineage 9 / 10

Official Salesforce tool (salesforcecli/cli) under BSD-3-Clause with weekly releases.

  • Official Salesforce GitHub organization and active release cadence
Docs & Verifiability 9 / 10

Extensive official Salesforce CLI Command Reference and --help introspection.

  • Official unified CLI reference docs and consistent oclif help schemas

Security, Auth & Guardrails

Auth Modes
OAuth Browser Env API Key Config File
Credential Storage

Stores encrypted org auth files under ~/.sfdx/ and ~/.sf/, or accepts SFDX_AUTH_URL / JWT bearer flows for headless CI.

Side Effects
Read-Only Local Write Remote Write Destructive
Cost & Quotas

CLI is free (BSD-3-Clause); Salesforce Developer Edition and Scratch Orgs via Dev Hub are free within edition limits.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# 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

List authenticated Salesforce orgs
sf org list --json

Enumerates connected Dev Hubs, sandboxes, and scratch orgs with alias and status metadata.

Run a bounded SOQL read query
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

Validate metadata deployment with dry-run
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 --json support plus SF_CONTENT_TYPE=JSON makes output parsing deterministic.
  • + First-class --dry-run deployment 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_URL or JWT connected apps ahead of time.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI