sf
Salesforce development command-line interface
TLDR
Log in to a Salesforce org via web browser
SYNOPSIS
sf command [subcommand] [flags]
DESCRIPTION
sf (Salesforce CLI) is the official command-line interface for Salesforce development. It manages Salesforce DX projects, creates and manages scratch orgs and sandboxes, deploys and retrieves source code, runs tests, and handles package development.
The CLI uses a hierarchical command structure where commands are grouped by topic (org, project, data, apex, package). Most commands accept a --target-org flag to specify which org to operate on, and --json for machine-readable output.
Configuration is stored in ~/.sf/ and project-specific settings in sfdx-project.json. Orgs can be aliased for convenience using sf alias set.
PARAMETERS
--target-org, -o alias
Specify the target org by username or alias--json
Output results in JSON format--help
Display help for a command--version
Display CLI version
CONFIGURATION
~/.sf/
User-level configuration directory storing authentication tokens, org connections, and CLI settings.sfdx-project.json
Project-level configuration file defining source paths, namespace, API version, and package dependencies.SF_ACCESS_TOKEN
Environment variable for providing an org access token directly.
COMMANDS
org login web
Authenticate to an org using OAuth via web browserorg login jwt
Authenticate using JWT-based floworg create scratch
Create a scratch org for developmentorg create sandbox
Create a sandbox orgorg list
List all authenticated orgsorg display
Display details about an orgproject deploy start
Deploy source to an orgproject retrieve start
Retrieve metadata from an orgproject convert mdapi
Convert metadata API format to source formatapex run
Execute anonymous Apex codeapex run test
Run Apex testsdata query
Execute a SOQL querydata create record
Create a record in an orgpackage create
Create a packagepackage install
Install a package in an orgconfig set
Set CLI configuration valuesalias set
Create aliases for orgs
CAVEATS
The older sfdx command is deprecated; migrate to sf commands. Some operations require specific org permissions or Salesforce editions. Scratch orgs have time limits (default 7 days) and namespace considerations for packaging.
HISTORY
Salesforce CLI was introduced as sfdx (Salesforce DX CLI) in 2017 alongside the Salesforce DX development model. The sf command was introduced in 2022 as a unified, redesigned CLI with improved command structure. The sfdx-style commands were deprecated in 2024 with full transition to sf.
