The Rise of Agentic Coding: How Sourcegraph Pushes Past Copilot
AI-assisted — drafted with AI, reviewed by editorsAlex Chen
AI engineer and open-source contributor. Writes about agent architectures and LLM tooling.
# The Rise of Agentic Coding: How Sourcegraph Pushes Past Copilot ## What Sourcegraph Cody Is and Who It’s For Sourcegraph Cody is an AI coding assistant that treats the large language model (LLM) a...
The Rise of Agentic Coding: How Sourcegraph Pushes Past Copilot
What Sourcegraph Cody Is and Who It’s For
Sourcegraph Cody is an AI coding assistant that treats the large language model (LLM) as a reasoning engine and couples it with Sourcegraph’s code graph to perform multi‑step, tool‑driven tasks inside a developer’s workflow. Unlike simple autocomplete tools, Cody can read and write across multiple files, answer natural‑language questions about a codebase, generate tests, refactor code, and even execute batch changes when given explicit instructions.
Cody targets engineers who work in large, monorepo‑style projects or microservices ecosystems where understanding cross‑file dependencies is critical. It is also aimed at teams that need a self‑hostable, privacy‑first AI assistant because Cody can run against a private Sourcegraph instance, keeping code inside the corporate network.
Key Features and Capabilities
- Codebase‑aware chat: Cody answers questions like “Where is the authentication logic used?” by querying the Sourcegraph code graph and returning precise file locations and snippets.
- Multi‑file editing: Commands such as “Add logging to all entry points in the HTTP layer” trigger Cody to locate relevant functions across several repositories and apply the change in a single step.
- Test generation: Given a function signature, Cody can produce unit tests that match the project’s testing framework and import style.
- Refactoring assistance: Commands like “Rename this variable and update all references” leverage the code graph to find every usage, even across language boundaries (e.g., TypeScript ↔️ Go).
- Batch change execution: Through the
cody batchsubcommand, Cody can create a Sourcegraph Batch Changes spec that applies a transformation (e.g., upgrading a library version) across many repositories and opens a pull request per repo. - IDE‑agnostic: Extensions exist for VS Code, JetBrains, Neovim, and Emacs; a CLI is available for terminal‑centric workflows.
- Privacy options: When pointed at a self‑hosted Sourcegraph instance, no code leaves the organization's network; the LLM calls can be routed to an internal model or a trusted provider via an API gateway.
Architecture and How It Works
Cody’s architecture consists of three loosely coupled layers:
- Interface layer – The IDE extension or CLI captures user intent (chat message, command, or inline prompt) and forwards it to the Cody backend via a secure WebSocket or HTTP endpoint.
- Reasoning & planning layer – Hosted on Sourcegraph’s servers (or a self‑hosted deployment), this layer receives the prompt, selects an LLM (default: GPT‑4‑turbo, configurable to Claude 3 or local models), and constructs a plan that may involve multiple tool invocations: code‑graph search, file read/write, test execution, or batch‑change generation.
- Tool layer – Implements the actual actions. The most important tool is the Sourcegraph Code Search API, which returns symbol definitions, references, and file snippets in milliseconds. Other tools include the filesystem (for local edits), the Git CLI (to create commits), and the Batch Changes API (to propose cross‑repo changes).
When a user asks Cody to “Explain how the payment flow works”, the planning layer:
- Sends a code‑graph query for symbols containing “payment” or “checkout”.
- Retrieves the top‑scoring files and functions.
- Calls the LLM with those snippets to generate a natural‑language explanation.
- Returns the answer to the IDE, where it appears in a chat pane.
For a command like “Add a logger.info call at the start of every public method in src/api”, the planner:
- Uses the code graph to list all public methods matching the pattern.
- For each location, constructs an edit (insert line after the function signature).
- Applies the edits via the filesystem tool, optionally creating a Git commit.
This separation lets Cody scale to very large codebases because the heavy lifting (search, impact analysis) is done by the optimized Sourcegraph graph, not by the LLM alone.
Real-World Use Cases
Onboarding New Engineers
A fintech company with a 150‑monorepo codebase uses Cody to answer questions like “Where is the KYC validation invoked?” New hires receive instant, accurate pointers to the relevant Go and TypeScript files, cutting ramp‑up time from weeks to days.
Cross‑Repository Library Upgrade
A platform team needed to upgrade a logging library from version 1.x to 2.x across 42 services. Using Cody’s batch change feature, they ran:
cody batch --repo 'github.com/myorg/*' \
--match 'go.mod' \
--replace 'github.com/myorg/logger v1.2.3' 'github.com/myorg/logger v2.0.0'
Cody generated a Batch Changes spec, created a pull request per repository, and the team merged them in a single CI pipeline.
Automated Test Generation for Legacy Code
An internal API written in Java 8 lacked unit tests. Developers selected a package and invoked Cody:
cody test --package com.billing.service
Cody analyzed the public methods, produced JUnit 5 test skeletons with appropriate mocks, and added them to src/test/java. The team then refined the assertions, achieving 68 % coverage in two days.
Incident Response: Hotfix Propagation
During a security incident, a patch needed to be applied to a specific helper function used in 12 services. Cody located all call sites via the code graph, applied the fix, and opened a batch change. The mean time to mitigate dropped from 4 hours to 25 minutes.
Strengths and Limitations
Strengths
- Deep context: The code graph gives Cody precise, whole‑repository awareness that generic autocomplete tools lack.
- Privacy‑first: Self‑hosted deployments keep source code inside the organization's network.
- Actionable output: Cody doesn’t just suggest; it can create commits, pull requests, or batch changes when instructed.
- Language agnostic: Because it relies on symbol search rather than language‑specific parsers, it works for any language indexed by Sourcegraph.
Limitations
- Dependency on Sourcegraph: To get the full agentic benefits, a Sourcegraph instance (cloud or self‑hosted) must be running and indexing the repositories.
- Latency: The extra hop to the code‑graph service can add a few hundred milliseconds to responses, noticeable in very large codebases.
- Tool maturity: While Cody can run batch changes, the workflow still requires familiarity with Sourcegraph’s Batch Changes CLI; some edge cases (e.g., complex merge conflicts) need manual intervention.
- Model reliance: The quality of answers depends on the underlying LLM; if a weaker model is selected, performance drops.
Comparison with Alternatives
The table below summarizes how Cody stacks up against other prominent AI coding agents as of late 2025. Features marked ✅ are fully supported; ⚠️ indicates partial or experimental support; ❌ means not available.
| Feature / Product | Sourcegraph Cody | GitHub Copilot | Cursor | Windsurf (Codeium) | Cline | Aider | SWE‑agent | Devin | OpenHands |
|---|---|---|---|---|---|---|---|---|---|
| IDE integration | ✅ (VS Code, JetBrains, Neovim, Emacs) | ✅ (VS Code, JetBrains, Neovim) | ✅ (Custom IDE) | ✅ (VS Code, JetBrains) | ✅ (VS Code) | ✅ (Terminal) | ❌ (CLI only) | ❌ (Web UI) | ❌ (CLI) |
| Multi‑file edits | ✅ (via code graph) | ❌ (single‑file focus) | ✅ (limited) | ✅ (limited) | ✅ (via agent) | ✅ (terminal) | ✅ (autonomous) | ✅ (autonomous) | ✅ (agent) |
| Code‑base Q&A | ✅ (natural‑language search) | ❌ (no deep Q&A) | ❌ | ❌ | ✅ (limited) | ✅ (via prompts) | ✅ (task‑oriented) | ✅ (task‑oriented) | ✅ (task‑oriented) |
| Batch changes / PRs | ✅ (Sourcegraph Batch Changes) | ❌ | ❌ | ❌ | ✅ (via agent) | ❌ | ❌ | ❌ | ❌ |
| Self‑hostable | ✅ (private Sourcegraph) | ❌ (SaaS only) | ✅ (local) | ✅ (local) | ✅ (local) | ✅ (local) | ✅ (local) | ❌ (SaaS) | ✅ (local) |
| Tool extensibility | ✅ (custom tools via API) | ❌ | ✅ (plugin) | ✅ (plugin) | ✅ (agent framework) | ✅ (scriptable) | ✅ (framework) | ✅ (framework) | ✅ (framework) |
| Typical latency | 300‑800 ms (graph + LLM) | 100‑200 ms (LLM only) | 150‑300 ms | 150‑300 ms | 400‑900 ms (agent planning) | 200‑500 ms (terminal) | 500‑1500 ms (autonomous loops) | 800‑2000 ms (multi‑step) | 600‑1200 ms (agent) |
Cody’s edge lies in its ability to combine deep static analysis with LLM reasoning, enabling reliable multi‑repo operations that most competitors either cannot perform or do only in a narrow, experimental fashion.
Getting Started Guide
Prerequisites
- A Sourcegraph instance (either sourcegraph.com or a self‑hosted deployment).
- An IDE that supports the Cody extension (VS Code 1.88+, JetBrains 2024.2+, Neovim 0.9+).
- (Optional) An API key for an LLM provider if you want to use a model other than the default.
1. Install the Cody Extension
In VS Code, open the Extensions view (Ctrl+Shift+X) and search for Sourcegraph Cody. Click Install.
Alternatively, via the command line:
code --install-extension sourcegraph.cody-ai
2. Connect to Your Sourcegraph Instance
Open the Settings (Ctrl+,) and search for Cody: Sourcegraph Endpoint. Set it to the URL of your instance, e.g., https://sourcegraph.com or https://sg.internal.mycompany.com.
If using a self‑hosted instance with a self‑signed certificate, add:
"cody.acceptInvalidCerts": true
3. Configure LLM Provider (Optional)
By default Cody uses the model configured on the Sourcegraph backend. To override, add:
"cody.llm.provider": "openai",
"cody.llm.apiKey": "sk‑…",
"cody.llm.model": "gpt-4-turbo"
Supported providers include openai, anthropic, azure, and local (for models served via an OpenAI‑compatible endpoint).
4. First Interaction
Open any file in your workspace, then press Ctrl+Shift+P → Cody: Ask. Type a question such as:
"Where is the UserService constructor defined?"
Cody will query the code graph, fetch the relevant snippet, and display the answer in a chat pane.
5. Running a Multi‑File Command
Try a refactor across the codebase:
- Open the Command Palette (
Ctrl+Shift+P). - Select Cody: Run Command.
- Enter:
Add a TODO comment at the start of every function named `handleRequest`
Cody will locate all matches, apply the edits, and show a diff preview. Confirm to apply the changes or abort.
6. Creating a Batch Change
If you have the Sourcegraph CLI (src) installed, you can trigger a batch change from the terminal:
src batch -f - <<EOF
name: update-logger-v2
description: Upgrade logger to v2 across all services
changesetTemplate:
- |-
sed -i 's|github.com/myorg/logger v1\.[0-9]\+\.[0-9]\+|github.com/myorg/logger v2.0.0|g' go.mod
go mod tidy
EOF
Cody can generate the same spec via the UI if you prefer a graphical approach.
7. Tips for Effective Use
- Scope your queries: Adding file path hints (e.g.,
in src/api) reduces latency and improves relevance. - Leverage the chat history: Cody retains context within a session, allowing follow‑up questions like
Now show me the tests for that function. - Review batch changes: Always inspect the generated diffs before merging, especially when the operation touches many repositories.
Honest Assessment
Sourcegraph Cody delivers on the promise of agentic coding by grounding LLM reasoning in a precise, searchable code graph. Its strengths shine in environments where understanding cross‑dependency impact is non‑trivial—large monorepos, microservices suites, or security‑sensitive settings requiring self‑hosting. The ability to move from suggestion to concrete action (edits, commits, batch changes) sets it apart from pure completion tools like Copilot.
However, the dependency on a functioning Sourcegraph deployment introduces operational overhead; teams without existing Sourcegraph investment may find the setup cost prohibitive compared to plug‑and‑play alternatives. Latency, while acceptable for most interactive tasks, can become noticeable when the code graph is extremely large or hosted remotely with suboptimal network conditions.
When compared to agents that operate purely within an IDE (Cursor, Windsurf) or terminal‑centric tools (Aider, SWE‑agent), Cody trades some immediacy for deeper semantic awareness. For teams that already rely on Sourcegraph for code navigation and code intelligence, adding Cody is a low‑friction upgrade that unlocks true multi‑step, tool‑driven AI assistance.
In short, if your organization values codebase‑wide context, privacy, and the ability to let the AI act on your behalf—not just suggest—Sourcegraph Cody is currently the most mature agentic coding option available.
This article reflects the state of Sourcegraph Cody as of late 2025. Features and performance may evolve with future releases.