If you're just getting started with Salesforce development, the CLI is one of the most powerful tools in your toolkit. Let me walk you through the essentials.
Installation
First things first — install the Salesforce CLI. The easiest way is via npm:
npm install -g @salesforce/cli
Verify it's installed:
sf --version
Authenticating to an Org
Before you can do anything useful, you need to connect to a Salesforce org:
sf org login web -a my-dev-org
This opens a browser window where you log in. The -a flag sets an alias so you don't have to type the full username every time.
Creating a Project
Scaffold a new SFDX project:
sf project generate -n my-project
cd my-project
This gives you the standard force-app/main/default directory structure that Salesforce expects.
Retrieving Metadata
Pull metadata from your org into your local project:
sf project retrieve start -o my-dev-org
Or retrieve specific metadata types:
sf project retrieve start -o my-dev-org -m ApexClass CustomObject
Deploying Changes
Once you've made changes locally, deploy them back:
sf project deploy start -o my-dev-org
Pro tip: Always run a validation first with
--dry-runbefore deploying to production. Trust me on this one.
What's Next?
This barely scratches the surface. In future posts, I'll cover:
- Manifest files — How to use
package.xmlfor targeted deployments - Scratch orgs — Disposable development environments
- Custom scripts — Automating repetitive CLI workflows
- Troubleshooting — The errors you'll definitely encounter (and how to fix them)
The Salesforce CLI is one of those tools that gets more powerful the more you learn about it. Start with these basics and build from there.
Happy deploying!