/kb-code:kb-review-workfrom kb-code
Work a kb-code PR review as the agent half of the loop — sync the PR into the review store, read the patchset (not the clone) with `diff`/`log`/`cat`, drain the human's questions/dispositions, answer with code-verified evidence, author + gate with `compose --slugify` + `verify`, and run the manual GitHub publish round from the export payload. Use when the operator says "work the review", "answer the review questions", "sync the PR" or "re-sync it", after a `kb-code annotate watch` surface names review activity, or on a cadence over `kb-code review inbox`. `review status` is the drift question; `review sync` is the one call that re-syncs. The daemon stores; YOU author — every reply, verdict and gh call is agent-layer.
Ships in kb-code. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A PR review in kb-code is a durable dialogue: the reviewer agent imported
findings (kbc-findings/1), the human read them in the Review Room and left
dispositions, questions, and their own findings. This skill is the AGENT half:
read what awaits, answer with evidence, change code where agreed, and (only
when asked) publish to GitHub via gh from the export payload. kb-code never
calls GitHub's write API — you do, deliberately, at the end.
Contract:
hover, usages, framework,
diagnostics, callers), same discipline as the review that started this.waive/re-import without it) — never argue past
the code.kb-code suggest apply/apply-batch. Never force anything
on a dirty tree.export-github's payload (its line/side/commit_id are
ladder-verified), and every posted item is recorded back via
kb-code review publish so nothing double-posts.Addressing. One parser (parse_review_ref) knows <id>, pr:<N>,
<id>/ps<n> and pr:<N>/ps<n>, inferring the repo from the store when
pr:<N> is unique (--repo to disambiguate) — but NOT every verb takes
every form, and guessing wrong costs you a clap error, a usage error, or a
silently-ignored patchset:
diff, log, cat, verify take the FULL address, /ps<n> included
(--ps N is the equivalent flag; giving both with different values is a
usage error naming both).status and retrack take <id> or pr:<N> ONLY. A /ps<n> address is
a USAGE ERROR (exit 2, before any request) — they act on the whole review.find and sync take a PR as pr:<N> (find pr:7, sync pr:7 --repo R)
or the --pr N flag; sync also takes --repo R --open. An <id> there
is a usage error.The older verbs (show, comments, findings list, timeline,
github-threads, export-github, publish, distill) take a numeric
<id>; get it once from find/status and reuse it.
kb-code review find --pr N --json returns every review bound to PR N
(across every configured repo unless --repo narrows it). Then
kb-code review status pr:N --json to decide whether anything actually
moved before you spend anything. For the whole queue:
kb-code review queue --json — what is waiting for YOU, the agent: an
open question whose latest voice is not an agent (lane question), then a
disputed finding with no agent reply since the dispute (lane dispute),
an agreed/fix-later finding with no suggestion or author hunk yet (lane
follow-up), a PR whose head moved past the latest patchset (lane
pr-drift), then an open flag-for-agent thread (lane flag), oldest
first within a lane. --watch keeps polling and prints only new rows. Take the top row; it carries the next command to run. An
empty queue is a real answer. (review inbox --all-repos --json is the
HUMAN-ordered view of the same reviews; use it to see what the human has
outstanding, not to pick your next task.)kb-code review context <ref> --budget 20000 --json returns the budgeted bundle (header with how the base
was resolved, open human threads, findings, other reviews' disputes on the
same paths, the author's changes since the verdict, reading order, change
set, and the patch in reading order). A cut is never silent: read
omitted[] and re-run with a bigger --budget or take the narrower read
it points to. kb-code review explain-base <ref> says how the base was
chosen. The finer reads (all --json): review status <id> is THE drift
answer — head_moved against the LATEST patchset tip, base state, the
file-count drift vs. the forge, verdict staleness, open findings. Also
review show <id> · review findings list <id> (dispositions + resolution
confidence) · review timeline <id> · review github-threads <id> (what
was already said ON GitHub). To look at a change set use
review diff <ref> --stat (per-file counts, the default), or --path P
to narrow it, or --patch for unified text — three SEPARATE invocations,
never one combined line. --budget N belongs to the PATCH view: it cuts
the diff text and IMPLIES --patch; combined with --stat or
--name-only it is a usage error. All of it is computed in the store against the patchset's own
base, and it works with no refs/kbc/* in the clone. For a repo whose
review store is READY there is no git -C path to the PR any more — the
store owns those refs. Before the store is ready (absent, seeding,
broken, or disabled) the pre-store fallback still fetches
refs/kbc/pr/<n> into the clone, so the ref may be there.review log <ref> for the patchset's
commits, and review cat <ref> <path> --side old|new for one file at its
base (old) or tip (new, the default). Secret-denylisted paths are
refused here, as everywhere.kb-code review comments <id> --json (or live:
kb-code annotate watch --review <id> --ignore-agents; --ignore-agents
skips every agent author name, not just claude). For each
open question whose last voice is the human: verify against the checkout
(kb-code hover/usages/framework/resolve-symbol/diagnostics …), then
kb-code annotate reply <annotation-id> -m "<evidenced answer>" — the
reply is saved under --author > $KB_CODE_AUTHOR > $KB_HARNESS >
claude (never the human you; export KB_HARNESS for your harness or
pass --author) — and
annotate resolve only when genuinely settled — an open question you
answered but that awaits the human's read stays open.agree / fix-later→now: make the change — small mechanical fixes as
suggestions on the finding's thread (kb-code suggest <annotation-id> --from-file fix.txt), then suggest apply (or apply-batch for the
accepted set); larger fixes as ordinary edits in the checkout.dispute: re-verify from scratch. Refuted → reply conceding, recommend
waive or drop it from the next import. Confirmed → reply with the
evidence chain and leave the disposition to the human. Never flip a
disposition yourself — it is the human's column.waive: acknowledge in-thread only if there's something to add.review status says head_moved): ONE
call replaces the old pr fetch + snapshot pair —
kb-code review sync --repo <REPO> --pr N --json. It creates the review
if missing, fetches base + head into the store, and snapshots only when
(tip, merge-base) changed. Branch on reason — one of created,
head-moved, base-moved, retargeted, unchanged, merged-final —
together with minted. Use --wait[=SECS]: bare --wait = 600 s,
--wait=0 returns the daemon job id at once (re-running the same sync
attaches to the running job). A partly-failed run exits 7 (partial). For a
pinned or retargeted base, move it with kb-code review retrack <id> --base main; --base on sync itself applies ONLY when sync CREATES the review,
never to an existing one. (A closed review whose PR reopened is never
reopened unattended — sync reports review-closed-pr-open; re-run with
--reopen.) Then rerun the analysis and review findings import <id> --stdin (mode full — dispositions and manual findings survive by
construction; absent findings tombstone).kb-code review compose <id> --doc review.md --findings findings.json --slugify writes the document and the findings in
one transaction. --slugify gives every finding without a valid slug the
ASCII f-<kebab> slug derived from its title (when several findings share
a base slug, each gets a -<6 hex> suffix from its content fingerprint, so
reordering or inserting findings never moves a slug and its disposition onto
different text) instead of letting the WHOLE batch 400 on invalid_slug, and
it is UTF-8-safe — every non-ASCII character (a title with à) is treated
as a separator and never sliced, so it cannot panic. Author-written VALID
slugs are never touched. compose is a LOOPBACK-ONLY route (D22): from a
remote session it 404s with an empty body and exits 8, which verify then
reports as a missing document — so on an empty 404, stop here and say the
authoring lane needs the daemon's host, rather than "fixing" the document.
Then the MANDATORY post-compose gate:
kb-code review verify <id> --json — it checks the document is present and
lints clean, counts findings (≥ --min-findings if given), that every
finding anchor resolves, and that the verdict sits on the latest patchset;
it EXITS 3 on failure. A failed verify is not a formality to note and move
past — it is the reason the review is not done.kb-code review export-github <id> --json — heed stale_export (run
review sync first if it is set). Post via gh exactly what the payload
contains (gh api repos/{owner}/{repo}/pulls/{n}/comments -f body=… -f commit_id=… -f path=… -F line=… -f side=… per comment;
gh pr review {n} --approve|--request-changes|--comment -b … for the
event). After each successful post: kb-code review publish <id> <slug> --url <html_url> (and --verdict for the review event). Skipped
orphans stay in skipped_orphaned — there is no file-level granularity
in the export payload. The ONE opt-in is the named flag
--include-orphaned-as-general on export-github, which moves each
orphan into general_comments instead (post it with
gh pr review {n} --comment -b …, no line to aim at).kb-code review distill <id> --json and — an explicit judgment call —
keep what matters via kb notes new / kb remember citing the review
id + head sha.kb-code review sync --repo <REPO> --open [--merged-since DATE] --json
replaces a hand-orchestrated sweep. It runs the single sync for every open PR
(and, with --merged-since, the PRs merged since that date) SEQUENTIALLY, each
under the per-repo sync lock, so a caller no longer needs a "the lead owns
every fetch" rule. The per-shape --wait default is 600 s for one PR and 3600 s
for --open. When some PRs succeeded and some failed, the run is PARTIAL: it
exits 7 with degraded: true, so a partial morning is visible rather than
silent.
Verbs that need the daemon's HOST. A non-loopback session gets a 404 with an EMPTY body — the gate hides the route rather than admitting it exists — so when one of these 404s, say so and stop that lane; never route around the gate.
compose (step 7's own step, and the reason the list used
to be a trap: everything around it runs, then this one 404s), doc render,
report, start, start-pr, snapshot, sync, retrack, sweep,
close, reopen, delete, gc, refs gc, findings import,
suggest apply/apply-batchstore credentials READ, which is
the family's one bearer route: store show, store members, store doctor (all three read the SAME GET /api/repos/{name}/store card), store sync, store gc, store set-base-url, store credentials --test, store legacy-refs, store export-legacy, store maintainNot on that list, but they still stop a remote lane by default: verdict,
disposition, findings add and publish sit behind [review] remote_mutations (default OFF) rather than on the loopback router, and
answer the same empty 404 unless the operator turned that flag on; and
status --fetch is a bearer read that refuses INSIDE the handler with a
403, so it exits 4, not 8. docs/kb-code.md's "The route gates" table is
the complete map; this is the review-work slice of it. If the repo isn't
mounted in kb-code, findings orphan honestly; the metadata lanes still work.
Exit codes (the shipped table in crates/kb-code-cli/src/envelope.rs; the
design's §13 table — 3 = not found, 4 = conflict — was NOT adopted, and
review_agent.rs says so in a test comment):
| code | meaning |
|---|---|
| 0 | ok |
| 1 | generic failure |
| 2 | usage (bad flag / bad <id>·pr:<N> address) |
| 3 | conflict — HTTP 409 and 503, plus a failed verify and a store still seeding |
| 4 | refused (401/403 only) |
| 5 | unreachable (daemon down) |
| 6 | upstream (a forge fetch/API call failed) |
| 7 | partial (degraded: true) |
| 8 | not found — EVERY HTTP 404, whatever the body |
Branch on the difference between 3 and 8 rather than guessing.
AgentError::from_http matches on the STATUS alone: every 404 exits 8, with
no body inspection deciding it. That is deliberate — a loopback-only route
deliberately 404s a non-loopback caller (hiding the route's existence is
the point), the same posture as an ordinary "no such id" — so the two cases
are structurally indistinguishable from the exit code. The ONLY signal
separating them is the hint an EMPTY-body 404 carries ("an empty 404 is also
what a loopback-only route answers off-loopback"). Never conclude "no such
review" from 8 alone: read the body's code/message and that hint first.
What SKILL.md sets; muted values are Claude Code's defaults
2 skills in this plugin
Other plugins' skills for the same job
npx claudepluginhub nicolasacchi/kb --plugin kb-code