Skip to main content
This guide walks you through installing Cody for VS Code, connecting to your Sourcegraph account, and using Cody’s core features for the first time.
Cody is available in multiple editors. This guide uses the VS Code extension, which is recommended for new users. See Clients for installation guides for JetBrains, Visual Studio, and other platforms.

Prerequisites

  • VS Code installed (latest stable version)
  • A Sourcegraph Enterprise account with Cody enabled
  • A project open in VS Code

Install and connect Cody

1

Install the Cody extension

Open VS Code and press Cmd+Shift+X (macOS) or Ctrl+Shift+X (Windows/Linux) to open the Extensions panel.Search for Cody AI and click Install.Alternatively, install it directly from the VS Code Marketplace.After installation, VS Code may prompt you to reload the window to activate the extension.
2

Sign in to your Sourcegraph instance

Click the Cody icon in the Activity Bar on the left side of VS Code.Click Sign In to Your Enterprise Instance and enter the URL of your Sourcegraph Enterprise instance. If you are unsure of the URL, contact your administrator.A browser window will open asking you to authorize VS Code to connect to Sourcegraph. Click Authorize.
3

Generate an access token

If the browser authorization does not complete automatically, you can connect using an access token:
  1. In your Sourcegraph instance, go to Account Settings > Access Tokens
  2. Click + Generate new token, give it a name, and click Generate
  3. Copy the token
  4. Back in VS Code, click Sign In to Your Enterprise Instance, choose Sign In to Sourcegraph Instances v5.1 and above, and paste your token when prompted
Store your access token securely. Treat it like a password — do not commit it to source control.
4

Verify the connection

Once connected, click the Cody icon in the Activity Bar again. The Cody panel opens in the sidebar.To confirm that Cody is working, create a new file called code.js and type:
function bubbleSort(array) {}
Cody will provide an autocomplete suggestion in dimmed gray text. Press Tab to accept it.

Use chat

Chat is the most direct way to interact with Cody. Open the Cody sidebar and type a question in the input field at the top of the panel.
1

Ask a question about your code

Click the Cody icon to open the chat panel. By default, the input includes context chips for your current file and repository.Try asking:
  • “What does this file do?”
  • “Explain this codebase in three to four lines”
  • “Are there any performance issues in this code?”
Cody will respond with an explanation, pulling context from the files shown in the context chips.
2

Add more context with @-mentions

Type @ in the chat input to open the context picker. You can add:
  • @filename — include a specific file
  • @#symbolName — include a function, class, or type definition
  • @filepath:1-50 — include a specific line range
For example:
@src/utils/auth.ts How does the token validation work?
3

Apply a code suggestion

When Cody responds with a code block, you have three options:
  • Click the Copy icon to copy the code to your clipboard
  • Click Insert at cursor to insert the code at your current cursor position
  • Click Apply to use Smart Apply — Cody will analyze your open file, find the right location, and insert a diff for you to review

Use autocomplete

Cody provides real-time inline code suggestions as you type.
1

Start typing in any file

Open any code file and start typing a function or expression. Cody will suggest a completion in dimmed gray text after a brief pause.
2

Accept or dismiss suggestions

  • Press Tab to accept the full suggestion
  • Press Esc to dismiss it
  • Continue typing to refine the suggestion
Cody’s default autocomplete model is DeepSeek V2, which is optimized for low latency and high accuracy across single-line and multi-line completions.

Refactor code with inline edit

You can request code edits inline without opening the chat panel.
1

Select the code you want to change

Highlight a function or block of code in your editor.
2

Open the inline edit input

Press Opt+K (macOS) or Alt+K (Windows/Linux) to open the Edit Code input field above the selection.
3

Describe the change

Type a description of the edit you want, for example:
Refactor to sort dates in descending order
Press Enter. Cody generates a diff in seconds.
4

Review and accept

Review the proposed diff. Click Accept to apply it, Reject to dismiss, or Edit & Retry to iterate on your prompt.

Debug code

Cody can identify and fix errors directly in your editor.
1

Notice an error in your code

When VS Code detects an error, a red underline and a lightbulb icon appear next to the problematic line.
2

Ask Cody to fix it

Click the lightbulb icon and select Ask Cody to fix. Cody analyzes the error and generates a suggested fix with a diff view.
3

Accept or reject the fix

Review the proposed change. Click Accept to apply it or Undo to discard.

Use prompts

Prompts are pre-built or custom templates that automate common tasks.
1

Open the prompts list

In the Cody chat panel, click the Prompts dropdown to see available prompts. Built-in prompts include:
  • document-code — Generate inline documentation for a function or class
  • explain-code — Get a plain-language explanation of selected code
  • find-code-smells — Identify potential issues or anti-patterns
  • generate-unit-tests — Generate unit tests for a function
2

Run a prompt

Select code in your editor, then click a prompt from the list. Cody will run the prompt using your selection as context.For prompts in Edit code mode (like document-code), Cody applies the result directly to your file.
3

Create a custom prompt

Go to Tools > Prompt Library in your Sourcegraph instance to create and save your own prompts. Custom prompts appear in the Cody chat panel automatically.

Keyboard shortcuts

ActionmacOSWindows / Linux
Open / toggle chatOpt+LAlt+L
New chat sessionShift+Opt+LShift+Alt+L
Inline editOpt+KAlt+K
Quick fix menuCmd+.Ctrl+.

Next steps

Capabilities

Learn about all Cody features in depth, including auto-edit, prompts, and context filters.

Clients

Set up Cody in JetBrains, Visual Studio, or use the CLI and web app.

Build docs developers (and LLMs) love