Introduction
The Visual Studio Code CLI (code) is a powerful command-line interface built in Rust that provides comprehensive control over VS Code installations, extensions, and remote development features. The CLI enables automation, scripting, and headless operations for developers and administrators.
Installation
The VS Code CLI is automatically included with VS Code installations. You can verify the installation by running:Basic Usage
The CLI follows a standard command structure:Opening Files and Folders
Open a file or folder in VS Code:Reading from stdin
You can pipe content directly into VS Code:Common Use Cases
Development Workflow
Opening Projects
Opening Projects
Managing Extensions
Managing Extensions
Remote Development
Remote Development
Automation and Scripting
The CLI is ideal for automated workflows:Key Features
Extension Management
Install, uninstall, and manage VS Code extensions from the command line
Remote Tunnels
Create secure tunnels to access VS Code from anywhere via vscode.dev
Version Management
Switch between different VS Code versions (stable, insiders, or specific versions)
Web Server
Run a local web version of VS Code for browser-based development
Global Options
These options are available for all commands:Enable verbose output for detailed logging
Set log level:
trace, debug, info, warn, error, critical, offDirectory where CLI metadata should be stored (also via
VSCODE_CLI_DATA_DIR environment variable)Disable telemetry for the current command
Set telemetry level:
off, crash, error, allEditor Options
When opening files or folders, you can use these options:Compare two files side by side
Open file at specific line and optional character position
Force opening a new window instead of reusing existing one
Force reusing the last active window
Wait for the files to be closed before returning (useful for git commit messages)
Set the display language (e.g.,
en-US, zh-TW, fr-FR)Data Directories
Specify a custom directory for user data (allows running multiple isolated instances)
Set a custom extensions directory
Using custom data directories allows you to maintain separate VS Code configurations for different projects or purposes.
Next Steps
Commands Reference
Explore all available CLI commands and their options
Remote Tunnels
Learn how to set up remote development with tunnels
Additional Resources
- Run
code --helpfor a complete list of options - Use
code <command> --helpfor command-specific help - The CLI supports both integrated mode (with VS Code installed) and standalone mode