The Salesforce Administrator role keeps changing, and picking up new tools pays for itself in productivity. This article covers the Salesforce CLI and Visual Studio Code for administrators and developers who have not used either.
Understanding Salesforce CLI
The Salesforce CLI (Command Line Interface) is a local command-line utility for working with your Salesforce orgs. You use it to create and manage Salesforce projects on your own machine, which you can then put under version control in a repository like GitHub or BitBucket. It is how your machine reaches Salesforce metadata and connects to orgs for deployments, retrievals, testing, and more.
The CLI lives in a terminal, which puts some people off. Visual Studio Code wraps it in an interface that is easier to get along with.
Visual Studio Code: the developer's editor
Visual Studio Code (VS Code) is a free, open-source source code editor from Microsoft that runs on every major platform. You get an integrated terminal and a file explorer in the same window.

Installing Visual Studio Code
Download VS Code from the official website: https://code.visualstudio.com/. There are installers for Windows, macOS, and Linux.
Installing Salesforce CLI
Download the installer from the official Salesforce CLI documentation: https://developer.salesforce.com/tools/sfdxcli, then follow the instructions for your platform. Check the install by running sf --version in your terminal.
Installing Salesforce extensions for VS Code
VS Code needs extensions before it can do anything useful with Salesforce metadata. Install the Salesforce Extension Pack or Salesforce Extension Pack (Expanded) from the VS Code Marketplace:
- Open Visual Studio Code.
- Navigate to the Extensions view (Ctrl+Shift+X or ⌘+Shift+X).
- Search for "Salesforce Extension Pack".
- Click "Install" on the extension published by Salesforce.
Creating a Salesforce project
Keep all your Salesforce projects under one dedicated folder on your local machine.
- Create a root folder for your Salesforce projects (e.g.,
~/SalesforceProjects). - Open this folder in Visual Studio Code.
- Open the Command Palette (Ctrl+Shift+P or ⌘+Shift+P).
- Type
sfdxand selectSFDX: Create Project. - Choose the
Standardproject template.
That generates the standard project structure in your VS Code workspace. Metadata files live in the force-app/main/default directory.
Salesforce CLI command evolution
The CLI has been through a few names: Force.com CLI, then SFDX, and now the consolidated sf CLI. The sf command set uses a simpler noun-verb syntax.
Older sfdx commands may still function, and new work should use the modern sf commands:
- Legacy:
sfdx force:source:deploy - Modern:
sf project deploy start
Salesforce groups commands into sets, org for org management and project for project-specific operations.
Key Salesforce CLI commands
Authenticating a Salesforce org
Before the CLI can touch an org, you have to authenticate it, which usually means a web-based login flow:
sf org login web --alias <your_alias> --browser <browser_name> --instance-url <your_instance_url>
sf org login web: starts a web-based login in theorgcommand set.--alias <your_alias>: gives the org a nickname so you can refer to it easily.--browser <browser_name>: picks the browser to authenticate in (e.g.,chrome,firefox).--instance-url <your_instance_url>: the login URL of your Salesforce org.
This opens your default browser on the Salesforce login page. Once you are authenticated, you can verify the connection.
Displaying connected orgs
To list the orgs you have authenticated:
sf org list
The output is a table with the org type, alias, username, Org ID, status, and expiration date where one applies.
Retrieving metadata
To pull metadata from an authenticated org into your local project:
sf project retrieve start --metadata <MetadataType>:<MetadataName> --target-org <your_alias>
sf project retrieve start: starts a metadata retrieval in theprojectcommand set.--metadata <MetadataType>:<MetadataName>: the type and name of the metadata to retrieve (e.g.,Flow:My_Flow).--target-org <your_alias>: the alias of the org to retrieve from.
Leave a Comment