Salesforce CLI

The Salesforce CLI is the free tool behind half the clever things you have seen people do with Claude and Salesforce, and its name scares off most admins. You don’t need to code to set it up. One installer, one login, and a couple of commands to prove it worked.

One free installThe Salesforce CLI, straight from Salesforce
About 15 minutesThe first time, start to finish
Mac and WindowsThe same commands on both
Nothing to install in SalesforceYour login is saved on your computer
On this page
  1. The problem
  2. What you need first
  3. 1 · Install the CLI
  4. 2 · Check the install
  5. 3 · Log in to your org
  6. 4 · Test the connection
  7. What to do next
  8. Gotchas and FAQ
The problem

Admins click. The CLI types.

Everything you do in Setup by clicking, the Salesforce CLI can do by typing a command. That sounds like a developer thing, and for years it mostly was.

Then AI showed up. Claude is very good at writing and running Salesforce CLI commands, which means an admin who has the CLI set up can ask for a validation rule, a permission set change or a record count in plain English and let Claude do the typing. An admin who doesn’t have it set up gets a lovely command pasted into the chat and the job of running it themselves.

This post is the setup, and only the setup: install the CLI, log it in to one Salesforce org, and check that the two are talking. No code, no config files, and nothing gets installed in Salesforce. The fun stuff comes after.

Before you start

Four things, and you probably have three.

Each of these has stopped someone halfway through setup, usually right before a meeting.

  1. Permission to install software on your computer. Most personal Macs are fine. On a company laptop, especially a Windows one, you may need IT to run the installer for you or give you temporary admin rights. Ask before you start.
  2. A sandbox and a user that can log in to it. Use your normal admin user. It needs the API Enabled permission, which the System Administrator profile already has. A Developer Edition org works too if you want a playground.
  3. The sandbox’s login address, if the org uses single sign-on. Most sandboxes log in at test.salesforce.com. If you normally use a company login page, copy that address. It usually ends in .sandbox.my.salesforce.com.
  4. A nickname for the org. Use client-environment, lowercase with dashes and no spaces. This guide uses acme-dev.

Do I need Node.js, Git or VS Code?

No. You might see those in developer guides. The Salesforce CLI installer brings everything it needs, so for this setup you install exactly one thing. You also don’t need to know any code. You will type about six commands, and every one of them is on this page for you to copy.

Step 1

Install the Salesforce CLI.

Download the installer that matches your computer and click through it like any other app.

Go to the Salesforce CLI download page and scroll to Choose your operating system. There are two installers each for macOS and Windows, so first work out which one is yours.

The Salesforce CLI download page on developer.salesforce.com, with the macOS and Windows headings circled above their installer links: Apple Silicon and Intel CPU for macOS, x64 and ARM64 for Windows.
Two links per system. The cards below tell you which one is yours. Linux people, you already know.
MAC

Apple Silicon or Intel?

Click the Apple menu, then About This Mac. “Chip: Apple M…” means Download for macOS (Apple Silicon). “Processor: Intel…” means Download for macOS (Intel CPU).

The About This Mac window for a 24-inch iMac, with the line Chip: Apple M4 outlined in red.
Apple M-anything means Apple Silicon. This one is an M4, so it gets the first link.

Open the .pkg file it downloads and click Continue through the installer. When you see the green check mark, click Close.

The macOS installer window titled Install sf-arm64 on its Summary step, showing a green check mark and The installation was successful, with the Close button under the cursor. The Salesforce CLI download page is behind it.
“sf-arm64” is the Apple Silicon installer. If macOS offers to move it to the Trash afterwards, let it.
WINDOWS

x64 or ARM64?

Open Settings > System > About and look at System type. Most PCs say “x64-based,” which means Download for Windows x64. If yours says “ARM-based,” use Download for Windows ARM64. Run the installer it downloads and click through.

Windows screenshots coming soon.

Installer asking for a password you don’t have? That is your computer’s admin password, not a Salesforce one. On a company laptop, this is the moment to message IT.

Step 2

Check that it installed.

Open a terminal and ask the CLI what version it is. If it answers, you are in business.

A terminal is the window where you type commands. Open a fresh one after the installer finishes, because a terminal only notices programs that were installed before it opened.

 MacWindows
UseTerminalCommand Prompt (not PowerShell)
To open itPress Command + Space, type Terminal, press ReturnClick Start, type cmd, open Command Prompt
If it was already openQuit it with Command + Q and reopen itClose the window and open a new one

Type this and press Return (Mac) or Enter (Windows):

sf --version

What you should see: a line starting with @salesforce/cli/2. followed by more numbers. The first run can take 20 seconds or so while the CLI gets itself together. Patience.

Mac Terminal with the command sf --version outlined in red, an update-available warning below it, and the result line @salesforce/cli/2.156.8 darwin-arm64 node-v24.22.1 outlined in red.
Your numbers will differ, and that is fine. The node-v24 part is the CLI’s own built-in copy of Node, not something you had to install.

See a yellow Warning: @salesforce/cli update available line above the version, like the one in the screenshot? That isn’t an error. Salesforce releases a new CLI version almost every week, so the installer is often a version or two behind by the time you run it. Ignore it for now, or run sf update to catch up.

Windows screenshots coming soon.

Why not PowerShell? PowerShell can block some commands with a “running scripts is disabled on this system” error. Command Prompt doesn’t have that problem, so use it for everything in this guide.

Step 3

Log the CLI in to your org.

One command opens a normal Salesforce login page. You log in, click Allow, and the CLI remembers that org under the nickname you gave it.

Pick the login address for the kind of org you are connecting:

Connecting aUse this --instance-url
Sandboxhttps://test.salesforce.com
Production or Developer Edition orghttps://login.salesforce.com
Org with single sign-on or a custom login pageThat org’s My Domain address, such as https://acme--dev.sandbox.my.salesforce.com

For Acme’s dev sandbox, the command is this, on a Mac or a PC:

sf org login web --alias acme-dev --instance-url https://test.salesforce.com
Mac Terminal with the command sf org login web --alias acme-dev --instance-url https://test.salesforce.com typed at the prompt and highlighted, wrapping onto a second line.
It wraps onto two lines in a small window. It is still one command, so press Return once.

--alias is the nickname. It is how you, and later Claude, tell the CLI which org you mean. It doesn’t matter which folder your terminal is in when you run this, because the CLI saves logins for your whole computer.

A browser window opens on the Salesforce login page. Log in with your sandbox username, which usually ends in the sandbox name, like you@acme.com.dev.

The Salesforce login page at test.salesforce.com, opened by the CLI, with an empty Username field, a Log In to Sandbox button, and Forgot Your Password? and Use Custom Domain links underneath.
“Log In to Sandbox” means test.salesforce.com did its job. If your org uses single sign-on, Use Custom Domain is the way through.

Salesforce then asks whether the Salesforce CLI can have access. Click Allow.

The Salesforce Allow Access? screen, saying Salesforce CLI is asking to access the identity URL service, manage user data via web browsers and APIs, and perform requests at any time, with the Allow button circled. The username and org address are pixelated.
The list sounds dramatic. It is the CLI asking to do what your own user can already do, and you can revoke it any time in your personal settings.

Go back to the terminal and wait for the success message.

What you should see: Successfully authorized you@acme.com.dev with org ID 00D…

Mac Terminal after running sf org login web, showing an update-available warning and then the green line Successfully authorized with the username pixelated and an org ID starting 00D, the rest of the org ID pixelated.
Green means go. This one used the nickname abc-dev, so yours will show whatever you typed after --alias. Every org ID starts with 00D.

The most common mistake here is logging in to the wrong org, and it usually isn’t your fault. The browser happily reuses whatever Salesforce session it already has open. Log out of Salesforce in that browser (or use a private window), then run the same command again. The new login replaces the wrong one.

Connecting production? You can, with https://login.salesforce.com and a nickname ending in -prod. Once it is connected, every command that names it runs in the live org. Start with a sandbox while you learn.

Step 4

Prove the CLI can talk to Salesforce.

Three quick commands: see the org in your list, open it, and ask it a question.

First, the list of orgs the CLI knows about:

sf org list

You should see acme-dev in the table next to your username.

Next, open the org straight from the CLI. If Setup opens in the sandbox you expected, the nickname points at the right place.

sf org open --target-org acme-dev

Last, a real question. This counts the Accounts in the sandbox, and it only reads data, so it can’t break anything:

sf data query --query "SELECT COUNT() FROM Account" --target-org acme-dev

What you should see: Total number of records retrieved: followed by a number. Any number is fine, including zero in an empty Developer Edition org. If you got a number, the CLI is installed, logged in and talking to Salesforce. Go tell someone.

What to do next

You have a working CLI. Now use it.

The hard part was the one-time setup, and it is done. Here is where to go from here.

  1. 1

    Add your other orgs

    Every extra sandbox, production org or Developer Edition org is the same login command with a different nickname. The quick guide to adding another org to the CLI covers that, plus sandbox refreshes, renaming a nickname and logging out when a project ends.

  2. 2

    Keep the CLI updated

    Salesforce updates the CLI often. Every month or so, run sf update in a terminal to get the latest version. It is the same command on a Mac and a PC.

  3. 3

    Hand the typing to Claude

    With the CLI logged in, Claude can run these commands for you and handle the setup work you would normally click through. That is the next part of this series.

Gotchas

The things that go wrong, and the fixes.

command not found: sf, or ‘sf’ is not recognized
Close the terminal and open a new one, because a terminal only sees programs installed before it opened. If it still fails, run the installer again. On Windows, make sure you are in Command Prompt.
It says an update is available
Normal, and not an error. The CLI checks for new versions and Salesforce ships them constantly. Run sf update whenever you have a minute, or ignore it. Everything in this guide works either way.
The installer wants an admin password I don’t have
That is your computer’s administrator password. On a company laptop, ask IT to install the Salesforce CLI for you or grant temporary admin rights.
Windows says running scripts is disabled on this system
You are in PowerShell. Open Command Prompt instead (Start, type cmd) and run the same command.
It logged me in to the wrong org
The browser reused a Salesforce session that was already open. Log out of Salesforce in that browser, or use a private window, then run the login command again with the same nickname. The new login replaces the old one.
No browser opened, or the wrong login page opened
If nothing opened, look in the terminal for a web address, copy it into your browser and log in there. If the wrong login page opened, check the --instance-url: test.salesforce.com for sandboxes, login.salesforce.com for production and Developer Edition, or the org’s own My Domain address if it uses single sign-on.
The terminal just sits there after I log in
Quit the terminal (Command + Q on a Mac, close the window on Windows), open a new one and run sf org list. If your nickname is in the list, the login worked. If it isn’t, run the login command again.
The query says it can’t find my org
The nickname after --target-org has to match sf org list exactly, dashes and all. If it matches and still fails, the login has probably expired, which happens when a sandbox gets refreshed. Run the login command again with the same nickname.
How do I log out?
Run sf org logout --target-org acme-dev with your org’s nickname, then type y when it asks if you are sure. The guide to adding and removing orgs walks through it with a screenshot, plus how to log out of every org at once.
Is this safe to run against a client’s org?
Everything in this guide only logs in and reads. The CLI uses your own login, so it can’t do anything your user can’t already do in Setup, and nothing gets installed in the org. When you are done with an org, log the CLI out of it.
Get started

Fifteen minutes now, a lot less clicking later.

The Salesforce CLI is free and comes straight from Salesforce. Install it, log in once, and it is ready whenever you are.

Know an admin who still thinks the CLI is just for developers?

Share on LinkedIn