# 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. ## Install Copy the content below into your project: ## Quick Use 1. Sign up at sourcegraph.com (free tier available) 2. Install: `brew install sourcegraph/amp/amp` 3. `amp auth login`, then `amp ""` in any indexed repo --- ## Intro Amp is Sourcegraph's AI coding agent that reads the *whole* repo before it edits. Where Cursor and Claude Code rely on per-file context windows, Amp queries Sourcegraph's pre-indexed code graph — symbol references, type hierarchies, dependency maps — to ground every edit. Best for: monorepo refactors and codebases too large for any single context window. Works with: terminal CLI + VS Code extension + Sourcegraph web. Setup time: 5 minutes (Sourcegraph account + API token). --- ### What Amp does differently Most AI coding tools approximate "see the whole codebase" by stuffing files into the context window. Amp doesn't approximate — Sourcegraph already indexes your repo (symbols, references, types, history) and Amp queries that index. Concretely: - When you ask "rename `getUser` to `fetchUser` everywhere", Amp uses *symbol references*, not text search. No false positives in comments or strings. - When you ask "where is this called", Amp returns actual call sites from the graph, not regex matches. - When you ask for a refactor, Amp reads the type hierarchy first and proposes changes that respect interfaces and overrides. ### CLI usage ```bash # Install brew install sourcegraph/amp/amp # Authenticate (opens browser) amp auth login # Run a task in the current repo amp "Refactor the User type to add a 'plan' field. Update all call sites." # Run on a specific Sourcegraph-indexed repo (no need to clone) amp --repo github.com/sourcegraph/sourcegraph "List all uses of the deprecated AuthService" ``` ### Connect Amp to Claude Code or Cursor Amp ships an MCP server. Add to your MCP config: ```json { "mcpServers": { "sourcegraph": { "command": "amp", "args": ["mcp"], "env": { "SRC_ACCESS_TOKEN": "your-token" } } } } ``` Now Claude Code / Cursor / Codex CLI can call `sourcegraph_search`, `sourcegraph_symbol_references`, `sourcegraph_blame` — using your repo graph as a tool. ### When to choose Amp over Cursor / Claude Code - Your codebase is >1M LOC and doesn't fit any context window - You need refactors that respect actual symbol references, not regex - You want consistent answers across teammates (everyone queries the same indexed graph) --- ### FAQ **Q: Is Amp free?** A: Sourcegraph offers a free tier with limited indexed repos. Pro plans (and the Amp coding agent itself) are subscription-based. Pricing on sourcegraph.com/pricing. **Q: Does Amp work without a Sourcegraph account?** A: No — Amp queries the Sourcegraph code graph, which requires Sourcegraph to index your repo. For single-repo work without indexing, Cursor or Claude Code is simpler. **Q: Can I use Amp on private repos?** A: Yes. Sourcegraph self-hosted and Sourcegraph Cloud both support private repos. Amp authenticates via SRC_ACCESS_TOKEN scoped to repos you have access to. --- ## Source & Thanks > Built by [Sourcegraph](https://github.com/sourcegraph). Commercial product with free tier. > > [sourcegraph/amp](https://sourcegraph.com/amp) — Sourcegraph code graph required --- ## 快速使用 1. 在 sourcegraph.com 注册(有免费档) 2. 装:`brew install sourcegraph/amp/amp` 3. `amp auth login`,然后在已索引的仓库里跑 `amp "<你的任务>"` --- ## 简介 Amp 是 Sourcegraph 的 AI 编码 agent,编辑之前先读 *整个* 仓库。Cursor 和 Claude Code 靠单文件上下文窗口,Amp 查 Sourcegraph 预索引的代码图谱 —— 符号引用、类型层级、依赖关系 —— 给每次编辑做接地。适合 monorepo 重构和任何单上下文窗口装不下的代码库。兼容终端 CLI + VS Code 扩展 + Sourcegraph 网页版。装机时间 5 分钟(Sourcegraph 账号 + API token)。 --- ### Amp 跟其他工具的根本区别 多数 AI 编码工具靠"把文件塞进上下文窗口"来近似"看到整个代码库"。Amp 不近似 —— Sourcegraph 本身已经把你的仓库索引好了(符号、引用、类型、历史),Amp 直接查这个索引。 具体说: - 你说"把 `getUser` 重命名成 `fetchUser`",Amp 用 *符号引用*,不是文本搜索。注释和字符串里的 `getUser` 不会被误改。 - 你问"这个函数在哪被调用",Amp 从图谱返回真实调用点,不是 regex 匹配。 - 你要求重构,Amp 先读类型层级再提改动,尊重接口和覆盖关系。 ### CLI 用法 ```bash # 装 brew install sourcegraph/amp/amp # 认证(弹浏览器) amp auth login # 在当前仓库跑任务 amp "Refactor the User type to add a 'plan' field. Update all call sites." # 在某个 Sourcegraph 已索引的仓库跑(不用 clone) amp --repo github.com/sourcegraph/sourcegraph "List all uses of the deprecated AuthService" ``` ### 把 Amp 接到 Claude Code 或 Cursor Amp 自带 MCP server。加到你的 MCP 配置: ```json { "mcpServers": { "sourcegraph": { "command": "amp", "args": ["mcp"], "env": { "SRC_ACCESS_TOKEN": "your-token" } } } } ``` 之后 Claude Code / Cursor / Codex CLI 就能调用 `sourcegraph_search` / `sourcegraph_symbol_references` / `sourcegraph_blame` —— 把你的仓库图谱当成工具用。 ### 什么时候选 Amp 而不是 Cursor / Claude Code - 你的代码库 >100 万行,任何上下文窗口都装不下 - 你需要尊重真实符号引用的重构,不是 regex - 你要团队成员答案一致(大家查同一个索引图谱) --- ### FAQ **Q: Amp 免费吗?** A: Sourcegraph 有免费档(限索引仓库数)。Pro 套餐和 Amp coding agent 是订阅制。价格见 sourcegraph.com/pricing。 **Q: 没 Sourcegraph 账号能用 Amp 吗?** A: 不能。Amp 查的是 Sourcegraph 代码图谱,需要 Sourcegraph 先索引你的仓库。单仓库不需要索引时,Cursor / Claude Code 更简单。 **Q: 私有仓库能用 Amp 吗?** A: 可以。Sourcegraph 自托管和云版本都支持私有仓库。Amp 通过 SRC_ACCESS_TOKEN 鉴权,只能访问你有权限的仓库。 --- ## 来源与感谢 > Built by [Sourcegraph](https://github.com/sourcegraph). Commercial product with free tier. > > [sourcegraph/amp](https://sourcegraph.com/amp) — Sourcegraph code graph required --- Source: https://tokrepo.com/en/workflows/amp-by-sourcegraph-whole-repo-ai-coding-agent Author: Sourcegraph