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.

AI CLI·25 commands·Last updated 2026-08-23

Install & Auth 5

npm install -g @sourcegraph/amp
Install Amp CLI globally
amp --version
Show installed version
amp login
Sign in to Sourcegraph interactively
amp logout
Sign 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-stream
Disable streaming, return the result whole
amp --help
Show all commands and flags

Thread Management 5

amp threads
List all conversation threads
amp threads new
Create and enter a new thread
amp threads continue <id>
Resume a specific thread
amp threads list
List threads only (script-friendly)
amp --resume
Resume 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 --verbose
Show per-turn tool execution details

Tips 5

amp -x is execution, amp is conversation
Pick the mode by intent
Isolate context per topic with threads
Open a thread per task
CI runs -x with AMP_API_KEY
Headless env needs no login state
--json feeds scripts
Structured output parses cleanly
Switch --model by need
Strong 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 Us

Edit this page on GitHub

Edit the source file directly and open a PR to improve this cheatsheet.