ScriptsApr 7, 2026·3 min read

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.

TL;DR
AI coding assistant by Sourcegraph that understands your entire codebase for context-aware code generation and answers.
§01

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.

§02

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.

§03

How to use

  1. Install the Cody extension in VS Code by searching 'Cody' in the Extensions marketplace.
  1. Sign in with a Sourcegraph account (free tier available).
  1. 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'
§04

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.

§05

Related on TokRepo

§06

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

How does Cody differ from GitHub Copilot?+

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.

Which LLM models does Cody use?+

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.

Is Cody free to use?+

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.

Does Cody work with languages other than TypeScript?+

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.

Can Cody access private repositories?+

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)
🙏

Source & Thanks

Created by Sourcegraph. Licensed under Apache 2.0.

sourcegraph/cody — 5k+ stars

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets