codebase-snapshot

· 4 min read · by

Briefs

codebase-snapshot brief packs one reviewer-ready Markdown document: a question or a change, the impact it reaches, the candidate tests, and bounded redacted source windows. It is the formatting layer over impact and context; it does not invent a second graph.

Run it

codebase-snapshot brief "how does authentication work?"
codebase-snapshot brief --diff origin/main
codebase-snapshot brief --paths src/router.ts --out notes/review.md
codebase-snapshot brief --diff HEAD --copy
codebase-snapshot brief --diff HEAD --format json

With neither a question nor --diff/--paths, the change is the working tree against HEAD. The brief uses the live index by default and writes nothing into the repository; --no-live requires the persisted snapshot.

What it contains

  1. A trust stamp: index source, freshness, coverage, redaction count, omitted count, and any named partial reason.
  2. The question or impact summary.
  3. For a change: changed files, symbol-pruned affected files, routes, candidate tests and warnings.
  4. For a diff: the diff hunks, passed through the same span-masking redaction as every other artifact. No raw credential excerpt is copied into the brief.
  5. Bounded source windows for the files that matter, until --max-tokens is reached.
  6. A named list of files that did not fit or are unavailable. Nothing is dropped silently.

--format pr-comment renders the affected-file list and details as a collapsible GitHub comment. --out writes inside the repository only; a path that escapes through .. or a link is refused. --copy uses the platform clipboard command (clip, pbcopy, wl-copy or xclip) with shell: false.

Options

Option Meaning
--diff <ref> Compare the working tree with a git ref.
--paths <a,b> Treat repository-relative paths as the change.
--max-tokens <n> Token budget for the assembled brief (default 12000, minimum 500).
--lines-per-file <n> Line window per file (default 80).
--include-tests Include candidate tests, not only production impact.
--copy Copy the finished brief to the clipboard.
--out <path> Write the brief to a repository-relative path.
--format json Return { markdown, usedTokens, files, omitted, trust } and keep stdout parseable.
--format pr-comment Render collapsible PR-comment sections.
--no-cache Bypass the OS live-index summary cache.
--no-live Require the generated snapshot.

When a brief is the right tool

Use a snapshot instead when the task is "explain this repository"; use impact when the task is "tell me what this change reaches" and you do not need prose.

What a review looks like

codebase-snapshot brief --diff origin/main --format pr-comment
# Change brief

Trust: source=live-overlay · freshness=live-computed · coverage=complete · redacted=0 · omitted=0

**Changed:** 3 · **Affected:** 7 · **Tests:** 2

<details><summary>Affected files</summary>
...
</details>

### `src/auth/session.ts` — changed
...

The exact headings depend on the format. In every format the same three facts are present: what changed, what the tool believes it reaches, and what it could not include.

What it does not do

Why it exists

A review starts with a diff, but the diff is not the change: the call sites, the route and the test that will fail are elsewhere. The brief puts those on one page, marks what is evidence and what is a candidate, and stamps the trust envelope so a reader can tell a complete answer from a partial one.

→ Impact reports · CLI reference · MCP tools