Cody — AI Coding Assistant by Sourcegraph
AI coding assistant with full codebase context. Cody searches your entire repo, reads relevant files, and answers questions or generates code with deep understanding.
Review-first install path
This asset needs a review step. The copied prompt tells the agent to dry-run, show the writes, then proceed only after confirmation.
npx -y tokrepo@latest install 9fc7d409-3a97-4a10-9770-959a9dbce67b --target codexDry-run first, confirm the writes, then run this command.
What it is
Cody is an AI coding assistant built by Sourcegraph that has deep understanding of your entire codebase. Unlike generic code completion tools, Cody searches your repository, reads relevant files, and uses that context to answer questions and generate code that fits your existing patterns. It is available as a VS Code extension and supports multiple LLM backends.
Cody targets developers working on large codebases where generic AI suggestions miss project-specific conventions, types, and architecture decisions. The free tier provides access to core features, with paid plans for larger teams and enterprise deployments.
How it saves time or tokens
Cody's codebase-aware context selection means it retrieves relevant files automatically, eliminating the manual process of copying code into AI prompts. For questions like 'how does authentication work in this project', Cody searches across your repo and synthesizes an answer from the actual implementation. This reduces hallucination because the model works with your real code, not generic patterns from training data.
How to use
- Install the Cody extension in VS Code by searching 'Cody' in the Extensions marketplace.
- Sign in with a Sourcegraph account (free tier available).
- Start chatting about your codebase or use inline completions as you type:
# In the Cody chat panel:
'How is the user authentication flow implemented?'
'Write a unit test for the PaymentService class'
'Explain what this function does and suggest improvements'
Example
Using Cody for context-aware code generation:
// Ask Cody: 'Create a new API endpoint for user preferences
// following the same pattern as the existing user routes'
// Cody reads your existing route files, understands the patterns,
// and generates code that matches your project conventions:
import { Router } from 'express';
import { authenticate } from '../middleware/auth';
import { PreferenceService } from '../services/preference';
const router = Router();
router.get('/preferences', authenticate, async (req, res) => {
const prefs = await PreferenceService.getByUserId(req.user.id);
res.json({ data: prefs });
});
export default router;
The generated code follows your existing patterns for middleware, service layer, and response format.
Related on TokRepo
- AI Tools for Coding — Compare AI coding assistants and their context capabilities
- AI Tools for Documentation — Documentation tools that complement code understanding
Common pitfalls
- Cody's context quality depends on Sourcegraph indexing. For large monorepos, ensure your repo is properly indexed to get accurate cross-file references.
- Free tier has usage limits on chat messages and completions per month. Heavy usage requires a paid plan.
- Cody works best with well-structured codebases. Projects with poor naming conventions or deeply nested file structures may produce less relevant context retrieval.
Frequently Asked Questions
Cody differentiates through codebase-aware context. While Copilot uses the current file and nearby tabs for context, Cody searches your entire repository using Sourcegraph's code intelligence to find relevant files, types, and patterns for more accurate suggestions.
Cody supports multiple LLM backends. The specific models available depend on your plan tier. Enterprise customers can configure their preferred LLM provider for compliance and cost control.
Yes, Cody offers a free tier with access to core chat and completion features. The free tier has monthly usage limits. Paid plans provide higher limits, additional features, and enterprise integrations.
Yes. Cody works with all major programming languages. Its codebase search is language-agnostic, using Sourcegraph's universal code intelligence to understand project structure regardless of the language.
Yes. Cody connects to your Sourcegraph instance which can index private repositories. Your code stays within your Sourcegraph deployment and is not shared with other users or used for training.
Citations (3)
- Sourcegraph Cody— Cody is an AI coding assistant by Sourcegraph with full codebase context
- Cody VS Code Extension— VS Code extension for AI-assisted coding
- Sourcegraph Documentation— Sourcegraph code intelligence for repository search
Related on TokRepo
Source & Thanks
Created by Sourcegraph. Licensed under Apache 2.0.
sourcegraph/cody — 5k+ stars
Discussion
Related Assets
Cody by Sourcegraph — AI with Full Codebase Context
AI code assistant that understands your entire codebase. Chat, completions, edits, and deep search across repos. Enterprise-grade.
Tabby — Self-Hosted AI Coding Assistant
Self-hosted AI code completion and chat assistant. Privacy-first alternative to GitHub Copilot. Supports 20+ models, repo-aware context, and IDE integrations. 33K+ stars.
Refact — Local-First AI Coding Assistant
Refact is an open-source, local-first AI coding assistant: install the IDE plugin, run local refact-lsp, and connect a model provider.
Amp by Sourcegraph — Whole-Repo AI Coding Agent
Sourcegraph's Amp reads the entire repo's symbol graph before editing. Symbol-aware retrieval, no hallucinated imports, type-respecting refactors.