Full code review: triangulate every change statically, model state/timing slices dynamically. Use when reviewing a PR / branch / commit / working-tree diff; pass `hard` for per-slice subagent fan-out.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Cr?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/surething-io-cockpit-dc9944f1)
---
name: cr
description: "Full code review: triangulate every change statically, model state/timing slices dynamically. Use when reviewing a PR / branch / commit / working-tree diff; pass `hard` for per-slice subagent fan-out."
---
# cr — Full Code Review
> Form: **text diagrams for the skeleton, pseudocode for the deterministic logic
> (orchestration, gating, report format), short prose checklists for judgement.**
Most review is static — read the snapshot, judge right/wrong; easy, never skip it. The hard
part is **deriving dynamic behaviour from static code** (timing / state / concurrency). cr
does both tracks.
## Principles (reason from these when no rule fits)
- **P1 Independent judgement** — reviewers are clean subagents; they never see each other's
work; the main session never judges, filters, or steers between them.
- **P2 Lossless relay** — the main session owns only the frame; everything inside a finding
is the reviewer's own words.
- **P3 Real behaviour over proxies** — judge what code and dependencies actually do (source,
comparison, caller), not what a name, comment, mock, green test or intuition suggests.
- **P4 Solution diagram first, then the breaks** — the reader understands a problem only
against the whole solution; draw once, say only what the drawing can't; rate by the harm
the broken promise existed to prevent.
## Files
| File (under `{{COCKPIT_DIR}}/skills/cr/`) | Holds | Who opens it |
|---|---|---|
| `SKILL.md` | principles, §1 orchestration · rounds · brief, §5 fix plan | the main session only — including a session the whole review is handed to |
| `reviewer.md` | §2 review (static, dynamic, cg), §3 finding semantics, §4 report format and gate | every reviewer; the main session for §4 when gating and assembling |
Section numbers run across both files. A reviewer that never opens `reviewer.md` reviews
with no checklist and its report fails §4 — running it from memory is not running it.
**Where a rule goes.** Anything a reviewer emits or is checked against — checklists, finding
semantics, report format, the format gate, what to do with a malformed brief — lives in
`reviewer.md`. `SKILL.md` holds only what the main session does: choose the tier, dispatch,
assemble, plan fixes. A reviewer rule placed here is a rule no reviewer reads.
Reviewers are pointed at `reviewer.md`, never at this file (§1.2): its templates (especially
the fix plan) are the main session's, and a reviewer that reads them emits them.
> **A review subagent who landed here anyway:** close this file, open
> `{{COCKPIT_DIR}}/skills/cr/reviewer.md` and follow §2–§4 there. Don't spawn further subagents
> or disclaim their absence.
---
## 0. Skeleton
```text
run_cr (main, never reviews) ─► choose_tier: tiny → 1 × all · default → static + dynamic
· "hard" → static + 1 per slice ─► clean reviewers in parallel, isolated (reviewer.md §2)
─► format_gate (§4), bounce to the SAME reviewer ─► assemble: merge accomplices, place ✗#n
─► heading+verdict → diagram → findings → outside → coverage ─► fix plan (§5, main's own)
```
---
## 1. Main session
> §4 (report format and gate) lives in `reviewer.md`; open it before gating and assembling.
```python
def run_cr(target, user_args):
intent = frozen_intent(target) # round 1: requirements_only(target) — PR text /
# requirement / commit message, never the dev
# session's rationale. Later rounds reuse the
# round-1 text VERBATIM: invariants, mechanisms
# and fixes added since are not intent
task = (branch_or_pr(target), intent) # what is under review — §1.1
prev = last_review_heading(conversation, same_task=task)
new_task = prev is None or user_says_new_task(user_args) # "new", "新任务", other task
round = 1 if new_task else prev.round + 1
diff = GitDiff(merge_base(target)) + untracked() # EVERY round reviews the whole change
registered = registered_residuals() # flat list, one line each, no rationale
tier = choose_tier(diff, user_args)
scopes = {
"single": [Scope("all")],
"default": [Scope("static"), Scope("dynamic")],
"hard": [Scope("static")] + [Scope("slice", s) for s in spawn_triage(target)],
}[tier]
# tier == "hard" and no slices → note "no dynamic slice, fan-out degenerates to 1 static"
brief = PROMPT.fill(round, diff, intent, registered)
assert dispatch_check(brief, round) # §1.2 — before anything is sent
reports = parallel(spawn_clean(brief.with_scope(s)) for s in scopes)
for r in reports:
while (errors := format_gate(r)): # §4 — countable checks only
r = ask_same_reviewer(r, "fit your own findings to the format", errors)
# a bounce changes form only; a content change (a number, a rating, an origin)
# must be stated in the re-emitted report, never slipped in
return assemble(reports)
def choose_tier(target, user_args):
if "hard" in user_args: return "hard" # only when the user asks; never escalate,
# never suggest it
if clearly_tiny(target): return "single" # size only — dynamic-surface is the
return "default" # reviewer's call; unsure → default
PROMPT = BRIEF_TEMPLATE # §1.2 — filled in verbatim, nothing added
```
```python
def assemble(reports):
# The ONLY things the main session does to reviewer text (P2) — anything not listed here
# is not done, however small (no trimming, re-wording, re-counting inside a block):
# 1. REORDER findings, outside lines and coverage lines;
# 2. RENUMBER through one old→new table: every "#n" / "✗#n" in reviewer text is replaced
# by the table, nothing else on the line;
# 3. APPEND its own lines after a reviewer's block, each marked "(main)" — never
# between or inside a reviewer's lines;
# 4. DROP an outside line whose file:line repeats one already kept.
# MAY also: ask a reviewer for ITS OWN missing detail; format-gate bounce
# MUST NOT: relay one reviewer's findings / hints to another; point a reviewer at a path;
# downgrade, drop, re-title, rewrite, summarise, reclassify Origin
# dispute a finding → spawn a FRESH clean subagent to re-check
findings = merge_accomplices(f for r in reports for f in r.findings)
# same root cause → one finding: keep the highest-rated block (tie: the one tracing
# more of the effect) — heading and body verbatim, so no rating is rewritten — and
# append (op 3): "(main) Independently confirmed by the <other> reviewer (<file:line>,
# rated <sev>, origin <origin>)"
findings.sort(key=(severity desc, origin order))
renumber(findings) # op 2
diagram = static_report(reports).diagram # static reviewer covers the whole diff
for f in findings:
diagram.mark_once(f.break_location, f"✗#{f.n} {f.severity} {f.break_note}")
# mechanical placement only — no other edit to the diagram
return render(heading_and_verdict(findings), # the ONLY text the main session writes
# (incl. the > 5 findings index, §4),
diagram, # together with the coverage block
[f.block for f in findings],
outside(reports), # union, op 4, verbatim
coverage(reports))
```
### 1.1 Rounds — every round reviews the whole change
Each round reviews the whole change (`git diff <merge-base>` plus untracked files), not only
what changed since the last round. One review misses things, and it misses different things
each time; a later full round is the second look that catches what an earlier one missed.
Reviewing only the increment would leave every miss of round 1 unreviewed for good.
What keeps the change from growing is not looking less but fixing less: every finding is
classified against the intent (§3 — in scope, or outside and only registered), and only
in-scope findings enter the fix plan (§5). Registered residuals are listed in the brief so a
full round does not report them again unless this change makes one worse.
**Rounds belong to a task, not to the conversation.** One main session often finishes a
task and starts the next on the same branch; the next task's first review is round 1 again.
- Same task → next round: the same branch / PR and the same intent, and the work since the
last review is fixing that review's findings.
- New task → round 1: another branch or PR, or the intent changed (a new feature on the same
PR), or the user says so (`/cr new`). Unsure which → ask the user one question. On a
branch that already carries earlier tasks, their code is in the diff too; findings that
belong to an earlier task's intent and that this task neither wrote nor activated go to
"outside".
- The heading carries the task and the round: `## Review: <task> (round N)` — that is how
the next round finds `prev`.
### 1.2 Brief — fill in verbatim, add nothing
One template, two openings — pick by the role of whoever receives it:
- **Handing the whole review to another session or agent**: exactly **one** brief, opening
`You run this review from §1 choose_tier on: spawn the reviewers, gate and assemble.
Round and intent below are given.` (no scope line). It sends
its reviewers the second opening; the result comes back as one assembled report.
- **A reviewer** (one per scope, spawned by whoever runs §1), opening
`You are the clean reviewer (§2). Your scope: <all | static | dynamic | slice: <name>>.`
The two openings read different files: the hand-off reads this `SKILL.md`, a reviewer reads
`reviewer.md` only. This template is the whole brief, however it is transported.
```text
Read and follow <absolute path to SKILL.md (hand-off) | reviewer.md (reviewer)>. <opening, as above>
Write the report in <user's language>; identifiers and file:line unchanged.
## Change under review
Repo: <abs path> Branch: <name> PR: <url or "none">
Round <N>. Review the whole change: `git diff <merge-base>` plus untracked files.
## Intent (round 1 text, unchanged)
<requirements_only(target) — PR text / requirement / commit message, copied from round 1>
## Already registered — report only if this change makes one worse
<one line per residual, no rationale; "none" if empty>
## Constraints
Read-only: no edits, commits, pushes, PR comments or external writes.
Tests: <exact commands> | not allowed. <environment limits the user stated, or omit>
## Output
The report exactly as §4 says.
```
Anything not in this template — focus areas ("please assess …"), earlier rounds' findings or
how they were fixed, invariants written while fixing, call-graph entry points or line numbers,
a test list, a restated report format — does not go in. Each of these aims the reviewer at the
author's newest mechanism, and the next round then reviews whatever the last fix added (P1).
If you believe the reviewer needs something else, the intent is incomplete: tell the user
instead of adding it to the brief. A user request to "generate review instructions" means
filling in this template.
```python
def dispatch_check(brief, round): # main session, before sending; any False →
return all([ # fix the brief, never send it as is
brief.sections == TEMPLATE.sections, # nothing added, nothing dropped
brief.intent == round_1_intent(task), # verbatim
f"Round {round}" in brief, # counted per task (§1.1)
brief.range == "git diff <merge-base> + untracked", # the whole change, every round
not handed_off or briefs_sent == 1, # a hand-off → one session runs the review
])
```
The reviewer's side of a malformed brief is in `reviewer.md` (top), where reviewers read it.
---
## 5. After the report — the fix plan (main session)
The reviewers' report ends at coverage and is relayed untouched (P2). The main session then
**always appends a fix plan** in the same message, under its own heading so it never reads as a
reviewer's verdict — a list of findings with no next step leaves the user picking one by one.
Written in the user's language, like the report:
````
---
## Fix plan (main session — not a review finding)
```text
① <cause, one line> #<n> #<m>
fix <one change at the cause> · ~<lines> · new review surface: <…>
when this PR | separate PR (why)
#<k> <fix> · this PR
```
★ Recommended: <which groups in this PR, in what order; what goes separate; what is only registered>
Reply with a plain yes in your language to apply it, or name groups (①②) / findings (#n).
````
Built only from the findings' own Break / Fix lines — no new analysis, no re-rating. No
findings → no plan; only "outside" items → one line "nothing to fix in this change; N
registered". When the user replies, apply the chosen groups by the same rules:
```python
def plan_fixes(report):
for item in report.outside:
register(item) # wherever the project tracks issues, or the PR's
# residual list;
# fixed here only if the user names it
groups = group_by_cause(report.findings) # findings one missing rule explains → one group;
# the rest stay single. Round ≥ 2: a finding in a
# class the last fix covered only by example →
# say "the last round fixed an example"
for g in groups:
fix = design_fix(g) # at the cause only if ALL three hold — else patch each
# symptom minimally here and register the cause:
# 1. the cause lives in code this change wrote or modified, not shared or old code
# 2. the fix adds no mechanism (below) and touches no module the diff didn't
# 3. it is not much larger than patching the symptoms one by one
# the same class back two rounds running → stop patching examples: the plan's first
# step is a structural diagnosis of that class (its root cause and the invariant that
# closes it), run once the user agrees; its fix is then placed by the three conditions
# above — this PR when all hold, else a separate PR
if fix.adds_mechanism: # new state, persisted shape, error / status code,
# background or retry path, or an edit in a module
# the diff didn't touch
ask_user("this PR or a separate one?", default="separate")
if fix.root_outside_diff: # "fix the root cause" whose root is shared or old code
contain_minimally_here(); propose_separate_pr(fix.root)
fix.cost += "new review surface: <what the next round will now have to review>"
present(groups) # the appended plan above; a plain yes applies the
# ★ groups, naming ①② or #n applies those
if diff_grew_well_past(round_1) or touches_new_module():
recommend("step back before the next round") # the scope is growing, not converging:
# re-check scope against the intent
if no introduced/activated 🔴 remains:
recommend("commit now; another round is optional") # say it, don't only offer fixes
# Findings from any other diagnosis of this change pass the same gate: only what the
# intent needs goes into this change, the rest is a follow-up. Accepting a recommendation
# means that needed set, not every finding in the report.
```
Why: every mechanism added to fix a finding becomes the next round's review surface, and
each round then finds the edges of the last fix. Fixing pre-existing problems "while we're
here" makes a small change grow round after round even when every finding is correct — the
reviewer is right each time, the scope is not. The opposite failure is fixing only the
example a reviewer named, so the next round reports the next example of the same class. A
cause fixed inside the change's own code ends that loop; a cause chased into shared or old
code restarts the first one — hence the three conditions.
---
## Self-check (main session)
```python
assert every reviewer judged alone; nothing relayed between tracks; findings verbatim # P1, P2
assert every report passed format_gate, or was bounced to its own author # P2
assert main session wrote only heading+verdict (+ index), coverage and the fix plan;
blank line before "## Review"; index (> 5 findings) is a "- " list # §4 —
# main-session text never passes format_gate
assert dispatch_check passed: brief == §1.2 template filled in, nothing added;
round counted per task; round 1's intent verbatim; the whole change reviewed # §1.1, §1.2
assert findings > 0 → a fix plan follows the report, headed as the main session's # §5
```