agentleFS
jiten-singh-shahijiten-singh-shahi/salesforce-claude-code/.cursor/skills/sf-cli-reference/SKILL.md

sf-cli-reference

Skill15 starsChanged 7 months agoMITView on GitHub

Use when looking up Salesforce CLI sf commands — org login, project deploy, apex run test, data query, package install, scratch org creation. Do NOT use for web documentation lookup or Apex code patterns.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When you need to find the right sf command for a Salesforce task

    line 13
  2. Distinctive:

    When constructing CLI commands with correct flags and syntax

    line 14
  3. Distinctive:

    When choosing between similar commands (e.g., deploy start vs deploy validate)

    line 15
  4. Distinctive:

    When setting up org authentication (web, jwt, sfdx-url)

    line 16
  5. Distinctive:

    When running Apex tests or querying data from the command line

    line 17
  6. Distinctive:

    When managing scratch orgs, packages, or metadata via CLI

    line 18

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

SF CLI Command Reference

Reference: @../_reference/SF_CLI_COMMANDS.md

When to Use

  • When you need to find the right sf command for a Salesforce task
  • When constructing CLI commands with correct flags and syntax
  • When choosing between similar commands (e.g., deploy start vs deploy validate)
  • When setting up org authentication (web, jwt, sfdx-url)
  • When running Apex tests or querying data from the command line
  • When managing scratch orgs, packages, or metadata via CLI

Command Decision Tree

Authenticate to an Org

ScenarioCommandKey Flags
Interactive browser loginsf org login web--alias, --set-default
CI/CD non-interactive loginsf org login jwt--client-id, --jwt-key-file, --username
Auth URL from filesf org login sfdx-url--sfdx-url-file
Log out of an orgsf org logout--target-org, --no-prompt
List all connected orgssf org list--all
Open org in browsersf org open--target-org, --path
Display org detailssf org display--target-org, --verbose

Deploy or Retrieve Source

ScenarioCommandKey Flags
Deploy source directorysf project deploy start--source-dir, --target-org
Deploy with manifestsf project deploy start--manifest, --target-org
Deploy specific metadatasf project deploy start--metadata "ApexClass:MyClass"
Validate without deployingsf project deploy validate--test-level, --target-org
Quick deploy after validationsf project deploy quick--job-id, --target-org
Check deploy statussf project deploy report--job-id
Resume failed deploysf project deploy resume--job-id
Cancel in-progress deploysf project deploy cancel--job-id
Retrieve from orgsf project retrieve start--source-dir, --target-org
Retrieve by manifestsf project retrieve start--manifest
Preview retrievalsf project retrieve preview--target-org
Generate manifestsf project generate manifest--source-dir, --output-dir
Convert source to mdapisf project convert source--root-dir, --output-dir
Convert mdapi to sourcesf project convert mdapi--root-dir, --output-dir
Create new projectsf project generate--name, --template

Run Apex Code and Tests

ScenarioCommandKey Flags
Execute anonymous Apexsf apex run--file, --target-org
Run all local testssf apex run test--test-level RunLocalTests
Run specific test classessf apex run test--class-names "MyTest,OtherTest"
Run specific test methodssf apex run test--tests "MyTest.testMethod"
Run tests with coveragesf apex run test--code-coverage, --output-dir
Run test suitesf apex run test--suite-names "MySuite"
Stream debug logs livesf apex tail log--target-org, --debug-level
Get a specific logsf apex get log--log-id
List recent logssf apex list log--target-org

Work with Data

ScenarioCommandKey Flags
Run SOQL querysf data query--query, --target-org
Run SOQL from filesf data query--file, --result-format
Bulk SOQL querysf data query--query, --bulk, --wait
Run SOSL searchsf data search--query
Create a recordsf data create record--sobject, --values
Update a recordsf data update record--sobject, --record-id, --values
Delete a recordsf data delete record--sobject, --record-id
Bulk upsert from CSVsf data upsert bulk--file, --sobject, --external-id
Bulk delete from CSVsf data delete bulk--file, --sobject
Export data as treesf data export tree--query, --plan
Import tree datasf data import tree--plan, --target-org

Manage Scratch Orgs and Sandboxes

ScenarioCommandKey Flags
Create scratch orgsf org create scratch--definition-file, --alias, --duration-days
Delete scratch orgsf org delete scratch--target-org, --no-prompt
Create sandboxsf org create sandbox--name, --definition-file, --alias
Clone sandboxsf org create sandbox--clone, --name
Delete sandboxsf org delete sandbox--target-org, --no-prompt
Resume sandbox creationsf org resume sandbox--name, --target-org
Assign permission setsf org assign permset--name, --target-org
Create usersf org create user--definition-file, --target-org

Manage Packages

ScenarioCommandKey Flags
Create packagesf package create--name, --package-type, --path
Create versionsf package version create--package, --installation-key, --code-coverage
Promote versionsf package version promote--package
Install packagesf package install--package, --target-org
Uninstall packagesf package uninstall--package, --target-org
List versionssf package version list--packages, --verbose
List installedsf package installed list--target-org

Work with Agentforce / AI Agents

ScenarioCommandKey Flags
Create agentsf agent create--target-org
Generate agent specsf agent generate spec--output-dir
Generate agent testssf agent generate test--spec-file, --output-dir
Run agent testssf agent test run--name, --target-org
Preview agentsf agent preview--name, --target-org
Activate agentsf agent activate--target-org
Deactivate agentsf agent deactivate--target-org

Note: sf agent commands are actively evolving. Run sf agent <command> --help for the latest flags.

Generate Code from Templates

ScenarioCommandKey Flags
Generate Apex classsf apex generate class--name, --output-dir, --template
Generate Apex triggersf apex generate trigger--name, --sobject, --output-dir
Generate LWCsf lightning generate component--name, --type lwc
Generate Aura componentsf lightning generate component--name, --type aura
Generate Lightning eventsf lightning generate event--name, --output-dir
Generate SObjectsf schema generate sobject--label, --output-dir
Generate fieldsf schema generate field--label, --object
Generate platform eventsf schema generate platformevent--label, --output-dir
Generate projectsf project generate--name, --template

Other Utilities

ScenarioCommandKey Flags
Set default orgsf config settarget-org=myOrg
List config valuessf config list
Set aliassf alias setmyAlias=user@org.com
Describe SObjectsf sobject describe--sobject, --target-org
List SObjectssf sobject list--sobject-type, --target-org
REST API requestsf api request rest(URL path), --method, --body
GraphQL requestsf api request graphql--body
Run Flow testssf logic run test--target-org
Diagnose CLI issuessf doctor
Install pluginsf plugins install(plugin name)
Update CLIsf update
Show release notessf info releasenotes display

Workflow Patterns

Authentication + Deploy

# Login and deploy source
sf org login web --alias myOrg --set-default
sf project deploy start --source-dir force-app --target-org myOrg --wait 30

CI/CD: Validate Then Quick Deploy

# Authenticate in CI
sf org login jwt \
    --client-id $SF_CLIENT_ID \
    --jwt-key-file server.key \
    --username $SF_USERNAME \
    --alias prod

# Validate (runs tests without committing)
sf project deploy validate \
    --source-dir force-app \
    --test-level RunLocalTests \
    --target-org prod \
    --wait 60

# Quick deploy after successful validation (use job ID from validation output)
sf project deploy quick --job-id $JOB_ID --target-org prod

Scratch Org Development Cycle

# Create scratch org
sf org create scratch \
    --definition-file config/project-scratch-def.json \
    --alias dev \
    --duration-days 7 \
    --set-default

# Push source and assign permissions
sf project deploy start --source-dir force-app --target-org dev
sf org assign permset --name MyPermSet --target-org dev

# Import sample data
sf data import tree --plan data/sample-data-plan.json --target-org dev

# Run tests
sf apex run test --test-level RunLocalTests --target-org dev --code-coverage

# Clean up
sf org delete scratch --target-org dev --no-prompt

Related

  • Skill: sf-deployment -- detailed deployment strategies and error resolution
  • Skill: sf-devops-ci-cd -- CI/CD pipeline setup with GitHub Actions
  • Skill: sf-debugging -- debug log setup and analysis with CLI commands
  • Skill: sf-metadata-management -- metadata types and source tracking
  • Skill: sf-docs-lookup -- web search for official Salesforce documentation

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.