reviewer-skill 0.0.0-stage → 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 itinance
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,127 @@
1
- # Temporary Holding Version
1
+ # reviewer-skill
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A pull-request review process for [Claude Code](https://claude.com/claude-code): every PR
4
+ round gets **3 separate review agents**, each with one focus.
5
+
6
+ | Agent | Focus |
7
+ |---|---|
8
+ | `review-correctness` | Does the change do what the PR says; edge cases; every caller of a changed contract; error paths; spec grounding |
9
+ | `review-security` | Access control, input validation, secrets in logs, sensitive data, the project's hard rules, supply chain |
10
+ | `review-tests` | Red-first tests that pin real behaviour, the right test layer, the full CI job set on the head, spec/docs match the code |
11
+
12
+ The rules:
13
+
14
+ - All 3 reviewers run on every round, also for small diffs, docs, specs and dependency bumps.
15
+ - A re-round after a fix push goes to the **same named agents** (`SendMessage` with the new
16
+ head sha). They check their own earlier findings and report only blocking problems. This
17
+ stops endless nit loops.
18
+ - Reviewers only read. They write the full report to `.scratch/reviews/<pr>-<area>[-rN].md`
19
+ and reply with the verdict only (CLEAN / FINDINGS, a count, the blocking titles).
20
+ - Findings are fixed **in the same PR**, also the non-blocking ones. Design questions go to
21
+ the human.
22
+
23
+ ## What gets installed
24
+
25
+ ```
26
+ .claude/agents/review-correctness.md
27
+ .claude/agents/review-security.md
28
+ .claude/agents/review-tests.md
29
+ .claude/skills/review-round/SKILL.md the orchestration: start, wait, fix, re-round, merge
30
+ docs/REVIEW_AND_MERGE.md rules + a "Project gates" section with TODO(project) placeholders
31
+ CLAUDE.md optional "Review and merge" section (asked)
32
+ .gitignore optional ".scratch/" entry (asked)
33
+ ```
34
+
35
+ The installer **never changes an existing file without asking**. For a file that exists with
36
+ different content it asks: skip (default), overwrite, or write a `.reviewer-skill.new` file
37
+ next to it. Without a terminal (for example when an agent runs it), it only creates missing
38
+ files and leaves every existing file alone. `--dry-run` shows what would happen.
39
+
40
+ ## Install
41
+
42
+ The package has **no dependencies and no install scripts**. Install it with an exact version.
43
+ Never use `@latest`, a bare package name, or `-y` / `--yes`.
44
+
45
+ ### 1. Check the release age first
46
+
47
+ Use a version that is at least **7 days** old (release cooldown). A fresh release is the
48
+ window in which a hijacked account or a bad publish does the most damage.
49
+
50
+ ```sh
51
+ npm view reviewer-skill time --json # publish date of every version
52
+ npm view reviewer-skill@0.1.0 dist.integrity
53
+ ```
54
+
55
+ ### 2. Run the installer in your project root
56
+
57
+ `--before <date>` lets npm enforce the cooldown: if the pinned version was published after
58
+ that date, npx stops with `notarget` before it downloads or runs anything.
59
+
60
+ ```sh
61
+ # macOS
62
+ npx --ignore-scripts --before "$(date -v-7d +%Y-%m-%d)" reviewer-skill@0.1.0 install --dry-run
63
+ npx --ignore-scripts --before "$(date -v-7d +%Y-%m-%d)" reviewer-skill@0.1.0 install
64
+
65
+ # Linux
66
+ npx --ignore-scripts --before "$(date -d '7 days ago' +%Y-%m-%d)" reviewer-skill@0.1.0 install
67
+ ```
68
+
69
+ `npx` asks "Ok to proceed?" before it downloads the package. Read it and answer it; do not
70
+ suppress it.
71
+
72
+ With Bun (Bun does not run lifecycle scripts of packages by default):
73
+
74
+ ```sh
75
+ bunx reviewer-skill@0.1.0 install
76
+ ```
77
+
78
+ Without the npm registry, from a git tag:
79
+
80
+ ```sh
81
+ git clone --depth 1 --branch v0.1.0 https://github.com/itinance/reviewer-skill.git /tmp/reviewer-skill
82
+ git -C /tmp/reviewer-skill rev-parse HEAD # compare with the commit of the v0.1.0 tag on GitHub
83
+ node /tmp/reviewer-skill/bin/reviewer-skill.js install --target .
84
+ ```
85
+
86
+ Do not install it globally. If you must: `npm install -g --ignore-scripts reviewer-skill@0.1.0`.
87
+
88
+ ### 3. After the install
89
+
90
+ 1. Fill in the project gates: `grep -n "TODO(project)" docs/REVIEW_AND_MERGE.md`
91
+ (test command, worktree install command, hard rules, sensitive-data check, release cooldown,
92
+ optional review bot and merge checks).
93
+ 2. Check that `.scratch/` is git-ignored: `git check-ignore -q .scratch/reviews/x.md && echo ok`.
94
+ 3. Restart Claude Code (or open `/agents`) so that it loads the new agents.
95
+ 4. Commit the files.
96
+
97
+ ## Use
98
+
99
+ Ask Claude Code: *"Run a review round on PR 123."* The `review-round` skill starts the 3
100
+ agents in parallel as `review-123-correctness`, `review-123-security`, `review-123-tests`,
101
+ waits for their verdicts, reads the reports, fixes the findings in the same PR, and sends the
102
+ new head sha to the same 3 agents until all are clean.
103
+
104
+ ## Commands
105
+
106
+ ```
107
+ reviewer-skill [install] [--target <dir>] [--dry-run]
108
+ reviewer-skill print-snippet print the CLAUDE.md section
109
+ reviewer-skill --help | --version
110
+ ```
111
+
112
+ ## Update
113
+
114
+ Run the installer again with the new exact version (after its cooldown). Files that you did not
115
+ change are reported as `unchanged` or are offered for overwrite; for files that you changed,
116
+ choose `n` and compare the `.reviewer-skill.new` file with your version.
117
+
118
+ ## Development
119
+
120
+ ```sh
121
+ npm test # node --test, no dependencies
122
+ npm pack --dry-run # check the package contents
123
+ ```
124
+
125
+ ## License
126
+
127
+ MIT
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+ import { readFileSync } from 'node:fs';
3
+ import { createInterface } from 'node:readline/promises';
4
+ import { install, snippetBlock } from '../lib/install.js';
5
+
6
+ const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
7
+
8
+ const HELP = `reviewer-skill ${pkg.version}
9
+
10
+ Installs the 3-reviewer PR process for Claude Code into a project:
11
+ .claude/agents/review-{correctness,security,tests}.md
12
+ .claude/skills/review-round/SKILL.md
13
+ docs/REVIEW_AND_MERGE.md (template, fill in the TODO(project) gates)
14
+ CLAUDE.md section, .gitignore entry (optional, asked)
15
+
16
+ Usage:
17
+ reviewer-skill [install] [--target <dir>] [--dry-run]
18
+ reviewer-skill print-snippet print the CLAUDE.md section
19
+ reviewer-skill --help | --version
20
+
21
+ Existing files are never changed without asking. Without a terminal (for example
22
+ when an agent runs it), missing files are created and existing files are left alone.
23
+ `;
24
+
25
+ function parseArgs(argv) {
26
+ const opts = { command: 'install', target: process.cwd(), dryRun: false };
27
+ const args = [...argv];
28
+ while (args.length) {
29
+ const a = args.shift();
30
+ if (a === 'install' || a === 'print-snippet') opts.command = a;
31
+ else if (a === '--target') {
32
+ const v = args.shift();
33
+ if (!v) throw new Error('--target needs a directory');
34
+ opts.target = v;
35
+ } else if (a === '--dry-run') opts.dryRun = true;
36
+ else if (a === '--help' || a === '-h') opts.command = 'help';
37
+ else if (a === '--version' || a === '-v') opts.command = 'version';
38
+ else throw new Error(`unknown argument: ${a}`);
39
+ }
40
+ return opts;
41
+ }
42
+
43
+ function makeAsk() {
44
+ if (!process.stdin.isTTY || !process.stdout.isTTY) return { ask: null, close() {} };
45
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
46
+ return {
47
+ async ask(question, choices, fallback) {
48
+ for (;;) {
49
+ const a = (await rl.question(`${question} `)).trim().toLowerCase();
50
+ if (a === '') return fallback;
51
+ if (choices.includes(a[0])) return a[0];
52
+ }
53
+ },
54
+ close: () => rl.close(),
55
+ };
56
+ }
57
+
58
+ async function main() {
59
+ const opts = parseArgs(process.argv.slice(2));
60
+ if (opts.command === 'help') return void process.stdout.write(HELP);
61
+ if (opts.command === 'version') return void process.stdout.write(`${pkg.version}\n`);
62
+ if (opts.command === 'print-snippet') return void process.stdout.write(await snippetBlock());
63
+
64
+ const prompt = opts.dryRun ? { ask: null, close() {} } : makeAsk();
65
+ let results;
66
+ try {
67
+ results = await install({ target: opts.target, ask: prompt.ask, dryRun: opts.dryRun });
68
+ } finally {
69
+ prompt.close();
70
+ }
71
+
72
+ if (!prompt.ask && !opts.dryRun) {
73
+ process.stdout.write('No terminal: existing files are left alone, optional steps are skipped.\n');
74
+ }
75
+ for (const r of results) {
76
+ process.stdout.write(` ${r.action.padEnd(12)} ${r.path}${r.note ? ` (${r.note})` : ''}\n`);
77
+ }
78
+ process.stdout.write(`
79
+ Next:
80
+ 1. Fill in the project gates: grep -n "TODO(project)" docs/REVIEW_AND_MERGE.md
81
+ 2. Restart Claude Code (or open /agents) so that it loads the new agents.
82
+ 3. Review a PR: ask Claude to "run a review round on PR <number>".
83
+ `);
84
+ }
85
+
86
+ main().catch((err) => {
87
+ process.stderr.write(`reviewer-skill: ${err.message}\n`);
88
+ process.exit(1);
89
+ });
package/lib/install.js ADDED
@@ -0,0 +1,190 @@
1
+ import { promises as fs } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ export const TEMPLATE_DIR = path.join(
6
+ path.dirname(fileURLToPath(import.meta.url)),
7
+ '..',
8
+ 'templates',
9
+ );
10
+
11
+ // Template file -> path in the target project.
12
+ export const FILES = [
13
+ { src: 'agents/review-correctness.md', dest: '.claude/agents/review-correctness.md' },
14
+ { src: 'agents/review-security.md', dest: '.claude/agents/review-security.md' },
15
+ { src: 'agents/review-tests.md', dest: '.claude/agents/review-tests.md' },
16
+ { src: 'skills/review-round/SKILL.md', dest: '.claude/skills/review-round/SKILL.md' },
17
+ { src: 'docs/REVIEW_AND_MERGE.md', dest: 'docs/REVIEW_AND_MERGE.md' },
18
+ ];
19
+
20
+ export const SNIPPET_SRC = 'CLAUDE.snippet.md';
21
+ export const SNIPPET_START = '<!-- reviewer-skill:start -->';
22
+ export const SNIPPET_END = '<!-- reviewer-skill:end -->';
23
+ export const GITIGNORE_ENTRY = '.scratch/';
24
+ export const NEW_SUFFIX = '.reviewer-skill.new';
25
+
26
+ async function lstatOrNull(p) {
27
+ try {
28
+ return await fs.lstat(p);
29
+ } catch (err) {
30
+ if (err.code === 'ENOENT') return null;
31
+ throw err;
32
+ }
33
+ }
34
+
35
+ function insideTarget(target, p) {
36
+ const rel = path.relative(target, p);
37
+ return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
38
+ }
39
+
40
+ export async function readTemplate(src) {
41
+ return fs.readFile(path.join(TEMPLATE_DIR, src), 'utf8');
42
+ }
43
+
44
+ export async function snippetBlock() {
45
+ const body = (await readTemplate(SNIPPET_SRC)).trimEnd();
46
+ return `${SNIPPET_START}\n${body}\n${SNIPPET_END}\n`;
47
+ }
48
+
49
+ // True when a .gitignore line already ignores the .scratch directory.
50
+ export function ignoresScratch(gitignoreText) {
51
+ return gitignoreText
52
+ .split(/\r?\n/)
53
+ .map((l) => l.trim())
54
+ .some((l) => ['.scratch', '.scratch/', '/.scratch', '/.scratch/', '.scratch/*', '/.scratch/*'].includes(l));
55
+ }
56
+
57
+ /**
58
+ * Install the review files into `target`.
59
+ *
60
+ * `ask(question, choices, fallback)` returns one of `choices`. When `ask` is null the
61
+ * run is non-interactive: it creates missing files and never changes an existing file.
62
+ * `dryRun` writes nothing and asks nothing.
63
+ *
64
+ * Returns a list of { path, action, note? } in install order.
65
+ */
66
+ export async function install({ target, ask = null, dryRun = false }) {
67
+ const root = path.resolve(target);
68
+ const rootStat = await lstatOrNull(root);
69
+ if (!rootStat || !rootStat.isDirectory()) {
70
+ throw new Error(`target is not a directory: ${root}`);
71
+ }
72
+
73
+ const results = [];
74
+ const record = (dest, action, note) => results.push({ path: dest, action, ...(note ? { note } : {}) });
75
+
76
+ for (const file of FILES) {
77
+ const dest = path.join(root, file.dest);
78
+ if (!insideTarget(root, dest)) throw new Error(`refusing path outside target: ${file.dest}`);
79
+ const content = await readTemplate(file.src);
80
+ const st = await lstatOrNull(dest);
81
+
82
+ if (!st) {
83
+ if (!dryRun) {
84
+ await fs.mkdir(path.dirname(dest), { recursive: true });
85
+ await fs.writeFile(dest, content, { flag: 'wx' });
86
+ }
87
+ record(file.dest, dryRun ? 'would-create' : 'created');
88
+ continue;
89
+ }
90
+
91
+ if (!st.isFile()) {
92
+ record(file.dest, 'skipped', 'exists and is not a regular file (symlink or directory); not touched');
93
+ continue;
94
+ }
95
+
96
+ const existing = await fs.readFile(dest, 'utf8');
97
+ if (existing === content) {
98
+ record(file.dest, 'unchanged');
99
+ continue;
100
+ }
101
+
102
+ if (dryRun) {
103
+ record(file.dest, 'would-ask', 'exists with different content');
104
+ continue;
105
+ }
106
+ if (!ask) {
107
+ record(file.dest, 'skipped', 'exists with different content; run in a terminal to choose');
108
+ continue;
109
+ }
110
+
111
+ const choice = await ask(
112
+ `${file.dest} exists and differs. [s]kip, [o]verwrite, write [n]ew file next to it?`,
113
+ ['s', 'o', 'n'],
114
+ 's',
115
+ );
116
+ if (choice === 'o') {
117
+ await fs.writeFile(dest, content);
118
+ record(file.dest, 'overwritten');
119
+ } else if (choice === 'n') {
120
+ const side = dest + NEW_SUFFIX;
121
+ try {
122
+ await fs.writeFile(side, content, { flag: 'wx' });
123
+ record(file.dest, 'new-file', `wrote ${file.dest}${NEW_SUFFIX}`);
124
+ } catch (err) {
125
+ if (err.code !== 'EEXIST') throw err;
126
+ record(file.dest, 'skipped', `${file.dest}${NEW_SUFFIX} already exists; not touched`);
127
+ }
128
+ } else {
129
+ record(file.dest, 'skipped', 'kept your version');
130
+ }
131
+ }
132
+
133
+ results.push(await installSnippet(root, { ask, dryRun }));
134
+ results.push(await installGitignore(root, { ask, dryRun }));
135
+ return results;
136
+ }
137
+
138
+ async function installSnippet(root, { ask, dryRun }) {
139
+ const rel = 'CLAUDE.md';
140
+ const dest = path.join(root, rel);
141
+ const st = await lstatOrNull(dest);
142
+ if (st && !st.isFile()) return { path: rel, action: 'skipped', note: 'not a regular file; not touched' };
143
+
144
+ const existing = st ? await fs.readFile(dest, 'utf8') : null;
145
+ if (existing !== null && existing.includes(SNIPPET_START)) return { path: rel, action: 'unchanged' };
146
+
147
+ const verb = existing === null ? 'Create CLAUDE.md with' : 'Append to CLAUDE.md';
148
+ if (dryRun) return { path: rel, action: 'would-ask', note: `optional: ${verb.toLowerCase()} the review section` };
149
+ if (!ask) {
150
+ return { path: rel, action: 'skipped', note: 'optional; print it with `reviewer-skill print-snippet`' };
151
+ }
152
+
153
+ const choice = await ask(`${verb} the "Review and merge" section? [y/N]`, ['y', 'n'], 'n');
154
+ if (choice !== 'y') return { path: rel, action: 'skipped', note: 'declined' };
155
+
156
+ const block = await snippetBlock();
157
+ if (existing === null) {
158
+ await fs.writeFile(dest, block, { flag: 'wx' });
159
+ return { path: rel, action: 'created' };
160
+ }
161
+ const sep = existing.endsWith('\n\n') ? '' : existing.endsWith('\n') ? '\n' : '\n\n';
162
+ await fs.appendFile(dest, sep + block);
163
+ return { path: rel, action: 'appended' };
164
+ }
165
+
166
+ async function installGitignore(root, { ask, dryRun }) {
167
+ const rel = '.gitignore';
168
+ const dest = path.join(root, rel);
169
+ const st = await lstatOrNull(dest);
170
+ if (st && !st.isFile()) return { path: rel, action: 'skipped', note: 'not a regular file; not touched' };
171
+
172
+ const existing = st ? await fs.readFile(dest, 'utf8') : null;
173
+ if (existing !== null && ignoresScratch(existing)) return { path: rel, action: 'unchanged' };
174
+
175
+ const note = `reports in .scratch/reviews/ must be git-ignored: add "${GITIGNORE_ENTRY}"`;
176
+ if (dryRun) return { path: rel, action: 'would-ask', note };
177
+ if (!ask) return { path: rel, action: 'skipped', note };
178
+
179
+ const verb = existing === null ? 'Create .gitignore with' : 'Add';
180
+ const choice = await ask(`${verb} "${GITIGNORE_ENTRY}" (review reports)? [y/N]`, ['y', 'n'], 'n');
181
+ if (choice !== 'y') return { path: rel, action: 'skipped', note };
182
+
183
+ const line = `${GITIGNORE_ENTRY}\n`;
184
+ if (existing === null) {
185
+ await fs.writeFile(dest, line, { flag: 'wx' });
186
+ return { path: rel, action: 'created' };
187
+ }
188
+ await fs.appendFile(dest, (existing === '' || existing.endsWith('\n') ? '' : '\n') + line);
189
+ return { path: rel, action: 'appended' };
190
+ }
package/package.json CHANGED
@@ -1,6 +1,29 @@
1
1
  {
2
2
  "name": "reviewer-skill",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Installs a 3-reviewer pull-request process (correctness, security, tests) for Claude Code into a project: agents, a review-round skill and a docs template.",
5
+ "keywords": ["claude-code", "claude", "code-review", "agents", "skill", "pull-request"],
6
+ "license": "MIT",
7
+ "author": "itinance",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/itinance/reviewer-skill.git"
11
+ },
12
+ "type": "module",
13
+ "bin": {
14
+ "reviewer-skill": "bin/reviewer-skill.js"
15
+ },
16
+ "files": [
17
+ "bin/",
18
+ "lib/",
19
+ "templates/",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "engines": {
24
+ "node": ">=18.17"
25
+ },
26
+ "scripts": {
27
+ "test": "node --test"
28
+ }
29
+ }
@@ -0,0 +1,3 @@
1
+ ## Review and merge
2
+
3
+ Every PR round gets 3 separate review agents: `review-correctness`, `review-security`, `review-tests` (`.claude/agents/`). This also applies to small diffs, docs, specs and dependency bumps. Run a round with the `review-round` skill. A re-round after a fix push goes to the same 3 named agents (`SendMessage`), not to new ones. Fix review findings in the same PR, never in a new PR. Merge only when all 3 are clean on the current head, with `gh pr merge --merge --match-head-commit <sha>` (never squash). The full rules and the project gates are in `docs/REVIEW_AND_MERGE.md`.
@@ -0,0 +1,53 @@
1
+ ---
2
+ name: review-correctness
3
+ description: CORRECTNESS reviewer for one PR (code or spec), one of 3 separate reviewers (correctness, security, tests) that every PR review round gets. Give it the PR number, the head sha and what the PR claims to do. Project rules come from CLAUDE.md and docs/REVIEW_AND_MERGE.md if present.
4
+ tools: Bash, Read, Grep, Glob, Write
5
+ ---
6
+
7
+ You are the CORRECTNESS reviewer for one pull request. Two other reviewers cover
8
+ security/guardrails and tests/spec quality; stay in your lane, but report a blocking problem
9
+ from another lane if you see one.
10
+
11
+ First read the project's CLAUDE.md and, if it exists, docs/REVIEW_AND_MERGE.md. Their rules
12
+ win over this file.
13
+
14
+ ## Rules (no exceptions)
15
+
16
+ - Read only. Use `gh pr view|diff|checks`, `git fetch`, `git show <sha>:<path>`,
17
+ `git diff origin/<base>...<sha>`, and the code on the base branch.
18
+ - Never `git checkout` or `git switch` in an existing checkout or worktree — another session
19
+ may work in it.
20
+ - Never run code from a fork PR: if `gh pr view <pr> --json isCrossRepository` is `true`, only
21
+ read. For a PR from the same repository, if you must run code, create a throwaway worktree
22
+ under `.claude/worktrees/rev-<pr>-correctness` (`git worktree add --detach <path> <sha>`) with
23
+ its own dependency install from the lockfile, and remove it at the end.
24
+ - Never edit a tracked file, commit, push, comment on GitHub, merge, trigger a review bot, or
25
+ call a paid API.
26
+ - Never print sensitive data (customer data, secrets, personal data). Report counts, statuses,
27
+ codes and file:line only.
28
+ - "Read only" is enforced by these rules; `Write` is only for your report file.
29
+
30
+ ## What to check
31
+
32
+ Code PR:
33
+ - The change does what the PR says, for every input: empty, malformed, huge, wrong type,
34
+ concurrent, repeated, the last page, the first run, a re-run, a partial failure.
35
+ - Every caller and consumer of a changed function, model or API shape still works, including
36
+ generated clients, types and test fixtures.
37
+ - Error paths fail loudly and are recorded; nothing is lost silently.
38
+ - Database migrations: one head, idempotent, downgrade stated, access rules still hold.
39
+
40
+ Spec PR:
41
+ - Every file:line grounding claim exists on the base branch and says what the spec says.
42
+ - Every target state can be built as written; API, migration and UI consequences are complete.
43
+ - No contradiction with other specs; recorded human decisions are applied, not re-argued.
44
+
45
+ ## Report
46
+
47
+ Write the full report to `.scratch/reviews/<pr>-correctness[-rN].md` (N = round, from 2 on).
48
+ Each finding: severity, file:line (or spec section + code file:line), a concrete failure
49
+ scenario, a fix direction, blocking yes/no. Then reply with ONLY: the verdict (CLEAN or
50
+ FINDINGS), the number of findings, and a one-line title for each blocking finding.
51
+
52
+ In a later round you get a new head sha by message: check that each earlier finding is fixed,
53
+ check only the changed text for new problems, and report only blocking ones.
@@ -0,0 +1,53 @@
1
+ ---
2
+ name: review-security
3
+ description: SECURITY / GUARDRAILS / SUPPLY-CHAIN reviewer for one PR (code, spec or dependency bump), one of 3 separate reviewers (correctness, security, tests) that every PR review round gets. Give it the PR number, the head sha and what the PR claims to do. Project rules come from CLAUDE.md and docs/REVIEW_AND_MERGE.md if present.
4
+ tools: Bash, Read, Grep, Glob, Write
5
+ ---
6
+
7
+ You are the SECURITY / GUARDRAILS reviewer for one pull request. Two other reviewers cover
8
+ correctness and tests/spec quality; stay in your lane, but report a blocking problem from
9
+ another lane if you see one.
10
+
11
+ First read the project's CLAUDE.md and, if it exists, docs/REVIEW_AND_MERGE.md. Their hard
12
+ rules and guardrails are part of your checklist and win over this file.
13
+
14
+ ## Rules (no exceptions)
15
+
16
+ - Read only: `gh pr view|diff|checks`, `git fetch`, `git show <sha>:<path>`, the code on the
17
+ base branch, and registry metadata as JSON (pypi.org, registry.npmjs.org). Never install,
18
+ download-and-run, or execute fetched code.
19
+ - Never `git checkout` or `git switch` in an existing checkout or worktree. Never edit a
20
+ tracked file, commit, push, comment on GitHub, merge, or trigger a review bot.
21
+ - Never print sensitive data, secrets, or the entries of any denylist or secret list.
22
+ - "Read only" is enforced by these rules; `Write` is only for your report file.
23
+
24
+ ## What to check
25
+
26
+ 1. Sensitive data: none in the diff, fixtures, specs, commit messages
27
+ (`git log --format=%B origin/<base>..<sha>`) or the PR body. If the project has a
28
+ denylist check (see its docs), run it on those texts and report only "hits: N" and the file.
29
+ 2. The project's hard guardrails (CLAUDE.md): untouched and not weakened; their guard tests
30
+ unchanged.
31
+ 3. Access control: every new or changed endpoint or action checks who may call it (role,
32
+ owner, tenant); ids from the request are looked up with the same scoping as the rest of the
33
+ route; an unknown and a foreign id give the same answer; database access rules hold.
34
+ 4. Secrets and credentials never reach logs, URLs, error messages, audit details or
35
+ responses; user input is validated; parsers are safe and bounded (size, depth, regex cost).
36
+ 5. Anything that reaches an LLM prompt, a report or a log goes through the project's
37
+ sanitizer, if it has one.
38
+ 6. Supply chain: exact pins where the project requires them, a release cooldown for every
39
+ changed lock entry (direct AND transitive — list each with its publish date), no new or
40
+ look-alike package names, no install scripts, normal registry URLs and integrity hashes;
41
+ no `curl | sh`, no floating tags in commands or CI.
42
+ 7. Error logging: clean messages for expected errors, no secrets or sensitive data in them.
43
+
44
+ ## Report
45
+
46
+ Write the full report to `.scratch/reviews/<pr>-security[-rN].md`. Each finding: severity,
47
+ file:line, a concrete scenario, a fix direction, blocking yes/no. Then reply with ONLY: the
48
+ verdict (CLEAN or FINDINGS), the number of findings, and a one-line title for each blocking
49
+ finding.
50
+
51
+ In a later round you get a new head sha by message: check that each earlier finding is fixed,
52
+ check only the changed text, run the sensitive-data check again on the new diff, commits and
53
+ body, and report only blocking problems.
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: review-tests
3
+ description: TESTS / CI / SPEC-QUALITY reviewer for one PR (code, spec or dependency bump), one of 3 separate reviewers (correctness, security, tests) that every PR review round gets. Give it the PR number, the head sha and what the PR claims to do. Project rules come from CLAUDE.md and docs/REVIEW_AND_MERGE.md if present.
4
+ tools: Bash, Read, Grep, Glob, Write
5
+ ---
6
+
7
+ You are the TESTS / SPEC reviewer for one pull request. Two other reviewers cover correctness
8
+ and security; stay in your lane, but report a blocking problem from another lane if you see one.
9
+
10
+ First read the project's CLAUDE.md and, if it exists, docs/REVIEW_AND_MERGE.md. Their test
11
+ and spec conventions win over this file.
12
+
13
+ ## Rules (no exceptions)
14
+
15
+ - Read only: `gh pr view|diff|checks`, `gh run list|view`, `git fetch`, `git show <sha>:<path>`.
16
+ - Never `git checkout` or `git switch` in an existing checkout or worktree.
17
+ - Never run code from a fork PR: if `gh pr view <pr> --json isCrossRepository` is `true`, only
18
+ read. For a PR from the same repository, if you must run a test, use a throwaway worktree
19
+ under `.claude/worktrees/rev-<pr>-tests` with its own dependency install, and remove it at
20
+ the end.
21
+ - Never edit a tracked file, commit, push, comment on GitHub, merge, or trigger a review bot.
22
+ - Never print sensitive data.
23
+ - "Read only" is enforced by these rules; `Write` is only for your report file.
24
+
25
+ ## What to check
26
+
27
+ Code PR:
28
+ - Red first: the new tests fail on the old code and pin the real behaviour, not mocks the test
29
+ set up itself. Edge cases: empty, invalid, boundary, the last page, concurrency, roles.
30
+ - The right test layer (unit, integration against a real database where access rules matter,
31
+ end-to-end) as the project defines it. Fixtures are synthetic.
32
+ - CI on the CURRENT head: every workflow run concluded success or skipped, and the job set is
33
+ complete. Compare the job count with the latest run on the base branch; GitHub has created
34
+ partial job sets before, and right after a push only skipped checks may exist — wait for the
35
+ run. Note whether the head is behind the base branch.
36
+
37
+ Spec PR and the spec part of a code PR:
38
+ - The spec describes the current intended state and matches the code; a decisions table holds
39
+ every human decision with its source and date; no open question blocks the build.
40
+ - Each item has a test plan that would catch its bug; acceptance criteria are testable (no
41
+ "about", "nice", "clear").
42
+ - The project's doc conventions are kept.
43
+
44
+ ## Report
45
+
46
+ Write the full report to `.scratch/reviews/<pr>-tests[-rN].md`, with run ids and job counts.
47
+ Then reply with ONLY: the verdict (CLEAN or FINDINGS), the number of findings, and a one-line
48
+ title for each blocking finding.
49
+
50
+ In a later round you get a new head sha by message: check that each earlier finding is fixed,
51
+ check only the changed text, check CI again on the new head, and report only blocking problems.
@@ -0,0 +1,100 @@
1
+ # Review and merge
2
+
3
+ These rules apply to every pull request, also to small diffs, docs, specs and dependency
4
+ bumps. They add to `CLAUDE.md` and do not repeat it.
5
+
6
+ Installed by `reviewer-skill`. Fill in every `TODO(project)` in section 4. Find them with
7
+ `grep -n "TODO(project)" docs/REVIEW_AND_MERGE.md`. A gate that still says `TODO(project)`
8
+ does not exist yet: reviewers report it as a note, they do not invent one.
9
+
10
+ ## 1. Three separate reviewers per round
11
+
12
+ - Every review round starts 3 separate review agents on the PR head:
13
+ - `review-correctness` (`.claude/agents/review-correctness.md`)
14
+ - `review-security` (`.claude/agents/review-security.md`)
15
+ - `review-tests` (`.claude/agents/review-tests.md`)
16
+ - The `review-round` skill (`.claude/skills/review-round/SKILL.md`) runs a round.
17
+ - Each agent gets a name with the PR number and its area, for example `review-123-security`.
18
+ All 3 start in one message, in the background, so that they run in parallel.
19
+ - The reviewers only read. They never check out a branch in a checkout that another session
20
+ uses. They never edit, never comment on GitHub, never merge.
21
+ - "Read only" is a rule in the agent prompt, not a tool limit. The agents need `Write` for
22
+ the report file, and `Bash` can write anywhere.
23
+ - The reviewers may run PR code only in a throwaway worktree under `.claude/worktrees/`, and
24
+ only when the PR head is in this repository. For a PR from a fork
25
+ (`gh pr view <pr> --json isCrossRepository` is `true`), they only read.
26
+ - Each reviewer writes its full report to `.scratch/reviews/<pr>-<area>[-rN].md`
27
+ (git-ignored) and replies with only: the verdict (CLEAN or FINDINGS), the number of
28
+ findings, and a one-line title for each blocking finding.
29
+ - Each finding has: file:line, a concrete failure scenario, a fix direction, blocking yes/no.
30
+ - After a fix push, the new head sha goes to the SAME three agents (`SendMessage`). Each one
31
+ checks its own earlier findings, checks only the changed text, and reports only blocking
32
+ problems. Repeat until all three are clean on the current head.
33
+ - The orchestrator (the main session) only relays while reviewers run. It does not edit code
34
+ until all three have replied.
35
+
36
+ ## 2. Findings are fixed in the same PR
37
+
38
+ - Fix every review finding in the PR that it was found in, also the non-blocking ones. Never
39
+ open a new PR for a review finding, also not for the same class of problem in another file.
40
+ - Push the fixes for one round as one push.
41
+ - A finding that needs a design decision goes to the human. The agent does not decide it.
42
+ - A real bug found outside the scope of the PR gets its own small PR from the base branch.
43
+
44
+ ## 3. Merge
45
+
46
+ - Merge only when all 3 reviewers are CLEAN on the current head, and every gate in
47
+ section 4 is green.
48
+ - Never start a merge in the same command as a safety check. Run the check on its own and
49
+ read its result first.
50
+ - Merge with `gh pr merge <pr> --merge --match-head-commit <sha>`. Never squash. Never
51
+ rebase a PR branch.
52
+ - Never merge the base branch into a work branch. When the head is behind, the merge step
53
+ runs `gh pr update-branch <pr>`, and the reviewers check CI again on the new head.
54
+ - After the merge: CI on the base branch is green.
55
+
56
+ ## 4. Project gates
57
+
58
+ <!-- Fill in each TODO(project). Delete a line that does not apply, and write "none". -->
59
+
60
+ ### 4.1 Commands
61
+
62
+ - Test command: TODO(project), for example `npm test` or `uv run pytest`.
63
+ - Lint and type check: TODO(project).
64
+ - Dependency install in a throwaway review worktree, from the lockfile, with install
65
+ scripts off: TODO(project), for example `npm ci --ignore-scripts`.
66
+ - CI workflow to compare job counts against: TODO(project), for example `ci.yml`.
67
+
68
+ ### 4.2 Hard rules
69
+
70
+ - Rules that a PR must never weaken, with their guard tests: TODO(project), for example
71
+ "the app never sends email to end users (`tests/test_no_outbound_email.py`)".
72
+
73
+ ### 4.3 Sensitive data
74
+
75
+ - What counts as sensitive in this project: TODO(project), for example customer data,
76
+ personal data, production ids.
77
+ - Sensitive-data check on the diff, the commit messages and the PR body: TODO(project) or
78
+ "none". The check must print counts only, never the matched text.
79
+
80
+ ### 4.4 Supply chain
81
+
82
+ - Exact version pins: TODO(project), for example "all direct dependencies".
83
+ - Release cooldown per ecosystem (at least 7 days): TODO(project), for example "npm 7 days,
84
+ PyPI 7 days".
85
+ - Install scripts: off (`ignore-scripts=true`) unless a package is listed here:
86
+ TODO(project).
87
+
88
+ ### 4.5 Extra merge gates
89
+
90
+ - AI review bot (optional): TODO(project) or "none". If used: keep it paused until the 3
91
+ reviewers are clean, then trigger it once. A pause posted right after `gh pr create` does
92
+ not stop the first review: open the PR as a draft, pause the bot, wait for its
93
+ confirmation, then mark the PR ready.
94
+ - Checks before a merge (for example "no live deploy running"): TODO(project) or "none".
95
+ - Paths or PR types that need a human approval: TODO(project) or "none".
96
+
97
+ ## 5. Decisions
98
+
99
+ - Every human decision on a PR goes into the decisions table of its spec, with the source and
100
+ the date, in the same turn.
@@ -0,0 +1,126 @@
1
+ ---
2
+ name: review-round
3
+ description: Use when a pull request needs a review, when a fix was pushed to a PR that is under review, when a reviewer reported findings, or before merging a PR. Covers code, spec, docs and dependency-bump PRs of any size.
4
+ ---
5
+
6
+ # Review round
7
+
8
+ Every PR round gets 3 separate review agents: `review-correctness`, `review-security`,
9
+ `review-tests` (`.claude/agents/`). The project rules are in `docs/REVIEW_AND_MERGE.md`;
10
+ read it first. Its section 4 holds the project gates.
11
+
12
+ You are the orchestrator. You start the reviewers, relay, fix, and re-round. You do not
13
+ review the PR yourself, and you do not edit code while reviewers run.
14
+
15
+ ## Before round 1
16
+
17
+ 1. Get the PR number, the head sha and the base branch:
18
+ `gh pr view <pr> --json number,headRefOid,baseRefName,isCrossRepository,title,body`.
19
+ 2. Check that the reports stay out of git: `git check-ignore -q .scratch/reviews/x.md`.
20
+ If this fails, stop and ask the human to add `.scratch/` to `.gitignore`.
21
+ 3. Write one line that says what the PR claims to do (from its title and body).
22
+
23
+ ## Round 1: start all 3 in one message
24
+
25
+ Send ONE message with 3 `Agent` calls, so that they run in parallel. Run each in the
26
+ background (`run_in_background: true` where the tool has it). The `name` makes the agent
27
+ addressable for later rounds.
28
+
29
+ ```
30
+ Agent(
31
+ name: "review-<pr>-correctness",
32
+ subagent_type: "review-correctness",
33
+ description: "Review PR <pr> correctness",
34
+ prompt: "PR <pr>, head <sha>, base <base>. Claims: <one line>. Round 1.
35
+ Report to .scratch/reviews/<pr>-correctness.md."
36
+ )
37
+ ```
38
+
39
+ Do the same for `review-<pr>-security` / `review-security` and `review-<pr>-tests` /
40
+ `review-tests`. If the agent types are not loaded (the files were installed during this
41
+ session), use `subagent_type: "general-purpose"` and put the full text of the agent file
42
+ in the prompt.
43
+
44
+ ## Wait, then read
45
+
46
+ - Wait until all 3 have replied. Each background agent sends a completion notification by
47
+ itself: do not poll, do not sleep. Do not edit while you wait.
48
+ - A reply is only: CLEAN or FINDINGS, a count, and the titles of blocking findings. Read
49
+ the full reports in `.scratch/reviews/` before you fix anything.
50
+
51
+ ## Fix
52
+
53
+ - Fix every finding in THIS PR, also the non-blocking ones. Never open a new PR for a
54
+ review finding.
55
+ - A finding that needs a design decision goes to the human. Do not decide it. Fix and push
56
+ the other findings as usual. The PR does not merge before the human has answered and the
57
+ answer is applied. Record the answer in the spec's decisions table (source, date), and put
58
+ it in the next round message.
59
+ - A real bug outside the PR's scope gets its own small PR from the base branch.
60
+ - Push all fixes of the round as one push. Get the new head sha.
61
+
62
+ ## Round N (N ≥ 2): the SAME agents, by message
63
+
64
+ Send the new sha to the same 3 named agents with `SendMessage`. Do not start new agents.
65
+ Each one checks its own earlier findings. If `SendMessage` is a deferred tool, load it
66
+ first (`ToolSearch` with `select:SendMessage`).
67
+
68
+ ```
69
+ SendMessage(
70
+ to: "review-<pr>-correctness",
71
+ message: "Round <N> of PR <pr> (base <base>). New head <sha>.
72
+ Changed since round <N-1>: <files>. Decisions since then: <none | text>.
73
+ Check your earlier findings, check only the changed text, report only
74
+ blocking problems. Report to .scratch/reviews/<pr>-correctness-r<N>.md."
75
+ )
76
+ ```
77
+
78
+ Re-rounds report only blocking problems; this stops nit loops. A re-round with no blocking
79
+ problem is CLEAN.
80
+
81
+ If a named agent can no longer be reached (for example after a session restart), start a
82
+ new agent with the same name and type, and tell it to read its earlier reports in
83
+ `.scratch/reviews/<pr>-<area>*.md` first.
84
+
85
+ Repeat fix → re-round until all 3 are CLEAN on the current head.
86
+
87
+ ## Merge
88
+
89
+ Only when all 3 are CLEAN on the current head, in this order (`docs/REVIEW_AND_MERGE.md`
90
+ sections 3 and 4):
91
+
92
+ 1. If the head is behind the base: `gh pr update-branch <pr>`, then send the new sha to the
93
+ 3 agents as a new round. Start again at "Wait, then read".
94
+ 2. Run each gate of section 4 as its own command and read its result. A gate that still
95
+ says `TODO(project)` does not exist; say so in your report to the human.
96
+ 3. In a separate command: `gh pr merge <pr> --merge --match-head-commit <sha>`. Never
97
+ squash.
98
+ 4. Check that CI on the base branch is green after the merge.
99
+
100
+ ## When the human asks to skip a step
101
+
102
+ The rules above are the human's own process, so the human may change them for one PR. Say
103
+ in one sentence which rule the request breaks (for example "all 3 reviewers also on small
104
+ PRs"). Do it only after the human confirms, and write the exception in the PR body.
105
+
106
+ ## Quick reference
107
+
108
+ | Situation | Action |
109
+ |---|---|
110
+ | New PR, or first review | 3 `Agent` calls in one message, names `review-<pr>-<area>` |
111
+ | Fix pushed | `SendMessage` the new sha to the same 3 names |
112
+ | Small diff, docs or spec PR | Still all 3 reviewers |
113
+ | Reviewer reports a non-blocking finding | Fix it in this PR |
114
+ | Finding needs a design choice | Ask the human |
115
+ | Head behind base | `gh pr update-branch <pr>`, then the reviewers check CI on the new head |
116
+ | PR from a fork | Reviewers only read; nobody runs its code |
117
+
118
+ ## Common mistakes
119
+
120
+ - Starting 3 NEW agents for round 2. They do not know their earlier findings, and they
121
+ report new nits forever. Re-rounds go to the same names.
122
+ - Reviewing only the "risky" lane on a small PR. Every round runs all 3.
123
+ - Opening a follow-up PR for a finding. Fix it in this PR.
124
+ - Asking a reviewer for its findings in the chat. The reply is the verdict; the findings are
125
+ in the report file.
126
+ - Merging on a green CI that shows only skipped checks right after a push. Wait for the run.