salesforce-cli — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited salesforce-cli (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Safety-first wrapper for Salesforce CLI (sf v2). Every command is classified by risk level before execution. NEVER modify Salesforce data or metadata without explicit user permission.
npm install -g @salesforce/cli or brew install sfsf org login web (interactive) or sf org login jwt (CI/CD)sf --version (requires v2.x)sf config set target-org <alias>Every sf command falls into one of four risk tiers. Default mode is read-only.
| Tier | Action Required | Examples |
|---|---|---|
| Safe | Execute immediately | sf org list, sf data query, sf project retrieve preview |
| Write | AskUserQuestion BEFORE executing | sf data create record, sf project deploy start --dry-run |
| Destructive | AskUserQuestion w/ explicit consequences | sf project deploy start, sf data delete, sf org delete |
| Forbidden | Multi-step validation, NEVER auto-confirm | Bulk delete in production, mass data wipe, production org delete |
See references/safety-rules.md for full classification and confirmation templates.
Detect org type before ANY write operation:
sf org display --target-org <alias> --jsonCheck instanceUrl and isScratch/isSandbox fields:
login.salesforce.com or no sandbox/scratch flag → PRODUCTION → extra confirmation requiredtest.salesforce.com or isSandbox: true → SandboxisScratch: true → Scratch orgFor production orgs: ALL write operations require AskUserQuestion w/ org alias typed confirmation.
Command received
→ Detect target org type (prod/sandbox/scratch)
→ Classify risk tier (see Quick Reference)
→ Safe? Execute immediately
→ Write? AskUserQuestion → wait for answer → execute or cancel
→ Destructive? AskUserQuestion w/ consequences → wait → execute or cancel
→ Forbidden? Warn → require typed confirmation → final confirm → execute or cancel
→ PRODUCTION? Add extra confirmation step regardless of tier| Command | Description |
|---|---|
sf org list | List authorized orgs |
sf org list --all | Include expired scratch orgs |
sf org display | Display org info |
sf org open | Open org in browser |
sf config list | List config values |
sf config get target-org | Get default org |
sf alias list | List aliases |
sf data query --query "..." | SOQL query (w/ mandatory LIMIT) |
sf data search --query "..." | SOSL search |
sf data get record | Get single record |
sf project retrieve preview | Preview what would be retrieved |
sf project deploy preview | Preview what would be deployed |
sf apex list log | List debug logs |
sf apex get log | Get debug log content |
sf apex tail log | Tail logs in real-time |
sf api request rest (GET) | Read-only REST API calls |
sf limits api display | Display API limits |
sf sobject describe --sobject <name> | Describe object schema (fields, types) |
sf package list | List packages |
sf package version list | List package versions |
sf plugins list | List installed plugins |
sf doctor | Run diagnostics |
sf org list auth | List auth connections (sf auth list = legacy alias) |
| Command | Description |
|---|---|
sf data create record | Create a single record |
sf data update record | Update a single record |
sf data import tree | Import data from tree files |
sf project deploy start --dry-run | Validate deployment (no changes) |
sf project retrieve start | Retrieve metadata to local |
sf org create scratch | Create scratch org |
sf alias set | Set an alias |
sf config set | Set config value |
sf package create | Create a package |
sf package version create | Create package version |
| Command | Description |
|---|---|
sf project deploy start (no dry-run) | Deploy metadata (modifies org) |
sf data delete record | Delete a single record |
sf data delete bulk | Bulk delete records |
sf data update bulk | Bulk update records — can corrupt data at scale |
sf data import bulk | Bulk import — can create thousands of duplicate records |
sf data upsert bulk | Bulk upsert — incorrect key can overwrite wrong records |
sf apex run | Execute anonymous Apex |
sf org delete scratch | Delete scratch org |
sf org delete sandbox | Delete sandbox |
sf org create sandbox | Create sandbox (long-running, uses resources) |
sf org assign permset | Assign permission set — can escalate privileges or lock users out |
sf package install | Install package — can modify schema, automation, and data |
sf package uninstall | Uninstall package |
sf org logout | Remove org auth |
sf api request rest -X POST/PUT/PATCH/DELETE | Write/delete REST API calls |
| Command | Description |
|---|---|
sf org delete targeting production | Delete production org connection |
| Bulk delete in production | Mass data deletion in production |
sf data delete bulk w/o WHERE in source query | Full-table data wipe risk |
sf project deploy start w/ destructiveChanges.xml in prod | Deploy destructive metadata changes to production |
sf project deploy start --test-level NoTestRun in prod | Skip tests in production (BLOCKED) |
sf org refresh sandbox | Refresh sandbox — overwrites ALL data and customizations |
sf org logout --all | Remove ALL org auth — can break CI/CD pipelines |
| Bulk loops w/o limits | Any loop running delete/update w/o LIMIT |
sf apex run in production w/o review | Execute unreviewed Apex in production |
| Dangerous deploy flags in prod | --ignore-conflicts, --ignore-warnings, --purge-on-delete |
Mandatory rules for ALL queries:
LIMIT 200 if user omits** — Expand fields via sf sobject describe --sobject <name>` or ask user--use-tooling-api flag for metadata queries# Safe SOQL query
sf data query --target-org my-org \
--query "SELECT Id, Name, Industry FROM Account WHERE Industry = 'Technology' LIMIT 100"
# SOQL w/ relationships
sf data query --target-org my-org \
--query "SELECT Id, Name, (SELECT Id, FirstName FROM Contacts) FROM Account LIMIT 50"
# SOQL w/ output format
sf data query --target-org my-org \
--query "SELECT Id, Name FROM Account LIMIT 100" \
--result-format csv --output-file accounts.csv
# Tooling API query
sf data query --target-org my-org --use-tooling-api \
--query "SELECT Id, Name FROM ApexClass WHERE Name LIKE '%Test%' LIMIT 50"
# SOSL search
sf data search --target-org my-org \
--query "FIND {Acme} IN NAME FIELDS RETURNING Account(Id, Name LIMIT 50)"See references/soql-sosl.md for query patterns, date literals, and aggregate examples.
# CSV export
sf data query --target-org my-org \
--query "SELECT Id, Name FROM Account LIMIT 200" \
--result-format csv --output-file accounts.csv
# JSON export
sf data query --target-org my-org \
--query "SELECT Id, Name FROM Account LIMIT 200" \
--json > accounts.json
# Tree export (preserves relationships)
sf data export tree --target-org my-org \
--query "SELECT Id, Name, (SELECT Id, FirstName FROM Contacts) FROM Account LIMIT 50" \
--output-dir ./data
# Bulk export (large datasets)
sf data export bulk --target-org my-org \
--query "SELECT Id, Name FROM Account" \
--output-file accounts.csv# Tree import (Write)
sf data import tree --target-org my-org --files Account.json,Contact.json
# Bulk import (Write)
sf data import bulk --sobject Account --file accounts.csv --target-org my-org
# Bulk upsert (Write)
sf data upsert bulk --sobject Account --file data.csv \
--external-id External_Id__c --target-org my-orgConvert between formats using the file-converter skill:
# Salesforce JSON → CSV (for spreadsheets)
python3 .claude/skills/file-converter/scripts/csv_json_yaml.py accounts.json accounts.csv
# CSV → JSON (for API import)
python3 .claude/skills/file-converter/scripts/csv_json_yaml.py data.csv data.json
# JSON → YAML (for config/review)
python3 .claude/skills/file-converter/scripts/csv_json_yaml.py accounts.json accounts.yaml
# Export → Convert → Report pipeline
sf data query --target-org my-org \
--query "SELECT Id, Name FROM Account LIMIT 200" --json > data.json
python3 .claude/skills/file-converter/scripts/csv_json_yaml.py data.json report.csvSee references/data-operations.md for bulk patterns and tree format details.
# Retrieve by source
sf project retrieve start --source-dir force-app --target-org my-org
# Retrieve by metadata type
sf project retrieve start --metadata ApexClass --target-org my-org
# Retrieve by manifest
sf project retrieve start --manifest package.xml --target-org my-orgAlways validate first:
# Step 1: Preview (Safe)
sf project deploy preview --source-dir force-app --target-org my-org
# Step 2: Validate / dry-run (Write — confirm first)
sf project deploy start --source-dir force-app --target-org my-org --dry-run
# Step 3: Actual deploy (Destructive — confirm w/ consequences)
sf project deploy start --source-dir force-app --target-org my-org
# Production deploy (always w/ tests)
sf project deploy start --source-dir force-app --target-org prod-org \
--test-level RunLocalTestsAlways show code before running. Always confirm.
# Step 1: Display the Apex code to the user (MANDATORY)
cat script.apex
# Step 2: AskUserQuestion — "Execute this Apex in <org>?"
# Step 3: Execute (Destructive tier)
sf apex run --target-org my-org --file script.apex
# Run tests (Write tier)
sf apex run test --target-org my-org --class-names MyClassTest --code-coverage
# Get latest log
sf apex get log --target-org my-org --number 1# Create (Write)
sf org create scratch --definition-file config/project-scratch-def.json \
--alias my-scratch --duration-days 7
# List (Safe)
sf org list --all
# Delete (Destructive — confirm first)
sf org delete scratch --target-org my-scratch# Create (Destructive — long-running, consumes resources)
sf org create sandbox --target-org prod-org --name dev-sandbox --alias dev-sb
# Refresh (Destructive)
sf org refresh sandbox --target-org dev-sb
# Delete (Destructive — confirm first)
sf org delete sandbox --target-org dev-sb# Web login (interactive — recommended for development)
sf org login web --alias my-org --set-default
# Sandbox login
sf org login web --alias my-sandbox --instance-url https://test.salesforce.com
# JWT login (CI/CD — non-interactive)
sf org login jwt --client-id <consumer_key> --jwt-key-file server.key \
--username [email protected] --alias my-org
# SFDX Auth URL (transfer auth between systems)
sf org login sfdx-url --sfdx-url-file auth.txt --alias my-org
# Device flow (headless environments)
sf org login device
# Verify auth
sf org display --target-org my-org
sf auth listSee references/auth-flows.md for detailed setup instructions.
{
"mcpServers": {
"salesforce-dx": {
"command": "npx",
"args": ["-y", "@salesforce/mcp", "--orgs", "DEFAULT_TARGET_ORG"]
}
}
}Available toolsets: Core, Orgs, Data, Users, Metadata, Testing, Code-Analysis, LWC, Aura, Mobile, Scale Products.
1. Check: Are Salesforce MCP tools available? (ToolSearch "salesforce")
→ YES: Use MCP tools (structured, validated)
→ NO: Fall back to sf CLI commands
→ NO CLI: Guide user through installation| Server | Tools | Best For |
|---|---|---|
@salesforce/mcp (official) | 60+ | Full DX workflow, LWC, testing, metadata |
tsmztech/mcp-server-salesforce | 16 | CRUD, schema, Apex, SOSL |
advancedcommunities/salesforce-mcp-server | 36 | Apex, testing, code analysis, data export |
See references/mcp-integration.md for setup and toolset details.
# REST API (Safe for GET, Write/Destructive for others)
sf api request rest /services/data/v67.0/sobjects/Account/describe
sf api request rest /services/data/v67.0/query?q=SELECT+Id+FROM+Account+LIMIT+10
# GraphQL
sf api request graphql --body query.graphql --target-org my-org
# Composite (multiple operations in one call)
sf api request rest /services/data/v67.0/composite --body composite.json -X POST# Publish platform event (Destructive — triggers automation)
sf data create record --sobject MyEvent__e --values "Field1__c='value'" --target-org my-org
# Subscribe to events (Safe — read-only)
sf apex run --target-org my-org --file subscribe_events.apex
# Check CDC-enabled objects (Safe)
sf data query --target-org my-org --use-tooling-api \
--query "SELECT QualifiedApiName FROM EntityDefinition WHERE IsEnabledForChangeDataCapture = true LIMIT 100"For ALL write, destructive, and forbidden operations, use AskUserQuestion w/ tailored options.
question: "Create a new Account record in <org-alias> (<org-type>)?"
header: "SF Write"
options:
- label: "Create record"
description: "Insert the Account record with the specified field values"
- label: "Cancel"
description: "Do not create any records"question: "Deploy metadata to <org-alias> (<org-type>)? <N> components will be modified."
header: "SF Deploy"
options:
- label: "Validate only (dry-run)"
description: "Run validation without making changes"
- label: "Deploy now"
description: "Deploy and modify the target org"
- label: "Cancel"
description: "Do not deploy"question: "Execute the following Apex in <org-alias> (<org-type>)?\n\n<code preview>"
header: "SF Apex"
options:
- label: "Execute"
description: "Run the Apex code in the target org"
- label: "Cancel"
description: "Do not execute"See references/safety-rules.md for all confirmation templates.
| Error | Cause | Fix |
|---|---|---|
sf: command not found | Not installed | npm install -g @salesforce/cli |
No default org set | No target org | sf config set target-org <alias> |
INVALID_SESSION_ID | Auth expired | sf org login web --alias <org> |
MALFORMED_QUERY | Bad SOQL syntax | Check query, verify field names |
INVALID_FIELD | Wrong field name | Use sf sobject describe --sobject <name> to check fields |
REQUEST_LIMIT_EXCEEDED | API limit hit | Check sf limits api display, wait or optimize |
DUPLICATE_VALUE | Unique constraint | Check external IDs, use upsert instead |
REQUIRED_FIELD_MISSING | Missing field | Check object requirements w/ describe |
DEPLOY_FAILED | Deploy validation error | Check error details, fix code, redeploy |
cat if output may trigger a pager: sf org list | cat--target-org to prevent accidental operations on wrong org--json for programmatic parsingsf v2 renames commands across releases. On any error: sf <topic> --help (authoritative for the installed version) → if unclear, WebFetch https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_unified.htm → adjust → re-run. Never guess flags twice; surface renamed commands w/ the doc link.
Pairs with:
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.