Skip to main content
This page provides a comprehensive reference for all Visual Studio Code CLI commands, options, and usage patterns.

Basic Syntax

code [options] [paths...]

Opening Files and Folders

The default behavior (no subcommand) launches VS Code with the specified files or folders.

Options

paths
string[]
One or more files, folders, or URIs to open. Can also use - to read from stdin.

Examples

code myfile.txt

Editor Options

--diff
string[]
Compare two files with each other.
code --diff file1.txt file2.txt
--add
string
Add folder(s) to the last active window.
code --add /path/to/folder
--goto
string
Open a file at the specified line and character position. Format: file:line[:character]
code --goto myfile.txt:42:5
--new-window
boolean
Force to open a new window.
code --new-window
--reuse-window
boolean
Force to open a file or folder in an existing window.
code --reuse-window myfile.txt
--wait
boolean
Wait for the files to be closed before returning. Useful for using VS Code as an editor for git commit messages.
code --wait myfile.txt
--locale
string
The locale to use (e.g., en-US or zh-TW).
code --locale ja
--enable-proposed-api
string[]
Enables proposed API features for extensions. Can receive one or more extension IDs.
code --enable-proposed-api ms-vscode.example-extension

Extension Commands

Manage VS Code extensions from the command line.

code ext list

List installed extensions.
--show-versions
boolean
Show versions of installed extensions.
code ext list --show-versions
--category
string
Filters installed extensions by provided category.
code ext list --category "Programming Languages"

code ext install

Install one or more extensions.
id-or-path
string[]
required
Extension identifier(s) in the format publisher.name or path(s) to VSIX file(s).
code ext install ms-python.python
code ext install ms-vscode.cpptools ms-dotnettools.csharp
code ext install /path/to/extension.vsix
--pre-release
boolean
Installs the pre-release version of the extension.
code ext install ms-python.python --pre-release
--force
boolean
Update to the latest version of the extension if it’s already installed.
code ext install ms-python.python --force
--donot-include-pack-and-dependencies
boolean
Don’t include installing pack and dependencies of the extension.

code ext uninstall

Uninstall one or more extensions.
ext-id
string[]
required
Extension identifier(s) to uninstall in the format publisher.name.
code ext uninstall ms-python.python
code ext uninstall ms-vscode.cpptools ms-dotnettools.csharp

code ext update

Update all installed extensions to their latest versions.
code ext update

Status Command

code status

Print process usage and diagnostics information.
code status
This command displays information about running VS Code processes, resource usage, and system diagnostics.

Version Commands

Manage which version of VS Code the CLI uses.

code version show

Show the currently configured editor version.
code version show
Output:
Current quality: stable
Installation path: /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code

code version use

Switch the version of VS Code you’re using.
version
string
required
The version to use. Can be:
  • stable - Latest stable release
  • insiders - Latest insiders build
  • x.y.z - Specific version number
  • Absolute path to an existing install
code version use stable
code version use insiders
code version use 1.85.0
code version use /path/to/vscode
--install-dir
string
The directory where the version can be found.
code version use stable --install-dir /custom/path

Tunnel Commands

Create and manage secure remote tunnels. See the Remote Tunnels page for detailed information.

code tunnel

Create a tunnel that’s accessible on vscode.dev from anywhere.
code tunnel
--name
string
Sets the machine name for port forwarding service.
code tunnel --name my-dev-machine
--random-name
boolean
Randomly name machine for port forwarding service.
code tunnel --random-name
--accept-server-license-terms
boolean
Accept the server license terms automatically without a user prompt.
code tunnel --accept-server-license-terms
--no-sleep
boolean
Prevents the machine from going to sleep while the tunnel is running.
code tunnel --no-sleep

Tunnel Subcommands

Get tunnel status information.
code tunnel status
Returns JSON output with tunnel and service status.

Tunnel User Commands

Manage authentication for tunnels.
Log in to the port forwarding service.
code tunnel user login
--provider
string
The auth provider to use. Options: github, microsoft
code tunnel user login --provider github
--access-token
string
Provide an access token for authentication. Requires --provider.
code tunnel user login --provider github --access-token TOKEN
Can also use environment variable: VSCODE_CLI_ACCESS_TOKEN

Tunnel Service Commands

Manage the tunnel as a system service (runs in background).
Install the tunnel service on the machine.
code tunnel service install
--name
string
Sets the machine name for the service.
--accept-server-license-terms
boolean
Accept server license terms automatically.

Serve Web Command

Run a local web version of VS Code.

code serve-web

code serve-web
--host
string
default:"localhost"
Host to listen on.
code serve-web --host 0.0.0.0
--port
number
default:"8000"
Port to listen on. If 0 is passed, a random free port is picked.
code serve-web --port 3000
code serve-web --port 0  # Random port
--socket-path
string
Path to a socket file for the server to listen to.
code serve-web --socket-path /tmp/vscode.sock
--connection-token
string
A secret that must be included with all requests.
code serve-web --connection-token my-secret-token
--connection-token-file
string
A file containing a secret that must be included with all requests.
code serve-web --connection-token-file /path/to/token.txt
--without-connection-token
boolean
Run without a connection token. Only use if the connection is secured by other means.
code serve-web --without-connection-token
--server-base-path
string
Specifies the path under which the web UI and code server are provided.
code serve-web --server-base-path /vscode
--server-data-dir
string
Specifies the directory that server data is kept in.
code serve-web --server-data-dir ~/.vscode-server-data
--commit-id
string
Use a specific commit SHA for the client.
code serve-web --commit-id abc123def456
--accept-server-license-terms
boolean
Accept the server license terms automatically.

Desktop Code Options

These options apply whenever the desktop editor is launched.
--extensions-dir
string
Set the root path for extensions.
code --extensions-dir ~/.vscode-extensions
--user-data-dir
string
Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of the editor.
code --user-data-dir ~/.vscode-dev
--use-version
string
Sets the editor version to use for this command. Can be stable, insiders, a version number, or an absolute path.
code --use-version insiders myfile.txt

Troubleshooting Options

--disable-extensions
boolean
Disable all installed extensions.
code --disable-extensions
--disable-extension
string[]
Disable specific extension(s).
code --disable-extension ms-python.python
--disable-gpu
boolean
Disable GPU hardware acceleration.
code --disable-gpu
--sync
string
Turn sync on or off. Values: on, off
code --sync off
--inspect-extensions
number
Allow debugging and profiling of extensions. Specify the debug port.
code --inspect-extensions 9333
--inspect-brk-extensions
number
Allow debugging and profiling of extensions with the extension host being paused after start.
code --inspect-brk-extensions 9333
--prof-startup
boolean
Run CPU profiler during startup.
code --prof-startup
--telemetry
boolean
Show all telemetry events which the editor collects.
code --telemetry

Global Options

These options are available for all commands.
--verbose
boolean
Print verbose output.
code --verbose tunnel
--log
string
Log level to use. Values: off, critical, error, warn, info, debug, trace
code --log debug tunnel
--cli-data-dir
string
Directory where CLI metadata should be stored.
code --cli-data-dir ~/.my-vscode-cli tunnel
Can also set via environment variable: VSCODE_CLI_DATA_DIR
--disable-telemetry
boolean
Disable telemetry for the current command.
code --disable-telemetry tunnel
--telemetry-level
string
Sets the initial telemetry level. Values: off, crash, error, all
code --telemetry-level off

Standalone CLI Commands

These commands are only available in standalone CLI installations.

code update

Update the CLI to the latest version.
code update
--check
boolean
Only check for updates without actually updating.
code update --check

Server Options

Options available for tunnel and serve-web commands that start a server.
--install-extension
string[]
Requests that extensions be preloaded and installed on connecting servers.
code tunnel --install-extension ms-python.python
--server-data-dir
string
Specifies the directory that server data is kept in.
code tunnel --server-data-dir ~/.vscode-server
--extensions-dir
string
Set the root path for extensions on the server.
code tunnel --extensions-dir ~/.vscode-server-extensions
--reconnection-grace-time
number
default:"10800"
Reconnection grace time in seconds. Default is 10800 (3 hours).
code tunnel --reconnection-grace-time 7200

Environment Variables

The CLI respects these environment variables:
VSCODE_CLI_DATA_DIR
string
Override the CLI data directory.
VSCODE_CLI_ACCESS_TOKEN
string
Provide access token for tunnel authentication.
VSCODE_CLI_REFRESH_TOKEN
string
Provide refresh token for tunnel authentication.
VSCODE_CLI_REQUIRE_TOKEN
string
Require token string for command shell connections.
VSCODE_CLI_NONINTERACTIVE
string
Disable interactive prompts.
NO_COLOR
string
Disable colored output.
TUNNEL_SERVICE_USER_AGENT
string
Custom user agent for tunnel service.

Exit Codes

The CLI uses standard exit codes:
  • 0 - Success
  • 1 - General error or operation failed
  • Other non-zero values indicate specific error conditions

Tips and Best Practices

Configure VS Code as your git commit message editor:
git config --global core.editor "code --wait"
The --wait flag makes git wait for you to close the file before continuing.
Use --new-window to avoid interfering with existing workspaces:
code --new-window /path/to/large/project
Use --user-data-dir to maintain separate profiles:
# Personal profile
code --user-data-dir ~/.vscode-personal

# Work profile
code --user-data-dir ~/.vscode-work
Install multiple extensions at once:
code ext install ms-python.python ms-vscode.cpptools ms-dotnettools.csharp
Export and import extension lists:
# Export
code ext list > extensions.txt

# Import
cat extensions.txt | xargs -L 1 code ext install

Next Steps

Remote Tunnels

Learn about secure remote access

Configuration

Configure the CLI for your workflow

Installation

Install the CLI on your system

Overview

Back to CLI overview