Now that you've created a Salesforce DX project, what's next? Here are some documentation resources to get you started.
Do you want to deploy a set of changes, or create a self-contained application? Choose a development model.
The sfdx-project.json file contains useful configuration information for your project. See Salesforce DX Project Configuration in the Salesforce DX Developer Guide for details about this file.
- Salesforce Extensions Documentation
- Salesforce CLI Setup Guide
- Salesforce DX Developer Guide
- Salesforce CLI Command Reference
Welcome to Salesforce development! This guide covers the most important CLI commands you'll need to get started with Salesforce development and deployment.
Note: Salesforce transitioned from sfdx to sf commands in July 2023. The new sf CLI is faster and more intuitive. Both command styles work, but sf is the future.
- New style:
sf org login web - Old style:
sfdx force:auth:web:login(still works but deprecated)
sf --versionsf --help
sf org --help
sf project --help# Login to a Salesforce org (opens browser)
sf org login web
# Login to a sandbox
sf org login web --instance-url https://test.salesforce.com
# Login with an alias (recommended for multiple orgs)
sf org login web --alias myorg# See all connected orgs
sf org list
# See more details
sf org list --all# Set default org for commands
sf config set target-org your-org-alias-or-username# Open default org
sf org open
# Open specific org
sf org open --target-org myorg# Create scratch org with default settings
sf org create scratch --definition-file config/project-scratch-def.json --alias myscratch
# Create with specific duration (1-30 days)
sf org create scratch --definition-file config/project-scratch-def.json --alias myscratch --duration-days 7 --set-defaultsf org delete scratch --target-org myscratch# Deploy all source to default org
sf project deploy start
# Deploy specific file or folder
sf project deploy start --source-dir force-app/main/default/classes/MyClass.cls
# Deploy with test run
sf project deploy start --test-level RunLocalTests# Get all changes from org
sf project retrieve start
# Retrieve specific metadata
sf project retrieve start --metadata ApexClass:MyClass# Push changes to scratch org (development only)
sf project deploy start --ignore-conflicts
# Pull changes from scratch org
sf project retrieve start --ignore-conflicts# Run all tests
sf apex run test
# Run specific test class
sf apex run test --class-names MyTestClass
# Run tests with code coverage
sf apex run test --code-coverage --result-format human# Get detailed test results with coverage
sf apex get test --test-run-id YOUR_TEST_RUN_ID --code-coverage --detailed-coverage# Export data using SOQL
sf data query --query "SELECT Id, Name FROM Account LIMIT 10"
# Import data from CSV
sf data import tree --plan data/sample-data-plan.json# Create a single record
sf data create record --sobject Account --values "Name='Test Account' Type='Customer'"# List recent logs
sf apex list log
# Get specific log
sf apex get log --log-id YOUR_LOG_ID
# Tail logs in real-time
sf apex tail log# 1. Create a new scratch org
sf org create scratch --definition-file config/project-scratch-def.json --alias feature-branch --duration-days 7 --set-default
# 2. Push your code
sf project deploy start
# 3. Work on your feature...
# 4. Run tests
sf apex run test --code-coverage
# 5. When done, delete scratch org
sf org delete scratch --target-org feature-branch# 1. Validate deployment (doesn't actually deploy)
sf project deploy start --dry-run --test-level RunLocalTests --target-org production
# 2. If validation passes, deploy for real
sf project deploy start --test-level RunLocalTests --target-org production- Authentication Issues: Run
sf org login webto re-authenticate - Permission Errors: Make sure you have the right permissions in your org
- Deployment Conflicts: Use
--ignore-conflictsflag for development orgs - Get Help: Use
--helpflag with any command for detailed information
| Task | New Command (sf) | Old Command (sfdx) |
|---|---|---|
| Login | sf org login web |
sfdx force:auth:web:login |
| Create Scratch Org | sf org create scratch |
sfdx force:org:create |
| Deploy Code | sf project deploy start |
sfdx force:source:push |
| Retrieve Code | sf project retrieve start |
sfdx force:source:pull |
| Run Tests | sf apex run test |
sfdx force:apex:test:run |
| Open Org | sf org open |
sfdx force:org:open |