/init-workflow — Bootstrap and Validate the Workflow
Run this skill inside a project once this plugin is installed. It
scaffolds whichever project-owned files are missing from this skill's
bundled templates — independently of one another, so a project can already
have its own AGENTS.md, its own CLAUDE.md, or none of it — then fills
them with this project's facts, interactively, and verifies the setup end
to end. It is idempotent — re-run it after a plugin update or whenever
setup drift is suspected, and it acts as a doctor, reporting what is
missing rather than redoing what is already filled.
Division of labor: this skill scaffolds, adapts, and validates
project-owned files. It never edits the plugin's own mechanism — the
skills, sub-agents, and the plugin's own documentation are off limits;
updates to those come from updating the plugin itself, not from this skill.
Ground rules:
- Propose, then write. Every value you detect is a proposal until the
user confirms it. Batch the confirmations (one round for the initial
scaffold, one for commands, one for AGENTS.md sections, one for review
and planning guidance) instead of asking one question at a time — Step 4's
own "do you already have docs?" question is a separate, necessarily-first
round of its own, since it decides what the rest of that step even asks.
Never invent facts about the project; where the user defers, leave an
explicit
[TODO: …] rather than a guess.
- Keep
AGENTS.md lean. You are filling a map, not writing the
territory — one line per command, one line per module, one bullet per
sensitive area. Depth belongs in docs/.
Step 1 — Scaffold if needed, then assess the current state
Every file under ${CLAUDE_SKILL_DIR}/templates/ maps to a
project-relative destination (this is the plugin's canonical enumeration —
see the file tree in the plugin's own documentation, kept in sync with this
directory by rule), except docs/agent-rules/code-critic.md and
docs/agent-rules/plan-critic.md, which Step 4 creates (or doesn't, if the
project already has equivalent docs) once it knows the answer; writing them
here too would leave an orphaned stub if Step 4 points elsewhere instead.
Check every other mapped file's destination on its own trigger — one
file's presence never gates another's, since a project can have
hand-written its own AGENTS.md long before adopting this plugin's review
gate, or vice versa:
- Destination missing → scaffold it. Strip the
.template suffix from
AGENTS.md.template and CLAUDE.md.template (landing at
AGENTS.md/CLAUDE.md) and from settings.json.template (landing at
.claude/settings.json, not project root) — on the destination copy
only; never strip it on the source inside templates/ itself, since an
un-suffixed AGENTS.md/CLAUDE.md left there would be auto-loaded by
Claude Code as this project's live guidance instead of a template. Copy
every other file (the rest of the docs/ tree) to the same relative
path it has under templates/.
- Destination exists as plain content (
AGENTS.md, docs/adr/*,
docs/product-context/*) → leave it untouched and list it as "already
present" in Step 6's report — never overwrite a file the project
already owns.
- Destination exists but needs special handling (
CLAUDE.md,
.claude/settings.json, githooks/pre-push, scripts/review-ok.sh,
scripts/check-hook-status.sh) — see immediately below.
CLAUDE.md. If it exists (e.g. from Claude Code's own /init) and
doesn't already contain @AGENTS.md, offer to append the import line —
never overwrite it with the template's version, and never append if the
import is already there (avoids a duplicate on a project that deleted
AGENTS.md but kept CLAUDE.md). If the user declines, report it in
Step 6 as a gap: CLAUDE.md won't load AGENTS.md's guidance into Claude
Code.
.claude/settings.json. A merge target, not a copy target — a
project-scope plugin install can create this file (recording the install
itself) before /init-workflow ever runs, so "already exists" here is a
common case, not the exception. If it exists, read it and propose adding
whichever of ${CLAUDE_SKILL_DIR}/templates/settings.json.template's
permissions.ask/permissions.deny entries aren't already present,
preserving everything else the file already has — never a flat overwrite.
If it doesn't exist, scaffold it directly from the template. If the
existing file doesn't parse as JSON, its root value isn't an object, or
permissions/permissions.ask/permissions.deny are present but not the
expected shape (an object, and two arrays), do not attempt a merge and do
not guess a fix — flag it as an unresolved item in this step's proposal
(the same way a hook conflict is flagged) and continue with the rest of
Step 1; a malformed pre-existing file on this security-relevant path needs
the user's own eyes, not an agent's improvised repair.
githooks/pre-push, scripts/review-ok.sh, scripts/check-hook-status.sh.
Two separate questions. The first is decided here and, once the step's
proposal is confirmed, written as part of that same single confirmation
round below — never before the user confirms. The second is evaluated
only after that write (or after the user declines it), as the first
thing in "continue below" once Step 1's proposal is confirmed and
written — never before, since its verdict is only meaningful against the
settled state, not a proposal still awaiting confirmation.
1. Is each of the three files, if it already exists, actually this
gate's own file? Check each independently: githooks/pre-push and
scripts/review-ok.sh each count as ours if their content references
.review-passed; scripts/check-hook-status.sh counts as ours if its
content references DEST_FOREIGN (a verdict string that appears only in
that script — unlike .review-passed or READY_TO_CONFIGURE, both of
which also appear in scripts/review-ok.sh's own logic, so neither is
unique enough to use here). This pair is not perfectly symmetric —
check-hook-status.sh necessarily contains the literal string
.review-passed too, since checking for that marker is its job — so a
contrived case (someone's check-hook-status.sh content placed at
githooks/pre-push) would misidentify as ours; accepted as a known,
low-probability gap rather than solved here.
- Any of the three is missing → scaffold it from the template,
preserving the executable bit.
- Any of the three exists but isn't ours → a real conflict, not a
benign "already present." Surface it explicitly and ask the user how to
proceed: replace it with the template's version, or explicitly decline.
For
githooks/pre-push specifically, do not offer to chain the
template's check into the existing script — a pre-push hook reads its
ref list from stdin exactly once, and a naively chained script can
silently consume it before the gate's own while read loop runs,
producing a hook that exits 0 on every push with no error. A declined
conflict is an open gap Step 6 must call out by name.
- Any of the three exists and is ours → leave it as is (Step 5 item 1
checks it's still executable).
2. Once question 1 has been written (or declined), is the gate actually
wired up? Don't hand-roll it: run
${CLAUDE_SKILL_DIR}/templates/scripts/check-hook-status.sh — the
plugin's own read-only copy, safe to run regardless of whether question
1's write happened, since a declined or not-yet-scaffolded
githooks/pre-push shouldn't stop this check — from the project root, and
act on its one-line verdict:
ACTIVE or NEEDS_CHMOD — already wired up (the second just
needs chmod +x, safe since the marker already identifies it as this
gate's file). Nothing else to do.
READY_TO_CONFIGURE — githooks/pre-push is ready but
core.hooksPath isn't wired to it. On a fresh project this is the
ordinary, expected state right after question 1's scaffold — offer
git config core.hooksPath githooks as the natural next step, not a
special case.
DEST_NEEDS_CHMOD — githooks/pre-push exists and is ours but
isn't executable; offer chmod +x.
UNCONFIGURED or DEST_FOREIGN — if question 1's proposal for
githooks/pre-push was declined, this is that same gap, already in
Step 6's report — don't report it a second time. If question 1 was
instead confirmed and written, this verdict is unexpected: the write
didn't take effect as intended, and that itself is what to report (Rule
2), not something to act on here.
FOREIGN — something else entirely already claims the active hook
slot (another hook manager, or core.hooksPath pointing at a directory
that isn't this project's own githooks/). Do not offer to change
core.hooksPath or replace anything; report exactly what the script
printed and leave reconciling it to the human — including, if they want
the two to coexist, that their existing hook would need to invoke
githooks/pre-push itself with correct stdin handling, not something to
draft on their behalf here.
Known limitation: check-hook-status.sh's marker check is a presence
check, not a version check, so a stale copy from before a later plugin
update still reads as ACTIVE; that gap is accepted for now, not solved
here.
Also append .review-passed, .qa-evidence/, and .workflow-log/ to
.gitignore if not already present (create the file if it doesn't exist)
— these are what the workflow writes locally and Step 5 checks for.
Known limitation: this step has no memory of a prior decline. A file the
user chose not to scaffold (e.g. a deleted docs/product-context/README.md
placeholder) is proposed again on the next run, since "destination missing"
can't distinguish "never created" from "deliberately removed." Confirming
"no" each time is the workaround until this needs solving properly.
Present the full proposal — files to scaffold, the .claude/settings.json
merge diff if any, the CLAUDE.md append if applicable, any hook or
settings conflict, and what's already present and left alone — in one
block for confirmation before writing anything, the same confirm-then-write
pattern as every other step here. Once confirmed and written, run question
2's gate-wiring check above and act on its verdict, then continue below.
Read AGENTS.md (whether just scaffolded or pre-existing). If it has a
Review & Planning Guidance section, read the files it names. A named
file that doesn't exist yet is not a Rule 2 failure to stop on here — it's
expected input to Step 4, whether AGENTS.md was just scaffolded (its two
entries default to docs/agent-rules/code-critic.md/plan-critic.md,
which Step 4 hasn't created yet) or pre-existing (a project adopting this
flow for the first time, whose named or default files may not exist
either); Step 5 item 7 decides separately, in whichever mode you end up in,
whether a still-missing file gets reported. Otherwise (no section at all)
check docs/agent-rules/code-critic.md and docs/agent-rules/plan-critic.md
directly. Classify each placeholder / [TODO: …] as filled or open.
- Mostly open → first-run mode: continue with Steps 2–4, then validate.
- Mostly filled → doctor mode: skip to Step 5, then report only what is
open or drifted.
Step 2 — Detect the commands, propose, confirm
Inspect the project's build configuration — whichever exist:
package.json scripts, Makefile, justfile, build.gradle(.kts),
pom.xml, pyproject.toml, Cargo.toml, go.mod, Gemfile,
docker-compose.yml. From them, propose values for every entry in
AGENTS.md → Commands:
- build / run-all-tests / all-checks / dev server / stop / single-test
example. Prefer wrapper commands (
make …, npm scripts, just …) over
raw tools — the wrapper may add environment setup the raw tool skips.
- app URL: from the dev-server config (port, host) if discoverable.
- default branch:
git symbolic-ref refs/remotes/origin/HEAD (fall back to
asking).
Present the full proposed Commands list in one block for the user to
confirm or correct. Flag any entry you could not derive — a missing stop
command or check command is common and worth an explicit decision (the
adversarial-qa and feature skills depend on them). After confirmation,
write the section, replacing the placeholders.
Step 3 — Fill the remaining AGENTS.md sections
For each still-open section, draft from evidence and confirm before writing:
- Project Overview: draft one paragraph from the project's README and
manifest (purpose, stack, key dependencies). Replace
[PROJECT_NAME]
in the title.
- Architecture: generate the top-level directory tree (source dirs
only — skip vendored/build output) with a one-line purpose per module,
inferred from its contents. Ask the user to correct wrong inferences —
a wrong map is worse than no map.
- Testing: name the framework(s) found, where tests live, and how to
run one (mirrors the single-test command).
- Sensitive Areas: propose candidates by scanning for the usual
expensive-mistake surfaces — auth/session/token code, security config,
route definitions, payment or billing flows, schema migrations, personal
data fields and their rendering paths, secret/config loading. One bullet
per confirmed area, naming a concrete file/package/pattern. This list
gates three workflow decisions (critic-skip, reviewer model escalation,
PR security flag) — an empty list disables those protections, so if the
user has no time now, leave the TODO in place and say so in the report.
- Rule 5 (project hygiene rule): ask whether one applies (e.g. reset a
dev database at session end); fill it or delete the placeholder.
Step 4 — Seed review and planning guidance
AGENTS.md's Review & Planning Guidance section takes exactly two
entries, labeled precisely Code review guidance and Planning guidance
(Step 5 and both skills key on these literal labels — do not paraphrase
them).
First ask: does this project already have docs for code review standards
and/or planning risk areas — a style guide, CONTRIBUTING.md, an
engineering handbook, anything like that? Handle each of the two
(code review guidance, planning guidance) independently based on the
answer:
- Doesn't have one → copy
${CLAUDE_SKILL_DIR}/templates/docs/agent-rules/code-critic.md
(or plan-critic.md) to the default path as the starting point — it
already carries the Rules/Checklist structure, the build-enforced-rules
doctrine, and the guidance comments; do not draft either file from
scratch. Interview briefly to fill it in, then point AGENTS.md's
section at it:
- Does the app hold personal data? Which categories are sensitive, and is
there a compliance doc? Which surfaces are public/unauthenticated? Any
identifiers public by design? Do any of the three privacy fitness tests
already exist?
→ fill the Privacy anchors section of
docs/agent-rules/code-critic.md.
- Any hard constraints the team already knows agents get wrong (framework
conventions, forbidden APIs, required registrations)?
→ add them as rules with severities, mirrored in the Checklist section.
- What are this product's highest-risk areas — the places where a generic
plan would miss something that matters here?
→ fill 4–7 lenses in
docs/agent-rules/plan-critic.md.
- Already has one → point
AGENTS.md's section at that existing file
instead of copying the template. Still ask the privacy/compliance
question above for code review guidance specifically — code-critic
binds its privacy rules to whatever ## Privacy anchors section it finds
in the named file (see that skill), so if the existing doc doesn't have
one, it needs a home. Offer to append a ## Privacy anchors section to
the end of the existing file (same heading the template uses, so
code-critic recognizes it the same way; clearly delineated as an
addition, not a rewrite of the user's own doc) — on the user's explicit
confirmation, since this edits a file they own that this plugin didn't
create. If they decline, say so plainly in the Step 6 report: privacy
anchors are not captured, and why. The hard-constraints and
high-risk-area questions are framed as "anything not already covered by
your existing doc" rather than a full draft, and only produce output if
the user has something to add.
Then present the drafted content (whichever combination of copied/filled
files, appended sections, and AGENTS.md pointer updates applies) in one
block for confirmation before writing — the same confirm-then-write
pattern as Steps 2 and 3; an answered question is input to the draft, not
approval of it. It is fine for newly filled files to stay thin beyond what
the interview produced — they are designed to accrete (see Evolving the
System in the AI Workflow plugin's own documentation). Record only what
the user confirms; keep the guidance comments in newly filled files for
future additions.
Step 5 — Validate the setup (doctor checklist)
Check each item and collect the results — fix only with the user's
confirmation, report what you cannot fix:
githooks/pre-push and scripts/review-ok.sh exist, are executable,
and their content references .review-passed; scripts/check-hook-status.sh
exists, is executable, and its content references DEST_FOREIGN (the
same three identity markers Step 1 uses) — existence alone isn't
enough; a foreign file at any of the three paths (see Step 1's identity
check) would pass an existence check while enforcing nothing or
behaving unpredictably.
- The pre-push review gate is active. Run
scripts/check-hook-status.sh
(the project's own copy, confirmed genuine by item 1) and map its
one-line verdict directly — this is the same script Step 1 and
scripts/review-ok.sh itself use, so there is nothing left to
hand-roll or re-derive here:
ACTIVE → pass.
NEEDS_CHMOD → offer chmod +x on the path the script printed (safe;
the marker already identifies it as this gate's file).
READY_TO_CONFIGURE → offer git config core.hooksPath githooks.
UNCONFIGURED, DEST_FOREIGN, or DEST_NEEDS_CHMOD → item 1 should
already have caught this (a missing or foreign githooks/pre-push);
if it didn't, that's the actual gap to report — don't act on this
verdict directly.
FOREIGN → do not offer to change core.hooksPath or replace
anything; report exactly what the script printed and leave
reconciling it to the human (see Step 1's note on why chaining isn't
offered).
CLAUDE.md exists and contains @AGENTS.md.
.gitignore covers .review-passed, .qa-evidence/, and
.workflow-log/.
.claude/settings.json has the ask rules for scripts/review-ok.sh
and the deny rules for the push-bypass flags.
AGENTS.md → Commands exists as a section and has no unfilled
placeholder remaining in it — a project whose hand-written AGENTS.md
never had a Commands section at all has nothing to flag as
"unfilled," but /feature, code-critic, and adversarial-qa all read
it by role and will fail at runtime without it; treat a missing section
the same as an unfilled placeholder (other sections may legitimately
keep TODOs the user deferred).
AGENTS.md has a Review & Planning Guidance section with entries
labeled exactly Code review guidance and Planning guidance — a
renamed or paraphrased label is invisible to both skills, which key on
the literal text, and silently falls back to the default
docs/agent-rules/ paths with no warning. Every file an entry names
must also actually exist: a missing section (or one missing an entry)
falls back to the default path if present; an entry that names a file
which doesn't exist runs that skill on base standards/lenses alone (it
does not fall back further to the default path) — either gap should
be surfaced, not left to fail silently on the next review.
Step 6 — Report
End with a short summary: what was written (file by file, including any
.claude/settings.json merge or CLAUDE.md import append), what already
existed and was left fully untouched (plain-content skips, or a
pre-existing gate script correctly identified as already this gate's),
any declined append or unresolved hook/settings conflict from Step 1 or
Step 5 item 2, what was deliberately deferred (the open TODOs and what
they disable), the doctor checklist results, and the suggested next
action — typically committing the setup changes, then starting the first
feature on a fresh branch with
/feature. For each item still open — including deferrals found in doctor
mode — offer to run the relevant step (2–4) for just that item now, so
deferred TODOs are re-offered on every run rather than silently carried
forward. Do not commit or push yourself unless the user asks — setup
changes deserve the user's own review. (If asked to push, Rule 4 in
AGENTS.md applies as always: code-critic pass, then scripts/review-ok.sh.)
1---2name: init-workflow3description: Bootstraps and validates the AI workflow in a project that has this plugin installed: scaffolds whichever project-owned files are missing, detects the project's commands, fills AGENTS.md, points it at review/planning guidance (seeding docs/agent-rules/ or reusing an existing doc), and verifies the review gate. Re-run any time as a doctor — it reports what is missing or drifted. (Named init-workflow so it does not collide with Claude Code's built-in /init command, which generates a CLAUDE.md.)4---56# /init-workflow — Bootstrap and Validate the Workflow78Run this skill inside a project once this plugin is installed. It9scaffolds whichever project-owned files are missing from this skill's10bundled templates — independently of one another, so a project can already11have its own `AGENTS.md`, its own `CLAUDE.md`, or none of it — then fills12them with *this* project's facts, interactively, and verifies the setup end13to end. It is idempotent — re-run it after a plugin update or whenever14setup drift is suspected, and it acts as a doctor, reporting what is15missing rather than redoing what is already filled.1617**Division of labor:** this skill scaffolds, adapts, and validates18project-owned files. It never edits the plugin's own mechanism — the19skills, sub-agents, and the plugin's own documentation are off limits;20updates to those come from updating the plugin itself, not from this skill.2122**Ground rules:**2324- **Propose, then write.** Every value you detect is a proposal until the25 user confirms it. Batch the confirmations (one round for the initial26 scaffold, one for commands, one for AGENTS.md sections, one for review27 and planning guidance) instead of asking one question at a time — Step 4's28 own "do you already have docs?" question is a separate, necessarily-first29 round of its own, since it decides what the rest of that step even asks.30 Never invent facts about the project; where the user defers, leave an31 explicit `[TODO: …]` rather than a guess.32- **Keep `AGENTS.md` lean.** You are filling a map, not writing the33 territory — one line per command, one line per module, one bullet per34 sensitive area. Depth belongs in `docs/`.3536---3738## Step 1 — Scaffold if needed, then assess the current state3940Every file under `${CLAUDE_SKILL_DIR}/templates/` maps to a41project-relative destination (this is the plugin's canonical enumeration —42see the file tree in the plugin's own documentation, kept in sync with this43directory by rule), **except** `docs/agent-rules/code-critic.md` and44`docs/agent-rules/plan-critic.md`, which Step 4 creates (or doesn't, if the45project already has equivalent docs) once it knows the answer; writing them46here too would leave an orphaned stub if Step 4 points elsewhere instead.47Check every other mapped file's destination on its **own** trigger — one48file's presence never gates another's, since a project can have49hand-written its own `AGENTS.md` long before adopting this plugin's review50gate, or vice versa:5152- **Destination missing → scaffold it.** Strip the `.template` suffix from53 `AGENTS.md.template` and `CLAUDE.md.template` (landing at54 `AGENTS.md`/`CLAUDE.md`) and from `settings.json.template` (landing at55 `.claude/settings.json`, **not** project root) — on the destination copy56 only; never strip it on the source inside `templates/` itself, since an57 un-suffixed `AGENTS.md`/`CLAUDE.md` left there would be auto-loaded by58 Claude Code as this project's live guidance instead of a template. Copy59 every other file (the rest of the `docs/` tree) to the same relative60 path it has under `templates/`.61- **Destination exists as plain content** (`AGENTS.md`, `docs/adr/*`,62 `docs/product-context/*`) → leave it untouched and list it as "already63 present" in Step 6's report — never overwrite a file the project64 already owns.65- **Destination exists but needs special handling** (`CLAUDE.md`,66 `.claude/settings.json`, `githooks/pre-push`, `scripts/review-ok.sh`,67 `scripts/check-hook-status.sh`) — see immediately below.6869**`CLAUDE.md`.** If it exists (e.g. from Claude Code's own `/init`) and70doesn't already contain `@AGENTS.md`, offer to append the import line —71never overwrite it with the template's version, and never append if the72import is already there (avoids a duplicate on a project that deleted73`AGENTS.md` but kept `CLAUDE.md`). If the user declines, report it in74Step 6 as a gap: `CLAUDE.md` won't load `AGENTS.md`'s guidance into Claude75Code.7677**`.claude/settings.json`.** A merge target, not a copy target — a78project-scope plugin install can create this file (recording the install79itself) before `/init-workflow` ever runs, so "already exists" here is a80common case, not the exception. If it exists, read it and propose adding81whichever of `${CLAUDE_SKILL_DIR}/templates/settings.json.template`'s82`permissions.ask`/`permissions.deny` entries aren't already present,83preserving everything else the file already has — never a flat overwrite.84If it doesn't exist, scaffold it directly from the template. If the85existing file doesn't parse as JSON, its root value isn't an object, or86`permissions`/`permissions.ask`/`permissions.deny` are present but not the87expected shape (an object, and two arrays), do not attempt a merge and do88not guess a fix — flag it as an unresolved item in this step's proposal89(the same way a hook conflict is flagged) and continue with the rest of90Step 1; a malformed pre-existing file on this security-relevant path needs91the user's own eyes, not an agent's improvised repair.9293**`githooks/pre-push`, `scripts/review-ok.sh`, `scripts/check-hook-status.sh`.**94Two separate questions. The first is decided here and, once the step's95proposal is confirmed, written as part of that same single confirmation96round below — never before the user confirms. The second is evaluated97only *after* that write (or after the user declines it), as the first98thing in "continue below" once Step 1's proposal is confirmed and99written — never before, since its verdict is only meaningful against the100settled state, not a proposal still awaiting confirmation.101102**1. Is each of the three files, if it already exists, actually this103gate's own file?** Check each independently: `githooks/pre-push` and104`scripts/review-ok.sh` each count as ours if their content references105`.review-passed`; `scripts/check-hook-status.sh` counts as ours if its106content references `DEST_FOREIGN` (a verdict string that appears only in107that script — unlike `.review-passed` or `READY_TO_CONFIGURE`, both of108which also appear in `scripts/review-ok.sh`'s own logic, so neither is109unique enough to use here). This pair is not perfectly symmetric —110`check-hook-status.sh` necessarily contains the literal string111`.review-passed` too, since checking for that marker is its job — so a112contrived case (someone's `check-hook-status.sh` content placed at113`githooks/pre-push`) would misidentify as ours; accepted as a known,114low-probability gap rather than solved here.115116- Any of the three is **missing** → scaffold it from the template,117 preserving the executable bit.118- Any of the three **exists but isn't ours** → a real conflict, not a119 benign "already present." Surface it explicitly and ask the user how to120 proceed: replace it with the template's version, or explicitly decline.121 For `githooks/pre-push` specifically, do **not** offer to chain the122 template's check into the existing script — a pre-push hook reads its123 ref list from stdin exactly once, and a naively chained script can124 silently consume it before the gate's own `while read` loop runs,125 producing a hook that exits 0 on every push with no error. A declined126 conflict is an open gap Step 6 must call out by name.127- Any of the three **exists and is ours** → leave it as is (Step 5 item 1128 checks it's still executable).129130**2. Once question 1 has been written (or declined), is the gate actually131wired up?** Don't hand-roll it: run132`${CLAUDE_SKILL_DIR}/templates/scripts/check-hook-status.sh` — the133plugin's own read-only copy, safe to run regardless of whether question1341's write happened, since a declined or not-yet-scaffolded135`githooks/pre-push` shouldn't stop this check — from the project root, and136act on its one-line verdict:137138- **`ACTIVE`** or **`NEEDS_CHMOD`** — already wired up (the second just139 needs `chmod +x`, safe since the marker already identifies it as this140 gate's file). Nothing else to do.141- **`READY_TO_CONFIGURE`** — `githooks/pre-push` is ready but142 `core.hooksPath` isn't wired to it. On a fresh project this is the143 ordinary, expected state right after question 1's scaffold — offer144 `git config core.hooksPath githooks` as the natural next step, not a145 special case.146- **`DEST_NEEDS_CHMOD`** — `githooks/pre-push` exists and is ours but147 isn't executable; offer `chmod +x`.148- **`UNCONFIGURED`** or **`DEST_FOREIGN`** — if question 1's proposal for149 `githooks/pre-push` was declined, this is that same gap, already in150 Step 6's report — don't report it a second time. If question 1 was151 instead confirmed and written, this verdict is unexpected: the write152 didn't take effect as intended, and that itself is what to report (Rule153 2), not something to act on here.154- **`FOREIGN`** — something else entirely already claims the active hook155 slot (another hook manager, or `core.hooksPath` pointing at a directory156 that isn't this project's own `githooks/`). Do **not** offer to change157 `core.hooksPath` or replace anything; report exactly what the script158 printed and leave reconciling it to the human — including, if they want159 the two to coexist, that their existing hook would need to invoke160 `githooks/pre-push` itself with correct stdin handling, not something to161 draft on their behalf here.162163Known limitation: `check-hook-status.sh`'s marker check is a presence164check, not a version check, so a stale copy from before a later plugin165update still reads as `ACTIVE`; that gap is accepted for now, not solved166here.167168Also append `.review-passed`, `.qa-evidence/`, and `.workflow-log/` to169`.gitignore` if not already present (create the file if it doesn't exist)170— these are what the workflow writes locally and Step 5 checks for.171172Known limitation: this step has no memory of a prior decline. A file the173user chose not to scaffold (e.g. a deleted `docs/product-context/README.md`174placeholder) is proposed again on the next run, since "destination missing"175can't distinguish "never created" from "deliberately removed." Confirming176"no" each time is the workaround until this needs solving properly.177178Present the full proposal — files to scaffold, the `.claude/settings.json`179merge diff if any, the `CLAUDE.md` append if applicable, any hook or180settings conflict, and what's already present and left alone — in one181block for confirmation before writing anything, the same confirm-then-write182pattern as every other step here. Once confirmed and written, run question1832's gate-wiring check above and act on its verdict, then continue below.184185Read `AGENTS.md` (whether just scaffolded or pre-existing). If it has a186**Review & Planning Guidance** section, read the files it names. A named187file that doesn't exist yet is not a Rule 2 failure to stop on here — it's188expected input to Step 4, whether `AGENTS.md` was just scaffolded (its two189entries default to `docs/agent-rules/code-critic.md`/`plan-critic.md`,190which Step 4 hasn't created yet) or pre-existing (a project adopting this191flow for the first time, whose named or default files may not exist192either); Step 5 item 7 decides separately, in whichever mode you end up in,193whether a still-missing file gets reported. Otherwise (no section at all)194check `docs/agent-rules/code-critic.md` and `docs/agent-rules/plan-critic.md`195directly. Classify each placeholder / `[TODO: …]` as filled or open.196197- Mostly open → **first-run mode**: continue with Steps 2–4, then validate.198- Mostly filled → **doctor mode**: skip to Step 5, then report only what is199 open or drifted.200201## Step 2 — Detect the commands, propose, confirm202203Inspect the project's build configuration — whichever exist:204`package.json` scripts, `Makefile`, `justfile`, `build.gradle(.kts)`,205`pom.xml`, `pyproject.toml`, `Cargo.toml`, `go.mod`, `Gemfile`,206`docker-compose.yml`. From them, propose values for every entry in207`AGENTS.md` → *Commands*:208209- build / run-all-tests / all-checks / dev server / stop / single-test210 example. Prefer wrapper commands (`make …`, npm scripts, `just …`) over211 raw tools — the wrapper may add environment setup the raw tool skips.212- app URL: from the dev-server config (port, host) if discoverable.213- default branch: `git symbolic-ref refs/remotes/origin/HEAD` (fall back to214 asking).215216Present the full proposed Commands list in one block for the user to217confirm or correct. Flag any entry you could not derive — a missing stop218command or check command is common and worth an explicit decision (the219adversarial-qa and feature skills depend on them). After confirmation,220write the section, replacing the placeholders.221222## Step 3 — Fill the remaining AGENTS.md sections223224For each still-open section, draft from evidence and confirm before writing:225226- **Project Overview**: draft one paragraph from the project's README and227 manifest (purpose, stack, key dependencies). Replace `[PROJECT_NAME]`228 in the title.229- **Architecture**: generate the top-level directory tree (source dirs230 only — skip vendored/build output) with a one-line purpose per module,231 inferred from its contents. Ask the user to correct wrong inferences —232 a wrong map is worse than no map.233- **Testing**: name the framework(s) found, where tests live, and how to234 run one (mirrors the single-test command).235- **Sensitive Areas**: propose candidates by scanning for the usual236 expensive-mistake surfaces — auth/session/token code, security config,237 route definitions, payment or billing flows, schema migrations, personal238 data fields and their rendering paths, secret/config loading. One bullet239 per confirmed area, naming a concrete file/package/pattern. This list240 gates three workflow decisions (critic-skip, reviewer model escalation,241 PR security flag) — an empty list disables those protections, so if the242 user has no time now, leave the TODO in place and say so in the report.243- **Rule 5** (project hygiene rule): ask whether one applies (e.g. reset a244 dev database at session end); fill it or delete the placeholder.245246## Step 4 — Seed review and planning guidance247248`AGENTS.md`'s `Review & Planning Guidance` section takes exactly two249entries, labeled precisely `Code review guidance` and `Planning guidance`250(Step 5 and both skills key on these literal labels — do not paraphrase251them).252253First ask: does this project already have docs for code review standards254and/or planning risk areas — a style guide, `CONTRIBUTING.md`, an255engineering handbook, anything like that? Handle each of the two256(code review guidance, planning guidance) independently based on the257answer:258259- **Doesn't have one** → copy `${CLAUDE_SKILL_DIR}/templates/docs/agent-rules/code-critic.md`260 (or `plan-critic.md`) to the default path as the starting point — it261 already carries the Rules/Checklist structure, the build-enforced-rules262 doctrine, and the guidance comments; do not draft either file from263 scratch. Interview briefly to fill it in, then point `AGENTS.md`'s264 section at it:265 - Does the app hold personal data? Which categories are sensitive, and is266 there a compliance doc? Which surfaces are public/unauthenticated? Any267 identifiers public by design? Do any of the three privacy fitness tests268 already exist?269 → fill the *Privacy anchors* section of `docs/agent-rules/code-critic.md`.270 - Any hard constraints the team already knows agents get wrong (framework271 conventions, forbidden APIs, required registrations)?272 → add them as rules with severities, mirrored in the *Checklist* section.273 - What are this product's highest-risk areas — the places where a generic274 plan would miss something that matters here?275 → fill 4–7 lenses in `docs/agent-rules/plan-critic.md`.276- **Already has one** → point `AGENTS.md`'s section at that existing file277 instead of copying the template. Still ask the privacy/compliance278 question above for code review guidance specifically — `code-critic`279 binds its privacy rules to whatever `## Privacy anchors` section it finds280 in the named file (see that skill), so if the existing doc doesn't have281 one, it needs a home. Offer to append a `## Privacy anchors` section to282 the *end* of the existing file (same heading the template uses, so283 `code-critic` recognizes it the same way; clearly delineated as an284 addition, not a rewrite of the user's own doc) — on the user's explicit285 confirmation, since this edits a file they own that this plugin didn't286 create. If they decline, say so plainly in the Step 6 report: privacy287 anchors are not captured, and why. The hard-constraints and288 high-risk-area questions are framed as "anything not already covered by289 your existing doc" rather than a full draft, and only produce output if290 the user has something to add.291292Then present the drafted content (whichever combination of copied/filled293files, appended sections, and `AGENTS.md` pointer updates applies) in one294block for confirmation before writing — the same confirm-then-write295pattern as Steps 2 and 3; an answered question is input to the draft, not296approval of it. It is fine for newly filled files to stay thin beyond what297the interview produced — they are designed to accrete (see *Evolving the298System* in the AI Workflow plugin's own documentation). Record only what299the user confirms; keep the guidance comments in newly filled files for300future additions.301302## Step 5 — Validate the setup (doctor checklist)303304Check each item and collect the results — fix only with the user's305confirmation, report what you cannot fix:3063071. `githooks/pre-push` and `scripts/review-ok.sh` exist, are executable,308 and their content references `.review-passed`; `scripts/check-hook-status.sh`309 exists, is executable, and its content references `DEST_FOREIGN` (the310 same three identity markers Step 1 uses) — existence alone isn't311 enough; a foreign file at any of the three paths (see Step 1's identity312 check) would pass an existence check while enforcing nothing or313 behaving unpredictably.3142. The pre-push review gate is active. Run `scripts/check-hook-status.sh`315 (the project's own copy, confirmed genuine by item 1) and map its316 one-line verdict directly — this is the same script Step 1 and317 `scripts/review-ok.sh` itself use, so there is nothing left to318 hand-roll or re-derive here:319 - `ACTIVE` → pass.320 - `NEEDS_CHMOD` → offer `chmod +x` on the path the script printed (safe;321 the marker already identifies it as this gate's file).322 - `READY_TO_CONFIGURE` → offer `git config core.hooksPath githooks`.323 - `UNCONFIGURED`, `DEST_FOREIGN`, or `DEST_NEEDS_CHMOD` → item 1 should324 already have caught this (a missing or foreign `githooks/pre-push`);325 if it didn't, that's the actual gap to report — don't act on this326 verdict directly.327 - `FOREIGN` → do **not** offer to change `core.hooksPath` or replace328 anything; report exactly what the script printed and leave329 reconciling it to the human (see Step 1's note on why chaining isn't330 offered).3313. `CLAUDE.md` exists and contains `@AGENTS.md`.3324. `.gitignore` covers `.review-passed`, `.qa-evidence/`, and333 `.workflow-log/`.3345. `.claude/settings.json` has the `ask` rules for `scripts/review-ok.sh`335 and the `deny` rules for the push-bypass flags.3366. `AGENTS.md` → *Commands* exists as a section and has no unfilled337 placeholder remaining in it — a project whose hand-written `AGENTS.md`338 never had a *Commands* section at all has nothing to flag as339 "unfilled," but `/feature`, `code-critic`, and `adversarial-qa` all read340 it by role and will fail at runtime without it; treat a missing section341 the same as an unfilled placeholder (other sections may legitimately342 keep TODOs the user deferred).3437. `AGENTS.md` has a `Review & Planning Guidance` section with entries344 labeled exactly `Code review guidance` and `Planning guidance` — a345 renamed or paraphrased label is invisible to both skills, which key on346 the literal text, and silently falls back to the default347 `docs/agent-rules/` paths with no warning. Every file an entry names348 must also actually exist: a missing section (or one missing an entry)349 falls back to the default path if present; an entry that names a file350 which doesn't exist runs that skill on base standards/lenses alone (it351 does *not* fall back further to the default path) — either gap should352 be surfaced, not left to fail silently on the next review.353354## Step 6 — Report355356End with a short summary: what was written (file by file, including any357`.claude/settings.json` merge or `CLAUDE.md` import append), what already358existed and was left fully untouched (plain-content skips, or a359pre-existing gate script correctly identified as already this gate's),360any declined append or unresolved hook/settings conflict from Step 1 or361Step 5 item 2, what was deliberately deferred (the open TODOs and what362they disable), the doctor checklist results, and the suggested next363action — typically committing the setup changes, then starting the first364feature on a fresh branch with365`/feature`. For each item still open — including deferrals found in doctor366mode — offer to run the relevant step (2–4) for just that item now, so367deferred TODOs are re-offered on every run rather than silently carried368forward. Do not commit or push yourself unless the user asks — setup369changes deserve the user's own review. (If asked to push, Rule 4 in370`AGENTS.md` applies as always: code-critic pass, then `scripts/review-ok.sh`.)