| name | digest |
| description | Human-review digest for a PR/MR โ chunks the diff into a noise-filtered, risk-ranked, code-first review surface (green/red diffs, ๐ข/๐ก/๐ด, design-decision callouts) WITHOUT abstracting the code away. Deterministic chunker + one bounded codex pass. Sits alongside /code-review (the gate) and /iterate (tests). Use on /digest or 'digest this PR for review'. Renders in TerMinal. |
/digest โ human-review digest (noise-filtered, code-first)
/code-review is the automated merge gate; /digest is the human read
surface. It does not decide merge-readiness. It makes a technical reviewer read
a diff in seconds by ranking it, never by hiding code โ every line stays
reachable; the digest only decides what's expanded vs. collapsed and where your
eyes land. The contract + schema live in
.agents/digest.md.
Output: one in-repo artifact .TerMinal/reviews/<pr>/<short>.chunks.json
(v2) or .reviews/<pr>/<short>.chunks.json (legacy v1), next to the review .md.
Token contract (non-negotiable)
The expensive part is deterministic. The codex pass sees only the non-๐ข
hunks and emits a length-capped JSON patch โ never prose. ๐ข chunks
(lockfile/docs/rename/whitespace/import/generated) are classified and labeled by
chunk-diff and never reach the model. See .agents/digest.md โ "Token
contract".
Workflow (chunk-diff โ one codex pass โ merge-digest)
1. chunk-diff (deterministic, $0) โ <short>.chunks.json skeleton
2. codex exec (bounded) โ <short>.digest-patch.json
3. merge-digest (deterministic, $0) โ <short>.chunks.json final
Stage 0 โ resolve context (reuse the review's, or compute):
PR=<number>; HEAD=$(git rev-parse HEAD); SHORT=${HEAD:0:7}
BASE=<target branch>
REPO=$(basename "$PWD")
REVIEW_ROOT=$([ -d .reviews ] && [ ! -f .TerMinal/template.json ] && echo .reviews || echo .TerMinal/reviews)
DIR="$REVIEW_ROOT/$PR"; mkdir -p "$DIR"
Stage 1 โ deterministic chunking (zero tokens):
git diff "origin/$BASE...$HEAD" > "$DIR/$SHORT.diff.patch"
.claude/bin/chunk-diff \
--patch "$DIR/$SHORT.diff.patch" \
$( [ -f "$DIR/findings.json" ] && echo --findings "$DIR/findings.json" ) \
--pr "$REPO#$PR" --short "$SHORT" \
--out "$DIR/$SHORT.chunks.json" \
--scoped-out "$DIR/$SHORT.scoped.diff"
--scoped-out drops every ๐ข block (lockfile / generated / docs / whitespace /
rename) from the model's input. On a logic-heavy MR this is ~0% (nothing to cut);
on an MR that regenerates a big lockfile or snapshot it can be most of the diff โ
the silent token killer never reaches the LLM.
For a joint MR (factory/stacked-MR), add --joint "<member-mr-csv>".
Stage 2 โ codex digest pass (the only LLM step; bounded output, ~60s):
sed "s|{{PR}}|$PR|; s|{{SHORT}}|$SHORT|; s|{{BASE}}|$BASE|; s|{{HEAD}}|$HEAD|; \
s|{{DIR}}|$DIR|; s|{{DIFF_PATH}}|$DIR/$SHORT.scoped.diff|" \
.claude/skills/digest/prompt.md > /tmp/digest-prompt-$$.txt
codex exec -s workspace-write -c model_reasoning_effort="low" -C "$PWD" \
"$(cat /tmp/digest-prompt-$$.txt)" < /dev/null
Three deliberate speed/safety levers (a digest is bounded extraction, not a
review โ it doesn't need depth or broad access):
< /dev/null โ mandatory. Without it codex exec blocks on
Reading additional input from stdinโฆ and hangs indefinitely in
headless/background invocations.
-c model_reasoning_effort="low" โ the task is fill-a-JSON-patch; low
reasoning cuts wall-clock to ~60s with no quality loss.
-s workspace-write (not danger-full-access) โ the pass only reads
$DIR/$SHORT.{chunks.json,diff.patch} and writes one file under cwd. No
tests run, so the macOS Mach-port carve-out /code-review needs doesn't apply.
The pass writes $DIR/$SHORT.digest-patch.json and nothing else.
In factory/stacked-MR mode, skip Stage 2's separate codex call โ the joint
MR's /code-review codex session emits the patch alongside its review (it
already holds the diff + deterministic evidence). Only Stages 1 and 3 run
around it.
Stage 3 โ merge (deterministic; enforces risk-override rules, sorts
decisions, recomputes stats):
.claude/bin/merge-digest \
--chunks "$DIR/$SHORT.chunks.json" \
--patch "$DIR/$SHORT.digest-patch.json"
Hard rules
- Never abstract code away. The digest ranks and annotates; it never
replaces the diff. TerMinal renders the real green/red lines from
git diff; chunks.json only carries paths + hunk headers + annotations.
- ๐ข chunks cost zero tokens. If the codex pass writes a summary for a ๐ข
chunk, drop it in merge โ green labels are deterministic.
- The model can't lower a deterministic ๐ด.
merge-digest enforces this.
- Bounded output only.
summary โค 200 chars, one-line notes, no prose
blocks. Diagram is emitted only for structural changes.
Relationship to /code-review and /iterate
/code-review โ six-axis gate + verdict + findings (<short>.md). The merge bar.
/iterate โ tests-only refresh.
/digest โ the human read surface (<short>.chunks.json). Informational.
Run /digest after /code-review when you're about to merge a non-trivial PR
or batch, or standalone any time you want to read a diff fast.
Activity
terminal-cli activity digest "Digest ยท !$PR ยท ${RED}๐ด ${YEL}๐ก ${GRN}๐ข" "$REPO @ $SHORT"