Amp Code Spec

Reproduction-ready specification for building AI coding agents.

!
Not Claude Code. This specification is derived from reverse-engineering Amp Code (Sourcegraph's coding agent). The patterns are instructive for understanding how production coding agents work.
36 documents
17.5K lines
43+ tools
11 subagents

After reading this, you should be able to build a coding agent that takes a task like "add a login button" and actually does it—finds the file, makes the edit, verifies it works.

Reading Paths

Minimal Agent (fastest)

01 02 03 04 05 10

Production Agent (complete)

01 → 11 + 12 → 16

The Key Insight

Agents don't know when they're wrong.

An LLM will say "Done!" when the edit silently failed, the code doesn't compile, or the tests are broken. The solution: verification.

edit → run tests → fail → read error → fix → run tests → pass

Production agents don't trust themselves. They verify.

What We Found (Not in Public Docs)

  • Course Correction — Meta-agent (Gemini 3 Pro) monitors and injects corrections after 5+ tool calls
  • Threads — First-class persistence with forking, relationships, and RxJS observation
  • Skills — 9 discovery locations, progressive token disclosure (~100 tokens at startup)
  • Token Economics — 100K compaction threshold, 25K handoff budget, 3.5 bytes/token

Evidence Base

npm @sourcegraph/amp v0.0.1769212917 (Jan 2026)
Analysis 346K lines deobfuscated JavaScript
Rosetta Stone v0.0.1744408301-dev (original TypeScript)