Sourcegraph Cody
Sourcegraph
An AI programming assistant from Sourcegraph, skilled at understanding large codebases.
Overview
Cody is Sourcegraph's AI programming assistant, focused on understanding large codebases. Its core advantage is leveraging Sourcegraph's code search and indexing technology to understand the context of an entire codebase. Cody supports code completion, AI chat, commands, code search, and other features. Unlike ordinary AI assistants, Cody can answer questions about the entire codebase, such as 'where is this function called?'. It supports multiple LLM backends, including Claude, GPT-4, local models, and more.
Installation
Cody is installed via IDE plugins. It supports VS Code, JetBrains, Neovim, Emacs, and more. After installation, you need to log in to a Sourcegraph account (free version) or configure an enterprise instance.
# VS Code installation
# 1. Open the extension store
# 2. Search for "Cody"
# 3. Click install
# 4. Restart VS Code
# 5. Log in to your Sourcegraph account
# JetBrains installation
# Settings -> Plugins -> Search for "Cody"Code Search
Cody integrates Sourcegraph's code search capabilities. You can search the entire codebase, find definitions, references, usage patterns, and more. Search supports regular expressions, file filters, language filters, and more. This is Cody's core advantage, able to understand large codebases.
# Code search example
# In Cody chat:
# "Find all places that call the getUserData function"
# "Which files use React hooks?"
# "Find all TODO comments"
# "Show the inheritance hierarchy of the UserService class"Autocomplete
Cody provides smart code completion, supporting single-line and multi-line completion. It provides suggestions based on codebase context, understanding project structure and patterns. Completion is fast with low latency. It supports completion for multiple languages.
# Cody configuration
{
"cody.autocomplete.enabled": true,
"cody.autocomplete.languages": {
"*": true,
"python": true,
"typescript": true
},
"cody.autocomplete.smartThrottle": true
}Chat
Cody Chat provides a conversational AI assistant that can answer questions about the codebase. Chat understands the entire codebase context and can reference multiple files. It supports code generation, explanation, refactoring, debugging, and more. Chat history can be saved and searched.
# Use Chat
# Shortcut: Alt+C
# Example conversations:
# "Explain what this function does"
# "What is the call chain of this API?"
# "Add error handling to this function"
# "Which places need to be modified to support the new requirement?"Commands
Cody provides predefined commands to quickly perform common operations, such as explaining code, generating tests, fixing bugs, generating documentation, and more. Custom commands are also supported. Commands can be executed against selected code or the current file.
# Built-in commands
# /explain - explain code
# /test - generate tests
# /smell - detect code smells
# /doc - generate documentation
# Custom commands
# .vscode/cody.json
{
"commands": {
"refactor": {
"description": "Refactor the selected code",
"prompt": "Refactor the following code to improve readability: {selection}"
}
}
}Context
Cody's core advantage is context understanding. It can use the entire codebase as context to provide accurate answers. It supports multiple context sources: current file, open files, search results, custom context, and more. You can manually add or remove context files.
# Context configuration
{
"cody.context": {
"currentFile": true,
"openTabs": true,
"searchResults": true,
"customPatterns": [
"**/*.ts",
"**/*.tsx"
]
}
}Enterprise
Cody Enterprise connects to a Sourcegraph instance, providing enterprise-grade code understanding capabilities. It supports private codebases, SSO, audit logs, access control, and more. The enterprise version can leverage Sourcegraph's code graph to provide deeper code understanding. It is suitable for large enterprises.
# Enterprise configuration
{
"cody.serverEndpoint": "https://sourcegraph.company.com",
"cody.enterprise": true,
"cody.codebase": "github.com/company/repo"
}Configuration
Cody provides rich configuration options. You can choose the LLM backend (Claude, GPT-4, local models), adjust completion behavior, configure context, and more. Project-level configuration is supported.
# Full configuration example
{
"cody.autocomplete.enabled": true,
"cody.chat.model": "claude-3-5-sonnet",
"cody.autocomplete.model": "starcoder-2",
"cody.context.currentFile": true,
"cody.telemetry": "off"
}More AI Guides
Claude Code
A terminal-native AI coding agent from Anthropic that autonomously understands codebases, edits files, runs commands, and completes multi-step development tasks.
OpenAI Codex
An official command-line AI coding assistant from OpenAI, built on the GPT model family and optimized for code generation and development workflows.
Trae
ByteDance's AI-native IDE—the first of its kind in China—deeply integrates LLMs such as Doubao and DeepSeek, supporting natural-language interaction and multimodal collaboration.
Cursor
A next-generation AI code editor from Anysphere with a built-in Composer agent that can run multiple coding tasks in parallel.
GitHub Copilot
An AI coding assistant co-developed by GitHub and OpenAI, offering code completion, chat, and an Agent mode.
Windsurf
An AI-native IDE from Codeium with a built-in Cascade agent that deeply couples the terminal and editor.