reviewer-skill 0.1.0 → 0.3.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/README.md CHANGED
@@ -22,25 +22,89 @@ The rules:
22
22
 
23
23
  ## What gets installed
24
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
25
+ | Template in this repo | Path in your project |
26
+ |---|---|
27
+ | `templates/agents/review-correctness.md` | `.claude/agents/review-correctness.md` |
28
+ | `templates/agents/review-security.md` | `.claude/agents/review-security.md` |
29
+ | `templates/agents/review-tests.md` | `.claude/agents/review-tests.md` |
30
+ | `templates/skills/review-round/SKILL.md` | `.claude/skills/review-round/SKILL.md` (start, wait, fix, re-round, merge) |
31
+ | `templates/docs/REVIEW_AND_MERGE.md` | `docs/REVIEW_AND_MERGE.md` (rules + section 4 "Project gates" to fill in) |
32
+ | `templates/CLAUDE.snippet.md` | optional: appended to `CLAUDE.md` between `<!-- reviewer-skill:start -->` and `<!-- reviewer-skill:end -->` |
33
+ | — | optional: a `.scratch/` line in `.gitignore` (the review reports) |
34
+
35
+ There are two ways to install: a Claude agent copies the files (no network code runs), or
36
+ the npm installer copies them. Both start in a feature branch.
37
+
38
+ ## Install with a Claude agent (local, no npx)
39
+
40
+ This path runs no downloaded code. The agent only reads the templates and writes files.
41
+ Give your Claude Code session this section and the tag to use, for example: *"Install
42
+ reviewer-skill v0.3.0 as described in its README section 'Install with a Claude agent'."*
43
+
44
+ Steps for the agent:
45
+
46
+ 1. **Branch first.** Run `git branch --show-current` and `git status --short`. Never install
47
+ on the default branch. Create a branch or a worktree, for example
48
+ `git switch -c chore/reviewer-skill`. Note every file that is already modified: those
49
+ changes are not part of this install.
50
+ 2. **Get the templates without running them.** Use a tag that is at least 7 days old
51
+ (release cooldown):
52
+ ```sh
53
+ git clone --depth 1 --branch v0.3.0 https://github.com/itinance/reviewer-skill.git /tmp/reviewer-skill-v0.3.0
54
+ git -C /tmp/reviewer-skill-v0.3.0 log -1 --format='%H %cI' # tag commit and date; compare with the tag on GitHub
55
+ ```
56
+ Do not run anything from the clone. Read the files only.
57
+ 3. **Copy the 5 files** in the table above with Read and Write. If a destination exists
58
+ with other content, do not overwrite it: show the human the difference and ask.
59
+ 4. **CLAUDE.md and .gitignore.** If `CLAUDE.md` does not contain
60
+ `<!-- reviewer-skill:start -->`, append the text of `templates/CLAUDE.snippet.md` between
61
+ the start and end markers. If no `.gitignore` line ignores `.scratch/`, add `.scratch/`.
62
+ Check with `git check-ignore -q .scratch/reviews/x.md`.
63
+ 5. **Fill in section 4 of `docs/REVIEW_AND_MERGE.md` from repo facts only.** Write the
64
+ source file after each value. The section says what to read for each gate. In short:
65
+ - Test and lint: the task runner (Justfile, Makefile, package.json scripts) and the CI
66
+ workflows (`.github/workflows/*.yml`, job names). Prefer the project's safe test
67
+ wrapper (for example one with a throwaway database). Copy forbidden commands from
68
+ CLAUDE.md into the gate.
69
+ - Local runs by reviewers: by default none; the tests reviewer reads the CI results.
70
+ Allow a local run only if the project wants it, with its exact command.
71
+ - Merge method and where decisions are recorded: copy them from CLAUDE.md (for example
72
+ "merge commit; the base is merged into the branch by hand").
73
+ - Supply chain: `.npmrc` (`ignore-scripts`), `pnpm-workspace.yaml` (`minimumReleaseAge`,
74
+ `onlyBuiltDependencies`, `ignoredBuiltDependencies`), `bunfig.toml`, the uv/pip config
75
+ (`exclude-newer`). If no setting enforces a cooldown, write "not enforced by config;
76
+ the security reviewer checks publish dates".
77
+ - Hard rules: grep the tests for existing guard tests and name the file and the test
78
+ functions. A rule without a guard test: "no guard test yet". Never invent one.
79
+ - Human-approval paths: find the real directories (for example
80
+ `find . -type d -name versions` for migrations). Do not assume a framework default.
81
+ - AI review bot: copy the project's existing rules from CLAUDE.md, and name removed bots.
82
+ - Sensitive data: list the classes only (customer names, personal emails, live database
83
+ rows, `.env` contents). Never write a real value. If there is no check script, say so.
84
+ 6. **Verify section 4 is complete.** This prints `0` when every gate is filled in:
85
+ ```sh
86
+ sed -n '/^## 4\./,/^## 5\./p' docs/REVIEW_AND_MERGE.md | grep -c 'TODO(project)'
87
+ ```
88
+ 7. **Commit only the install.** Stage the installed files, `CLAUDE.md` and `.gitignore` by
89
+ name (never `git add -A`). For any other change in the checkout, ask the human, or put it
90
+ in a separate commit.
91
+ 8. **Open a draft PR** and make it the first review round of the new process. The new agent
92
+ types load only after a restart of Claude Code or `/agents`. In the same session, start
93
+ each reviewer with `subagent_type: "general-purpose"` and the full text of its agent file
94
+ in the prompt.
95
+ 9. **Clean up:** `rm -rf /tmp/reviewer-skill-v0.3.0`.
96
+
97
+ **If the files were already written on the default branch** (for example by an older
98
+ installer): create the branch or worktree, copy the installed files there, apply the
99
+ `CLAUDE.md` and `.gitignore` changes there, and check that the files are the same
100
+ (`diff -r`). Then, on the default branch, delete the new files and run
101
+ `git restore CLAUDE.md .gitignore`. Leave unrelated changes alone.
102
+
103
+ ## Install with npm
41
104
 
42
105
  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`.
106
+ Never use `@latest`, a bare package name, or `-y` / `--yes`. `npx` downloads and runs code:
107
+ if your rules forbid fetch-and-execute, use the agent path above.
44
108
 
45
109
  ### 1. Check the release age first
46
110
 
@@ -49,50 +113,55 @@ window in which a hijacked account or a bad publish does the most damage.
49
113
 
50
114
  ```sh
51
115
  npm view reviewer-skill time --json # publish date of every version
52
- npm view reviewer-skill@0.1.0 dist.integrity
116
+ npm view reviewer-skill@0.3.0 dist.integrity
53
117
  ```
54
118
 
55
- ### 2. Run the installer in your project root
119
+ ### 2. Run the installer in a feature branch of your project
120
+
121
+ The installer refuses to write on the default branch (`origin/HEAD`, else `main` or
122
+ `master`). It reads the branch with your local `git`; that is the only program it runs.
123
+ Create a branch first: `git switch -c chore/reviewer-skill`.
56
124
 
57
125
  `--before <date>` lets npm enforce the cooldown: if the pinned version was published after
58
126
  that date, npx stops with `notarget` before it downloads or runs anything.
59
127
 
60
128
  ```sh
61
129
  # 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
130
+ npx --ignore-scripts --before "$(date -v-7d +%Y-%m-%d)" reviewer-skill@0.3.0 install --dry-run
131
+ npx --ignore-scripts --before "$(date -v-7d +%Y-%m-%d)" reviewer-skill@0.3.0 install
64
132
 
65
133
  # Linux
66
- npx --ignore-scripts --before "$(date -d '7 days ago' +%Y-%m-%d)" reviewer-skill@0.1.0 install
134
+ npx --ignore-scripts --before "$(date -d '7 days ago' +%Y-%m-%d)" reviewer-skill@0.3.0 install
67
135
  ```
68
136
 
69
137
  `npx` asks "Ok to proceed?" before it downloads the package. Read it and answer it; do not
70
138
  suppress it.
71
139
 
72
- With Bun (Bun does not run lifecycle scripts of packages by default):
140
+ In a terminal, the installer asks before each change to an existing file and before the
141
+ optional `CLAUDE.md` and `.gitignore` edits. Without a terminal (an agent runs it), it only
142
+ creates missing files. An agent names the optional edits explicitly:
73
143
 
74
144
  ```sh
75
- bunx reviewer-skill@0.1.0 install
145
+ npx --ignore-scripts --before "$(date -v-7d +%Y-%m-%d)" reviewer-skill@0.3.0 install --append-claude-md --gitignore-scratch
76
146
  ```
77
147
 
78
- Without the npm registry, from a git tag:
148
+ Both edits are idempotent: the `CLAUDE.md` section is added once (marker check), and the
149
+ `.scratch/` line only if no line ignores `.scratch` yet. There is no flag that answers every
150
+ question with yes.
151
+
152
+ With Bun (Bun does not run lifecycle scripts of packages by default):
79
153
 
80
154
  ```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 .
155
+ bunx reviewer-skill@0.3.0 install
84
156
  ```
85
157
 
86
- Do not install it globally. If you must: `npm install -g --ignore-scripts reviewer-skill@0.1.0`.
158
+ Do not install it globally. If you must: `npm install -g --ignore-scripts reviewer-skill@0.3.0`.
87
159
 
88
160
  ### 3. After the install
89
161
 
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.
162
+ Follow steps 5 to 8 of the agent path: fill in section 4 from repo facts, verify it, commit
163
+ only the installed files, open a draft PR as the first review round, and restart Claude Code
164
+ (or open `/agents`) so that it loads the new agents.
96
165
 
97
166
  ## Use
98
167
 
@@ -104,16 +173,21 @@ new head sha to the same 3 agents until all are clean.
104
173
  ## Commands
105
174
 
106
175
  ```
107
- reviewer-skill [install] [--target <dir>] [--dry-run]
176
+ reviewer-skill [install] [options]
177
+ --target <dir> project root (default: current directory)
178
+ --dry-run show what would happen; write nothing
179
+ --append-claude-md append the marked review section to CLAUDE.md (once)
180
+ --gitignore-scratch add ".scratch/" to .gitignore (once)
181
+ --allow-default-branch install on the default branch (normally refused)
108
182
  reviewer-skill print-snippet print the CLAUDE.md section
109
183
  reviewer-skill --help | --version
110
184
  ```
111
185
 
112
186
  ## Update
113
187
 
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.
188
+ Run the installer again with the new exact version (after its cooldown), or repeat the agent
189
+ path with the new tag. A file that differs from the new template is never overwritten without
190
+ asking; choose `n` to get a `.reviewer-skill.new` file and compare it with your version.
117
191
 
118
192
  ## Development
119
193
 
@@ -11,19 +11,35 @@ Installs the 3-reviewer PR process for Claude Code into a project:
11
11
  .claude/agents/review-{correctness,security,tests}.md
12
12
  .claude/skills/review-round/SKILL.md
13
13
  docs/REVIEW_AND_MERGE.md (template, fill in the TODO(project) gates)
14
- CLAUDE.md section, .gitignore entry (optional, asked)
14
+ CLAUDE.md section, .gitignore entry (optional: asked, or by flag)
15
15
 
16
16
  Usage:
17
- reviewer-skill [install] [--target <dir>] [--dry-run]
17
+ reviewer-skill [install] [options]
18
18
  reviewer-skill print-snippet print the CLAUDE.md section
19
19
  reviewer-skill --help | --version
20
20
 
21
+ Options:
22
+ --target <dir> project root (default: current directory)
23
+ --dry-run show what would happen; write nothing
24
+ --append-claude-md append the marked review section to CLAUDE.md (once)
25
+ --gitignore-scratch add ".scratch/" to .gitignore (once)
26
+ --allow-default-branch install on the default branch (normally refused)
27
+
21
28
  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.
29
+ when an agent runs it), missing files are created and existing files are left alone;
30
+ only the two edits named by --append-claude-md and --gitignore-scratch are made.
31
+ There is no flag that answers every question with yes.
23
32
  `;
24
33
 
25
34
  function parseArgs(argv) {
26
- const opts = { command: 'install', target: process.cwd(), dryRun: false };
35
+ const opts = {
36
+ command: 'install',
37
+ target: process.cwd(),
38
+ dryRun: false,
39
+ appendClaudeMd: false,
40
+ gitignoreScratch: false,
41
+ allowDefaultBranch: false,
42
+ };
27
43
  const args = [...argv];
28
44
  while (args.length) {
29
45
  const a = args.shift();
@@ -33,6 +49,9 @@ function parseArgs(argv) {
33
49
  if (!v) throw new Error('--target needs a directory');
34
50
  opts.target = v;
35
51
  } else if (a === '--dry-run') opts.dryRun = true;
52
+ else if (a === '--append-claude-md') opts.appendClaudeMd = true;
53
+ else if (a === '--gitignore-scratch') opts.gitignoreScratch = true;
54
+ else if (a === '--allow-default-branch') opts.allowDefaultBranch = true;
36
55
  else if (a === '--help' || a === '-h') opts.command = 'help';
37
56
  else if (a === '--version' || a === '-v') opts.command = 'version';
38
57
  else throw new Error(`unknown argument: ${a}`);
@@ -64,22 +83,30 @@ async function main() {
64
83
  const prompt = opts.dryRun ? { ask: null, close() {} } : makeAsk();
65
84
  let results;
66
85
  try {
67
- results = await install({ target: opts.target, ask: prompt.ask, dryRun: opts.dryRun });
86
+ results = await install({
87
+ target: opts.target,
88
+ ask: prompt.ask,
89
+ dryRun: opts.dryRun,
90
+ appendClaudeMd: opts.appendClaudeMd,
91
+ gitignoreScratch: opts.gitignoreScratch,
92
+ allowDefaultBranch: opts.allowDefaultBranch,
93
+ });
68
94
  } finally {
69
95
  prompt.close();
70
96
  }
71
97
 
72
98
  if (!prompt.ask && !opts.dryRun) {
73
- process.stdout.write('No terminal: existing files are left alone, optional steps are skipped.\n');
99
+ process.stdout.write('No terminal: existing files are left alone; optional edits only by flag.\n');
74
100
  }
75
101
  for (const r of results) {
76
102
  process.stdout.write(` ${r.action.padEnd(12)} ${r.path}${r.note ? ` (${r.note})` : ''}\n`);
77
103
  }
78
104
  process.stdout.write(`
79
105
  Next:
80
- 1. Fill in the project gates: grep -n "TODO(project)" docs/REVIEW_AND_MERGE.md
106
+ 1. Fill in the project gates (section 4) from repo facts:
107
+ sed -n '/^## 4\./,/^## 5\./p' docs/REVIEW_AND_MERGE.md | grep -c 'TODO(project)' # 0 when done
81
108
  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>".
109
+ 3. Commit only these files, open a draft PR, and make it the first review round.
83
110
  `);
84
111
  }
85
112
 
package/lib/install.js CHANGED
@@ -1,7 +1,11 @@
1
1
  import { promises as fs } from 'node:fs';
2
+ import { execFile } from 'node:child_process';
2
3
  import path from 'node:path';
4
+ import { promisify } from 'node:util';
3
5
  import { fileURLToPath } from 'node:url';
4
6
 
7
+ const execFileP = promisify(execFile);
8
+
5
9
  export const TEMPLATE_DIR = path.join(
6
10
  path.dirname(fileURLToPath(import.meta.url)),
7
11
  '..',
@@ -54,24 +58,68 @@ export function ignoresScratch(gitignoreText) {
54
58
  .some((l) => ['.scratch', '.scratch/', '/.scratch', '/.scratch/', '.scratch/*', '/.scratch/*'].includes(l));
55
59
  }
56
60
 
61
+ async function git(cwd, args) {
62
+ try {
63
+ const { stdout } = await execFileP('git', ['-C', cwd, ...args]);
64
+ return stdout.trim();
65
+ } catch {
66
+ return null;
67
+ }
68
+ }
69
+
70
+ /**
71
+ * The current branch of the checkout at `target` and the names that count as its default
72
+ * branch: `origin/HEAD` if it is set, else `main` and `master`. Returns null when `target`
73
+ * is not in a git work tree. `current` is '' on a detached HEAD.
74
+ */
75
+ export async function branchInfo(target) {
76
+ if ((await git(target, ['rev-parse', '--is-inside-work-tree'])) !== 'true') return null;
77
+ const current = (await git(target, ['branch', '--show-current'])) ?? '';
78
+ const originHead = await git(target, ['symbolic-ref', '--quiet', '--short', 'refs/remotes/origin/HEAD']);
79
+ const defaults = originHead ? [originHead.replace(/^origin\//, '')] : ['main', 'master'];
80
+ return { current, defaults, onDefault: current !== '' && defaults.includes(current) };
81
+ }
82
+
57
83
  /**
58
84
  * Install the review files into `target`.
59
85
  *
60
86
  * `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.
87
+ * run is non-interactive: it creates missing files and never changes an existing file,
88
+ * except for the two optional edits that the caller asks for by name:
89
+ * `appendClaudeMd` (the marked section in CLAUDE.md) and `gitignoreScratch` (the
90
+ * `.scratch/` line in .gitignore). Both are idempotent.
62
91
  * `dryRun` writes nothing and asks nothing.
92
+ * The install refuses to write on the default branch unless `allowDefaultBranch` is set.
63
93
  *
64
94
  * Returns a list of { path, action, note? } in install order.
65
95
  */
66
- export async function install({ target, ask = null, dryRun = false }) {
96
+ export async function install({
97
+ target,
98
+ ask = null,
99
+ dryRun = false,
100
+ appendClaudeMd = false,
101
+ gitignoreScratch = false,
102
+ allowDefaultBranch = false,
103
+ }) {
67
104
  const root = path.resolve(target);
68
105
  const rootStat = await lstatOrNull(root);
69
106
  if (!rootStat || !rootStat.isDirectory()) {
70
107
  throw new Error(`target is not a directory: ${root}`);
71
108
  }
72
109
 
110
+ const branch = await branchInfo(root);
111
+ if (branch?.onDefault && !allowDefaultBranch && !dryRun) {
112
+ throw new Error(
113
+ `the checkout is on the default branch "${branch.current}". Install in a feature branch ` +
114
+ 'or worktree (for example `git switch -c chore/reviewer-skill`), or pass --allow-default-branch.',
115
+ );
116
+ }
117
+
73
118
  const results = [];
74
119
  const record = (dest, action, note) => results.push({ path: dest, action, ...(note ? { note } : {}) });
120
+ if (branch?.onDefault && !allowDefaultBranch && dryRun) {
121
+ record(`branch ${branch.current}`, 'would-refuse', 'default branch; create a feature branch or worktree first');
122
+ }
75
123
 
76
124
  for (const file of FILES) {
77
125
  const dest = path.join(root, file.dest);
@@ -130,12 +178,12 @@ export async function install({ target, ask = null, dryRun = false }) {
130
178
  }
131
179
  }
132
180
 
133
- results.push(await installSnippet(root, { ask, dryRun }));
134
- results.push(await installGitignore(root, { ask, dryRun }));
181
+ results.push(await installSnippet(root, { ask, dryRun, wanted: appendClaudeMd }));
182
+ results.push(await installGitignore(root, { ask, dryRun, wanted: gitignoreScratch }));
135
183
  return results;
136
184
  }
137
185
 
138
- async function installSnippet(root, { ask, dryRun }) {
186
+ async function installSnippet(root, { ask, dryRun, wanted }) {
139
187
  const rel = 'CLAUDE.md';
140
188
  const dest = path.join(root, rel);
141
189
  const st = await lstatOrNull(dest);
@@ -145,13 +193,17 @@ async function installSnippet(root, { ask, dryRun }) {
145
193
  if (existing !== null && existing.includes(SNIPPET_START)) return { path: rel, action: 'unchanged' };
146
194
 
147
195
  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`' };
196
+ if (dryRun) {
197
+ if (wanted) return { path: rel, action: existing === null ? 'would-create' : 'would-append' };
198
+ return { path: rel, action: 'would-ask', note: `optional: ${verb.toLowerCase()} the review section` };
199
+ }
200
+ if (!wanted) {
201
+ if (!ask) {
202
+ return { path: rel, action: 'skipped', note: 'optional; pass --append-claude-md, or print it with `reviewer-skill print-snippet`' };
203
+ }
204
+ const choice = await ask(`${verb} the "Review and merge" section? [y/N]`, ['y', 'n'], 'n');
205
+ if (choice !== 'y') return { path: rel, action: 'skipped', note: 'declined' };
151
206
  }
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
207
 
156
208
  const block = await snippetBlock();
157
209
  if (existing === null) {
@@ -163,7 +215,7 @@ async function installSnippet(root, { ask, dryRun }) {
163
215
  return { path: rel, action: 'appended' };
164
216
  }
165
217
 
166
- async function installGitignore(root, { ask, dryRun }) {
218
+ async function installGitignore(root, { ask, dryRun, wanted }) {
167
219
  const rel = '.gitignore';
168
220
  const dest = path.join(root, rel);
169
221
  const st = await lstatOrNull(dest);
@@ -172,13 +224,17 @@ async function installGitignore(root, { ask, dryRun }) {
172
224
  const existing = st ? await fs.readFile(dest, 'utf8') : null;
173
225
  if (existing !== null && ignoresScratch(existing)) return { path: rel, action: 'unchanged' };
174
226
 
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 };
227
+ const note = `reports in .scratch/reviews/ must be git-ignored: add "${GITIGNORE_ENTRY}" or pass --gitignore-scratch`;
228
+ if (dryRun) {
229
+ if (wanted) return { path: rel, action: existing === null ? 'would-create' : 'would-append' };
230
+ return { path: rel, action: 'would-ask', note };
231
+ }
232
+ if (!wanted) {
233
+ if (!ask) return { path: rel, action: 'skipped', note };
234
+ const verb = existing === null ? 'Create .gitignore with' : 'Add';
235
+ const choice = await ask(`${verb} "${GITIGNORE_ENTRY}" (review reports)? [y/N]`, ['y', 'n'], 'n');
236
+ if (choice !== 'y') return { path: rel, action: 'skipped', note };
237
+ }
182
238
 
183
239
  const line = `${GITIGNORE_ENTRY}\n`;
184
240
  if (existing === null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reviewer-skill",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
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
5
  "keywords": ["claude-code", "claude", "code-review", "agents", "skill", "pull-request"],
6
6
  "license": "MIT",
@@ -1,3 +1,3 @@
1
1
  ## Review and merge
2
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`.
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 the project's merge method. The full rules and the project gates are in `docs/REVIEW_AND_MERGE.md`.
@@ -17,10 +17,9 @@ win over this file.
17
17
  `git diff origin/<base>...<sha>`, and the code on the base branch.
18
18
  - Never `git checkout` or `git switch` in an existing checkout or worktree — another session
19
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.
20
+ - Do not run the PR's code or its test suite; read the CI results for the head instead. Run
21
+ code only if `docs/REVIEW_AND_MERGE.md` section 4.1 allows local runs, and only as it says.
22
+ Never run code from a fork PR (`gh pr view <pr> --json isCrossRepository` is `true`).
24
23
  - Never edit a tracked file, commit, push, comment on GitHub, merge, trigger a review bot, or
25
24
  call a paid API.
26
25
  - Never print sensitive data (customer data, secrets, personal data). Report counts, statuses,
@@ -14,10 +14,9 @@ and spec conventions win over this file.
14
14
 
15
15
  - Read only: `gh pr view|diff|checks`, `gh run list|view`, `git fetch`, `git show <sha>:<path>`.
16
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.
17
+ - Do not run the PR's code or its test suite; read the CI results for the head instead. Run
18
+ code only if `docs/REVIEW_AND_MERGE.md` section 4.1 allows local runs, and only as it says.
19
+ Never run code from a fork PR (`gh pr view <pr> --json isCrossRepository` is `true`).
21
20
  - Never edit a tracked file, commit, push, comment on GitHub, merge, or trigger a review bot.
22
21
  - Never print sensitive data.
23
22
  - "Read only" is enforced by these rules; `Write` is only for your report file.
@@ -35,8 +34,9 @@ Code PR:
35
34
  run. Note whether the head is behind the base branch.
36
35
 
37
36
  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.
37
+ - The spec describes the current intended state and matches the code; every human decision
38
+ is recorded where the project records decisions, with its source and date; no open question
39
+ blocks the build.
40
40
  - Each item has a test plan that would catch its bug; acceptance criteria are testable (no
41
41
  "about", "nice", "clear").
42
42
  - The project's doc conventions are kept.
@@ -3,9 +3,10 @@
3
3
  These rules apply to every pull request, also to small diffs, docs, specs and dependency
4
4
  bumps. They add to `CLAUDE.md` and do not repeat it.
5
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.
6
+ Installed by `reviewer-skill`. Section 4 holds the project gates. Each open gate carries a
7
+ TODO marker. Fill in every gate from facts in this repository, and name the file that each
8
+ fact comes from. A gate that is still open does not exist yet: reviewers report it as a
9
+ note, they do not invent one.
9
10
 
10
11
  ## 1. Three separate reviewers per round
11
12
 
@@ -20,9 +21,9 @@ does not exist yet: reviewers report it as a note, they do not invent one.
20
21
  uses. They never edit, never comment on GitHub, never merge.
21
22
  - "Read only" is a rule in the agent prompt, not a tool limit. The agents need `Write` for
22
23
  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.
24
+ - The reviewers do not run the PR's code or tests unless section 4.1 allows it. The tests
25
+ reviewer reads the CI results for the head. For a PR from a fork
26
+ (`gh pr view <pr> --json isCrossRepository` is `true`), nobody runs its code.
26
27
  - Each reviewer writes its full report to `.scratch/reviews/<pr>-<area>[-rN].md`
27
28
  (git-ignored) and replies with only: the verdict (CLEAN or FINDINGS), the number of
28
29
  findings, and a one-line title for each blocking finding.
@@ -45,56 +46,76 @@ does not exist yet: reviewers report it as a note, they do not invent one.
45
46
 
46
47
  - Merge only when all 3 reviewers are CLEAN on the current head, and every gate in
47
48
  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.
49
+ - Merge exactly the head that the reviewers saw clean, with the method from section 4.5
50
+ (for example `gh pr merge <pr> --match-head-commit <sha>` plus the method flag). Every new
51
+ head, also one that brings in the base branch, gets a new round first.
52
+ - Run each safety check on its own and read its result before you start the merge.
54
53
  - After the merge: CI on the base branch is green.
55
54
 
56
55
  ## 4. Project gates
57
56
 
58
- <!-- Fill in each TODO(project). Delete a line that does not apply, and write "none". -->
57
+ <!--
58
+ Replace each open marker with a fact from this repository and its source, for example
59
+ "`make test` (source: Makefile, .github/workflows/ci.yml job `test`)". A line that does not
60
+ apply: write "none". Never write a guess, and never write a real sensitive value.
61
+ -->
59
62
 
60
63
  ### 4.1 Commands
61
64
 
62
- - Test command: TODO(project), for example `npm test` or `uv run pytest`.
65
+ Read the task runner (Justfile, Makefile, package.json scripts), the CI workflows
66
+ (`.github/workflows/*.yml`, job names) and CLAUDE.md first.
67
+
68
+ - Test command: TODO(project). Use the project's safe wrapper (for example one that uses
69
+ a throwaway database), not a raw `pytest` or `npm test`, if the project has one.
70
+ - Forbidden commands: TODO(project), for example "plain `pytest` hits the live database"
71
+ (source: CLAUDE.md), or "none".
63
72
  - 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`.
73
+ - Local runs by reviewers: TODO(project). Write "none; reviewers read the CI results" (the
74
+ default), or the exact command that a reviewer may run and where.
75
+ - CI workflow and job set to compare job counts against: TODO(project).
67
76
 
68
77
  ### 4.2 Hard rules
69
78
 
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`)".
79
+ - Rules that a PR must never weaken, each with its guard test (file and test function):
80
+ TODO(project). Find the guard tests with a grep over the tests. A rule without a guard
81
+ test: write "no guard test yet". Do not invent a test.
72
82
 
73
83
  ### 4.3 Sensitive data
74
84
 
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.
85
+ - Classes of sensitive data in this project: TODO(project), for example customer names,
86
+ personal emails, live database rows, `.env` contents. Classes only: never a real value.
87
+ - Sensitive-data check on the diff, the commit messages and the PR body: TODO(project).
88
+ If the project has no such script, write "none; reviewers report file:line and counts
89
+ only". A check must print counts only, never the matched text.
79
90
 
80
91
  ### 4.4 Supply chain
81
92
 
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).
93
+ Read `.npmrc`, `pnpm-workspace.yaml` (`minimumReleaseAge`, `onlyBuiltDependencies`,
94
+ `ignoredBuiltDependencies`), `bunfig.toml` and the uv/pip config (`exclude-newer`).
95
+
96
+ - Exact version pins: TODO(project).
97
+ - Release cooldown per ecosystem (at least 7 days): TODO(project). Write the setting that
98
+ enforces it. If no config enforces it, write "not enforced by config; the security
99
+ reviewer checks publish dates". Never claim a cooldown that no config enforces.
100
+ - Install scripts: TODO(project), for example "off (`ignore-scripts=true` in .npmrc);
101
+ allowed only for the packages in `onlyBuiltDependencies`".
87
102
 
88
103
  ### 4.5 Extra merge gates
89
104
 
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".
105
+ - AI review bot: TODO(project). Copy the project's own rules for it (CLAUDE.md), for
106
+ example "manual trigger only, backend PRs only", and name bots that were removed; or
107
+ "none". If a bot is used: keep it paused until the 3 reviewers are clean, then trigger it
108
+ once. A pause posted right after `gh pr create` does not stop the first review: open the
109
+ PR as a draft, pause the bot, wait for its confirmation, then mark the PR ready.
110
+ - Merge method, and how a branch takes in changes from the base branch: TODO(project), for
111
+ example "merge commit; the base is merged into the branch by hand" (source: CLAUDE.md).
112
+ - Where human decisions are recorded: TODO(project), for example "the PR body".
113
+ - Checks before a merge: TODO(project) or "none".
114
+ - Paths or PR types that need a human approval: TODO(project) or "none". Use the real
115
+ paths (find them, for example `find . -type d -name versions` for migrations); do not
116
+ assume a framework's default layout.
96
117
 
97
118
  ## 5. Decisions
98
119
 
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.
120
+ - Record every human decision on a PR, with the source and the date, in the same turn: where
121
+ section 4.5 says, else in the PR body.
@@ -54,8 +54,8 @@ in the prompt.
54
54
  review finding.
55
55
  - A finding that needs a design decision goes to the human. Do not decide it. Fix and push
56
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.
57
+ answer is applied. Record the answer with source and date where section 4.5 of the docs
58
+ says (else in the PR body), and put it in the next round message.
59
59
  - A real bug outside the PR's scope gets its own small PR from the base branch.
60
60
  - Push all fixes of the round as one push. Get the new head sha.
61
61
 
@@ -89,13 +89,14 @@ Repeat fix → re-round until all 3 are CLEAN on the current head.
89
89
  Only when all 3 are CLEAN on the current head, in this order (`docs/REVIEW_AND_MERGE.md`
90
90
  sections 3 and 4):
91
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
92
+ 1. Run each gate of section 4 as its own command and read its result. A gate that still
95
93
  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.
94
+ 2. Merge exactly the reviewed head, with the method from section 4.5, in a separate
95
+ command: for example `gh pr merge <pr> --match-head-commit <sha>` plus the method flag.
96
+ 3. Check that CI on the base branch is green after the merge.
97
+
98
+ If the head changed after the clean round (a fix, or changes taken in from the base
99
+ branch), that is a new round first: send the new sha to the same 3 agents.
99
100
 
100
101
  ## When the human asks to skip a step
101
102
 
@@ -112,7 +113,7 @@ PRs"). Do it only after the human confirms, and write the exception in the PR bo
112
113
  | Small diff, docs or spec PR | Still all 3 reviewers |
113
114
  | Reviewer reports a non-blocking finding | Fix it in this PR |
114
115
  | 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
+ | Base branch taken into the PR | New head: a new round to the same 3 agents |
116
117
  | PR from a fork | Reviewers only read; nobody runs its code |
117
118
 
118
119
  ## Common mistakes