reviewer-skill 0.1.0 → 0.2.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 +112 -39
- package/bin/reviewer-skill.js +35 -8
- package/lib/install.js +75 -19
- package/package.json +1 -1
- package/templates/docs/REVIEW_AND_MERGE.md +45 -23
package/README.md
CHANGED
|
@@ -22,25 +22,88 @@ The rules:
|
|
|
22
22
|
|
|
23
23
|
## What gets installed
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.claude/agents/review-
|
|
28
|
-
.claude/agents/review-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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.2.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.2.0 https://github.com/itinance/reviewer-skill.git /tmp/reviewer-skill-v0.2.0
|
|
54
|
+
git -C /tmp/reviewer-skill-v0.2.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
|
+
- Worktree install: the real layout, with the lockfile and install scripts off, for
|
|
70
|
+
example `npm ci --ignore-scripts`, `pnpm install --frozen-lockfile --ignore-workspace
|
|
71
|
+
--ignore-scripts` for a standalone app in a workspace, `uv sync --frozen`.
|
|
72
|
+
- Supply chain: `.npmrc` (`ignore-scripts`), `pnpm-workspace.yaml` (`minimumReleaseAge`,
|
|
73
|
+
`onlyBuiltDependencies`, `ignoredBuiltDependencies`), `bunfig.toml`, the uv/pip config
|
|
74
|
+
(`exclude-newer`). If no setting enforces a cooldown, write "not enforced by config;
|
|
75
|
+
the security reviewer checks publish dates".
|
|
76
|
+
- Hard rules: grep the tests for existing guard tests and name the file and the test
|
|
77
|
+
functions. A rule without a guard test: "no guard test yet". Never invent one.
|
|
78
|
+
- Human-approval paths: find the real directories (for example
|
|
79
|
+
`find . -type d -name versions` for migrations). Do not assume a framework default.
|
|
80
|
+
- AI review bot: copy the project's existing rules from CLAUDE.md, and name removed bots.
|
|
81
|
+
- Sensitive data: list the classes only (customer names, personal emails, live database
|
|
82
|
+
rows, `.env` contents). Never write a real value. If there is no check script, say so.
|
|
83
|
+
6. **Verify section 4 is complete.** This prints `0` when every gate is filled in:
|
|
84
|
+
```sh
|
|
85
|
+
sed -n '/^## 4\./,/^## 5\./p' docs/REVIEW_AND_MERGE.md | grep -c 'TODO(project)'
|
|
86
|
+
```
|
|
87
|
+
7. **Commit only the install.** Stage the installed files, `CLAUDE.md` and `.gitignore` by
|
|
88
|
+
name (never `git add -A`). For any other change in the checkout, ask the human, or put it
|
|
89
|
+
in a separate commit.
|
|
90
|
+
8. **Open a draft PR** and make it the first review round of the new process. The new agent
|
|
91
|
+
types load only after a restart of Claude Code or `/agents`. In the same session, start
|
|
92
|
+
each reviewer with `subagent_type: "general-purpose"` and the full text of its agent file
|
|
93
|
+
in the prompt.
|
|
94
|
+
9. **Clean up:** `rm -rf /tmp/reviewer-skill-v0.2.0`.
|
|
95
|
+
|
|
96
|
+
**If the files were already written on the default branch** (for example by an older
|
|
97
|
+
installer): create the branch or worktree, copy the installed files there, apply the
|
|
98
|
+
`CLAUDE.md` and `.gitignore` changes there, and check that the files are the same
|
|
99
|
+
(`diff -r`). Then, on the default branch, delete the new files and run
|
|
100
|
+
`git restore CLAUDE.md .gitignore`. Leave unrelated changes alone.
|
|
101
|
+
|
|
102
|
+
## Install with npm
|
|
41
103
|
|
|
42
104
|
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`.
|
|
105
|
+
Never use `@latest`, a bare package name, or `-y` / `--yes`. `npx` downloads and runs code:
|
|
106
|
+
if your rules forbid fetch-and-execute, use the agent path above.
|
|
44
107
|
|
|
45
108
|
### 1. Check the release age first
|
|
46
109
|
|
|
@@ -49,50 +112,55 @@ window in which a hijacked account or a bad publish does the most damage.
|
|
|
49
112
|
|
|
50
113
|
```sh
|
|
51
114
|
npm view reviewer-skill time --json # publish date of every version
|
|
52
|
-
npm view reviewer-skill@0.
|
|
115
|
+
npm view reviewer-skill@0.2.0 dist.integrity
|
|
53
116
|
```
|
|
54
117
|
|
|
55
|
-
### 2. Run the installer in your project
|
|
118
|
+
### 2. Run the installer in a feature branch of your project
|
|
119
|
+
|
|
120
|
+
The installer refuses to write on the default branch (`origin/HEAD`, else `main` or
|
|
121
|
+
`master`). It reads the branch with your local `git`; that is the only program it runs.
|
|
122
|
+
Create a branch first: `git switch -c chore/reviewer-skill`.
|
|
56
123
|
|
|
57
124
|
`--before <date>` lets npm enforce the cooldown: if the pinned version was published after
|
|
58
125
|
that date, npx stops with `notarget` before it downloads or runs anything.
|
|
59
126
|
|
|
60
127
|
```sh
|
|
61
128
|
# macOS
|
|
62
|
-
npx --ignore-scripts --before "$(date -v-7d +%Y-%m-%d)" reviewer-skill@0.
|
|
63
|
-
npx --ignore-scripts --before "$(date -v-7d +%Y-%m-%d)" reviewer-skill@0.
|
|
129
|
+
npx --ignore-scripts --before "$(date -v-7d +%Y-%m-%d)" reviewer-skill@0.2.0 install --dry-run
|
|
130
|
+
npx --ignore-scripts --before "$(date -v-7d +%Y-%m-%d)" reviewer-skill@0.2.0 install
|
|
64
131
|
|
|
65
132
|
# Linux
|
|
66
|
-
npx --ignore-scripts --before "$(date -d '7 days ago' +%Y-%m-%d)" reviewer-skill@0.
|
|
133
|
+
npx --ignore-scripts --before "$(date -d '7 days ago' +%Y-%m-%d)" reviewer-skill@0.2.0 install
|
|
67
134
|
```
|
|
68
135
|
|
|
69
136
|
`npx` asks "Ok to proceed?" before it downloads the package. Read it and answer it; do not
|
|
70
137
|
suppress it.
|
|
71
138
|
|
|
72
|
-
|
|
139
|
+
In a terminal, the installer asks before each change to an existing file and before the
|
|
140
|
+
optional `CLAUDE.md` and `.gitignore` edits. Without a terminal (an agent runs it), it only
|
|
141
|
+
creates missing files. An agent names the optional edits explicitly:
|
|
73
142
|
|
|
74
143
|
```sh
|
|
75
|
-
|
|
144
|
+
npx --ignore-scripts --before "$(date -v-7d +%Y-%m-%d)" reviewer-skill@0.2.0 install --append-claude-md --gitignore-scratch
|
|
76
145
|
```
|
|
77
146
|
|
|
78
|
-
|
|
147
|
+
Both edits are idempotent: the `CLAUDE.md` section is added once (marker check), and the
|
|
148
|
+
`.scratch/` line only if no line ignores `.scratch` yet. There is no flag that answers every
|
|
149
|
+
question with yes.
|
|
150
|
+
|
|
151
|
+
With Bun (Bun does not run lifecycle scripts of packages by default):
|
|
79
152
|
|
|
80
153
|
```sh
|
|
81
|
-
|
|
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 .
|
|
154
|
+
bunx reviewer-skill@0.2.0 install
|
|
84
155
|
```
|
|
85
156
|
|
|
86
|
-
Do not install it globally. If you must: `npm install -g --ignore-scripts reviewer-skill@0.
|
|
157
|
+
Do not install it globally. If you must: `npm install -g --ignore-scripts reviewer-skill@0.2.0`.
|
|
87
158
|
|
|
88
159
|
### 3. After the install
|
|
89
160
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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.
|
|
161
|
+
Follow steps 5 to 8 of the agent path: fill in section 4 from repo facts, verify it, commit
|
|
162
|
+
only the installed files, open a draft PR as the first review round, and restart Claude Code
|
|
163
|
+
(or open `/agents`) so that it loads the new agents.
|
|
96
164
|
|
|
97
165
|
## Use
|
|
98
166
|
|
|
@@ -104,16 +172,21 @@ new head sha to the same 3 agents until all are clean.
|
|
|
104
172
|
## Commands
|
|
105
173
|
|
|
106
174
|
```
|
|
107
|
-
reviewer-skill [install] [
|
|
175
|
+
reviewer-skill [install] [options]
|
|
176
|
+
--target <dir> project root (default: current directory)
|
|
177
|
+
--dry-run show what would happen; write nothing
|
|
178
|
+
--append-claude-md append the marked review section to CLAUDE.md (once)
|
|
179
|
+
--gitignore-scratch add ".scratch/" to .gitignore (once)
|
|
180
|
+
--allow-default-branch install on the default branch (normally refused)
|
|
108
181
|
reviewer-skill print-snippet print the CLAUDE.md section
|
|
109
182
|
reviewer-skill --help | --version
|
|
110
183
|
```
|
|
111
184
|
|
|
112
185
|
## Update
|
|
113
186
|
|
|
114
|
-
Run the installer again with the new exact version (after its cooldown)
|
|
115
|
-
|
|
116
|
-
choose `n`
|
|
187
|
+
Run the installer again with the new exact version (after its cooldown), or repeat the agent
|
|
188
|
+
path with the new tag. A file that differs from the new template is never overwritten without
|
|
189
|
+
asking; choose `n` to get a `.reviewer-skill.new` file and compare it with your version.
|
|
117
190
|
|
|
118
191
|
## Development
|
|
119
192
|
|
package/bin/reviewer-skill.js
CHANGED
|
@@ -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,
|
|
14
|
+
CLAUDE.md section, .gitignore entry (optional: asked, or by flag)
|
|
15
15
|
|
|
16
16
|
Usage:
|
|
17
|
-
reviewer-skill [install] [
|
|
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 = {
|
|
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({
|
|
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
|
|
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
|
|
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.
|
|
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({
|
|
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)
|
|
149
|
-
|
|
150
|
-
return { path: rel, action: '
|
|
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)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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.
|
|
3
|
+
"version": "0.2.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",
|
|
@@ -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`.
|
|
7
|
-
|
|
8
|
-
does not exist yet: reviewers report it as a
|
|
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
|
|
|
@@ -55,44 +56,65 @@ does not exist yet: reviewers report it as a note, they do not invent one.
|
|
|
55
56
|
|
|
56
57
|
## 4. Project gates
|
|
57
58
|
|
|
58
|
-
<!--
|
|
59
|
+
<!--
|
|
60
|
+
Replace each open marker with a fact from this repository and its source, for example
|
|
61
|
+
"`make test` (source: Makefile, .github/workflows/ci.yml job `test`)". A line that does not
|
|
62
|
+
apply: write "none". Never write a guess, and never write a real sensitive value.
|
|
63
|
+
-->
|
|
59
64
|
|
|
60
65
|
### 4.1 Commands
|
|
61
66
|
|
|
62
|
-
|
|
67
|
+
Read the task runner (Justfile, Makefile, package.json scripts), the CI workflows
|
|
68
|
+
(`.github/workflows/*.yml`, job names) and CLAUDE.md first.
|
|
69
|
+
|
|
70
|
+
- Test command: TODO(project). Use the project's safe wrapper (for example one that uses
|
|
71
|
+
a throwaway database), not a raw `pytest` or `npm test`, if the project has one.
|
|
72
|
+
- Forbidden commands: TODO(project), for example "plain `pytest` hits the live database"
|
|
73
|
+
(source: CLAUDE.md), or "none".
|
|
63
74
|
- Lint and type check: TODO(project).
|
|
64
75
|
- Dependency install in a throwaway review worktree, from the lockfile, with install
|
|
65
|
-
scripts off: TODO(project)
|
|
66
|
-
|
|
76
|
+
scripts off, for the real layout: TODO(project). Examples: `npm ci --ignore-scripts`;
|
|
77
|
+
`pnpm install --frozen-lockfile --ignore-scripts` (add `--ignore-workspace` for a
|
|
78
|
+
standalone app inside a workspace); `uv sync --frozen`.
|
|
79
|
+
- CI workflow and job set to compare job counts against: TODO(project).
|
|
67
80
|
|
|
68
81
|
### 4.2 Hard rules
|
|
69
82
|
|
|
70
|
-
- Rules that a PR must never weaken, with
|
|
71
|
-
|
|
83
|
+
- Rules that a PR must never weaken, each with its guard test (file and test function):
|
|
84
|
+
TODO(project). Find the guard tests with a grep over the tests. A rule without a guard
|
|
85
|
+
test: write "no guard test yet". Do not invent a test.
|
|
72
86
|
|
|
73
87
|
### 4.3 Sensitive data
|
|
74
88
|
|
|
75
|
-
-
|
|
76
|
-
personal
|
|
77
|
-
- Sensitive-data check on the diff, the commit messages and the PR body: TODO(project)
|
|
78
|
-
|
|
89
|
+
- Classes of sensitive data in this project: TODO(project), for example customer names,
|
|
90
|
+
personal emails, live database rows, `.env` contents. Classes only: never a real value.
|
|
91
|
+
- Sensitive-data check on the diff, the commit messages and the PR body: TODO(project).
|
|
92
|
+
If the project has no such script, write "none; reviewers report file:line and counts
|
|
93
|
+
only". A check must print counts only, never the matched text.
|
|
79
94
|
|
|
80
95
|
### 4.4 Supply chain
|
|
81
96
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
-
|
|
86
|
-
|
|
97
|
+
Read `.npmrc`, `pnpm-workspace.yaml` (`minimumReleaseAge`, `onlyBuiltDependencies`,
|
|
98
|
+
`ignoredBuiltDependencies`), `bunfig.toml` and the uv/pip config (`exclude-newer`).
|
|
99
|
+
|
|
100
|
+
- Exact version pins: TODO(project).
|
|
101
|
+
- Release cooldown per ecosystem (at least 7 days): TODO(project). Write the setting that
|
|
102
|
+
enforces it. If no config enforces it, write "not enforced by config; the security
|
|
103
|
+
reviewer checks publish dates". Never claim a cooldown that no config enforces.
|
|
104
|
+
- Install scripts: TODO(project), for example "off (`ignore-scripts=true` in .npmrc);
|
|
105
|
+
allowed only for the packages in `onlyBuiltDependencies`".
|
|
87
106
|
|
|
88
107
|
### 4.5 Extra merge gates
|
|
89
108
|
|
|
90
|
-
- AI review bot
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
109
|
+
- AI review bot: TODO(project). Copy the project's own rules for it (CLAUDE.md), for
|
|
110
|
+
example "manual trigger only, backend PRs only", and name bots that were removed; or
|
|
111
|
+
"none". If a bot is used: keep it paused until the 3 reviewers are clean, then trigger it
|
|
112
|
+
once. A pause posted right after `gh pr create` does not stop the first review: open the
|
|
113
|
+
PR as a draft, pause the bot, wait for its confirmation, then mark the PR ready.
|
|
94
114
|
- 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".
|
|
115
|
+
- Paths or PR types that need a human approval: TODO(project) or "none". Use the real
|
|
116
|
+
paths (find them, for example `find . -type d -name versions` for migrations); do not
|
|
117
|
+
assume a framework's default layout.
|
|
96
118
|
|
|
97
119
|
## 5. Decisions
|
|
98
120
|
|