In this categoryVS Code Setup ยท 25
VS Code SetupBeginner

How to Install a VS Code Extension from the Command Line

Install and pin VS Code extensions with the code CLI so a fresh machine or container is set up in seconds.

6 minBeginner

Clicking through the Extensions panel is fine for one extension, but it does not reproduce. The code CLI installs extensions by id, which means you can script a full editor setup and run it on any new machine or dev container. This guide installs one, then captures your whole list.

What you need

  • VS Code installed with the code command on PATH
  • The id of an extension you want
  • About 5 minutes

Step 1: Find the extension id

Every extension has a publisher.name id shown on its marketplace page. That id is what the CLI installs, not the display name.

VS Code - extension id
ESLint
Identifier: dbaeumer.vscode-eslint
Publisher: Microsoft
Use the Identifier with code --install-extension.
The id is publisher.name, shown on the extension page.

Step 2: Install it from the CLI

Pass the id to the install flag. The CLI downloads and enables it without opening the panel.

zsh - install extension
$code --install-extension dbaeumer.vscode-eslint
Installing extensions...
Extension 'dbaeumer.vscode-eslint' was successfully installed.
$

Step 3: Save your full list

Export every installed extension to a file. This is the reproducible setup you can commit and re-run anywhere.

terminal
code --list-extensions > extensions.txt
# later, on a new machine:
cat extensions.txt | xargs -L1 code --install-extension
Check it into the repo
Commit extensions.txt, or a .vscode/extensions.json recommendations file, so teammates and dev containers get the same editor setup with one command.

Result: extensions install from a script instead of clicks, so a fresh environment matches your working setup in seconds.

Watch related tutorials

Free weekly email

New guides in your inbox

Fresh step-by-step how-to guides as we publish them. One email a week, no more.

Tags
#vscode#extensions#cli#setup#reproducible