Beginner 20 min read

Salesforce CLI Basics

By the end of this lesson, you'll be able to:

  • Explain what the Salesforce CLI (sf) is used for
  • Name three common CLI tasks a developer performs daily
  • Read a simple sf command and explain what it does

Prerequisites: "VS Code and Salesforce Extensions"

What it is

The Salesforce CLI is a command-line program (sf) you install once on your machine. Every time VS Code's Salesforce extensions deploy your code or retrieve metadata, they're actually calling the CLI under the hood — the extensions are a friendly wrapper around it.

You'll use it directly a lot once you reach the DevOps module, but it's worth a first look now so sf commands don't feel unfamiliar when they show up in later exercises.

Commands you will see again

  • sf org login web — opens a browser to log into a Salesforce org and remember it locally.
  • sf project deploy start — pushes local code changes up to a connected org.
  • sf apex run test — runs Apex tests from the command line, exactly what a CI/CD pipeline does automatically (covered in the DevOps module).

You don't need to run any of these yet — just recognize the shape: sf followed by a category (org, project, apex) and an action.

Exercise

Without running anything, write down what you'd expect the command `sf apex run test --code-coverage` to do, based only on its name and this lesson's explanation of sf's command shape.

Show hint

Break it into pieces: sf, apex (category), run test (action), --code-coverage (an option modifying the action).

Salesforce CLI Basics Quiz

1. What powers VS Code's Salesforce deployment features behind the scenes?

Log in to submit the quiz and save your score.

My Notes

Log in to keep private notes on this lesson.

Questions about this lesson

No questions yet — be the first to ask.

Log in to ask a question about this lesson.

Summary

The Salesforce CLI (the sf command) is the command-line tool that powers everything VS Code's extensions do behind the scenes — authenticating to orgs, deploying code, and running tests — and it's worth understanding on its own since real teams script and automate around it.