Installing Cody in VS Code
Learn how to use Cody and its features with the VS Code editor.
The Cody extension by Sourcegraph enhances your coding experience in VS Code by providing intelligent code sugsgestions, context-aware completions, and advanced code analysis. This guide will walk you through the steps to install and set up the Cody within your VS Code environment.
- You have the latest version of VS Code installed
- You have enabled an instance for Cody from your Sourcegraph.com account
Install the VS Code extension
Follow these steps to install the Cody AI extension for VS Code:
- Open VS Code editor on your local machine
- Click the "Extensions" icon in the Activity Bar on the side of VS Code, or use the keyboard shortcut
- Type "Cody AI" in the search bar and press "Enter"
- Click on the "Install" button next to the "Cody AI" by Sourcegraph
- After installing the extension, you may be prompted to restart VS Code to activate the extension
Alternatively, you can also download and install the extension from the VS Code Marketplace directly.
Connect the extension to Sourcegraph
After a successful installation, Cody's icon appears in the side bar. When you click it, you're asked to either "Download the Cody App" or use "Other Sign In Options…" to connect to a Sourcegraph instance.
You can connect either an enterprise instance or Sourcegraph.com via the following ways:
- Sign in to Sourcegraph Enterprise instance
- Sign in to Sourcegraph Enterprise instance via Access Token
- Sign in to Sourcegraph.com
- Sign in with URL and Access Token
For Sourcegraph enterprise users
Log in to your Sourcegraph instance and go to
access token (
https://<your-instance>.sourcegraph.com/users/<your-instance>/settings/tokens). From here, generate a new access token.
Then, you will paste your access token and instance address in to the Cody extension.
For Sourcegraph.com users
Continue with Sourcegraph.com in the Cody extension. From there, you'll be taken to Sourcegraph.com, which will authenticate your extension.
Verifying the installation
Once connected, click the Cody icon from the sidebar again, and a panel will open. To verify that the Cody extension has been successfully installed and is working as expected:
- As you start typing, Cody should begin providing intelligent suggestions and context-aware completions based on your coding patterns and the context of your code
Cody also supports executing reusable prompts known as Commands from within the VS Code extension. They allow you to run predefined actions (like
Explain Selected Code and
Generate Unit Tests for example) with smart context-fetching anywhere in the editor.
Enable code graph context for context-aware answers (Optional)
You can optionally configure code graph content, which gives Cody the ability to provide context-aware answers. For example, Cody can write example API calls if has context of a codebase's API schema.
Learn more about how to:
- Configure code graph context for Sourcegraph.com
- Configure code graph context for Sourcegraph Enterprise
Updating the extension
VS Code will typically notify you when updates are available for installed extensions. Follow the prompts to update the Cody AI extension to the latest version.
Read more about Cody Capabilities to learn about all the features it provides to boost your development productivity.
For more information on what to do next, we recommend the following resources: