From d64fcd622b47f103c05dce6a8597460f03feeb24 Mon Sep 17 00:00:00 2001 From: vitya Date: Wed, 12 Aug 2026 18:30:17 +0300 Subject: [PATCH] =?UTF-8?q?feat(code-review):=20v0.1.0=20=E2=80=94=20two-a?= =?UTF-8?q?xis=20review=20(Standards/Spec=20parallel=20clean=20subagents)?= =?UTF-8?q?=20+=20Fowler=20smell=20baseline=20(mattpocock)=20=C3=97=20cave?= =?UTF-8?q?man-review=20output=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + README.ru.md | 1 + dist/code-review.skill | Bin 0 -> 3999 bytes skills/code-review/SKILL.md | 175 ++++++++++++++++++++++++++++++++++++ 4 files changed, 177 insertions(+) create mode 100644 dist/code-review.skill create mode 100644 skills/code-review/SKILL.md diff --git a/README.md b/README.md index 85e9e38..19c2e18 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,7 @@ an explicit `adapted-from` marker in its frontmatter. | `diagnosing-bugs` | `adapted-from: mattpocock/skills @ 84fdeffd` (MIT) + superpowers 6.2.0 concepts (Iron Law, red flags) | | `loop-me` | `adapted-from: mattpocock/skills @ 84fdeffd` (MIT) — workflow-spec design gate | | `review-kit-pi-method` | `author: ours` — pi-native spawn for clean-context review subagents | +| `code-review` | `adapted-from: mattpocock/skills @ 84fdeffd` (MIT) — two-axis + Fowler baseline; output: caveman-review format | | `writing-skills` | `adapted-from: obra/superpowers @ 6.2.0` (MIT) — TDD-for-skills core + ideya 8 self-skill-authoring | | all other `skills/*` | `author: ours` | diff --git a/README.ru.md b/README.ru.md index c5d5f93..dd8d7c5 100644 --- a/README.ru.md +++ b/README.ru.md @@ -88,6 +88,7 @@ bash scripts/build.sh caveman # один | `diagnosing-bugs` | `adapted-from: mattpocock/skills @ 84fdeffd` (MIT) + superpowers 6.2.0 (Iron Law, red flags) | | `loop-me` | `adapted-from: mattpocock/skills @ 84fdeffd` (MIT) — дизайн-гейт workflow-спец | | `review-kit-pi-method` | `author: ours` — pi-спавн чистых review-субагентов | +| `code-review` | `adapted-from: mattpocock/skills @ 84fdeffd` (MIT) — двухосевость + Fowler-база; формат вывода: caveman-review | | `writing-skills` | `adapted-from: obra/superpowers @ 6.2.0` (MIT) — TDD-for-skills ядро + идея 8 self-skill-authoring | | остальные `skills/*` | `author: ours` | diff --git a/dist/code-review.skill b/dist/code-review.skill new file mode 100644 index 0000000000000000000000000000000000000000..fc9f658158dc850a184af6e141640b8b454f9f45 GIT binary patch literal 3999 zcmV;Q4`A?6O9KQH000080G5*sUAn5W(-jW@0Gc2G02BZK0Ap`tWi4`Lc4=jIFH=iN zOiV6qWQ|$Pj@-r(zVj&>tAl68GhF@oZzV`s?@G1+Nvmkruy2|kvS+5fB%5NBJDN-2 z7(q@(0wlf$M$WkyhK(q;;{bkw-B<7vIFUG>#hU)4+|lc>asTJWL~*^PwnKou1lA=9y&D!; z`p$dr-Au2U+1qn7yZP?5cW%tyHdo)edR+}3JvbSvUq1U%)hjpAFRWL-u9~E7Dx=<1 z_uVQpm6~a9GFzBiYVInW2Yd9H$#oG-+KJ9g<*h6B)YbS}d^JjqPbyp1{OC@k)JeO$ ze4yN1X_eafTzOk02LG7b7baDuvqh~2iOX|akJYTwMY0^LS}(@fB{$W=OvoCs`MB0a zs;ktiLF$ZG_0q7XU}l!N75}?3rF+Ax)Fn-B3iu8C`0l&zias}4)?M`OP+^5SE=>}) zwzaZ(nHkzct(Ll`&9RlM?7|khw#7nO?;Er0=_Bn=aT|E+?l4yGyLzeg3+z%g1zxFA zS31i~rjpFSiHU<EiQ?&(6O)|K{S0i$9(JOP#+w|L6ISc<^uj^YY@)KmRbs!p$Oe@q2at{rOK= z^&{SYe*U%kgx2f?BuM-}*`fI2fdAmjpU%HI|L)?mi!apqxA^1_N}l4|m*?MLzw`fK z^Y71J_P5asZ3|y3^8U`|alHiQ1V!P5o@FroYek#k*-M=I?ax2N>JXp=m=$H$C7ADF zI|SYe&|G0A!ojHIVn??YcDGmO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DG+^)Qpb`i{|LJkO7C@)SLe<|!{)2~*8* z*F3^CGP_t(Sz%%{C?tmtR0P9-A|8qn94ZuZa6&sW?kJ}n&{9Yv)FeAI?HDplBzd^4 zM*V5-h$g)EWdba8687Ex$!Smh+F|pceY>ar`_-4h$acd7u^ zchxU{`>T2m`FupejbbUZ#|DgLejD-gqRD5hQ23eh>wM-iCLhmZJbU1K4LQwOwD3(}Iiy_qE` z2lP>kCB@c3^{zLyhpTo=F2FO2vJ7^qSASixM!LcTBKnF{TOOw9Nn4$%_XXCM{hv%q z8CZ*YAWcn~ex@@v{Y3D1`A2E8=hDy8)NK`hjwjGpEND}?`B5Vkn@ELN^N^b7$44iS zTXX)7hMY}ZHg)?8#>}i;h++V5?{~h + Two-axis review of a diff since a fixed point (commit, branch, tag, + merge-base) — Standards (does the code follow the repo's documented + standards + Fowler smell baseline?) and Spec (does it implement what the + originating issue/spec asked for?). Both axes run as parallel clean-context + sub-agents (review-kit-pi-method spawn) and are reported side by side. + Findings formatted caveman-style (L:line, severity prefix). Use when the + user says «отревьюй изменения», «ревью с коммита X», "review since X", + «проверь диф против спеки», "review against spec", "review this branch", + «ревью за период». Differs from caveman-review: that is the one-liner FORMAT + for quick PR comments ("review this PR", "review the diff", "code review" → + caveman-review); this is the full two-axis METHOD. +--- + +# Code review (two-axis) + +Review the diff between `HEAD` and a fixed point the user supplies, along two +independent axes: + +- **Standards** — does the code conform to this repo's documented coding + standards (+ the Fowler smell baseline below)? +- **Spec** — does the code faithfully implement the originating issue / spec? + +Both axes run as **parallel clean-context sub-agents** (see +review-kit-pi-method for the spawn) so they don't pollute each other's +context, then this skill aggregates their findings. + +Findings are formatted **caveman-style** (`L: . .` +— see caveman-review for the format and severity prefixes). + +## Why two axes + +A change can pass one axis and fail the other: + +- Code that follows every standard but implements the wrong thing → + **Standards pass, Spec fail.** +- Code that does exactly what the issue asked but breaks the project's + conventions → **Spec pass, Standards fail.** + +Reporting them separately stops one axis from masking the other. + +## Process + +### 1. Pin the fixed point + +Whatever the user said — a commit SHA, branch name, tag, `main`, `HEAD~5`, +etc. If they didn't specify one, ask for it. + +Capture the diff command once: `git diff ...HEAD` (three-dot, so +the comparison is against the merge-base). Also note the commit list: +`git log ..HEAD --oneline`. + +Before going further, confirm the fixed point resolves (`git rev-parse +`) and the diff is non-empty. A bad ref or empty diff should fail +here — not inside two parallel sub-agents. + +### 2. Identify the spec source + +Look for the originating spec, in this order: + +1. Issue/task references in the commit messages (`#123`, `Closes #45`, + `slug` references to `.tasks/`) — check `.tasks/` for the task block. +2. A path the user passed as an argument. +3. A spec under `.wiki/concepts/`, `.brainstorm/`, `docs/`, or `specs/` + matching the branch name or feature. +4. If nothing is found, ask the user where the spec is. If they say there + isn't one, the **Spec** sub-agent skips and reports "no spec available". + +### 3. Identify the standards sources + +Anything in the repo that documents how code should be written: +`CODING_STANDARDS.md`, `CONTRIBUTING.md`, the project's `.wiki/CLAUDE.md` +schema, CLAUDE.md conventions. + +On top of whatever the repo documents, the Standards axis always carries the +**smell baseline** below — a fixed set of Fowler code smells (_Refactoring_, +ch.3) that applies even when a repo documents nothing. Two rules bind it: + +- **The repo overrides.** A documented repo standard always wins; where it + endorses something the baseline would flag, suppress the smell. +- **Always a judgement call.** Each smell is a labelled heuristic ("possible + Feature Envy"), never a hard violation — and, like any standard here, skip + anything tooling already enforces. + +Each smell reads *what it is* → *how to fix*; match it against the diff: + +- **Mysterious Name** — a function, variable, or type whose name doesn't + reveal what it does or holds. → rename it; if no honest name comes, the + design's murky. +- **Duplicated Code** — the same logic shape appears in more than one hunk or + file in the change. → extract the shared shape, call it from both. +- **Feature Envy** — a method that reaches into another object's data more + than its own. → move the method onto the data it envies. +- **Data Clumps** — the same few fields or params keep travelling together (a + type wanting to be born). → bundle them into one type, pass that. +- **Primitive Obsession** — a primitive or string standing in for a domain + concept that deserves its own type. → give the concept its own small type. +- **Repeated Switches** — the same `switch`/`if`-cascade on the same type + recurs across the change. → replace with polymorphism, or one map both sites + share. +- **Shotgun Surgery** — one logical change forces scattered edits across many + files in the diff. → gather what changes together into one module. +- **Divergent Change** — one file or module is edited for several unrelated + reasons. → split so each module changes for one reason. +- **Speculative Generality** — abstraction, parameters, or hooks added for + needs the spec doesn't have. → delete it; inline back until a real need + shows. +- **Message Chains** — long `a.b().c().d()` navigation the caller shouldn't + depend on. → hide the walk behind one method on the first object. +- **Middle Man** — a class or function that mostly just delegates onward. → + cut it, call the real target direct. +- **Refused Bequest** — a subclass or implementer that ignores or overrides + most of what it inherits. → drop the inheritance, use composition. + +### 4. Spawn both sub-agents in parallel + +Per review-kit-pi-method: parallel runs, one question each, clean spawn. + +**Standards sub-agent prompt** — include: + +- The full diff command and commit list. +- The list of standards-source files found in step 3, **plus the smell + baseline from step 3 pasted in full** — the sub-agent has no other access + to it. +- The brief: "Report — per file/hunk where relevant — (a) every place the + diff violates a documented standard: cite the standard (file + the rule); + and (b) any baseline smell you spot: name it and quote the hunk. Distinguish + hard violations from judgement calls — documented-standard breaches can be + hard, but baseline smells are always judgement calls, and a documented repo + standard overrides the baseline. Skip anything tooling enforces." + +**Spec sub-agent prompt** — include: + +- The diff command and commit list. +- The path or fetched contents of the spec. +- The brief: "Report: (a) requirements the spec asked for that are missing or + partial; (b) behaviour in the diff that wasn't asked for (scope creep); + (c) requirements that look implemented but where the implementation looks + wrong. Quote the spec line for each finding." + +If the spec is missing, skip the Spec sub-agent and note this in the final +report. + +### 5. Aggregate + +Present the two reports under `## Standards` and `## Spec` headings, verbatim +or lightly cleaned. Do **not** merge or rerank findings — the two axes are +deliberately separate (see *Why two axes*). + +Format every finding caveman-style: `L: . .` +(severity: 🔴 bug / 🟡 risk / 🔵 nit / ❓ q). One line per finding, exact +line numbers, exact symbol names, concrete fix. + +End with a one-line summary: total findings per axis, and the worst issue +_within each axis_ (if any). Don't pick a single winner across axes — that's +the reranking the separation exists to prevent. + +## Cross-agent applicability + +Pure methodology — the spawn command is pi-specific (review-kit-pi-method); +on any runtime that can spawn a fresh-context subprocess, use its equivalent. +The two-axis structure and Fowler baseline transfer unchanged. + +## Out of scope + +- Does NOT define the output format beyond the caveman one-liner convention + (see caveman-review for full format rules). +- Does NOT fix the code — reviews only. +- Does NOT approve/request-changes formally — presents findings. +- Does NOT run linters/builds — tooling-enforced checks are skipped per the + Standards axis rule.