@olegkoval/agent-skills 1.27.0 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/.claude-plugin/plugin.json +2 -1
  2. package/README.md +4 -3
  3. package/catalog/skills.json +18 -0
  4. package/package.json +1 -1
  5. package/packages/software-development/lekker-review/SKILL.md +519 -0
  6. package/packages/software-development/lekker-review/adapters/claude/plugin.json +5 -0
  7. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/SKILL.md +520 -0
  8. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/agents/completeness-critic.md +21 -0
  9. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/agents/conventions.md +124 -0
  10. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/agents/fix-verifier.md +84 -0
  11. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/agents/fixer.md +120 -0
  12. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/agents/implementation.md +53 -0
  13. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/agents/prover.md +135 -0
  14. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/agents/quality.md +72 -0
  15. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/agents/simplification.md +45 -0
  16. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/agents/test-quality.md +170 -0
  17. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/agents/triage-logic.md +27 -0
  18. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/agents/triage-quality.md +41 -0
  19. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/agents/verifier.md +295 -0
  20. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/artifact-page.md +143 -0
  21. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/context-gathering.md +162 -0
  22. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/fix-mode.md +329 -0
  23. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/github-post.md +205 -0
  24. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/house-rules.md +76 -0
  25. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/references/output-format.md +232 -0
  26. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/scripts/changed-files.sh +77 -0
  27. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/scripts/setup-worktree.sh +337 -0
  28. package/packages/software-development/lekker-review/adapters/claude/skills/lekker-review/scripts/verify-fixes.sh +231 -0
  29. package/packages/software-development/lekker-review/fix-workflow.js +273 -0
  30. package/packages/software-development/lekker-review/references/agents/completeness-critic.md +21 -0
  31. package/packages/software-development/lekker-review/references/agents/conventions.md +124 -0
  32. package/packages/software-development/lekker-review/references/agents/fix-verifier.md +84 -0
  33. package/packages/software-development/lekker-review/references/agents/fixer.md +120 -0
  34. package/packages/software-development/lekker-review/references/agents/implementation.md +53 -0
  35. package/packages/software-development/lekker-review/references/agents/prover.md +135 -0
  36. package/packages/software-development/lekker-review/references/agents/quality.md +72 -0
  37. package/packages/software-development/lekker-review/references/agents/simplification.md +45 -0
  38. package/packages/software-development/lekker-review/references/agents/test-quality.md +170 -0
  39. package/packages/software-development/lekker-review/references/agents/triage-logic.md +27 -0
  40. package/packages/software-development/lekker-review/references/agents/triage-quality.md +41 -0
  41. package/packages/software-development/lekker-review/references/agents/verifier.md +295 -0
  42. package/packages/software-development/lekker-review/references/artifact-page.md +143 -0
  43. package/packages/software-development/lekker-review/references/context-gathering.md +162 -0
  44. package/packages/software-development/lekker-review/references/fix-mode.md +329 -0
  45. package/packages/software-development/lekker-review/references/github-post.md +205 -0
  46. package/packages/software-development/lekker-review/references/house-rules.md +76 -0
  47. package/packages/software-development/lekker-review/references/output-format.md +232 -0
  48. package/packages/software-development/lekker-review/scripts/changed-files.sh +77 -0
  49. package/packages/software-development/lekker-review/scripts/setup-worktree.sh +337 -0
  50. package/packages/software-development/lekker-review/scripts/verify-fixes.sh +231 -0
  51. package/packages/software-development/lekker-review/workflow.js +602 -0
@@ -0,0 +1,520 @@
1
+ ---
2
+ name: lekker-review
3
+ description: >
4
+ FAANG-quality PR code review, adaptable to any team. Checks out the branch in an
5
+ isolated worktree, gathers context from your issue tracker, chat, docs, CI
6
+ checks, and (optionally) production monitoring, runs 5 parallel specialized
7
+ review agents (quality/implementation/simplification/conventions/test-quality),
8
+ verifies every finding against the diff, then outputs a single unified markdown
9
+ review — file + risk + bad code + why it's wrong + fix — ready to paste directly
10
+ into GitHub. Saves every review to ~/code-reviews/*.md. Covers business logic,
11
+ scalability, complexity, data integrity, security, integration contracts, error
12
+ handling, and migration safety. Critical findings come with PROOF: a prover
13
+ agent writes a failing test in the worktree demonstrating each bug, and fix
14
+ mode later re-runs it to show the fix flips it green. Every review also
15
+ publishes a private living artifact page whose URL stays stable across
16
+ re-reviews, so the author watches findings close commit by commit.
17
+ With --fix (or by accepting the post-review offer) it also APPLIES its own
18
+ Critical/Important findings as real code in the worktree, verifies each edit,
19
+ commits them, and pushes to the PR branch only after explicit confirmation.
20
+ Use when the user says "review this PR", "lekker review", "check this PR",
21
+ "do a code review on PR #N", "review and fix this PR", "apply the review
22
+ fixes", provides a GitHub PR URL, or asks for a pull request review in any
23
+ form.
24
+ license: MIT
25
+ allowed-tools: Bash, Read, Write, Edit, Agent, Workflow, AskUserQuestion, Artifact
26
+ compatibility: Claude Code only. Requires the Workflow tool (multi-agent orchestration)
27
+ and the Artifact tool (living review page) — other Agent Skills-compatible tools
28
+ without an equivalent to Workflow cannot run the review/verify/critic pipeline this
29
+ skill depends on. Requires git and gh (GitHub CLI) authenticated.
30
+ metadata:
31
+ targets: [_source-only]
32
+ author: Oleg Koval
33
+ tags:
34
+ - code-review
35
+ - pull-request
36
+ - github
37
+ - multi-agent
38
+ - workflow
39
+ - quality
40
+ argument-hint: "<github-pr-url | repo pr-number | repo pr-title> [scan|medium|deep] [--post] [--fix]"
41
+ ---
42
+ <!-- Generated by scripts/build-adapters.sh. Do not edit directly. -->
43
+
44
+ # Lekker Review
45
+
46
+ FAANG-grade code review. Isolated worktree checkout, full context gathering
47
+ (issue tracker + chat + docs + framework docs + monitoring + CI, whichever
48
+ you have MCP tools configured for), then 5 parallel specialized review
49
+ agents, a finding-verification pass, and one unified markdown output.
50
+
51
+ Each finding contains: **file + risk** · **bad code verbatim** · **why it's
52
+ wrong** · **fix with code example** - ready to paste directly into GitHub.
53
+ Reviews are saved to `~/code-reviews/` for future reference.
54
+
55
+ Optionally the skill then **applies** its own findings (`--fix`): fix agents edit
56
+ the worktree, a read-only verifier checks each edit against the real `git diff`,
57
+ static checks run, one commit lands per file, and nothing is pushed until the
58
+ user says so. Procedure in `references/fix-mode.md`.
59
+
60
+ No nitpicking. Critical and Important findings are reserved for things that
61
+ could cause bugs, outages, data loss, security incidents, or real performance
62
+ problems at scale.
63
+
64
+ **HARD RULE: the `## 💰 Review Cost` block is mandatory.** Every review MUST
65
+ end with a fully-populated cost block (token + price breakdown, real numbers,
66
+ no `<N>` placeholders). A review without the cost block is incomplete. If you
67
+ are about to present the review without it, stop and compute it first.
68
+
69
+ ---
70
+
71
+ ## Set up before first use
72
+
73
+ This skill ships with **no** hard rules of its own — `references/house-rules.md`
74
+ is a template. Fill it in with your team's own non-negotiable conventions
75
+ (type safety, pagination, PR-title format, repo-placement taxonomy, stack
76
+ context) before relying on the Critical-severity hard-rule gate. Until then,
77
+ the 5 specialist agents still run and still find real bugs — they just don't
78
+ have a codified "always Critical" rule list to check against.
79
+
80
+ If any hard rule you define carries a `rule` tag (e.g. `"TS-1"`), reviewer
81
+ agents attach that tag to matching findings and the workflow **skips
82
+ adversarial verification** for them. This is deliberate: the verifier's five
83
+ challenges ask runtime-failure questions ("does this fail on a normal
84
+ execution?", "can you write the failing test?") that a standards violation
85
+ can never answer, so verifying them systematically drops the very findings
86
+ your policy declares non-negotiable. A tagged finding keeps its Critical
87
+ severity; the workflow returns how many were exempted as `hardRuleCount`, and
88
+ each carries a `verifierReasoning` saying so.
89
+
90
+ `${CLAUDE_PLUGIN_ROOT}` below refers to this skill's own installed directory
91
+ — resolve every `references/...` and script path relative to it.
92
+
93
+ ---
94
+
95
+ ## Step 0 - Parse input
96
+
97
+ Accept any of:
98
+ - Full GitHub URL: `https://github.com/owner/repo/pull/123`
99
+ - Repo + number: `my-service 42`
100
+ - Repo + partial title: `my-service "add offline orders"`
101
+
102
+ If the user gives a short repo name without an org/owner, ask once which
103
+ org/owner it belongs to (or use a default you've configured), then build
104
+ `REPO_SLUG` as `<owner>/<name>`.
105
+
106
+ Derive and carry these variables through every subsequent step:
107
+ - `REPO_SLUG` (e.g. `my-org/my-service`)
108
+ - `PR_NUMBER`
109
+ - `PR_BRANCH` (from `gh pr view`)
110
+ - `PR_URL` = `https://github.com/<REPO_SLUG>/pull/<PR_NUMBER>`
111
+
112
+ **Depth:** explicit keyword `scan`, `medium`, or `deep` wins. If absent, run
113
+ `gh pr view <PR_NUMBER> --repo <REPO_SLUG> --json additions,deletions,changedFiles`
114
+ and apply AUTO-DEPTH:
115
+ - `scan` if additions+deletions < 150 AND changedFiles <= 5
116
+ - `deep` if additions+deletions > 800 OR changedFiles > 25 OR diff touches
117
+ `migrations/` or `*.sql`
118
+ - `medium` otherwise
119
+
120
+ State the chosen depth (and whether it was auto-selected) in the review header.
121
+
122
+ **`--post` flag:** parse and store as `POST_REVIEW=true`.
123
+
124
+ **`--fix` flag:** parse and store as `FIX_MODE=true`. Fix mode needs a real
125
+ checkout, so `--fix` forces Track A (worktree setup) to run even when
126
+ depth=scan. If the user did NOT pass `--fix`, leave `FIX_MODE=false` for now -
127
+ Step 4 offers it after the review is printed.
128
+
129
+ **`--no-artifact` flag:** parse and store as `ARTIFACT=false` (default true).
130
+ Skips Step 3.5 (living review artifact) silently.
131
+
132
+ **Re-review detection:** run
133
+ `ls ~/code-reviews/*-pr-<PR_NUMBER>-<repo-short-name>.md 2>/dev/null | sort | tail -1`
134
+ to find the newest prior review for this PR (repo-short-name = last segment of
135
+ REPO_SLUG; keeps PR numbers from colliding across repos). If found, grep it for
136
+ `\*\*Head:\*\*` and extract the short sha. Set `PREV_SHA=<sha>` and
137
+ `PREV_REVIEW_FILE=<path>`. If no Head line exists in the file (older format),
138
+ treat as a full review and leave PREV_SHA unset. Also grep the same file for
139
+ `\*\*Artifact:\*\*` and set `PREV_ARTIFACT_URL=<url>` (null when absent) - Step
140
+ 3.5 republishes to the SAME url so the artifact stays a living page for this PR.
141
+
142
+ ---
143
+
144
+ ## Depth gate
145
+
146
+ | Step | scan | medium | deep |
147
+ |-----------------------------|-----------------------|---------------------|----------------------------|
148
+ | Context: issue-tracker/CI/diff/existing-reviews | always | always | always |
149
+ | Context: chat/docs/framework-docs/monitoring/prior-review-memory (optional, MCP-dependent) | skip | included | included + broader recall |
150
+ | Worktree + static checks | skip (WORKTREE_PATH=null) unless `--fix` | included | included |
151
+ | Review agents | 2 triage (haiku) | 5 specialists (sonnet) | 5 specialists (sonnet) |
152
+ | Per-finding verification | none | Criticals only (hard rules exempt) | Criticals + Importants (hard rules exempt) |
153
+ | Completeness critic | skip | skip | included |
154
+ | Proof-of-bug (failing test per Critical) | skip | included (max 5) | included (max 5) |
155
+ | Living review artifact | included | included | included |
156
+ | Housekeeping (optional memory/notes writeback) | skip | included | included |
157
+ | `--post` | supported | supported | supported |
158
+ | `--fix` / fix offer | supported (forces worktree) | supported | supported |
159
+
160
+ For scan: note `⚡ scan - worktree unavailable, static checks skipped` in the
161
+ review header. When `--fix` forced the worktree at scan depth, drop that note
162
+ and say `⚡ scan - worktree created for --fix` instead.
163
+
164
+ ---
165
+
166
+ ## Step 1 - Context + worktree (concurrent)
167
+
168
+ Fire both tracks in the same turn.
169
+
170
+ ### Track A - worktree setup (skip when depth=scan, unless `--fix`)
171
+
172
+ Run via Bash with `run_in_background`:
173
+
174
+ ```bash
175
+ ${CLAUDE_PLUGIN_ROOT}/scripts/setup-worktree.sh \
176
+ <REPO_SLUG> <PR_BRANCH> <scratchpad>/worktree.json [PREV_SHA]
177
+ ```
178
+
179
+ On completion, read `worktree.json`. Keys emitted:
180
+ `worktreePath`, `repoRoot`, `headSha`, `headShaShort`, `tscTail`,
181
+ `tscChangedTail`, `tscErrorCount`, `eslintTail`, `eslintScope`, `changedFiles`,
182
+ `baseRef`, `projectRules`, `deltaFile`, `notes`.
183
+
184
+ Static checks are scoped so you can tell this PR's errors from the repo's
185
+ standing debt - do not try to infer that from the raw tail:
186
+
187
+ - `eslintTail` is the result of linting only `changedFiles` (`eslintScope` says
188
+ `changed-files`). Everything in it belongs to this PR. When `eslintScope` is
189
+ `full-fallback`, base-ref detection failed and the lint is repo-wide again -
190
+ in that case treat its contents as unattributed and say so rather than
191
+ blaming the author.
192
+ - `tscTail` is the raw repo-wide tail (tsc needs the whole program, so it cannot
193
+ be scoped). `tscChangedTail` holds only the errors in files this PR touched -
194
+ that is the attributable set. `tscErrorCount` is the repo-wide total; a large
195
+ count with an empty `tscChangedTail` means pre-existing debt, not a finding.
196
+ - If your stack doesn't use tsc/eslint, adapt `setup-worktree.sh`'s static
197
+ check step to your language's compiler/linter equivalents.
198
+
199
+ A failing CI build or test = Critical finding input.
200
+
201
+ When depth=scan: set `WORKTREE_PATH=null` without launching the script - unless
202
+ `FIX_MODE=true`, in which case run the script anyway (fix mode cannot edit code
203
+ from a diff).
204
+
205
+ ### Track B - metadata and signals (all calls fired in parallel)
206
+
207
+ Run ALL of the following in the same message. Full query details are in
208
+ `references/context-gathering.md` - follow it, do not paste it wholesale into
209
+ agent contexts.
210
+
211
+ - `gh pr view <PR_NUMBER> --repo <REPO_SLUG>` with fields: `number`, `title`,
212
+ `body`, `author`, `headRefName`, `baseRefName`, `labels`, `linkedBranches`,
213
+ `mergeStateStatus`, `additions`, `deletions`, `changedFiles`, `isDraft`,
214
+ `headRefOid`. Extract `headRefOid` (full sha) and `headShaShort` (first 7).
215
+ - Title/ticket-prefix check (if `house-rules.md` defines one): scan commit log
216
+ for the ticket pattern; set `PR_TITLE_ISSUE` and `RECOMMENDED_PREFIX`.
217
+ - `gh pr diff <PR_NUMBER> --repo <REPO_SLUG> > <scratchpad>/pr.diff` - fetched
218
+ ONCE; all agents read this file via `DIFF_FILE`.
219
+ - `gh pr checks <PR_NUMBER> --repo <REPO_SLUG>`
220
+ - `gh pr reviews <PR_NUMBER> --repo <REPO_SLUG>` and review comments
221
+ - Issue-tracker lookup (Linear/Jira/GitHub Issues MCP, if configured) per
222
+ ticket ID found in title/body/branch; collect ACs as numbered list (`acList`).
223
+ - (medium/deep only, optional) Chat search (Slack/Discord MCP, if configured):
224
+ PR-title keywords and ticket ID.
225
+ - (medium/deep only, optional) Docs search (Notion/Confluence/wiki MCP, if
226
+ configured): feature name or ticket title.
227
+ - (medium/deep only, optional, only when relevant) Framework/API docs MCP for
228
+ the specific framework or third-party API the diff touches.
229
+ - (medium/deep only, optional) Monitoring search (Sentry/Rollbar/etc. MCP, if
230
+ configured) for filenames or service names from the diff.
231
+ - (medium/deep only, optional) Prior-review-memory recall, if you maintain
232
+ such a system: patterns and false positives specific to this repo.
233
+
234
+ ### Assemble CONTEXT_FILE
235
+
236
+ Write `<scratchpad>/context.json` with keys:
237
+
238
+ ```json
239
+ {
240
+ "acList": "<numbered ACs from your issue tracker, or empty>",
241
+ "projectRules": "<worktree.json projectRules + any recalled review patterns appended under '## Recalled patterns'>",
242
+ "sentrySignals": "<monitoring issue summaries, or null>",
243
+ "ciStatus": "<passing | failing: <names> | pending | N/A>",
244
+ "existingReviews": "<prior review summaries>",
245
+ "deltaFile": "<worktree.json deltaFile, or null>",
246
+ "houseRulesFile": "${CLAUDE_PLUGIN_ROOT}/references/house-rules.md"
247
+ }
248
+ ```
249
+
250
+ Agents read keys from this file. Nothing from CONTEXT_FILE is pasted into
251
+ their prompts wholesale - the workflow script delivers it by path.
252
+
253
+ ---
254
+
255
+ ## Step 2 - Workflow (review + verify + critic)
256
+
257
+ Invoke the Workflow tool:
258
+
259
+ ```
260
+ scriptPath: ${CLAUDE_PLUGIN_ROOT}/workflow.js
261
+ args: {
262
+ repoSlug,
263
+ prNumber,
264
+ prUrl,
265
+ depth,
266
+ diffFile: "<scratchpad>/pr.diff",
267
+ contextFile: "<scratchpad>/context.json",
268
+ worktreePath: <null for scan, else from worktree.json>,
269
+ promptDir: "${CLAUDE_PLUGIN_ROOT}/references/agents",
270
+ prevSha: <null unless re-review>
271
+ }
272
+ ```
273
+
274
+ The workflow runs three phases:
275
+
276
+ - **Review:** scan uses `[triage-quality, triage-logic]` on `haiku`; medium/deep
277
+ use 5 specialists (quality, implementation, simplification, conventions,
278
+ test-quality) on `sonnet`. Agents receive DIFF_FILE + CONTEXT_FILE by path.
279
+ All reviewers run to completion before verification starts.
280
+ - **Dedup:** findings are merged across dimensions on `file:line` + title
281
+ token-similarity, so one issue found by three agents is verified once, not
282
+ three times. A merge keeps the highest severity and the longest
283
+ description/badCode/fix of the set - a Critical is never demoted by an
284
+ Observation someone else filed at the same line - and records every
285
+ contributing dimension in `agreedBy`.
286
+ - **Verify:** scan verifies nothing; medium verifies Criticals; deep verifies
287
+ Criticals + Importants. Hard-rule findings (`rule` set) are always exempt.
288
+ Each verifier runs the five-challenge adversarial refutation from
289
+ `references/agents/verifier.md` against one finding, returns
290
+ `{verdict, newSeverity?, reasoning}`.
291
+ - **Critic (deep only):** completeness critic gets the full deduped finding
292
+ list + DIFF_FILE; its findings go through verifier agents before promotion.
293
+ - **Prove (medium/deep, worktree required):** each non-hard-rule Critical gets
294
+ one prover agent (`references/agents/prover.md`, sonnet, max 5) that writes a
295
+ test asserting the CORRECT behavior, runs it in the worktree, and captures it
296
+ failing because of the bug. The proof rides on the finding as
297
+ `proof: {attempted, proven, reason, testCode?, testCommand?, redOutput?}`.
298
+ A proof that comes back GREEN (code behaved correctly) is counter-evidence -
299
+ Step 3 must downgrade or explicitly justify the finding, never ignore it.
300
+ Hard-rule findings are never proved (policy violations have no failing test).
301
+
302
+ Findings have schema:
303
+ `{file, line, severity, title, description, badCode, fix, rule?, precedent?, agreedBy?, verifierReasoning?, proof?}`
304
+ `badCode` and `fix` are schema-required: an empty string is allowed only on
305
+ `observation` / `idiomatic` findings.
306
+
307
+ Model tiers: triage on `haiku`, specialists on `sonnet`, verifiers + critic +
308
+ provers on `sonnet`, housekeeping on `haiku`. Only the synthesis in Step 3 runs
309
+ on the session model.
310
+
311
+ Return value from the workflow:
312
+ `{findings, droppedCount, downgradedCount, hardRuleCount, proveAttemptCount, provenCount, agentCount, outputTokens, turnTokensTotal}`
313
+ `outputTokens` is this workflow's own output spend; `turnTokensTotal` is the
314
+ whole turn's shared pool (main loop included).
315
+
316
+ Wait for the workflow to complete before proceeding to Step 3.
317
+
318
+ ---
319
+
320
+ ## Step 3 - Synthesize and output
321
+
322
+ **Mindset:** the author's name is not evidence. Bot review scores are not
323
+ anchors. Apply your own judgment to every finding.
324
+
325
+ **Do NOT flag:**
326
+ - Style preferences or naming taste where no convention is violated
327
+ - Comment wording choices
328
+ - Scenarios requiring multiple simultaneous unrealistic failures
329
+ - Tiny DRY opportunities (2-3 duplicated lines)
330
+ - Pre-existing code not touched by this diff
331
+ - Anything you are not confident about - omit rather than hedge
332
+
333
+ **Idiomatic & Consistency exception:** the conventions agent raises non-blocking
334
+ suggestions ONLY when a concrete better pattern provably already exists in the
335
+ codebase. Never on taste alone. These land in their own section, not in
336
+ Critical/Important. A finding without a cited precedent from the codebase is
337
+ dropped.
338
+
339
+ **Format** the review per `references/output-format.md` (read it now). Key
340
+ requirements:
341
+
342
+ - Header must include `**Head:** <headShaShort>` (enables future delta mode).
343
+ - When `isDraft=true`: add `**DRAFT PR** - findings recorded for when this
344
+ is ready to merge.` after the header block.
345
+ - When `mergeStateStatus` is not CLEAN: note it (e.g. conflicts, failing
346
+ required checks).
347
+ - When `PR_TITLE_ISSUE=true`: insert the `⛔ CANNOT MERGE` block before the
348
+ Summary.
349
+ - When `sentrySignals` is non-empty: include `## 🔥 Production Signals`.
350
+ - When `PREV_SHA` is set: include `## 🔁 Since last review` comparing
351
+ `PREV_REVIEW_FILE` findings against the new head - list each as fixed or
352
+ still open, before any new findings.
353
+ - Test Quality section: populate from the test-quality agent's fields
354
+ (`coverageVerdict`, `mutationSlip`, `mockSmells`).
355
+ - Idiomatic section: populated from severity=idiomatic findings only.
356
+ - **💰 Review Cost block:** `outputTokens` from the workflow return is the
357
+ ACTUAL output spend of the review workflow's own agents. `turnTokensTotal` is
358
+ the whole turn's shared pool - report it separately, never as the workflow's
359
+ cost. Input tokens are estimated (diff tokens x agent passes + context
360
+ + prompt files). Use the pricing table in `references/output-format.md`.
361
+ Real numbers only - no `<N>` placeholders.
362
+
363
+ **Save the review:**
364
+
365
+ ```bash
366
+ mkdir -p ~/code-reviews
367
+ REVIEW_FILE=~/code-reviews/$(date +%Y-%m-%d)-pr-<PR_NUMBER>-<repo-short-name>.md
368
+ # write the review to $REVIEW_FILE
369
+ ```
370
+
371
+ After writing, re-read the file and emit a receipt:
372
+ `✓ Review saved -> <path>`
373
+
374
+ Also write the workflow's `findings` array verbatim to
375
+ `<scratchpad>/findings.json` - fix mode reads its selection from there (the
376
+ `proof` objects ride along for the Step 5b proof flip), and it is the receipt
377
+ that what was reported equals what was found.
378
+
379
+ Then print the full review as the response.
380
+
381
+ ---
382
+
383
+ ## Step 3.5 - Living review artifact (skip when ARTIFACT=false)
384
+
385
+ Immediately after printing the review, follow `references/artifact-page.md`:
386
+ launch ONE background sonnet agent that renders the review as a self-contained
387
+ HTML page and publishes it via the Artifact tool - passing `PREV_ARTIFACT_URL`
388
+ when set, so a re-review UPDATES the same page instead of minting a new URL.
389
+ The page is the living version of the review: verdict header, since-last-review
390
+ timeline, findings with proof panels, all private by default.
391
+
392
+ Never block on it: the printed review and the saved file are the deliverable;
393
+ the artifact is an enhancement. When the URL comes back, append/refresh the
394
+ `**Artifact:** <url>` header line in the saved review file (re-read to confirm)
395
+ and print one line: `🔗 Living review: <url>`.
396
+
397
+ ---
398
+
399
+ ## Step 4 - Fix mode (after the review is printed)
400
+
401
+ ### Trigger
402
+
403
+ - `FIX_MODE=true` (the user passed `--fix`) -> go straight to
404
+ `references/fix-mode.md`.
405
+ - `FIX_MODE=false` and at least one Critical or Important finding has a `fix`
406
+ field -> ask once, via AskUserQuestion:
407
+
408
+ > Apply these fixes to the PR branch?
409
+ > - **Critical + Important** (N findings) - fix agents edit the worktree,
410
+ > verified, committed; push needs your confirmation
411
+ > - **Critical only** (N findings)
412
+ > - **No, review only**
413
+
414
+ Set `FIX_MODE=true` and `FIX_SCOPE=<critical+important | critical>` from the
415
+ answer. On "No", skip to Step 5.
416
+ - No fixable findings, or the review found nothing -> do not ask. Say
417
+ `nothing to auto-fix` in one line and skip to Step 5.
418
+ - **Unattended run** (cron, `/loop`, background agent): never ask. Run fix mode
419
+ only when `--fix` was passed explicitly, and stop before pushing.
420
+
421
+ ### Procedure
422
+
423
+ Read `references/fix-mode.md` and follow it. Shape of the run:
424
+
425
+ 1. Preconditions: worktree exists + clean, `origin/<PR_BRANCH>` still at
426
+ `headSha`, PR open, head repo writable.
427
+ 2. Select eligible findings (Critical/Important with a `fix`, real file,
428
+ non-generated). Never auto-fix Observation, Idiomatic, or a title/process rule.
429
+ 3. Invoke the fix workflow:
430
+ ```
431
+ scriptPath: ${CLAUDE_PLUGIN_ROOT}/fix-workflow.js
432
+ args: { repoSlug, prNumber, worktreePath, diffFile, contextFile, promptDir,
433
+ findings: [<selected findings verbatim>] }
434
+ ```
435
+ One `sonnet` fix agent per file (never two on the same file), then a
436
+ read-only `sonnet` fix-verifier per file reading the actual `git diff`. One
437
+ retry max on a non-`good` verdict.
438
+ 4. Revert every group the verifier did not pass.
439
+ 5. Run `scripts/verify-fixes.sh <WORKTREE_PATH> <scratchpad>/fix-verify.json tests`
440
+ and diff the output against the baseline `tscTail`/`eslintTail` from
441
+ worktree.json. Newly introduced errors -> revert that group.
442
+ 5b. Proof flip: for findings with `proof.proven`, re-run the captured failing
443
+ test after the fix. Still red -> the fix did not fix the bug: revert the
444
+ group even if the fix-verifier said `good`. An executed test outranks an
445
+ agent's opinion. Green -> record `proofFlip: green` in the status table.
446
+ 6. Commit one commit per file with an explicit `git add -- <files>`.
447
+ 7. Push ONLY after the user confirms, with `git push origin HEAD:refs/heads/<PR_BRANCH>`
448
+ and a re-fetch sha guard. Never force, never rebase, never push to
449
+ main/master/staging/develop. Verify via `gh pr view --json headRefOid`.
450
+ 8. Print the per-finding status table and append `## 🔧 Fixes applied` to the
451
+ saved review file.
452
+
453
+ Fix-agent tokens are additional spend: add a `Fix agents:` line to the
454
+ `## 💰 Review Cost` block.
455
+
456
+ ---
457
+
458
+ ## Step 5 - Post-review (after the review and any fixes)
459
+
460
+ ### If POST_REVIEW=true
461
+
462
+ Follow `references/github-post.md`:
463
+ - Build a JSON payload with Critical + Important findings as inline comments
464
+ (only for lines present in the diff hunks).
465
+ - POST via `gh api repos/<REPO_SLUG>/pulls/<PR_NUMBER>/reviews` with NO
466
+ `event` field (creates PENDING, visible only to you).
467
+ - Verify post-condition: fetch review list, confirm PENDING state exists.
468
+ - Print count + link.
469
+ - Observation and Idiomatic findings go in the review body, never inline.
470
+ - Never submit the review programmatically.
471
+ - When fix mode applied and committed a finding, EXCLUDE it from the inline
472
+ comments - do not ask for a change you already made. Mention the applied
473
+ fixes in one line of the review body instead.
474
+
475
+ ### Housekeeping (skip when depth=scan, optional)
476
+
477
+ If you maintain a persistent notes/memory system across reviews, launch ONE
478
+ background Agent with `model: 'haiku'`, passing the review file path +
479
+ repo-short-name + PR author login, instructed to follow
480
+ `references/post-review.md` if you've written one for your own setup:
481
+ - Log durable patterns (recurring findings, confirmed false positives) scoped
482
+ to the repo, never to the author.
483
+ - Skip entirely if you have no such system — nothing else in this skill
484
+ depends on it.
485
+
486
+ ### Cleanup (when a worktree was created)
487
+
488
+ **Fix-mode override:** if fix mode produced commits that were NOT pushed, do
489
+ NOT clean up. Keep the worktree and the repo clone, print the worktree path and
490
+ the exact push command. Deleting it destroys the only copy of the work. Clean up
491
+ normally when the push succeeded or nothing was committed.
492
+
493
+ ```bash
494
+ git -C <repoRoot> worktree remove --force <worktreePath> \
495
+ || rm -rf <worktreePath>
496
+ git -C <repoRoot> worktree prune
497
+ ```
498
+
499
+ If `repoRoot` starts with `/tmp/lekker-clone-`, also remove that clone dir.
500
+ Remove the delta file if `deltaFile` was set in worktree.json. Verify with
501
+ `git -C <repoRoot> worktree list` that no `lekker-review` entries remain.
502
+
503
+ ---
504
+
505
+ ## Failure rules
506
+
507
+ Two identical failures = stop and diagnose, don't loop blindly.
508
+
509
+ If the Workflow tool is unavailable or the run dies: fall back to launching the
510
+ 5 agents via the Agent tool with the same prompt files, do verification inline
511
+ per `references/agents/verifier.md`, and state this fallback in the review
512
+ output under a `**Note:** Workflow tool unavailable - ran agents directly`
513
+ line in the header.
514
+
515
+ Fix-mode specific:
516
+ - Never claim a fix landed without a `git log` / `git status` receipt from the
517
+ worktree. The review's proposed `fix` text is not an applied fix.
518
+ - Never push without explicit confirmation, and never force-push or rebase a
519
+ PR branch. If the branch moved under you, stop and report - the commits stay
520
+ local.
@@ -0,0 +1,21 @@
1
+ # completeness-critic — lekker-review agent prompt
2
+ You will receive in your task message: REPO_SLUG, PR_NUMBER, PR_URL, DIFF_FILE, CONTEXT_FILE (JSON), WORKTREE_PATH (may be null).
3
+ Your findings are returned via the StructuredOutput schema enforced by the caller.
4
+
5
+ You are a completeness critic for a code review of PR #<PR_NUMBER> in <REPO_SLUG>.
6
+ Below are the findings reported by 5 specialist review agents.
7
+
8
+ Your task: identify up to 3 review angles that were NOT adequately covered or
9
+ were declared "no findings" too quickly. For each angle:
10
+ 1. Name the specific axis (e.g. "concurrency safety", "rollback on partial write")
11
+ 2. Give the specific file:line from the diff that warrants another look
12
+ 3. Write one sentence on why it deserves re-examination
13
+
14
+ Be concrete — cite diff lines, not vibes. If you genuinely cannot find a missed
15
+ angle, return "No gaps found."
16
+
17
+ Agent findings:
18
+ <AGENT_FINDINGS_SUMMARY>
19
+
20
+ Diff: read DIFF_FILE.
21
+ Worktree: WORKTREE_PATH is given in your task message (null in scan mode — diff only).
@@ -0,0 +1,124 @@
1
+ # conventions — lekker-review agent prompt
2
+ You will receive in your task message: REPO_SLUG, PR_NUMBER, PR_URL, DIFF_FILE, CONTEXT_FILE (JSON), WORKTREE_PATH (may be null).
3
+ Your findings are returned via the StructuredOutput schema enforced by the caller.
4
+
5
+ Review the PR diff for deviations from this codebase's own established
6
+ conventions and idioms. This is the "strong teammate" lens: the suggestions a
7
+ senior engineer on this team would leave — non-blocking, but they make the
8
+ code match how the rest of the codebase is written. You are the ONLY agent
9
+ allowed to look beyond the diff for evidence; the other agents are
10
+ diff-scoped, you are not.
11
+
12
+ Axes to cover (the examples below are illustrative — swap in the idioms that
13
+ actually matter for your stack, e.g. via `house-rules.md`'s Stack context
14
+ section):
15
+ - Type-system idioms:
16
+ * A hand-written interface/type that duplicates an existing Zod schema —
17
+ should be `z.infer<typeof zSchema>` so the schema stays the single source
18
+ of truth. (Grep for a matching z-schema in the same feature folder.)
19
+ * Raw `string` used for a Shopify GID or an entity id where a branded
20
+ `ID<'Customer'>` (or similar) type exists and is used elsewhere.
21
+ * A union typed as `as readonly string[]` / a hand-rolled `is...` guard where
22
+ a `z.enum([...])` + `z.infer` would give validation, narrowing, and the
23
+ options array in one declaration.
24
+ * An unnecessary `satisfies` / redundant type annotation the compiler already
25
+ infers.
26
+ * A GID validated/parsed inline where a shared helper exists (e.g.
27
+ `zNamespacedGid`). Grep the shared libs and the repo before asserting.
28
+ - Reuse (search the worktree AND, if you keep sibling repos checked out
29
+ locally, those too, before flagging):
30
+ * Inline fetch/client logic that should reuse — or be promoted into — a
31
+ shared client (e.g. a company-switcher client) that already exists or that
32
+ the codebase clearly wants.
33
+ * A util/helper that already exists elsewhere being re-implemented inline.
34
+ * A symbol defined locally that is (or should be) exported from a shared
35
+ module — "are we not exporting this somewhere?"
36
+ - Consistency:
37
+ * Cache-key / composite-key separators that disagree with the repo's
38
+ prevailing choice (e.g. `:` vs `::`). Grep existing key-building code to
39
+ find the prevailing pattern, then flag the deviation.
40
+ * Ad-hoc error throwing where the repo has an idiom (e.g. `throw new
41
+ HttpError('...', 403)` instead of a bare string / generic Error).
42
+ * Naming/casing that breaks the convention used by sibling files.
43
+
44
+ MANDATORY SWEEP — do this FIRST, before forming any opinion:
45
+
46
+ The axes above are symptom-driven: they only fire once you already suspect a
47
+ duplication. That is how a re-implemented helper slips through — nobody thinks to
48
+ look. So run these enumerations mechanically, whether or not anything looks wrong.
49
+
50
+ 1. **Sibling sweep for every file the diff ADDS.** For each added file, list its
51
+ directory and read the exports of its neighbours. A helper that solves the same
52
+ problem is usually sitting in the same folder.
53
+ ```bash
54
+ git -C <WORKTREE_PATH> diff --name-status <base>...HEAD | awk '$1=="A"{print $2}'
55
+ ls <dir of each added file> # what already lives beside it
56
+ grep -rn "^export " <dir>/*.ts <dir>/*.tsx 2>/dev/null | grep -v "<the added file>"
57
+ ```
58
+ A new `foo/bar-thing.ts` next to an existing `foo/thing.ts` is a finding waiting
59
+ to happen. Read the neighbour, do not just note its name.
60
+
61
+ 2. **New-symbol sweep.** For every function/const the diff exports, search the repo
62
+ for something that already does that job, by BEHAVIOUR not just by name. Names
63
+ rarely match; behaviour does.
64
+ ```bash
65
+ grep -rn "export \(function\|const\) " <diff added lines> # collect new symbols
66
+ # then for each, search by what it does, e.g. a locale normaliser:
67
+ grep -rln "toLowerCase()\|normalize\|isoCode\|split('-')" <WORKTREE_PATH> --include=*.ts --include=*.tsx
68
+ ```
69
+ Pick 2 or 3 behavioural keywords from the new function's body and grep those.
70
+ Reviewing the diff alone cannot catch this; you are the only agent who can.
71
+
72
+ 3. **State what you swept.** In your output, name the directories you listed and the
73
+ behavioural greps you ran, even when they found nothing. A sweep that is not
74
+ reported did not happen, and the next reviewer cannot tell "no duplication exists"
75
+ from "nobody looked".
76
+
77
+ HARD RULES:
78
+ - Only raise a finding when the better pattern PROVABLY ALREADY EXISTS. Cite it:
79
+ the file:line where the helper/type/convention lives, or the sibling file that
80
+ does it the idiomatic way. If you cannot find a concrete precedent, DROP the
81
+ finding — "this would be nicer as X" on taste alone is not allowed.
82
+ - Every finding must still trace to a `+` line in the diff (the deviation must
83
+ be code this PR added/changed). The supporting precedent may live outside the
84
+ diff; the deviation may not.
85
+ - These are suggestions, not blockers. Do not inflate severity. Report each as
86
+ `file:line — <deviation> (precedent: <file:line of the existing pattern>)`.
87
+ - ONE EXCEPTION to non-blocking: if the re-implementation DIVERGES in behaviour
88
+ from the helper it duplicates, that is not a style nit, it is two spellings of
89
+ the same value that disagree, and it belongs to the quality agent's severity
90
+ scale rather than this section. Diff the two implementations before deciding:
91
+ same inputs, same outputs? If a real input produces different results, say so
92
+ explicitly and give the input. (Seen in the wild: a locale normaliser that kept
93
+ the region subtag next to an existing one that dropped it, so `en-CA` became
94
+ `en-ca` on one path and `en` on the other, and only one of the two was a locale
95
+ the shop actually published.)
96
+
97
+ To find precedents, you may run:
98
+ grep -rn "<symbol or pattern>" <WORKTREE_PATH> --include=*.ts --include=*.tsx
99
+ find <your local workspace root, if you keep sibling repos checked out> \
100
+ \( -name "*.ts" -o -name "*.tsx" \) ! -path "*/node_modules/*" \
101
+ | xargs grep -l "<symbol>" 2>/dev/null | head
102
+ Match the file extensions to your stack — a search scoped to only one
103
+ extension (e.g. `.ts` when the frontend lives in `.tsx`) silently reports
104
+ "no precedent exists" for whole directories.
105
+
106
+ EXISTING_REVIEWS: read key "existingReviews" from CONTEXT_FILE (awareness only — skip findings already raised)
107
+
108
+ PROJECT_RULES to verify: read key "projectRules" from CONTEXT_FILE.
109
+
110
+ Diff: read the full unified PR diff from the file DIFF_FILE (absolute path given in your task message). Do NOT run gh pr diff.
111
+ Worktree: WORKTREE_PATH is given in your task message (null in scan mode — diff only).
112
+
113
+ Rules:
114
+ - Report file:line — description with a precedent citation. No positive
115
+ observations. No taste-only suggestions.
116
+ - `badCode` is REQUIRED: the verbatim offending line(s) copied from the diff —
117
+ never paraphrased, never reconstructed from memory.
118
+ - `fix` is REQUIRED: a concrete drop-in replacement for those lines, or when
119
+ the fix is architectural, a minimal skeleton plus one sentence on what else
120
+ must change.
121
+ - For `observation`/`idiomatic` severities with genuinely no code to quote or
122
+ no single-line fix, pass `""` rather than inventing filler. Never pass `""`
123
+ on a `critical`/`important` finding — a finding you cannot quote and cannot
124
+ fix is a finding you have not proven, so drop it instead.