Skip to main content
The Visual Studio Code CLI (code) is a powerful command-line tool that allows you to control and interact with VS Code from the terminal. It provides functionality for opening files and folders, managing extensions, creating remote tunnels, and much more.

What is the VS Code CLI?

The VS Code CLI is a Rust-based command-line interface that serves as the entry point for launching and controlling Visual Studio Code. It can:
  • Launch VS Code with specific files, folders, or workspaces
  • Manage extensions (install, uninstall, list)
  • Create secure remote tunnels for accessing your machine from anywhere
  • Run a local web version of VS Code
  • Switch between different VS Code versions (stable, insiders, or specific versions)
  • Configure editor settings and troubleshoot issues
The CLI is designed to work with both standalone installations and integrated VS Code installations.

Key Features

Remote Tunnels

Create secure tunnels to access your development environment from vscode.dev or any browser, from anywhere in the world.

Extension Management

Install, uninstall, list, and update extensions directly from the command line.

Version Management

Switch between stable, insiders, or specific versions of VS Code seamlessly.

Local Web Server

Run a local web version of VS Code for browser-based development.

Basic Usage

The basic syntax for using the VS Code CLI is:
code [options] [paths...]

Opening Files and Folders

code myfile.txt

Quick Examples

1

Open a file at a specific line

code --goto myfile.txt:42:5
Opens myfile.txt at line 42, column 5.
2

Compare two files

code --diff file1.txt file2.txt
Opens a diff view comparing the two files.
3

Install an extension

code ext install ms-python.python
Installs the Python extension.
4

Create a tunnel

code tunnel
Creates a secure tunnel to access your machine remotely.

Command Categories

The CLI is organized into several main command categories:

Core Commands

  • No subcommand - Launch VS Code with files/folders
  • status - Print process usage and diagnostics
  • version - Manage VS Code versions

Extension Commands

  • ext list - List installed extensions
  • ext install - Install extensions
  • ext uninstall - Uninstall extensions
  • ext update - Update extensions

Tunnel Commands

  • tunnel - Create and manage remote tunnels
  • tunnel service - Manage tunnel as a system service
  • tunnel user - Manage authentication for tunnels

Web Commands

  • serve-web - Run a local web version of VS Code
For detailed information about each command, see the Commands Reference page.

Global Options

These options can be used with any command:
--verbose
boolean
Print verbose output (implies —wait)
--log
string
Log level to use. Values: off, critical, error, warn, info, debug, trace
--cli-data-dir
string
Directory where CLI metadata should be stored
--disable-telemetry
boolean
Disable telemetry for the current command
--telemetry-level
string
Sets the initial telemetry level. Values: off, crash, error, all

Architecture

The VS Code CLI is built with:
  • Language: Rust
  • Binary name: code (or code-cli internally)
  • Command parsing: clap library for robust CLI argument parsing
  • Async runtime: tokio for asynchronous operations
  • Tunneling: Microsoft Dev Tunnels for secure remote access

Output Formats

Many commands support both text and JSON output formats:
Text output (default)
code tunnel status
JSON output
code tunnel status --format json

Environment Variables

The CLI respects several environment variables:
  • VSCODE_CLI_DATA_DIR - Override the CLI data directory
  • VSCODE_CLI_ACCESS_TOKEN - Provide access token for authentication
  • VSCODE_CLI_REFRESH_TOKEN - Provide refresh token for authentication
  • VSCODE_CLI_REQUIRE_TOKEN - Require token for command shell connections
  • VSCODE_CLI_NONINTERACTIVE - Disable interactive prompts
  • NO_COLOR - Disable colored output

Next Steps

Installation

Learn how to install the VS Code CLI on your system

Commands Reference

Explore all available CLI commands and options

Remote Tunnels

Set up secure remote access to your development environment

Configuration

Configure the CLI for your workflow