Sourcegraph Amp CLI Cheatsheet - Terminal AI Coding Agent Full Reference
All Sourcegraph Amp terminal coding-agent commands in one place — from install & login to prompts/background execution, thread management, and API integration — organized by scenario. Copy and go.
Install & Auth 5
npm install -g @sourcegraph/ampInstall Amp CLI globally
amp --versionShow installed version
amp loginSign in to Sourcegraph interactively
amp logoutSign out
export AMP_API_KEY=...Set API key (CI/headless)
One-shot Prompts 5
amp "refactor user-auth to use the new session API"Start a one-off task with an initial prompt
amp -x "list all TODO comments in this repo"-x runs in execution mode (more action-oriented)
amp --model claude-opus "write a CSV parser function"--model selects the underlying model
amp --no-streamDisable streaming, return the result whole
amp --helpShow all commands and flags
Thread Management 5
amp threadsList all conversation threads
amp threads newCreate and enter a new thread
amp threads continue <id>Resume a specific thread
amp threads listList threads only (script-friendly)
amp --resumeResume the most recent thread
Background & Integration 5
amp -x "run the test suite" &Run long tasks in the background
amp --json "..."Emit JSON for programmatic parsing
amp --cwd /path/to/repo "..."Run with a specified working directory
AMP_API_KEY=... amp -x "..."Headless CI task via API key
amp --verboseShow per-turn tool execution details
Tips 5
amp -x is execution, amp is conversationPick the mode by intent
Isolate context per topic with threadsOpen a thread per task
CI runs -x with AMP_API_KEYHeadless env needs no login state
--json feeds scriptsStructured output parses cleanly
Switch --model by needStrong model for hard tasks, fast for light
Tips
- Sourcegraph Amp is a terminal coding agent from Sourcegraph that can sit on multiple models; `amp` leans conversational, `amp -x` leans execution — pick by intent.
- The threads mechanism isolates context per task so a long conversation does not pollute another — handy in complex projects.
- In CI/headless, use `AMP_API_KEY` with `amp -x` for automation without interactive login.
- `--json` output feeds scripts for programmatic parsing (quality gates, batch audits).
Official References
Commands are compiled from the official docs below. Click to verify the latest usage.
Maintained by LaoHand
Publicly updated on Aug 23, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact UsEdit this page on GitHub
Edit the source file directly and open a PR to improve this cheatsheet.