AI Diff Reviewer — Generate Extension (sub-skill)
Companion to the ai-diff-reviewer skill. Where
ai-diff-reviewer runs the review, this sub-skill bootstraps the
configuration — turning "here's the default reviewer" into "here's a
reviewer that understands OUR stack, OUR conventions, and OUR history of
bugs."
Two output modes:
| Mode |
File written |
When |
| Extension (default) |
.review/extension.md |
Almost always — the recommended path. Layers repo-specific overrides ON TOP of the battle-tested default prompt. Cheap iteration; the default keeps improving upstream. |
| Full replacement (advanced) |
.github/prompts/pr-review.md |
Rare — teams that want total control, or whose codebase is so idiosyncratic (proprietary DSL, unusual paradigm) that the default is more noise than signal. Requires ongoing maintenance; you lose upstream improvements to the default. |
Activation
- "Generate a
.review/extension.md for this repo"
- "Customize the code review for our project"
- "Help me write repo-specific review rules"
- "Set up the AI reviewer for this codebase"
- "Tailor the reviewer to our stack"
- "Bootstrap the extension file"
The parent ai-diff-reviewer skill also routes to this
sub-skill in two situations:
- Explicit intent — the developer asks for setup/customization
instead of running a review (any of the triggers above).
- Automatic bootstrap — the developer runs the review on a repo
with no
.review/extension.md and no .review/.skip-bootstrap
marker, and answers yes at the Step 2.5 prompt in the parent
skill. In this case, when this sub-skill finishes writing the file,
control returns to the parent skill's Step 2 which layers the fresh
extension onto the base prompt and continues the review.
Both entry paths run the same Discovery + Write flow below. Do not
skip Discovery just because the invocation came from the bootstrap
offer — the whole value of the extension is the file-anchored
Discovery evidence, not the file itself.
Step 0 — Confirm mode with the developer
If the developer hasn't specified, ask ONE clarifying question:
Two modes available:
- Extension (recommended) — I'll write
.review/extension.md with
overrides that LAYER on top of the shipped default prompt. Small
file (~50-150 lines), easy to iterate, benefits from upstream
improvements.
- Full replacement (advanced) — I'll write
.github/prompts/pr-review.md — a complete standalone prompt that
REPLACES the default. Large file (~200-500 lines), full control,
requires maintenance.
Which one? (Default: extension.)
Record the choice. If the developer just says "go ahead" or answers
ambiguously, default to extension.
Step 1 — Discovery (mandatory, ≥ 12 tool calls)
Before writing anything, spend real tool calls learning the repo.
Skimping here produces a generic file that could belong to any repo —
which is the failure mode. Cover ALL five areas:
1a. Technology stack
Read whichever of these apply to this repo:
package.json, pnpm-lock.yaml, yarn.lock, .nvmrc
pyproject.toml, requirements*.txt, poetry.lock, Pipfile
go.mod, go.sum
Cargo.toml, Cargo.lock
Gemfile, Gemfile.lock
pom.xml, build.gradle, build.sbt
composer.json, mix.exs, deno.json
Identify: primary language + version, web framework, ORM/DB, testing
tool, linter/formatter/type-checker, auth library, runtime target.
1b. Architecture & implementation
Read README.md, docs/ARCHITECTURE.md, AGENTS.md,
CONTRIBUTING.md, then walk 2 levels of the source tree with glob
and grep. Identify:
- Shape: monolith / monorepo / microservices / library / CLI / hybrid.
- Layering: MVC? hexagonal? domain-driven? layered? flat?
- HTTP entry point (routes / handlers / controllers) — WHERE.
- Domain-logic location.
- Shared utilities location.
- DI / IoC framework (if any).
- Migration story (Alembic / knex / ActiveRecord / Prisma / etc.).
- Async model (promises / async-await / coroutines / actors / queues).
1c. Security surface
Grep for these patterns and note WHERE they live:
- Auth / session / JWT / OAuth / cookies.
- Input parsing (form / query / body / GraphQL / gRPC endpoints).
- File uploads + downloads.
- Outbound HTTP / webhook code.
subprocess, os.system, child_process, shell exec, eval, exec.
- SQL query construction — parameterized vs string-concatenated.
- Secret handling (env vars, secret managers, config files).
- CSRF / CORS / rate-limit / CSP config.
- Cryptography (hashing algorithm, signing, encryption, PRNG).
- Serialization (
pickle, yaml.load without SafeLoader, unserialize).
For each pattern found, remember the file path — you'll reference it
by name in the output.
1d. Existing quality standards
Look for:
.pre-commit-config.yaml, .husky/, lefthook.yml
.github/workflows/*.yml (existing CI checks)
CODEOWNERS, RULES.md, STYLE_GUIDE.md
docs/STANDARDS.md, docs/DEVELOPMENT_GUIDELINES.md
.editorconfig, linter config files
Identify: lint/format rules, test-coverage floor, commit convention
(Conventional Commits / gitmoji), prohibited patterns already codified
(e.g. "no console.log on main", "no print in production code").
1e. Historical pain points
Skim CHANGELOG.md and — if you have gh CLI access —
gh issue list --state closed --limit 30 and
gh pr list --state merged --limit 20 --label bug. Anything that hit
production twice is a candidate for always critical.
Step 2 — Compose the output
Extension mode (.review/extension.md)
Target: ~50-150 lines. Structure:
# Review overrides for <repo-name>
<Optional one-paragraph context: what this repo does, why it's tricky,
what "good review" looks like here.>
## Severity overrides for this codebase
- **Always `critical`:** <concrete, code-anchored pattern>. Example:
`SELECT * FROM users` in a request path → PII exposure (RFC-014).
- **Always `critical`:** <another>. Cite the file(s) where this class
of code lives.
- **Escalate to `warning`:** <a pattern default treats as `info` but
matters more here>. Cite files.
- **De-escalate to `info`:** <a pattern default treats as `warning` we
chose to accept — reference the ADR / RFC that decided it>.
## Don't comment on
- Formatting in `apps/legacy/*` — scheduled rewrite per RFC-018.
- Missing tests in `experiments/` — intentionally exploratory.
- <Other project-specific noise sources>.
## Repo-specific conventions
- **Money handling:** use `Decimal` (Python) / `bignumber.js` / etc.,
NEVER `float`. Files: `src/billing/*`.
- **Auth headers:** always through `middleware/auth.ts`, never
hand-rolled. Any handler that reads `req.headers.authorization`
directly is `warning`.
- **DB migrations:** must be reversible; irreversible migrations need
an explicit `# noqa: irreversible` comment + RFC link.
- <Add 3-8 more, all tied to specific files or modules>.
## Test-strategy expectations
- New handlers in `src/api/*` require a matching integration test
under `tests/api/*`.
- New database migrations require a rollback test.
- <Other test conventions>.
Full-replacement mode (.github/prompts/pr-review.md)
Target: 200-500 lines. Follow the 7-section structure from the source
meta-prompt (kept upstream in
examples/prompts/generate-custom-prompt-meta.md
for reference):
- Role & mission (name the stack).
- Tool schema summary (describe
read_file / grep / glob /
post_inline_comment / submit_review — don't redefine, don't
embed JSON schema).
- How to think about each finding (read → hypothesize → verify →
assign severity → comment with WHY).
- Severity definitions (
critical / warning / info, each with
≥ 2 concrete, code-anchored examples from THIS repo).
- Project-specific overrides (the section that earns its keep — ≥ 5
overrides).
- Style & tone (polite, specific, factual, no sycophancy).
- Comment format (2–5 sentences, WHY first, cite line, suggest fix).
See examples.md for condensed samples pulled from the
examples/prompts/ full-replacement worked examples
(python-strict.md, security-focused.md, typescript-strict.md).
Step 3 — Generation rules (both modes)
- English only even if the codebase is in another language — the
LLM operates in English.
- Concrete over abstract. Every override must reference a real
file, module, or pattern you SAW during Discovery. "Anywhere handling
money uses
Decimal" is good; "financial precision matters" is bad.
- No secrets in the output. Never echo an env var, token, or
credential value. Reference their NAMES if needed (e.g.
"
STRIPE_SECRET_KEY is loaded via config/secrets.py") but never
the values.
- No content that could apply to any other repo. If a section
would survive copy-paste to a different codebase unchanged, delete
or rewrite it.
- No YAML frontmatter, no HTML comments in the output — the LLM
reads raw markdown. Start with
# (h1) and go from there.
- Do not embed the tool schema JSON. Describe the tools; the
runtime injects the actual schema.
Step 4 — Quality gate (self-check before writing the file)
Verify:
If any check fails, go back to Discovery — don't ship a mediocre
extension.
Step 5 — Write the file
Confirm the target path with the developer, then write it:
Extension mode:
mkdir -p .review
# Write the composed content to .review/extension.md via the harness's file-write tool.
Full-replacement mode:
mkdir -p .github/prompts
# Write to .github/prompts/pr-review.md via the harness's file-write tool.
If a file already exists at the target path, ASK before overwriting.
Offer to append to an existing extension file instead (adding new
overrides at the bottom, preserving what's there).
Step 6 — Explain the next steps
After writing, tell the developer:
For extension mode:
- Review the diff:
git diff .review/extension.md
- Optional — reference the same file from CI so local and CI stay in
sync:
# .github/workflows/pr-review.yml
- uses: DailybotHQ/ai-diff-reviewer@v2
with:
api-key: ${{ secrets.ANTHROPIC_API_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
prompt-extension-file: .review/extension.md
- Test the extension locally by running the
ai-diff-reviewer skill
("review my current branch") on a PR-shaped diff. If a rule fires
too aggressively or misses a case, come back and refine.
- Commit with a message like:
chore(review): add repo-tailored .review/extension.md
For full-replacement mode:
- Review the diff:
git diff .github/prompts/pr-review.md
- Reference the file in your workflow with
prompt-file: (NOT
prompt-extension-file: — this is the full replacement):- uses: DailybotHQ/ai-diff-reviewer@v2
with:
api-key: ${{ secrets.ANTHROPIC_API_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
prompt-file: .github/prompts/pr-review.md
- Also update the local skill's prompt to match: copy the same
file into
.review/extension.md OR configure the local skill to
read from .github/prompts/pr-review.md — otherwise local and CI
will drift.
- Expect 2-3 iterations of feedback before the prompt feels dialed in.
Notes
- Discovery is the bulk of the value. Two skills producing the
same extension for the same repo aren't fungible if one skimped on
Discovery — the concrete file-anchored overrides are what turns a
generic reviewer into a senior teammate.
- Extension is a living document. After the first review batch,
come back and add "Don't comment on" entries for false positives,
and add "Always
critical" entries for anything the reviewer
missed. A tune sub-skill for this iterative refinement is on the
roadmap.
- The 3 stack-flavored worked examples in
examples/prompts/
(python-strict.md, security-focused.md, typescript-strict.md)
are copy-paste-ready full-replacement prompts. Reference them in
Discovery as a smell-check: "would this override look at home in
those examples?"
1---2name: ai-diff-reviewer-generate-extension3description: Generates a repo-tailored review-configuration file (`.review/extension.md` by default, or a full replacement `prompt-file` in advanced mode) by inspecting THIS codebase — stack, architecture, security surface, existing conventions, historical pain points — and producing concrete, code-anchored severity overrides. Uses the harness's Read/Grep/Glob tools to gather evidence before writing (12+ tool calls minimum). Default output extends the bundled AI Diff Reviewer prompt with project-specific rules; advanced mode replaces it entirely. Use when the developer says "customize the review for this repo", "generate review rules", "help me write my .review/extension.md", or when the local `ai-diff-reviewer` skill activates on a repo that has no extension file yet.4---56# AI Diff Reviewer — Generate Extension (sub-skill)78Companion to the [`ai-diff-reviewer`](../SKILL.md) skill. Where9`ai-diff-reviewer` **runs** the review, this sub-skill **bootstraps the10configuration** — turning "here's the default reviewer" into "here's a11reviewer that understands OUR stack, OUR conventions, and OUR history of12bugs."1314**Two output modes:**1516| Mode | File written | When |17|---|---|---|18| **Extension** (default) | `.review/extension.md` | Almost always — the recommended path. Layers repo-specific overrides ON TOP of the battle-tested default prompt. Cheap iteration; the default keeps improving upstream. |19| **Full replacement** (advanced) | `.github/prompts/pr-review.md` | Rare — teams that want total control, or whose codebase is so idiosyncratic (proprietary DSL, unusual paradigm) that the default is more noise than signal. Requires ongoing maintenance; you lose upstream improvements to the default. |2021---2223## Activation2425- "Generate a `.review/extension.md` for this repo"26- "Customize the code review for our project"27- "Help me write repo-specific review rules"28- "Set up the AI reviewer for this codebase"29- "Tailor the reviewer to our stack"30- "Bootstrap the extension file"3132The parent [`ai-diff-reviewer`](../SKILL.md) skill also routes to this33sub-skill in two situations:34351. **Explicit intent** — the developer asks for setup/customization36 instead of running a review (any of the triggers above).372. **Automatic bootstrap** — the developer runs the review on a repo38 with no `.review/extension.md` and no `.review/.skip-bootstrap`39 marker, and answers **yes** at the Step 2.5 prompt in the parent40 skill. In this case, when this sub-skill finishes writing the file,41 control returns to the parent skill's Step 2 which layers the fresh42 extension onto the base prompt and continues the review.4344Both entry paths run the same Discovery + Write flow below. **Do not45skip Discovery** just because the invocation came from the bootstrap46offer — the whole value of the extension is the file-anchored47Discovery evidence, not the file itself.4849---5051## Step 0 — Confirm mode with the developer5253If the developer hasn't specified, ask ONE clarifying question:5455> **Two modes available:**56> - **Extension** (recommended) — I'll write `.review/extension.md` with57> overrides that LAYER on top of the shipped default prompt. Small58> file (~50-150 lines), easy to iterate, benefits from upstream59> improvements.60> - **Full replacement** (advanced) — I'll write61> `.github/prompts/pr-review.md` — a complete standalone prompt that62> REPLACES the default. Large file (~200-500 lines), full control,63> requires maintenance.64>65> Which one? (Default: **extension**.)6667Record the choice. If the developer just says "go ahead" or answers68ambiguously, default to **extension**.6970---7172## Step 1 — Discovery (mandatory, ≥ 12 tool calls)7374Before writing anything, spend real tool calls learning the repo.75Skimping here produces a generic file that could belong to any repo —76which is the failure mode. Cover ALL five areas:7778### 1a. Technology stack7980Read whichever of these apply to this repo:8182- `package.json`, `pnpm-lock.yaml`, `yarn.lock`, `.nvmrc`83- `pyproject.toml`, `requirements*.txt`, `poetry.lock`, `Pipfile`84- `go.mod`, `go.sum`85- `Cargo.toml`, `Cargo.lock`86- `Gemfile`, `Gemfile.lock`87- `pom.xml`, `build.gradle`, `build.sbt`88- `composer.json`, `mix.exs`, `deno.json`8990Identify: primary language + version, web framework, ORM/DB, testing91tool, linter/formatter/type-checker, auth library, runtime target.9293### 1b. Architecture & implementation9495Read `README.md`, `docs/ARCHITECTURE.md`, `AGENTS.md`,96`CONTRIBUTING.md`, then walk 2 levels of the source tree with `glob`97and `grep`. Identify:9899- Shape: monolith / monorepo / microservices / library / CLI / hybrid.100- Layering: MVC? hexagonal? domain-driven? layered? flat?101- HTTP entry point (routes / handlers / controllers) — WHERE.102- Domain-logic location.103- Shared utilities location.104- DI / IoC framework (if any).105- Migration story (Alembic / knex / ActiveRecord / Prisma / etc.).106- Async model (promises / async-await / coroutines / actors / queues).107108### 1c. Security surface109110Grep for these patterns and note WHERE they live:111112- Auth / session / JWT / OAuth / cookies.113- Input parsing (form / query / body / GraphQL / gRPC endpoints).114- File uploads + downloads.115- Outbound HTTP / webhook code.116- `subprocess`, `os.system`, `child_process`, shell exec, `eval`, `exec`.117- SQL query construction — parameterized vs string-concatenated.118- Secret handling (env vars, secret managers, config files).119- CSRF / CORS / rate-limit / CSP config.120- Cryptography (hashing algorithm, signing, encryption, PRNG).121- Serialization (`pickle`, `yaml.load` without `SafeLoader`, `unserialize`).122123For each pattern found, remember the file path — you'll reference it124by name in the output.125126### 1d. Existing quality standards127128Look for:129130- `.pre-commit-config.yaml`, `.husky/`, `lefthook.yml`131- `.github/workflows/*.yml` (existing CI checks)132- `CODEOWNERS`, `RULES.md`, `STYLE_GUIDE.md`133- `docs/STANDARDS.md`, `docs/DEVELOPMENT_GUIDELINES.md`134- `.editorconfig`, linter config files135136Identify: lint/format rules, test-coverage floor, commit convention137(Conventional Commits / gitmoji), prohibited patterns already codified138(e.g. "no `console.log` on `main`", "no `print` in production code").139140### 1e. Historical pain points141142Skim `CHANGELOG.md` and — if you have `gh` CLI access —143`gh issue list --state closed --limit 30` and144`gh pr list --state merged --limit 20 --label bug`. Anything that hit145production twice is a candidate for **always `critical`**.146147---148149## Step 2 — Compose the output150151### Extension mode (`.review/extension.md`)152153Target: ~50-150 lines. Structure:154155```markdown156# Review overrides for <repo-name>157158<Optional one-paragraph context: what this repo does, why it's tricky,159what "good review" looks like here.>160161## Severity overrides for this codebase162163- **Always `critical`:** <concrete, code-anchored pattern>. Example:164 `SELECT * FROM users` in a request path → PII exposure (RFC-014).165- **Always `critical`:** <another>. Cite the file(s) where this class166 of code lives.167- **Escalate to `warning`:** <a pattern default treats as `info` but168 matters more here>. Cite files.169- **De-escalate to `info`:** <a pattern default treats as `warning` we170 chose to accept — reference the ADR / RFC that decided it>.171172## Don't comment on173174- Formatting in `apps/legacy/*` — scheduled rewrite per RFC-018.175- Missing tests in `experiments/` — intentionally exploratory.176- <Other project-specific noise sources>.177178## Repo-specific conventions179180- **Money handling:** use `Decimal` (Python) / `bignumber.js` / etc.,181 NEVER `float`. Files: `src/billing/*`.182- **Auth headers:** always through `middleware/auth.ts`, never183 hand-rolled. Any handler that reads `req.headers.authorization`184 directly is `warning`.185- **DB migrations:** must be reversible; irreversible migrations need186 an explicit `# noqa: irreversible` comment + RFC link.187- <Add 3-8 more, all tied to specific files or modules>.188189## Test-strategy expectations190191- New handlers in `src/api/*` require a matching integration test192 under `tests/api/*`.193- New database migrations require a rollback test.194- <Other test conventions>.195```196197### Full-replacement mode (`.github/prompts/pr-review.md`)198199Target: 200-500 lines. Follow the 7-section structure from the source200meta-prompt (kept upstream in201[`examples/prompts/generate-custom-prompt-meta.md`](https://github.com/DailybotHQ/ai-diff-reviewer/blob/main/examples/prompts/generate-custom-prompt-meta.md)202for reference):2032041. Role & mission (name the stack).2052. Tool schema summary (describe `read_file` / `grep` / `glob` /206 `post_inline_comment` / `submit_review` — don't redefine, don't207 embed JSON schema).2083. How to think about each finding (read → hypothesize → verify →209 assign severity → comment with WHY).2104. Severity definitions (`critical` / `warning` / `info`, each with211 ≥ 2 concrete, code-anchored examples from THIS repo).2125. Project-specific overrides (the section that earns its keep — ≥ 5213 overrides).2146. Style & tone (polite, specific, factual, no sycophancy).2157. Comment format (2–5 sentences, WHY first, cite line, suggest fix).216217See [`examples.md`](examples.md) for condensed samples pulled from the218`examples/prompts/` full-replacement worked examples219(`python-strict.md`, `security-focused.md`, `typescript-strict.md`).220221---222223## Step 3 — Generation rules (both modes)2242251. **English only** even if the codebase is in another language — the226 LLM operates in English.2272. **Concrete over abstract.** Every override must reference a real228 file, module, or pattern you SAW during Discovery. "Anywhere handling229 money uses `Decimal`" is good; "financial precision matters" is bad.2303. **No secrets in the output.** Never echo an env var, token, or231 credential value. Reference their NAMES if needed (e.g.232 "`STRIPE_SECRET_KEY` is loaded via `config/secrets.py`") but never233 the values.2344. **No content that could apply to any other repo.** If a section235 would survive copy-paste to a different codebase unchanged, delete236 or rewrite it.2375. **No YAML frontmatter, no HTML comments in the output** — the LLM238 reads raw markdown. Start with `# ` (h1) and go from there.2396. **Do not embed the tool schema JSON.** Describe the tools; the240 runtime injects the actual schema.241242---243244## Step 4 — Quality gate (self-check before writing the file)245246Verify:247248- [ ] Extension mode: ≥ 5 severity overrides, ≥ 3 "don't comment on",249 ≥ 3 repo-specific conventions.250- [ ] Full-replacement mode: all 7 sections present; each severity251 level has ≥ 2 code-anchored examples.252- [ ] The output names the repo's language, framework, and 1–2253 distinctive libraries by name.254- [ ] No content that would survive unchanged in a different repo.255- [ ] No secrets, tokens, or credentials in the text.256- [ ] English only, well-structured markdown, one h1 at the top.257258If any check fails, go back to Discovery — don't ship a mediocre259extension.260261---262263## Step 5 — Write the file264265Confirm the target path with the developer, then write it:266267**Extension mode:**268```bash269mkdir -p .review270# Write the composed content to .review/extension.md via the harness's file-write tool.271```272273**Full-replacement mode:**274```bash275mkdir -p .github/prompts276# Write to .github/prompts/pr-review.md via the harness's file-write tool.277```278279If a file already exists at the target path, ASK before overwriting.280Offer to append to an existing extension file instead (adding new281overrides at the bottom, preserving what's there).282283---284285## Step 6 — Explain the next steps286287After writing, tell the developer:288289**For extension mode:**2902911. Review the diff: `git diff .review/extension.md`2922. Optional — reference the same file from CI so local and CI stay in293 sync:294 ```yaml295 # .github/workflows/pr-review.yml296 - uses: DailybotHQ/ai-diff-reviewer@v2297 with:298 api-key: ${{ secrets.ANTHROPIC_API_KEY }}299 github-token: ${{ secrets.GITHUB_TOKEN }}300 prompt-extension-file: .review/extension.md301 ```3023. Test the extension locally by running the `ai-diff-reviewer` skill303 ("review my current branch") on a PR-shaped diff. If a rule fires304 too aggressively or misses a case, come back and refine.3054. Commit with a message like:306 `chore(review): add repo-tailored .review/extension.md`307308**For full-replacement mode:**3093101. Review the diff: `git diff .github/prompts/pr-review.md`3112. Reference the file in your workflow with `prompt-file:` (NOT312 `prompt-extension-file:` — this is the full replacement):313 ```yaml314 - uses: DailybotHQ/ai-diff-reviewer@v2315 with:316 api-key: ${{ secrets.ANTHROPIC_API_KEY }}317 github-token: ${{ secrets.GITHUB_TOKEN }}318 prompt-file: .github/prompts/pr-review.md319 ```3203. **Also update the local skill's prompt** to match: copy the same321 file into `.review/extension.md` OR configure the local skill to322 read from `.github/prompts/pr-review.md` — otherwise local and CI323 will drift.3244. Expect 2-3 iterations of feedback before the prompt feels dialed in.325326---327328## Notes329330- **Discovery is the bulk of the value.** Two skills producing the331 same extension for the same repo aren't fungible if one skimped on332 Discovery — the concrete file-anchored overrides are what turns a333 generic reviewer into a senior teammate.334- **Extension is a living document.** After the first review batch,335 come back and add "Don't comment on" entries for false positives,336 and add "Always `critical`" entries for anything the reviewer337 missed. A `tune` sub-skill for this iterative refinement is on the338 roadmap.339- **The 3 stack-flavored worked examples** in340 [`examples/prompts/`](https://github.com/DailybotHQ/ai-diff-reviewer/tree/main/examples/prompts)341 (`python-strict.md`, `security-focused.md`, `typescript-strict.md`)342 are copy-paste-ready full-replacement prompts. Reference them in343 Discovery as a smell-check: "would this override look at home in344 those examples?"