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
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.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.
Generate an access token
If the browser authorization does not complete automatically, you can connect using an access token:
- In your Sourcegraph instance, go to Account Settings > Access Tokens
- Click + Generate new token, give it a name, and click Generate
- Copy the token
- 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
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.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?”
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
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.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.
Refactor code with inline edit
You can request code edits inline without opening the chat panel.Open the inline edit input
Press
Opt+K (macOS) or Alt+K (Windows/Linux) to open the Edit Code input field above the selection.Describe the change
Type a description of the edit you want, for example:Press
Enter. Cody generates a diff in seconds.Debug code
Cody can identify and fix errors directly in your editor.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.
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.
Use prompts
Prompts are pre-built or custom templates that automate common tasks.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
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.Keyboard shortcuts
| Action | macOS | Windows / Linux |
|---|---|---|
| Open / toggle chat | Opt+L | Alt+L |
| New chat session | Shift+Opt+L | Shift+Alt+L |
| Inline edit | Opt+K | Alt+K |
| Quick fix menu | Cmd+. | 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.