How to Install VS Code Extensions and Configure API Keys Securely

    This guide explains how to check your environment before installing a VS Code extension, compare Marketplace, command-line, and offline VSIX installation, and store API keys without hardcoding them or committing them to a repository.

    1. Check the environment first

    Before installing, confirm the following three points.

    1. The VS Code version meets the extension’s requirements. Open the extension’s page in the Marketplace and find the stated minimum version. Then choose Help > About from the menu bar, or run code --version in a terminal. The first line of the output is the version number.
    2. The operating system is supported. VS Code supports Windows, macOS, and mainstream Linux distributions. Use the system requirements on the official VS Code site for the minimum OS version, because those numbers change with releases.
    3. The machine can reach the provider’s API. Opening the provider’s console in a browser does not mean the editor can reach the API. If the company network uses a proxy, configure that proxy in user settings.

    2. Three installation methods

    The table compares when to use each method. The steps for each method follow.

    Method When to use it Prerequisites If it fails
    Marketplace Individual developers whose machines can reach the Marketplace Network access to the Marketplace Use the command line or an offline install
    Command line Team scripts and bulk installs on build machines The code command is on the system PATH If the command is unavailable, use an offline install
    Offline VSIX Machines on a private network that cannot reach the Marketplace A .vsix file from a trusted source Obtain the package again and recheck its checksum

    Method 1: Install from the Marketplace

    Press Ctrl+Shift+X (Cmd+Shift+X on macOS) to open the Extensions view and search for the extension name. Results may include third-party extensions with similar names. Before installing, check two things. First, confirm that the publisher is the provider or its official organization. Second, confirm that the Unique Identifier on the details page matches the official documentation. The format is publisher.extension-name. After you click Install, VS Code downloads and enables the extension, and its icon appears in the Activity Bar.

    Method 2: Install from the command line

    Initialization scripts and build pipelines often install extensions from the command line. First, put the code command on the system PATH. Press Ctrl+Shift+P and run Shell Command: Install ‘code’ command in PATH. Then run the command below, replacing the angle-bracket text with the Unique Identifier from the details page.

    1. code --install-extension <publisher>.<extension-name>

    To update an extension that is already installed, add the --force flag.

    On a build machine without a graphical interface, first confirm on a local machine that the code command runs correctly. If it fails, use the offline method.

    Method 3: Install an offline VSIX

    When a machine on a private network cannot reach the Marketplace, an administrator downloads the .vsix package from an external network and copies it to the developer machine through an internal channel. Complete two checks before installing.

    First, verify the source. Download the package only from the provider’s official site or official repository. Do not use files of unknown origin.

    Second, verify the SHA-256 checksum. The release page usually provides this value. On macOS or Linux, run:

    1. shasum -a 256 filename.vsix

    On Windows, run:

    1. certutil -hashfile filename.vsix SHA256

    In the certutil output, the second line is the hash. Compare it character by character with the value on the release page. Continue only if they match exactly. If any character differs, delete the file, download it again, and verify it again.

    After the checksum matches, install the package:

    1. code --install-extension filename.vsix

    After installation, verify that the extension is present and enabled.

    3. Configure API keys securely

    An API key is an access credential for the account. If it leaks, someone else can call the API with it and incur charges. Follow these rules when configuring it.

    • Do not hardcode the key. Do not put it in source code, configuration templates, scripts, or documentation.
    • Do not commit it to version control. If a key was written into a project file, add that file to .gitignore and review the commit history.
    • Use environment variables or a system secret store. On a personal machine, use the macOS Keychain or Windows Credential Manager. In a team environment, use the organization’s secret-management service.
    • If the extension provides a key field and stores the key in VS Code Secret Storage or the system credential store, prefer that method. Do not write the key in plain text in settings.json.
    • Use least privilege. In the provider’s console, create a separate key for each purpose, grant only the permissions the extension needs, and do not grant administrative permissions.
    • Set spending limits. If the provider supports them, set a monthly budget and usage alerts.
    • Rotate keys regularly. Replace keys on the schedule your team defines, and revoke the old key immediately after replacement.

    If you use an environment variable, set it in the terminal as follows. Use the variable name from the extension documentation; <KEY_VARIABLE_NAME> is a placeholder.

    1. export <KEY_VARIABLE_NAME>="your-key"

    Writing the key directly into ~/.zshrc or ~/.bashrc stores it in plain text in that file. Do not sync that file to a public location, and do not commit it to a code repository.

    Leak checklist

    1. Search the codebase for the provider’s key prefix and check for accidental commits.
    2. Check settings.json, .env files, scripts, and CI configuration.