create-anpunkit 2.0.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.
Files changed (66) hide show
  1. package/README.md +44 -0
  2. package/bin/cli.js +41 -0
  3. package/package.json +34 -0
  4. package/template/.claude/agents/debugger.md +47 -0
  5. package/template/.claude/agents/e2e-runner.md +63 -0
  6. package/template/.claude/agents/implementer.md +78 -0
  7. package/template/.claude/agents/infra-provisioner.md +159 -0
  8. package/template/.claude/agents/planner.md +78 -0
  9. package/template/.claude/agents/researcher.md +103 -0
  10. package/template/.claude/agents/synthesizer.md +74 -0
  11. package/template/.claude/agents/test-author.md +71 -0
  12. package/template/.claude/anpunkit-manifest.json +256 -0
  13. package/template/.claude/commands/infra.md +62 -0
  14. package/template/.claude/commands/log-decision.md +34 -0
  15. package/template/.claude/commands/log-issue.md +28 -0
  16. package/template/.claude/commands/overview.md +106 -0
  17. package/template/.claude/commands/phase.md +202 -0
  18. package/template/.claude/commands/quick.md +30 -0
  19. package/template/.claude/commands/replan.md +64 -0
  20. package/template/.claude/commands/store-wisdom.md +195 -0
  21. package/template/.claude/commands/synthesize.md +26 -0
  22. package/template/.claude/commands/unstuck.md +40 -0
  23. package/template/.claude/hooks/cursor-session-start.sh +14 -0
  24. package/template/.claude/hooks/pre-compact.sh +25 -0
  25. package/template/.claude/hooks/session-start.sh +135 -0
  26. package/template/.claude/hooks/subagent-stop.sh +11 -0
  27. package/template/.claude/settings.json +16 -0
  28. package/template/.claude/skills/caveman/SKILL.md +39 -0
  29. package/template/.claude/skills/grill-me/SKILL.md +10 -0
  30. package/template/.claude/skills/karpathy-guidelines/SKILL.md +34 -0
  31. package/template/.cursor/commands/infra.md +57 -0
  32. package/template/.cursor/commands/log-decision.md +29 -0
  33. package/template/.cursor/commands/log-issue.md +23 -0
  34. package/template/.cursor/commands/overview.md +102 -0
  35. package/template/.cursor/commands/phase.md +197 -0
  36. package/template/.cursor/commands/quick.md +25 -0
  37. package/template/.cursor/commands/replan.md +59 -0
  38. package/template/.cursor/commands/store-wisdom.md +191 -0
  39. package/template/.cursor/commands/synthesize.md +22 -0
  40. package/template/.cursor/commands/unstuck.md +36 -0
  41. package/template/.cursor/hooks.json +14 -0
  42. package/template/.cursor/rules/anpunkit.md +11 -0
  43. package/template/.gitattributes +12 -0
  44. package/template/AGENTS.md +216 -0
  45. package/template/CLAUDE.md +70 -0
  46. package/template/README.md +283 -0
  47. package/template/commands.src/infra.md +62 -0
  48. package/template/commands.src/log-decision.md +34 -0
  49. package/template/commands.src/log-issue.md +28 -0
  50. package/template/commands.src/overview.md +106 -0
  51. package/template/commands.src/phase.md +202 -0
  52. package/template/commands.src/quick.md +30 -0
  53. package/template/commands.src/replan.md +64 -0
  54. package/template/commands.src/store-wisdom.md +195 -0
  55. package/template/commands.src/synthesize.md +26 -0
  56. package/template/commands.src/unstuck.md +40 -0
  57. package/template/docker-compose.test.yml +34 -0
  58. package/template/docs/DESIGN_LOG.md +578 -0
  59. package/template/e2e/global-setup.ts +57 -0
  60. package/template/playwright.config.ts +28 -0
  61. package/template/scripts/auth-setup.sh +51 -0
  62. package/template/scripts/e2e-stack.sh +65 -0
  63. package/template/scripts/regression.sh +46 -0
  64. package/template/setup.sh +236 -0
  65. package/template/tests/phase-1/README.md +4 -0
  66. package/template/tests/regression/README.md +11 -0
@@ -0,0 +1,25 @@
1
+ Caveman ULTRA mode. Apply `karpathy-guidelines` skill.
2
+
3
+ Purpose: skip the orchestration tax for a 5-line fix.
4
+
5
+ Use `/quick` when ALL hold:
6
+ - change is small (under 30 lines) and obvious
7
+ - no new vertical slice
8
+ - no external service contract change
9
+ - not mid-phase
10
+
11
+ If any fail -> STOP, tell me, recommend `/phase`.
12
+ (Hard rule 11: never route phase-worthy work through `/quick` to dodge the RED gate.)
13
+
14
+ Steps:
15
+ 1. grep docs/ISSUES.md for anything related.
16
+ 2. Make the change. Smallest diff that works.
17
+ 3. Run it — lint/typecheck/smoke. Show me result.
18
+ 4. REGRESSION GUARD: run `scripts/regression.sh` (mock corpus). A break BLOCKS the
19
+ `/quick` — surface it to me and stop. No agent chain is added.
20
+ 5. Error you cannot fix in 2 tries -> STOP. Recommend `/phase`.
21
+ 6. Change revealed a bug -> `/log-issue`.
22
+ 7. ARCHITECTURE SELF-CHECK: touched an agent, hook, command, or workflow rule?
23
+ YES -> `/log-decision`.
24
+
25
+ No STATE.md rewrite, no synthesize, no /clear needed.
@@ -0,0 +1,59 @@
1
+ Caveman ULTRA mode.
2
+
3
+ Recommended: run from plan mode (Shift+Tab). Optional; the command stops for
4
+ your approval regardless.
5
+
6
+ Use when PLAN.md no longer matches reality. Change: $ARGUMENTS
7
+
8
+ ---
9
+
10
+ ## Steps
11
+
12
+ 1. PRE-FLIGHT. Read docs/STATE.md and docs/PLAN.md.
13
+ - Phase in progress -> tell me which. Ask: revise around it, or is it the
14
+ thing being changed? Do not silently rewrite a mid-execution phase.
15
+ - Done phases are FROZEN. /replan never edits or reorders done phases.
16
+ - Phase 0 (infra) is ALWAYS frozen once done.
17
+
18
+ 2. DESIGN RESEARCH CHECK. Scan $ARGUMENTS for signals that design research
19
+ is warranted before re-planning:
20
+ - A new external service is mentioned (Stripe, Twilio, a new Azure service, etc.)
21
+ - The change involves architecture (a new integration pattern, auth change, etc.)
22
+ - A service tier or quota change is implied
23
+
24
+ If ANY of these signals are present: dispatch `researcher` in DESIGN mode
25
+ with the specific new service/pattern as the DESIGN TOPICS list. Show me the
26
+ key findings before proceeding to step 3.
27
+
28
+ If none: proceed directly to step 3 (impl-research may still be dispatched
29
+ in step 3 for non-trivial changes per the original logic).
30
+
31
+ 3. IMPL RESEARCH if needed. If the change is non-trivial but design research
32
+ was not needed, dispatch `researcher` in IMPL mode to ground the re-plan
33
+ in facts.
34
+
35
+ 4. RE-PLAN. Dispatch `planner` with the change + current PLAN.md. It must:
36
+ - Keep done phases untouched.
37
+ - Insert / cut / split / merge / reorder only PENDING phases.
38
+ - Place new phases in correct DEPENDENCY order.
39
+ - Keep every phase a vertical slice with its own acceptance spec.
40
+ - Ensure the LAST pending phase still contains the deploy task block.
41
+ - Renumber pending phases if needed; update STATE.md `phase:` pointer.
42
+
43
+ 5. RECONCILE THE REGRESSION CORPUS (scoped to `tests/regression/`):
44
+ - A CUT phase -> retire its regression tests.
45
+ - A MERGE -> consolidate the merged phases' regression tests.
46
+ - A REORDER -> keep the tests as-is (contracts are phase-independent).
47
+ Do NOT touch phase-local `tests/phase-<n>/` here beyond renumbering dirs.
48
+ After reconciling, run `scripts/regression.sh --real` to confirm the
49
+ reconciled corpus still passes against live services. A failure -> surface it
50
+ and stop before approval.
51
+
52
+ 6. SHOW ME the revised phase list + the regression-corpus changes, and STOP for
53
+ approval.
54
+
55
+ 7. ARCHITECTURE SELF-CHECK: re-planning is not normally a kit-architecture
56
+ change. Only run /log-decision if the workflow itself changed (rare).
57
+
58
+ Report what changed: phases added / cut / split / reordered, and regression
59
+ tests retired / consolidated.
@@ -0,0 +1,191 @@
1
+ Caveman ULTRA mode. You are the ORCHESTRATOR.
2
+
3
+ Purpose: share what this project learned with all future projects.
4
+ Only resolved issues and completed research qualify. Open issues do NOT.
5
+
6
+ ---
7
+
8
+ ## PRE-FLIGHT
9
+
10
+ 1. Read `.claude/kb-config.json`.
11
+ - Not found -> STOP. Tell me: "KB not configured. Run setup.sh to set up the
12
+ shared KB repo, then retry /store-wisdom."
13
+ - Found -> extract `kb_path` and `kb_remote`.
14
+
15
+ 2. Expand `kb_path` (resolve `~` to home directory).
16
+ Verify the path exists and is a git repo (`git -C <path> status`).
17
+ - Fails -> STOP. Tell me the path is broken and to re-run setup.sh.
18
+
19
+ ---
20
+
21
+ ## STEP 1 — PULL LATEST KB
22
+
23
+ Run: `git -C <kb_path> pull --ff-only`
24
+
25
+ - Success -> continue.
26
+ - Conflict or diverged -> STOP. Tell me:
27
+ "KB has a conflict. Resolve manually in <kb_path>, then retry /store-wisdom."
28
+ - Offline (no network) -> WARN me, ask: "KB pull failed (offline?). Continue
29
+ with local KB copy, or abort?" Wait for answer.
30
+
31
+ ---
32
+
33
+ ## STEP 2 — ANALYZE LOCAL PROJECT
34
+
35
+ Scan this project for promotion candidates:
36
+
37
+ ### From docs/ISSUES.md — resolved issues only
38
+ - Read all entries marked `- [x] resolved`.
39
+ - Exclude: entries with no root cause filled in, entries without a solution.
40
+ - For each qualifying entry, note: title, symptom, root cause, solution,
41
+ failed attempts.
42
+
43
+ ### From docs/research/ — completed research files
44
+ - Read docs/research/INDEX.md. For each entry:
45
+ - Read the corresponding file.
46
+ - A research entry qualifies if: it documents an external service behavior,
47
+ API contract, SDK gotcha, architectural constraint, or cost finding that
48
+ would be useful in a different project.
49
+ - A research entry does NOT qualify if: it is a project-specific config
50
+ finding, a one-off trace with no generalizable conclusion, or a debug
51
+ trace (`debug-*.md`).
52
+ - Note: research entries get a `created:` timestamp (today's date if not
53
+ already present in the file). Staleness is measured from this date.
54
+
55
+ ### Cross-check against KB
56
+ - Read `<kb_path>/INDEX.md` (if it exists).
57
+ - For each candidate: does a matching slug already exist in the KB?
58
+ - YES, fresh entry: skip (already in KB, not stale).
59
+ - YES, stale entry (marked [STALE] in the snapshot): flag as REWRITE candidate.
60
+ - NO: flag as NEW candidate.
61
+
62
+ ---
63
+
64
+ ## STEP 3 — PROPOSE CANDIDATES
65
+
66
+ Present candidates one at a time. For each:
67
+ ```
68
+
69
+ [N of M] <type: NEW | REWRITE> — <slug>
70
+ Domain: <inferred path, e.g. azure/auth.md or databricks/sdk.md>
71
+ Tags: <tag1, tag2, tag3>
72
+ Action: <“new entry” | “replaces stale entry from YYYY-MM-DD”>
73
+
74
+ ## Preview:
75
+
76
+ ## [<slug>]
77
+
78
+ ## created: <YYYY-MM-DD>
79
+ tags: <tags>
80
+ symptom/context: <…>
81
+ root-cause / finding: <…>
82
+ fix / recommendation: <…>
83
+
84
+ [APPROVE / EDIT / SKIP]
85
+
86
+ ```
87
+ - APPROVE: add to approved list.
88
+ - EDIT: ask me for the edit, apply it, re-show, wait for APPROVE or SKIP.
89
+ - SKIP: discard this candidate.
90
+
91
+ After all candidates: show me the summary:
92
+ ```
93
+
94
+ Approved: <N> entries
95
+ Skipped: <M> entries
96
+ Domains to write: <list>
97
+ New domain folders to create: <list or “none”>
98
+ Proceed? [yes / abort]
99
+
100
+ ```
101
+ Wait for "yes" before writing anything.
102
+
103
+ ---
104
+
105
+ ## STEP 4 — WRITE TO KB
106
+
107
+ For each approved entry:
108
+
109
+ 1. Determine the domain file path: `<kb_path>/<domain>/<file>.md`
110
+ - If the directory does not exist: create it.
111
+ - If the file does not exist: create it with a `# <domain> — <file>` header.
112
+
113
+ 2. REWRITE candidates: find the existing `## [<slug>]` block in the file and
114
+ replace it entirely with the new entry.
115
+
116
+ 3. NEW candidates: append the entry to the end of the domain file.
117
+
118
+ 4. Update `<kb_path>/INDEX.md`:
119
+ - For NEW entries: append a line:
120
+ `YYYY-MM-DD | <domain>/<file> | <slug> | <one-sentence summary>`
121
+ - For REWRITE entries: update the existing line in-place (new date, same slug).
122
+
123
+ 5. If this is the first `/store-wisdom` run (no INDEX.md existed):
124
+ Also create `<kb_path>/KB_GUIDE.md` with the entry format reference:
125
+
126
+ ```markdown
127
+ # anpunkit-kb — guide
128
+
129
+ This repo accumulates resolved issues and research findings from anpunkit projects.
130
+ Populated by `/store-wisdom`. Read by the anpunkit `researcher` agent at session start.
131
+
132
+ ## Entry format — issues
133
+ ## [slug]
134
+ created: YYYY-MM-DD
135
+ tags: tag1, tag2
136
+ symptom: what was observed
137
+ root-cause: the real underlying cause
138
+ fix: exact solution
139
+ failed-attempts: what did not work
140
+
141
+ ## Entry format — research
142
+ ## [slug]
143
+ created: YYYY-MM-DD
144
+ tags: tag1, tag2
145
+ symptom/context: what prompted the research
146
+ finding: what was discovered
147
+ recommendation: what to do
148
+
149
+ ## INDEX.md format
150
+ YYYY-MM-DD | domain/file | slug | one-sentence summary
151
+
152
+ ## Staleness
153
+ Research entries older than 6 months are flagged [STALE] at session load.
154
+ Stale entries are re-researched locally and rewritten via /store-wisdom.
155
+ Issue entries never go stale.
156
+ ```
157
+
158
+ -----
159
+
160
+ ## STEP 5 — COMMIT AND PUSH
161
+
162
+ Run from `<kb_path>`:
163
+
164
+ ```bash
165
+ git add -A
166
+ git commit -m "store-wisdom: <N> entries from <project-name> (<YYYY-MM-DD>)"
167
+ git push
168
+ ```
169
+
170
+ - Push success -> tell me:
171
+
172
+ ```
173
+ KB updated.
174
+ - entries written: <N> (<list of slugs>)
175
+ - domains touched: <list>
176
+ - new domains created: <list or "none">
177
+ - pushed to: <kb_remote>
178
+ ```
179
+ - Push fails -> tell me the push failed, show the git error.
180
+ The entries ARE written locally — tell me to push manually:
181
+ `git -C <kb_path> push`
182
+
183
+ -----
184
+
185
+ ## NOTES
186
+
187
+ - `/store-wisdom` never modifies docs/ISSUES.md or docs/research/ in this project.
188
+ It reads them; it does not change them.
189
+ - If there are no qualifying candidates, tell me so and stop. Do not push an empty commit.
190
+ - The KB is append-only except for REWRITE of stale research entries.
191
+ Issue entries are never deleted or overwritten — they are facts.
@@ -0,0 +1,22 @@
1
+ Caveman ULTRA mode.
2
+
3
+ Trigger: end of a phase, or any time STATE.md / ISSUES.md feel bloated.
4
+
5
+ Dispatch the `synthesizer` subagent.
6
+
7
+ For a normal phase: it rewrites STATE.md, dedups ISSUES.md, prunes snapshots,
8
+ appends to HISTORY.md.
9
+
10
+ For the FINAL phase (no further pending phases): also pass the signal
11
+ "FINAL PHASE" so the synthesizer runs the extended pass — updating OVERVIEW.md
12
+ and README.md to reflect the completed project state.
13
+
14
+ To determine if this is the final phase: read docs/PLAN.md. If no phases remain
15
+ with status "pending" after the current one, it is the final phase.
16
+
17
+ When synthesizer returns "safe to /clear: yes", tell me:
18
+ - before/after line counts
19
+ - whether the final-pass ran
20
+ - that I can now run /clear (or proceed to the endpoint summary if final phase)
21
+
22
+ If it returns anything unsafe, show me what and stop.
@@ -0,0 +1,36 @@
1
+ Caveman ULTRA mode.
2
+
3
+ Trigger: I chose "re-research" at a circuit breaker (see /phase step 5).
4
+
5
+ Steps:
6
+
7
+ 1. WRITE IT DOWN. Append to docs/ISSUES.md as OPEN:
8
+ ```
9
+
10
+ ### <error title>
11
+
12
+ - [ ] open - stuck after 3 attempts
13
+ - symptom: <…>
14
+ - attempts that FAILED: <hypothesis 1>, <2>, <3>
15
+
16
+ ```
17
+ Reference the existing debug-<slug>.md.
18
+
19
+ 2. RESET FRAME. The 3 failed hypotheses are probably all wrong. Discard them.
20
+
21
+ 3. DEEP RESEARCH. Dispatch `researcher` in IMPL mode WIDE:
22
+ - Read existing debug-<slug>.md and ISSUES.md failed-attempts FIRST.
23
+ - Re-read the actual error from scratch.
24
+ - Check real external service contract / docs.
25
+ - Look one layer below: config? env? version? data shape?
26
+ - Return fresh HYPOTHESIS backed by NEW evidence.
27
+
28
+ 4. RE-PLAN if needed. Research shows phase design was wrong -> dispatch planner.
29
+
30
+ 5. RESUME. Hand fresh hypothesis to `debugger`. It reads the prior debug file
31
+ (already knows what's ruled out). Budget = 3, NEW hypotheses only.
32
+
33
+ 6. This counts as the path chosen at the first breaker. If STUCK again ->
34
+ /phase step 5 SECOND STUCK. Do not loop further.
35
+
36
+ Report each step.
@@ -0,0 +1,14 @@
1
+ {
2
+ "version": 1,
3
+ "hooks": {
4
+ "sessionStart": [
5
+ { "command": "bash .claude/hooks/cursor-session-start.sh" }
6
+ ],
7
+ "preCompact": [
8
+ { "command": "bash .claude/hooks/pre-compact.sh" }
9
+ ],
10
+ "subagentStop": [
11
+ { "command": "bash .claude/hooks/subagent-stop.sh" }
12
+ ]
13
+ }
14
+ }
@@ -0,0 +1,11 @@
1
+ ---
2
+ description: anpunkit methodology — load on every session.
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # anpunkit
7
+
8
+ Methodology, roles, procedures, rituals, and hard rules live in `@AGENTS.md`
9
+ at the repo root. Read it and follow it for all work in this repository.
10
+
11
+ @AGENTS.md
@@ -0,0 +1,12 @@
1
+ # Shell scripts MUST stay LF, even on Windows.
2
+ *.sh text eol=lf
3
+ *.bash text eol=lf
4
+ .claude/hooks/* text eol=lf
5
+ *.js text eol=lf
6
+ *.mjs text eol=lf
7
+ *.ts text eol=lf
8
+ *.json text eol=lf
9
+ *.md text eol=lf
10
+ *.ps1 text eol=crlf
11
+ *.cmd text eol=crlf
12
+ *.bat text eol=crlf
@@ -0,0 +1,216 @@
1
+ # anpunkit — portable agent methodology (single source of truth)
2
+
3
+ <!-- ANPUNKIT-AGENTS-SENTINEL-v2.0 -->
4
+ > **SENTINEL.** The HTML comment above (`ANPUNKIT-AGENTS-SENTINEL-v2.0`) is a
5
+ > load-bearing marker. `setup.sh` greps for it to confirm this file resolved on
6
+ > disk and was not clobbered. Do not remove or rename it.
7
+
8
+ > **What this file is.** The complete, tool-agnostic methodology for the anpunkit
9
+ > workflow: the loop, the roles, the procedures, the rituals, and the hard rules.
10
+ > This is the ONE place every rule lives. Claude Code, Cursor, and any tool that
11
+ > reads the open `AGENTS.md` standard get the full methodology from here.
12
+
13
+ > **Anti-drift invariant (load-bearing).** Every rule lives in exactly ONE place:
14
+ > this file. `CLAUDE.md` restates NO rule — it only maps roles to Claude-native
15
+ > files and says "native mechanism X performs ritual Y automatically." A rule and
16
+ > its automation may never contradict. Duplication between files is an
17
+ > architectural defect, not a convenience.
18
+
19
+ Caveman ULTRA mode always on. Apply the `karpathy-guidelines` skill (engineering
20
+ discipline) on every coding and debugging task.
21
+
22
+ -----
23
+
24
+ ## The loop
25
+
26
+ `design-research -> grill (×2) -> plan -> implement -> test -> deploy`, one
27
+ VERTICAL SLICE per phase. Implement AND test a phase before the next. The last
28
+ phase always includes deployment.
29
+
30
+ A phase runs in one of two orders, chosen at RESEARCH time by the TDD
31
+ APPLICABILITY check (see Procedures → `phase`):
32
+
33
+ - **TDD phase** (`TDD_PHASE=true`):
34
+ `RESEARCH -> SCAFFOLD -> RED -> GREEN -> TEST(e2e) -> FIX -> CLOSE`
35
+ - **Non-TDD phase** (pure infra / config / doc — `TDD_PHASE=false`):
36
+ `RESEARCH -> IMPLEMENT -> TEST -> FIX -> CLOSE`
37
+
38
+ `TDD_PHASE` = "the phase adds or changes a public callable surface (an endpoint,
39
+ exported function/class, CLI command, or message contract) that is assertable
40
+ from the acceptance spec." Size is NOT the criterion. On ambiguity, default
41
+ `TDD_PHASE=true` AND state the classification + reason so a human can override to
42
+ non-TDD before SCAFFOLD fires.
43
+
44
+ -----
45
+
46
+ ## Roles (fresh-context workers)
47
+
48
+ Each role is a fresh-context worker. Where the host tool supports named subagents
49
+ (Claude Code natively; Cursor reads the same `.claude/agents/` files via its
50
+ Claude-compatibility path), each maps to a definition file. Where it does not, the role
51
+ degrades to a bounded sub-task that dumps its noise to a file and returns only a
52
+ terse summary + path. Workers cannot address the user — only the orchestrator
53
+ can. Escalation is at most two hops.
54
+
55
+ - **researcher** — two modes. DESIGN: domain/constraint research before planning
56
+ (service limits, API contracts, architectural constraints, cost surprises).
57
+ IMPL: per-phase codebase + service investigation. Checks the shared KB snapshot
58
+ first (step 0). Writes findings to `docs/research/`; returns terse summary + path.
59
+ - **planner** — research → vertical-slice `docs/PLAN.md`. Phase 0 (infra) always
60
+ first; the last phase always contains the deploy task.
61
+ - **infra-provisioner** — generates Bicep, runs `az deployment what-if`, applies
62
+ only on human approval, writes `docs/INFRA.md` + `.env.test`.
63
+ - **implementer** — builds ONE phase. Two MODES for TDD phases (SCAFFOLD: stubs
64
+ only; FILL: logic to green) plus a legacy full-build mode for non-TDD phases.
65
+ Writes code, never tests. Maintains `docs/ENDPOINTS.md` each phase.
66
+ - **test-author** — writes tests BLIND (never reads implementation logic). On TDD
67
+ phases it is dispatched BEFORE logic exists (RED-first), so blindness is
68
+ structural, not honor-system. Writes a MOCK suite + a REAL API suite.
69
+ - **e2e-runner** — writes/runs functional browser E2E (Playwright) BLIND. Reads
70
+ `docs/INFRA.md` for the target.
71
+ - **debugger** — debugs in an ISOLATED context. Writes a trace to
72
+ `docs/research/debug-<slug>.md`; returns a summary.
73
+ - **synthesizer** — compresses `docs/STATE.md` / `docs/ISSUES.md`, prunes
74
+ snapshots. On the final phase, also updates `README.md` + `docs/OVERVIEW.md`.
75
+
76
+ The orchestrator ROUTES. It does not implement or debug.
77
+
78
+ -----
79
+
80
+ ## Procedures (the slash-command set)
81
+
82
+ Named procedures, each with a canonical body in `commands.src/<name>.md` and a
83
+ generated copy per tool (`.claude/commands/`, `.cursor/commands/`).
84
+
85
+ - **overview** — bootstrap a project: design-research → grill r1 → design-research
86
+ → re-grill r2 → `OVERVIEW.md` → planner → `PLAN.md` (Phase 0 always first).
87
+ - **infra** — provision/verify Azure infra: Bicep → what-if → human review → apply
88
+ → `INFRA.md` + `.env.test`.
89
+ - **phase [n]** — run one phase end-to-end with the circuit breaker. Chooses the
90
+ TDD or non-TDD order at RESEARCH. CLOSE runs the regression guard + ENDPOINTS
91
+ coverage gate.
92
+ - **quick [change]** — small, obvious, non-phase change; no agent chain. Stays
93
+ non-TDD. Runs the mock regression corpus after the change.
94
+ - **unstuck** — deep re-research after a circuit breaker (human-triggered).
95
+ - **synthesize** — compress STATE.md, dedup ISSUES.md, prune snapshots. Run
96
+ before a context reset.
97
+ - **replan** — revise `PLAN.md` (add/cut/split/merge/reorder pending phases) and
98
+ reconcile the regression corpus in step.
99
+ - **log-issue** — append an error to `ISSUES.md` with root cause + failed attempts.
100
+ - **log-decision** — record an architectural change in `docs/DESIGN_LOG.md`.
101
+ - **store-wisdom** — promote resolved issues + research to the shared KB.
102
+
103
+ -----
104
+
105
+ ## Rituals (model-run fallback for hooks)
106
+
107
+ Where the host tool can run lifecycle hooks (Claude Code, Cursor), these rituals
108
+ are AUTOMATED by hook scripts and must NOT be run by hand. Where the tool cannot
109
+ inject context, the model performs them itself.
110
+
111
+ ### SESSION-OPEN (start / clear / compact-resume)
112
+
113
+ At the start of every session, before any other work, surface:
114
+ 1. git state (branch, uncommitted count, last 3 commits).
115
+ 2. `docs/STATE.md` — the current position. READ THIS FIRST.
116
+ 3. open items in `docs/ISSUES.md`.
117
+ 4. `docs/research/INDEX.md` (research map) + infra status + auth nudge.
118
+ 5. shared KB: pull latest + load `docs/.kb-snapshot.md` if `.claude/kb-config.json`
119
+ exists.
120
+ 6. a one-line reminder of the hard rules below.
121
+
122
+ ### COMPRESS (before a context compaction)
123
+
124
+ Snapshot the live position to `docs/.snapshots/` so a post-compact session can
125
+ recover: current phase, next action, open blocker.
126
+
127
+ -----
128
+
129
+ ## Hard rules (1–11)
130
+
131
+ 1. Before debugging ANY error: grep `docs/ISSUES.md` AND `docs/research/INDEX.md`.
132
+ The SESSION-OPEN ritual surfaces ISSUES.md — there is no excuse to miss it.
133
+ 2. Debug attempt cap = 3: WARN the user at attempt 2; the FIRST hard-stop at 3
134
+ STOPS and asks the user. No 4th in-place attempt.
135
+ 3. Every resolved error -> logged to `docs/ISSUES.md` with root cause + failed
136
+ attempts.
137
+ 4. End of phase -> synthesize -> context reset -> next phase.
138
+ 5. **PHASE GATE** = the current-phase REAL API suite passes AND (frontend phase)
139
+ the E2E suite passes AND the accumulated mock regression corpus stays green AND
140
+ every `docs/ENDPOINTS.md` entry has at least one test in `tests/regression/`.
141
+ The final phase additionally runs the full REAL regression corpus. A green
142
+ mock suite alone can never close a phase.
143
+ 6. Tests are written by `test-author`, which never sees the implementation logic
144
+ (unbiased). On TDD phases the suite is written before the logic (RED-first).
145
+ 7. Service outage is not a bug — `SERVICE UNAVAILABLE` / `AZURE UNAVAILABLE` /
146
+ `STACK NOT READY` / `FLAKE` do not spend the debug budget. Only `LOGIC FAIL`
147
+ reaches the debugger.
148
+ 8. E2E auth = ROPC with a dedicated MFA-excluded test account. NEVER script the
149
+ Microsoft login UI.
150
+ 9. Architectural change (new/removed agent, hook, command, or a changed workflow
151
+ rule)? -> run `log-decision` before closing.
152
+ 10. Azure project? Run `scripts/auth-setup.sh` ONCE per session before any Azure
153
+ work. Never debug an auth error without checking this first.
154
+ 11. **No-rationalization (scoped).** Do not downgrade a TDD phase to non-TDD to
155
+ dodge the RED gate, and do not route phase-worthy work through `quick` to
156
+ dodge it. (Scoped deliberately to these two seams; this is not a broad
157
+ "never make excuses" rule.)
158
+
159
+ -----
160
+
161
+ ## Shared KB (optional)
162
+
163
+ If `.claude/kb-config.json` exists, the SESSION-OPEN ritual pulls the KB and loads
164
+ a snapshot to `docs/.kb-snapshot.md`. The researcher checks the snapshot (step 0)
165
+ before any web search. Run `store-wisdom` to promote resolved issues + research to
166
+ the KB. The kit works normally without a KB.
167
+
168
+ -----
169
+
170
+ ## File contract
171
+
172
+ - `docs/STATE.md` — current position. Small. Rewritten, not appended.
173
+ - `docs/ISSUES.md` — error log. Deduped by synthesizer.
174
+ - `docs/PLAN.md` — the phase plan. Phase 0 (infra) always first; last phase has
175
+ the deploy task.
176
+ - `docs/HISTORY.md` — one line per finished phase.
177
+ - `docs/DESIGN_LOG.md` — kit architectural rationale (§5.x decision log).
178
+ - `docs/OVERVIEW.md` — project scope. Written after the double-grill in `overview`.
179
+ - `docs/INFRA.md` — Azure infra manifest: resource IDs, endpoints, cost estimates,
180
+ E2E target.
181
+ - `docs/ENDPOINTS.md` — API/service endpoint catalogue. Maintained by implementer
182
+ each phase. Drives the CLOSE coverage gate.
183
+ - `docs/research/` — full research + debug files. `INDEX.md` is the searchable map.
184
+ `design-<slug>.md` (design research), `<slug>.md` (impl research),
185
+ `debug-<slug>.md` (debugger traces).
186
+ - `docs/.snapshots/` — pre-compact recovery markers (auto-pruned, gitignored).
187
+ - `infra/` — Bicep templates. Committed (IaC audit trail). `infra/params.json`
188
+ holds no secrets.
189
+ - `e2e/`, `scripts/e2e-stack.sh`, `docker-compose.test.yml`, `playwright.config.ts`
190
+ — the E2E stack.
191
+ - `tests/phase-<n>/` — phase-local test suites.
192
+ - `tests/regression/` — cross-phase contract tests (the regression corpus). Run by
193
+ `scripts/regression.sh` (default mock; `--real` runs the real corpus).
194
+ - `scripts/auth-setup.sh` — session Azure credential check. Run once per session.
195
+ - `.claude/kb-config.json` — shared KB path + remote (optional, written by setup.sh).
196
+ - `docs/.kb-snapshot.md` — KB INDEX loaded this session (auto-generated, gitignored).
197
+
198
+ -----
199
+
200
+ ## Capability matrix (which tools get what)
201
+
202
+ - **Claude Code — full (reference implementation).** Generated commands; all three
203
+ lifecycle hooks WITH context injection (SessionStart / PreCompact / SubagentStop);
204
+ named subagents (`.claude/agents/*.md`); `@AGENTS.md` import; shared KB.
205
+ - **Cursor — full (verified against cursor.com/docs, 2026-06).** Generated
206
+ commands (`.cursor/commands/`); the three lifecycle hooks via `.cursor/hooks.json`
207
+ (sessionStart / preCompact / subagentStop) wired to the SAME shared hook scripts —
208
+ sessionStart injects context via a JSON-envelope wrapper
209
+ (`cursor-session-start.sh`); named subagents work natively because Cursor reads
210
+ `.claude/agents/*.md` directly (no duplication); methodology via a
211
+ `.cursor/rules/` pointer at this file. Known degradations: `model: haiku/opus`
212
+ tiers are Claude-specific (Cursor falls back to inherit/compatible), and Cursor's
213
+ preCompact is observational (the snapshot side-effect still runs; no context
214
+ modification).
215
+ - **Everything else.** Reads this `AGENTS.md` if it supports the open standard.
216
+ No generated adapters. Not claimed as supported in v2.0.
@@ -0,0 +1,70 @@
1
+ @AGENTS.md
2
+
3
+ # CLAUDE.md — Claude Code native wiring (thin shim)
4
+
5
+ > This file restates NO methodology. Every rule, role, procedure, and ritual
6
+ > lives in `AGENTS.md`, imported above via the bare `@AGENTS.md` line (the first
7
+ > non-comment line — `setup.sh` VERIFY checks it is bare, top-level, and
8
+ > unfenced). This shim only maps the methodology onto Claude Code's native
9
+ > mechanisms.
10
+
11
+ ## Subagent roster
12
+
13
+ The roles defined in AGENTS.md map to these Claude Code subagent files:
14
+
15
+ |Role |Definition file |Model tier|
16
+ |------------------|--------------------------------------|----------|
17
+ |researcher |`.claude/agents/researcher.md` |haiku |
18
+ |planner |`.claude/agents/planner.md` |opus |
19
+ |infra-provisioner |`.claude/agents/infra-provisioner.md` |opus |
20
+ |implementer |`.claude/agents/implementer.md` |opus |
21
+ |test-author |`.claude/agents/test-author.md` |opus |
22
+ |e2e-runner |`.claude/agents/e2e-runner.md` |opus |
23
+ |debugger |`.claude/agents/debugger.md` |opus |
24
+ |synthesizer |`.claude/agents/synthesizer.md` |haiku |
25
+
26
+ ## Hooks automate the AGENTS.md rituals
27
+
28
+ On Claude Code, do NOT run the SESSION-OPEN or COMPRESS rituals by hand — the
29
+ hooks (wired in `.claude/settings.json`) perform them:
30
+
31
+ - **SessionStart** (`.claude/hooks/session-start.sh`) automates SESSION-OPEN:
32
+ auto session-open + KB pull + STATE/ISSUES/research/infra injection into context.
33
+ - **PreCompact** (`.claude/hooks/pre-compact.sh`) automates COMPRESS: snapshots the
34
+ live position before compaction.
35
+ - **SubagentStop** (`.claude/hooks/subagent-stop.sh`) writes a subagent trace.
36
+
37
+ The same script bodies are wired for Cursor in `.cursor/hooks.json`; only the
38
+ wiring differs (Cursor's sessionStart expects JSON output, so it runs the shared
39
+ body through the `cursor-session-start.sh` envelope wrapper). Cursor also reads
40
+ `.claude/agents/*.md` natively for subagents — one set of role files serves both
41
+ tools.
42
+
43
+ ## /clear keeps hooks
44
+
45
+ `/clear` does not drop hooks — the wiring lives in `settings.json`, not in
46
+ context. After `/clear`, SessionStart fires again and re-injects state.
47
+
48
+ ## Skills resolution
49
+
50
+ - `karpathy-guidelines` — kit-owned (`.claude/skills/karpathy-guidelines/`).
51
+ - `caveman`, `grill-me` — global-authoritative if installed; the vendored copies
52
+ under `.claude/skills/` are a fallback only.
53
+
54
+ ## Platform notes
55
+
56
+ - **Windows / Git Bash.** Hooks are bash scripts. Hook commands use a BARE `bash`
57
+ prefix (`bash .claude/hooks/session-start.sh`) — never an explicit `bash.exe`
58
+ path (triggers a Claude Code argument-splitter bug). `.gitattributes` pins all
59
+ `.sh` files to LF. WSL runs the kit as-is.
60
+ - **Plan mode.** Run planning-heavy commands (`/overview`, `/replan`) from plan
61
+ mode (Shift+Tab).
62
+
63
+ ## Silent injection (Claude Code 2.1.x) + fresh-session test
64
+
65
+ On Claude Code 2.1.x the SessionStart injection may be silent (no visible banner).
66
+ That is normal. To verify hooks are live, in a fresh session ask:
67
+
68
+ > What does my STATE.md say, and how many open issues are in ISSUES.md?
69
+
70
+ A correct answer without Claude reading any file = hooks working.