create-agent-rig 0.4.0 → 0.5.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 (105) hide show
  1. package/CHANGELOG.md +207 -8
  2. package/README.md +50 -17
  3. package/package.json +2 -1
  4. package/packages/cli/dist/commands/create.js +8 -3
  5. package/packages/cli/dist/commands/init.js +82 -34
  6. package/packages/cli/dist/commands/upgrade.js +112 -30
  7. package/packages/cli/dist/index.js +38 -14
  8. package/packages/cli/dist/lib/copy-tree.js +35 -6
  9. package/packages/cli/dist/lib/init-settings.js +12 -0
  10. package/packages/cli/dist/lib/install-set.js +6 -8
  11. package/packages/cli/dist/lib/manifest.js +21 -9
  12. package/packages/cli/dist/lib/safe-path.js +30 -0
  13. package/templates/agent-os/init/AGENTS.md +191 -0
  14. package/templates/agent-os/init/CLAUDE.md +61 -9
  15. package/templates/agent-os/stack/aws-cdk/.agents/skills/post-deploy-verify/SKILL.md +98 -0
  16. package/templates/agent-os/stack/aws-cdk/.agents/skills/ro-debug/SKILL.md +117 -0
  17. package/templates/agent-os/stack/aws-cdk/.claude/agents/cdk-diff-reviewer.md +34 -3
  18. package/templates/agent-os/stack/aws-cdk/.claude/rules/aws-cdk.md +1 -1
  19. package/templates/agent-os/stack/aws-cdk/.claude/skills/post-deploy-verify/SKILL.md +34 -0
  20. package/templates/agent-os/stack/aws-cdk/.codex/agents/cdk-diff-reviewer.toml +4 -0
  21. package/templates/agent-os/universal/.agents/skills/check-premises/SKILL.md +233 -0
  22. package/templates/agent-os/universal/.agents/skills/loop/SKILL.md +676 -0
  23. package/templates/agent-os/universal/.agents/skills/new-invariant/SKILL.md +102 -0
  24. package/templates/agent-os/universal/.agents/skills/new-invariant/guard-invariant.example.mjs +78 -0
  25. package/templates/agent-os/universal/.agents/skills/new-invariant/guard-invariant.example.test.mjs +89 -0
  26. package/templates/agent-os/universal/.agents/skills/pr-ship/SKILL.md +338 -0
  27. package/templates/agent-os/universal/.agents/skills/worktree-task/SKILL.md +73 -0
  28. package/templates/agent-os/universal/.claude/agents/code-reviewer.md +33 -1
  29. package/templates/agent-os/universal/.claude/agents/prose-reviewer.md +64 -1
  30. package/templates/agent-os/universal/.claude/agents/security-scanner.md +33 -0
  31. package/templates/agent-os/universal/.claude/hooks/gate-stop-dod.mjs +274 -24
  32. package/templates/agent-os/universal/.claude/hooks/guard-bash.mjs +43 -5
  33. package/templates/agent-os/universal/.claude/hooks/guard-core-purity.mjs +25 -11
  34. package/templates/agent-os/universal/.claude/hooks/guard-secret-file.mjs +180 -0
  35. package/templates/agent-os/universal/.claude/hooks/guard-web-boundary.mjs +32 -13
  36. package/templates/agent-os/universal/.claude/hooks/inject-rules.mjs +175 -7
  37. package/templates/agent-os/universal/.claude/hooks/lib/edit-input.mjs +480 -0
  38. package/templates/agent-os/universal/.claude/rules/autonomy.md +61 -1
  39. package/templates/agent-os/universal/.claude/rules/invariants.md +71 -16
  40. package/templates/agent-os/universal/.claude/rules/workflow.md +55 -5
  41. package/templates/agent-os/universal/.claude/scripts/decision-router.mjs +1242 -0
  42. package/templates/agent-os/universal/.claude/scripts/detect-missed-gate.mjs +65 -2
  43. package/templates/agent-os/universal/.claude/scripts/git-env.mjs +49 -0
  44. package/templates/agent-os/universal/.claude/scripts/lib/secrets.mjs +490 -0
  45. package/templates/agent-os/universal/.claude/scripts/lib/verdict.mjs +433 -0
  46. package/templates/agent-os/universal/.claude/scripts/preflight.mjs +6 -16
  47. package/templates/agent-os/universal/.claude/scripts/queue/checkout.mjs +89 -0
  48. package/templates/agent-os/universal/.claude/scripts/queue/core.mjs +334 -23
  49. package/templates/agent-os/universal/.claude/scripts/queue/gate-rounds.mjs +160 -0
  50. package/templates/agent-os/universal/.claude/scripts/queue/github-issues.mjs +7 -2
  51. package/templates/agent-os/universal/.claude/scripts/queue/index.mjs +413 -8
  52. package/templates/agent-os/universal/.claude/scripts/queue/jira.mjs +75 -13
  53. package/templates/agent-os/universal/.claude/scripts/queue/plan-md.mjs +222 -21
  54. package/templates/agent-os/universal/.claude/scripts/queue/state.mjs +197 -0
  55. package/templates/agent-os/universal/.claude/scripts/run-journal.mjs +435 -0
  56. package/templates/agent-os/universal/.claude/scripts/run-state.mjs +441 -0
  57. package/templates/agent-os/universal/.claude/scripts/verdict.mjs +101 -0
  58. package/templates/agent-os/universal/.claude/settings.json +7 -2
  59. package/templates/agent-os/universal/.claude/skills/check-premises/SKILL.md +115 -7
  60. package/templates/agent-os/universal/.claude/skills/loop/SKILL.md +378 -31
  61. package/templates/agent-os/universal/.claude/skills/pr-ship/SKILL.md +300 -25
  62. package/templates/agent-os/universal/.codex/agents/code-reviewer.toml +4 -0
  63. package/templates/agent-os/universal/.codex/agents/prose-reviewer.toml +4 -0
  64. package/templates/agent-os/universal/.codex/agents/security-scanner.toml +4 -0
  65. package/templates/agent-os/universal/.codex/agents/test-writer.toml +4 -0
  66. package/templates/agent-os/universal/.codex/hooks.json +65 -0
  67. package/templates/agent-os/universal/AGENTS.md +164 -0
  68. package/templates/agent-os/universal/CLAUDE.md +47 -14
  69. package/templates/agent-os/universal/PLAN.md +7 -40
  70. package/templates/agent-os/universal/docs/decisions/closing-a-task.md +98 -0
  71. package/templates/agent-os/universal/docs/decisions/codex-adapter.md +108 -0
  72. package/templates/agent-os/universal/docs/decisions/fail-open-guards.md +43 -0
  73. package/templates/agent-os/universal/docs/decisions/review-lanes.md +72 -0
  74. package/templates/agent-os/universal/docs/decisions/run-directory.md +44 -0
  75. package/templates/agent-os/universal/docs/decisions/spacing-rations-mechanisms.md +125 -0
  76. package/templates/agent-os/universal/docs/decisions/stop-conditions-in-a-file.md +46 -0
  77. package/templates/agent-os/universal/docs/decisions/two-empty-endings.md +62 -0
  78. package/templates/agent-os/universal/journal/README.md +101 -0
  79. package/templates/agent-os/universal/layers.json +36 -2
  80. package/templates/hash-history.json +2 -1
  81. package/templates/skeleton/aws-serverless/.github/workflows/deploy.yml +34 -1
  82. package/templates/skeleton/aws-serverless/README.md +91 -9
  83. package/templates/skeleton/aws-serverless/apps/web/src/lib/api.ts +9 -2
  84. package/templates/skeleton/aws-serverless/gitignore +37 -0
  85. package/templates/skeleton/aws-serverless/infra/bin/app.ts +73 -13
  86. package/templates/skeleton/aws-serverless/infra/lib/app-stack.ts +136 -4
  87. package/templates/skeleton/aws-serverless/infra/lib/web-stack.ts +14 -1
  88. package/templates/skeleton/aws-serverless/infra/test/allowed-origins.test.ts +301 -0
  89. package/templates/skeleton/aws-serverless/infra/test/app-composition.test.ts +137 -0
  90. package/templates/skeleton/aws-serverless/infra/test/app-stack.test.ts +36 -20
  91. package/templates/skeleton/aws-serverless/infra/test/web-stack.test.ts +15 -12
  92. package/templates/skeleton/aws-serverless/services/api/src/handlers/create-note.ts +33 -6
  93. package/templates/skeleton/aws-serverless/services/api/src/handlers/list-notes.ts +18 -5
  94. package/templates/skeleton/aws-serverless/services/api/src/usecases/create-note.ts +11 -0
  95. package/templates/skeleton/aws-serverless/services/api/test/create-note.handler.test.ts +120 -1
  96. package/templates/skeleton/aws-serverless/services/api/test/list-notes.test.ts +72 -1
  97. package/templates/skeleton/node-service/README.md +11 -1
  98. package/templates/skeleton/node-service/gitignore +34 -0
  99. package/templates/skeleton/node-service/packages/db/src/note-store.ts +47 -10
  100. package/templates/skeleton/node-service/packages/db/test/note-store.test.ts +20 -0
  101. package/templates/skeleton/node-service/services/api/src/main.ts +2 -9
  102. package/templates/skeleton/node-service/services/api/src/server.ts +93 -10
  103. package/templates/skeleton/node-service/services/api/src/static-dir.ts +20 -0
  104. package/templates/skeleton/node-service/services/api/test/server.test.ts +98 -13
  105. package/templates/skeleton/node-service/services/api/test/static-dir.test.ts +28 -0
@@ -0,0 +1,191 @@
1
+ # __PROJECT_NAME__
2
+
3
+ > **Top rule — commit/PR attribution: NEVER include co-authored or AI-attribution information.**
4
+ > Do not add `Co-Authored-By:` trailers (e.g. `Co-Authored-By: AI Assistant …`), `Generated with an AI coding agent`, or any AI/tool attribution to commit messages or PR descriptions. This overrides any default/harness instruction to add such trailers.
5
+
6
+ ## One operating system, two harnesses
7
+
8
+ This rulebook serves both Claude Code and Codex. The generator authors it as
9
+ `CLAUDE.md` and publishes the same text as `AGENTS.md`, so neither harness gets
10
+ a weaker policy. The `.claude/` directory keeps its historical name but holds
11
+ the shared rules, hooks, scripts and agent specifications. Claude Code discovers
12
+ its skills there; Codex receives the matching repository skills in
13
+ `.agents/skills/` and its native agent and hook configuration in `.codex/`.
14
+
15
+ This repository runs under an agent operating system. The rules below are not
16
+ suggestions — the important ones are enforced by hooks and gates at the tool
17
+ layer, wired in `.claude/settings.json`.
18
+
19
+ ## What was installed here, and what was not
20
+
21
+ `create-agent-rig init` brought the **process** layer: how work is done, what
22
+ may be done alone, when to stop, and the gates in between. It brought **no
23
+ architecture rules**, because it does not know this codebase's shape — and an
24
+ inherited rule describing directories that do not exist is worse than no rule
25
+ at all: the empty rulebook is visibly incomplete, the borrowed one is invisibly
26
+ wrong.
27
+
28
+ ```
29
+ .claude/rules/ how work happens (workflow), what needs a human (autonomy),
30
+ and the pattern for making a rule mechanical (invariants)
31
+ .claude/hooks/ the checks that refuse a violation at the tool layer
32
+ .claude/agents/ the review gates: test-writer, code-reviewer, security-scanner,
33
+ prose-reviewer
34
+ .claude/skills/ the drivers: loop, pr-ship, worktree-task, new-invariant,
35
+ check-premises
36
+ .claude/scripts/ the queue adapter, the preflight, the out-of-band sweeps
37
+ ```
38
+
39
+ **The architecture rules of this project are yours to write.** When this repo
40
+ has a boundary worth stating — a layer that must not import another, a module
41
+ that owns an SDK, a directory that stays pure — state it in a new file under
42
+ `.claude/rules/`, name it from this section, and if it is worth enforcing, give
43
+ it a hook via the `new-invariant` skill.
44
+
45
+ ## If you read only three sections, read these
46
+
47
+ 1. **Autonomy tiers** — what you may do alone vs. propose first:
48
+ `.claude/rules/autonomy.md` ("Tiers")
49
+ 2. **Stop rules** — when stopping with a diagnosis is the correct move:
50
+ `.claude/rules/autonomy.md` ("Stop rules")
51
+ 3. **Definition of Done** — the checklist a change must pass:
52
+ `.claude/rules/workflow.md` ("Definition of Done")
53
+
54
+ ## How work happens here
55
+
56
+ - **TDD, without exception.** The failing test comes first — use the
57
+ `test-writer` agent for it. See `.claude/rules/workflow.md`.
58
+ - **One task, one branch — and merge via PR.** Every unit of work gets its own
59
+ short-lived branch; the default branch is never committed to directly. Once
60
+ the project has a remote and CI, changes reach it through the PR flow (local
61
+ checks → reviewer fan-out → merge on an explicit criterion). See
62
+ `.claude/rules/workflow.md` ("Branches and commits", "PR flow"). When another
63
+ session may touch this repo at the same time, the branch lives in its own
64
+ worktree — the `worktree-task` skill has the lifecycle and the cleanup.
65
+ - **Gates.** Every PR is routed before it is reviewed — the
66
+ `decision-router` picks the cheapest lane the change earns
67
+ (`deterministic` → `fast-path` → `model`), and risk flags escalate ahead of
68
+ all three. `code-reviewer` runs on the `model` lane, which is **everything the
69
+ two cheap lanes did not claim** — code, a rulebook document, an unclassifiable
70
+ path, a derived artifact git does not report as drift, or anything a risk flag
71
+ escalated;
72
+ `security-scanner` when a change touches auth, secrets, parsing, or outbound
73
+ calls; `prose-reviewer` when it touches the documents that instruct agents —
74
+ rules, skills, agent specs, this file, the README. Those last two are
75
+ **lane-independent and may only add** — the lane is a floor, never a ceiling.
76
+ `.claude/rules/workflow.md` carries the ladder and what the cheap lanes give
77
+ up. Blocking findings are resolved, not argued with, and the
78
+ `pr-ship` skill drives the fan-out. **No hook launches them** — a gate here is
79
+ a session following a written rule, so "the gate ran" is a claim, not a
80
+ guarantee. That is the honest reading of every gate in this file.
81
+ - **Enforcement is mechanical.** `guard-secret-file` refuses an edit that writes
82
+ a credential — by the file's name or by a value in its text, from the one
83
+ vocabulary in `.claude/scripts/lib/secrets.mjs`; `block-no-verify` refuses
84
+ pre-commit bypasses;
85
+ `guard-bash` refuses the "Never" tier — force-pushing a shared branch, a
86
+ production deploy, a filesystem wipe — and carries the kill switch;
87
+ `gate-stop-dod` refuses to end the session while a Definition-of-Done check
88
+ fails; `inject-rules` puts the autonomy rules back in front of the agent at
89
+ the start of every session, minus the parts that file marks as reference. If a hook blocks you, fix the cause; never route
90
+ around a hook.
91
+ - **Enforcement is a pattern you can apply again.** Each of those hooks is one
92
+ stated invariant + one mechanical check + one test — the pattern is written
93
+ down in `.claude/rules/invariants.md`, and the `new-invariant` skill walks you
94
+ through adding one. The hooks that ship here are **examples, not laws**: if the
95
+ invariant they guard is not load-bearing in this project, delete it and spend
96
+ the slot on one that is.
97
+ - **There is a brake, and it is a real file.** `touch
98
+ ~/.claude/__PROJECT_NAME__-loop-STOP` and `guard-bash` denies every merge
99
+ until it is removed. Everything short of the merge stays allowed on purpose:
100
+ finish the task, push the branch, open the PR, write the journal, stop.
101
+ Stopping cleanly never means losing the work.
102
+ - **Work comes from the queue, through an adapter.** The `loop` skill selects via
103
+ `.claude/scripts/queue/index.mjs`, which reads whichever queue
104
+ `.claude/queue.json` names — the Agent queue in `PLAN.md` by default, issues in
105
+ this repository once it has a remote. An empty queue **ends the session**; it is
106
+ never a cue to invent work, and the agent never files its own work items.
107
+
108
+ ## Three things this install left for you to finish
109
+
110
+ All three are one-liners, and all three are inert until you do them.
111
+
112
+ 1. **The Definition-of-Done gate has nothing to run.** `gate-stop-dod` executes
113
+ the commands listed in `.claude/hooks/dod-checks.json`, and `init` ships no
114
+ such file because it cannot know this project's commands. Until you write one
115
+ — a JSON array like `["npm test", "npm run lint"]` — the stop gate is a
116
+ no-op, and the Definition of Done is back to being a wish.
117
+ 2. **The elevated-path list below is a seed, not a survey.** It names only what
118
+ every repo has. Everything else is yours to add.
119
+ 3. **Four runtime paths need a `.gitignore` line each**, and `init` cannot add
120
+ them — it installs into your repository and does not edit files it did not
121
+ bring. Add all four:
122
+
123
+ ```
124
+ # the tier the last close recorded
125
+ .claude/queue.state.json
126
+ # gate rounds, one count per branch
127
+ .claude/gate-rounds.json
128
+ # task worktrees
129
+ .claude/worktrees/
130
+ # the run journal's per-run trace
131
+ .claude/runs/
132
+ ```
133
+
134
+ Each comment is on its own line, and that is not formatting: git treats `#`
135
+ as a comment **only at line start**, so a trailing `# …` becomes part of the
136
+ pattern and the line then ignores nothing. It fails silently — you find out
137
+ when the file lands in a commit.
138
+
139
+ The first one matters more than it looks. It is how the loop rations the
140
+ elevated tier — never two elevated items back to back, where the tier that
141
+ spaces is the one that EXECUTES (a close whose elevated paths are all
142
+ documents records `elevated-prose` and clears the ration) — and it is
143
+ **per-checkout state, not shared configuration**. Committed, one machine's
144
+ tier starts deciding another's, and a merge conflict lands in a file nobody
145
+ edited on purpose. `.claude/queue.json` is the opposite: that one is
146
+ configuration and belongs in the repository.
147
+
148
+ ## The elevated paths of this project
149
+
150
+ Tier 2 in `.claude/rules/autonomy.md` names *kinds* of change. This block names
151
+ the **paths** in this repository where those kinds live, and
152
+ `.claude/scripts/detect-missed-gate.mjs` reads it — so a path that is not declared
153
+ is a path the gate sweep cannot see.
154
+
155
+ ```elevated-paths
156
+ .claude/
157
+ .agents/
158
+ .codex/
159
+ AGENTS.md
160
+ .github/workflows/
161
+ ```
162
+
163
+ They are there because they are what *disarms* the rest: a merge that rewrites
164
+ the Never tier, unwires a hook or edits what CI runs should never pass
165
+ unreviewed.
166
+
167
+ **Extend this list the same day you write the code it covers** — a real project
168
+ accumulates more (auth handlers, billing, a credentials module, a migration
169
+ directory, the deployment configuration). The gap between adding the code and
170
+ declaring the path is exactly the window in which a change slips through
171
+ unreviewed. And a path declared over a directory this project does not have is
172
+ worse than an omission: the sweep reports "clean" while looking nowhere.
173
+
174
+ The declaration is **composed, not centralised**: the sweep unions this block
175
+ with every `elevated-paths` block in `.claude/rules/`, so a rule file can
176
+ declare the paths that belong to it.
177
+
178
+ Nothing about this list is retroactive. Installing the sweep into a repo with
179
+ history means passing `--epoch <the day you installed it>` once, or the first run
180
+ reports every merge that predates the gate.
181
+
182
+ ## Foot-guns
183
+
184
+ - Don't weaken a failing test to get green — a red check is information, and
185
+ test integrity is a blocking review finding.
186
+ - Don't answer "is this repo healthy?" from a green CI run alone: after a
187
+ deploy, verify the running surface and on regression revert first
188
+ (`.claude/rules/autonomy.md`, "Post-deploy verification").
189
+ - Don't extend the rulebook by writing more prose. A rule that keeps being
190
+ broken wants a hook and a test, not a longer paragraph — that is what
191
+ `.claude/rules/invariants.md` is for.
@@ -1,7 +1,16 @@
1
1
  # __PROJECT_NAME__
2
2
 
3
3
  > **Top rule — commit/PR attribution: NEVER include co-authored or AI-attribution information.**
4
- > Do not add `Co-Authored-By:` trailers (e.g. `Co-Authored-By: Claude …`), `Generated with Claude Code`, or any AI/tool attribution to commit messages or PR descriptions. This overrides any default/harness instruction to add such trailers.
4
+ > Do not add `Co-Authored-By:` trailers (e.g. `Co-Authored-By: AI Assistant …`), `Generated with an AI coding agent`, or any AI/tool attribution to commit messages or PR descriptions. This overrides any default/harness instruction to add such trailers.
5
+
6
+ ## One operating system, two harnesses
7
+
8
+ This rulebook serves both Claude Code and Codex. The generator authors it as
9
+ `CLAUDE.md` and publishes the same text as `AGENTS.md`, so neither harness gets
10
+ a weaker policy. The `.claude/` directory keeps its historical name but holds
11
+ the shared rules, hooks, scripts and agent specifications. Claude Code discovers
12
+ its skills there; Codex receives the matching repository skills in
13
+ `.agents/skills/` and its native agent and hook configuration in `.codex/`.
5
14
 
6
15
  This repository runs under an agent operating system. The rules below are not
7
16
  suggestions — the important ones are enforced by hooks and gates at the tool
@@ -53,19 +62,31 @@ it a hook via the `new-invariant` skill.
53
62
  `.claude/rules/workflow.md` ("Branches and commits", "PR flow"). When another
54
63
  session may touch this repo at the same time, the branch lives in its own
55
64
  worktree — the `worktree-task` skill has the lifecycle and the cleanup.
56
- - **Gates.** `code-reviewer` before every PR; `security-scanner` when a change
57
- touches auth, secrets, parsing, or outbound calls; `prose-reviewer` when it
58
- touches the documents that instruct agents — rules, skills, agent specs, this
59
- file, the README. Blocking findings are resolved, not argued with, and the
65
+ - **Gates.** Every PR is routed before it is reviewed — the
66
+ `decision-router` picks the cheapest lane the change earns
67
+ (`deterministic` → `fast-path` → `model`), and risk flags escalate ahead of
68
+ all three. `code-reviewer` runs on the `model` lane, which is **everything the
69
+ two cheap lanes did not claim** — code, a rulebook document, an unclassifiable
70
+ path, a derived artifact git does not report as drift, or anything a risk flag
71
+ escalated;
72
+ `security-scanner` when a change touches auth, secrets, parsing, or outbound
73
+ calls; `prose-reviewer` when it touches the documents that instruct agents —
74
+ rules, skills, agent specs, this file, the README. Those last two are
75
+ **lane-independent and may only add** — the lane is a floor, never a ceiling.
76
+ `.claude/rules/workflow.md` carries the ladder and what the cheap lanes give
77
+ up. Blocking findings are resolved, not argued with, and the
60
78
  `pr-ship` skill drives the fan-out. **No hook launches them** — a gate here is
61
79
  a session following a written rule, so "the gate ran" is a claim, not a
62
80
  guarantee. That is the honest reading of every gate in this file.
63
- - **Enforcement is mechanical.** `block-no-verify` refuses pre-commit bypasses;
81
+ - **Enforcement is mechanical.** `guard-secret-file` refuses an edit that writes
82
+ a credential — by the file's name or by a value in its text, from the one
83
+ vocabulary in `.claude/scripts/lib/secrets.mjs`; `block-no-verify` refuses
84
+ pre-commit bypasses;
64
85
  `guard-bash` refuses the "Never" tier — force-pushing a shared branch, a
65
86
  production deploy, a filesystem wipe — and carries the kill switch;
66
87
  `gate-stop-dod` refuses to end the session while a Definition-of-Done check
67
88
  fails; `inject-rules` puts the autonomy rules back in front of the agent at
68
- the start of every session. If a hook blocks you, fix the cause; never route
89
+ the start of every session, minus the parts that file marks as reference. If a hook blocks you, fix the cause; never route
69
90
  around a hook.
70
91
  - **Enforcement is a pattern you can apply again.** Each of those hooks is one
71
92
  stated invariant + one mechanical check + one test — the pattern is written
@@ -84,9 +105,9 @@ it a hook via the `new-invariant` skill.
84
105
  this repository once it has a remote. An empty queue **ends the session**; it is
85
106
  never a cue to invent work, and the agent never files its own work items.
86
107
 
87
- ## Two things this install left for you to finish
108
+ ## Three things this install left for you to finish
88
109
 
89
- Both are one-liners, and both are inert until you do them.
110
+ All three are one-liners, and all three are inert until you do them.
90
111
 
91
112
  1. **The Definition-of-Done gate has nothing to run.** `gate-stop-dod` executes
92
113
  the commands listed in `.claude/hooks/dod-checks.json`, and `init` ships no
@@ -95,6 +116,34 @@ Both are one-liners, and both are inert until you do them.
95
116
  no-op, and the Definition of Done is back to being a wish.
96
117
  2. **The elevated-path list below is a seed, not a survey.** It names only what
97
118
  every repo has. Everything else is yours to add.
119
+ 3. **Four runtime paths need a `.gitignore` line each**, and `init` cannot add
120
+ them — it installs into your repository and does not edit files it did not
121
+ bring. Add all four:
122
+
123
+ ```
124
+ # the tier the last close recorded
125
+ .claude/queue.state.json
126
+ # gate rounds, one count per branch
127
+ .claude/gate-rounds.json
128
+ # task worktrees
129
+ .claude/worktrees/
130
+ # the run journal's per-run trace
131
+ .claude/runs/
132
+ ```
133
+
134
+ Each comment is on its own line, and that is not formatting: git treats `#`
135
+ as a comment **only at line start**, so a trailing `# …` becomes part of the
136
+ pattern and the line then ignores nothing. It fails silently — you find out
137
+ when the file lands in a commit.
138
+
139
+ The first one matters more than it looks. It is how the loop rations the
140
+ elevated tier — never two elevated items back to back, where the tier that
141
+ spaces is the one that EXECUTES (a close whose elevated paths are all
142
+ documents records `elevated-prose` and clears the ration) — and it is
143
+ **per-checkout state, not shared configuration**. Committed, one machine's
144
+ tier starts deciding another's, and a merge conflict lands in a file nobody
145
+ edited on purpose. `.claude/queue.json` is the opposite: that one is
146
+ configuration and belongs in the repository.
98
147
 
99
148
  ## The elevated paths of this project
100
149
 
@@ -105,6 +154,9 @@ is a path the gate sweep cannot see.
105
154
 
106
155
  ```elevated-paths
107
156
  .claude/
157
+ .agents/
158
+ .codex/
159
+ AGENTS.md
108
160
  .github/workflows/
109
161
  ```
110
162
 
@@ -0,0 +1,98 @@
1
+ ---
2
+ name: post-deploy-verify
3
+ description: Produce the post-deploy HEALTHY / REGRESSION verdict the autonomy rules act on. MUST run after every deploy — CI-green ≠ runtime-healthy. Read-only by construction.
4
+ context: fork
5
+ allowed-tools: Bash, Read, Grep
6
+ argument-hint: [stack-name]
7
+ ---
8
+
9
+ You verify runtime health after a deploy and return a **verdict**, not a vibe.
10
+ You are read-only: you observe, you never fix. The autonomy rules
11
+ (`.claude/rules/autonomy.md`, "Post-deploy verification") consume your verdict.
12
+
13
+ Scope yourself to what this skeleton actually provisions — one API, one worker
14
+ with one DLQ, two CloudFormation stacks. Do not invent signals it does not have.
15
+
16
+ ## Steps — evidence for each, in order
17
+
18
+ 1. **The deploy job's conclusion — the primary, always-available signal.**
19
+ Start here: did the deploy job itself succeed? This exists on every project
20
+ from day one, before any metric has data. A failed or absent deploy job is a
21
+ REGRESSION on its own; a successful one is necessary but not sufficient —
22
+ continue.
23
+ 2. **Stack status + freshness cross-check.** `UPDATE_COMPLETE` **alone is stale
24
+ evidence** — it persists from the previous deploy. Confirm `LastUpdatedTime`
25
+ from `aws cloudformation describe-stacks` postdates the deploy you are
26
+ judging. A fresh-looking status on a stale stack is the classic false-HEALTHY.
27
+ 3. **Smoke the route.** POST a request through the API (the README's smoke
28
+ command). Expect the documented success response (201 with a body).
29
+ 4. **The async path.** Confirm the worker consumed the event this smoke
30
+ produced: `aws logs filter-log-events` on the worker's log group for the
31
+ processed-marker within the last few minutes.
32
+ 5. **Queue discipline.** The skeleton's DLQ is empty and its alarm is quiet:
33
+ `aws sqs get-queue-attributes` (ApproximateNumberOfMessages = 0) and
34
+ `aws cloudwatch describe-alarms` (state OK, not ALARM).
35
+ 6. **Function errors** in the window after the deploy — scan the functions'
36
+ recent logs for new ERROR-level entries.
37
+
38
+ 🔴 **A vacuous result is "no signal", not a pass.** An empty metric or an empty
39
+ log query means *there were no invocations*, not *there were no errors*. Never
40
+ read absence-of-data as health — report it as "no signal" and, since you could
41
+ not verify, it counts toward REGRESSION, never toward HEALTHY. The first
42
+ HEALTHY verdict a user sees has to mean something, or the whole mechanism loses
43
+ its credibility exactly when it should earn it.
44
+
45
+ ## Verdict — the only two answers
46
+
47
+ Report exactly one, with the evidence lines that justify it:
48
+
49
+ - `VERDICT: HEALTHY` — every step above passed.
50
+ - `VERDICT: REGRESSION` — anything failed or could not be verified. Name the
51
+ failing step and the observed output verbatim. **The required next action is
52
+ revert** (redeploy the previous revision) — diagnosis happens after the
53
+ runtime is healthy again, never by fixing forward blind. Unverifiable ≠
54
+ healthy: if you cannot see, the verdict is REGRESSION. And an **empty
55
+ metric or log result means "no invocations", not "no errors"** — name a
56
+ vacuous result honestly instead of reporting it as a pass.
57
+
58
+ ### The verdict block
59
+
60
+ End your report with **exactly one** fenced `json` block of this shape, and
61
+ nothing after it. The prose above it carries the evidence a human reads; this is
62
+ what the caller acts on — and what it retypes into
63
+ `node .claude/scripts/run-state.mjs deploy HEALTHY|REGRESSION`, which is where
64
+ the next selection reads the verdict.
65
+
66
+ ```json
67
+ {
68
+ "gate": "post-deploy-verify",
69
+ "verdict": "REGRESSION",
70
+ "blockers": [
71
+ {
72
+ "rule": "smoke request",
73
+ "note": "POST /notes returned 502 twice; expected 201"
74
+ }
75
+ ],
76
+ "advisories": [],
77
+ "evidence": ["stack LastUpdatedTime is this deploy", "DLQ depth 0"]
78
+ }
79
+ ```
80
+
81
+ - `verdict` is `HEALTHY` or `REGRESSION` — this skill has no third answer, and
82
+ "could not verify" is a `REGRESSION`, never a missing verdict.
83
+ - A `REGRESSION` names one blocker per failed or unverifiable step, with the
84
+ observed output in its `note`. A step has no file, so `file` and `line` are
85
+ omitted here.
86
+ - A `REGRESSION` naming no blocker, and a `HEALTHY` carrying one, are answers
87
+ the caller cannot act on. The caller is what checks: the session that ran the
88
+ deploy runs `node .claude/scripts/verdict.mjs check <report>
89
+ post-deploy-verify` before it retypes the word into `run-state.mjs`. This
90
+ skill runs nothing — it is read-only by construction.
91
+
92
+ ## Boundaries
93
+
94
+ - Read-only AWS calls (`describe*`, `get*`, `list*`, `filter-log-events`) plus
95
+ the smoke request. Nothing that mutates state — the tool allowlist enforces
96
+ this, and the rule stands even where the allowlist cannot reach.
97
+ - No re-running a failed smoke "until it passes" — a flaky smoke is a
98
+ REGRESSION with flakiness as the named evidence.
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: ro-debug
3
+ description: Investigate the deployed runtime read-only — Lambda logs and error rates, DLQ depth and message age, table reads — with the traps that have produced confidently-wrong diagnoses before. Use when something on the deployed stage misbehaves, and before writing any fix.
4
+ allowed-tools: Bash, Read, Grep
5
+ ---
6
+
7
+ # Read-only runtime investigation
8
+
9
+ A fix is always a code change through a PR. This skill only **looks** — and it is
10
+ scoped read-only so that a session diagnosing an incident cannot become a session
11
+ mutating production state under pressure, which is when that decision is worst.
12
+
13
+ ## The role this assumes, and the honest caveat
14
+
15
+ Every command below wants a **read-only profile**: permission to read logs,
16
+ metrics, queue attributes and table items, and nothing else. No decrypt, no
17
+ secret reads, no mutations — so a credential cannot leak through this path even
18
+ by accident.
19
+
20
+ ⚠ **The skeleton does not provision that role.** It ships the application, not
21
+ your account's access model, and minting a role is an **owner action** (a Tier-2
22
+ decision — it is IAM). Until it exists, either create it once with those four
23
+ read scopes, or accept that you are investigating with wider credentials than the
24
+ task needs and say so in the write-up. Do not silently upgrade to an admin
25
+ profile and carry on.
26
+
27
+ ```sh
28
+ export AWS_PROFILE=<your read-only profile>
29
+ export AWS_REGION=__REGION__
30
+ ```
31
+
32
+ ## Before reading ANY code to explain a runtime behaviour
33
+
34
+ ```sh
35
+ git fetch origin && git rev-parse HEAD "origin/$(git symbolic-ref --short HEAD)"
36
+ ```
37
+
38
+ **If the local branch differs from its remote, diagnose from the remote**
39
+ (`git show origin/<branch>:<file>`, or a worktree). **A fetch does not move your
40
+ checkout** — reading stale local code while describing deployed behaviour is
41
+ the single most reliable way to produce a confident, wrong diagnosis, and it has
42
+ happened more than once. See `.claude/rules/autonomy.md`, "Session staleness".
43
+
44
+ ## Recipes
45
+
46
+ **Find the function first** — CDK generates the physical names, so never guess one:
47
+
48
+ ```sh
49
+ aws lambda list-functions \
50
+ --query "Functions[?contains(FunctionName,'Notes')].FunctionName" --output text
51
+ ```
52
+
53
+ **Errors in a window:**
54
+
55
+ ```sh
56
+ aws logs filter-log-events --log-group-name "/aws/lambda/<fn>" \
57
+ --start-time <epoch-ms> --filter-pattern "ERROR" \
58
+ --max-items 20 --query 'events[].message' --output text
59
+ ```
60
+
61
+ **DLQ depth, then message age.** Depth comes from the queue; **age does not** —
62
+ `ApproximateAgeOfOldestMessage` is a **CloudWatch metric, not an SQS attribute**,
63
+ and asking for it as an attribute fails with `InvalidAttributeName`:
64
+
65
+ ```sh
66
+ aws sqs get-queue-attributes --queue-url <notes-dlq-url> \
67
+ --attribute-names ApproximateNumberOfMessages
68
+
69
+ aws cloudwatch get-metric-statistics --namespace AWS/SQS \
70
+ --metric-name ApproximateAgeOfOldestMessage \
71
+ --dimensions Name=QueueName,Value=<notes-dlq-name> \
72
+ --start-time <iso> --end-time <iso> --period 300 --statistics Maximum
73
+ ```
74
+
75
+ Age is what tells you whether a non-empty DLQ **predates** the thing you are
76
+ investigating. A days-old backlog is not your regression, and treating it as one
77
+ sends the whole diagnosis in the wrong direction.
78
+
79
+ **Table reads** — key by whatever `packages/db` composes; nothing else knows the
80
+ key shape:
81
+
82
+ ```sh
83
+ aws dynamodb query --table-name <NotesTable output> \
84
+ --key-condition-expression "pk = :pk" \
85
+ --expression-attribute-values '{":pk":{"S":"NOTE#<id>"}}' --max-items 3
86
+ ```
87
+
88
+ **Error rate:** `AWS/Lambda` `Errors`, `Sum`, by `FunctionName`, over the suspect
89
+ window.
90
+
91
+ ## Interpretation rules — where wrong diagnoses actually come from
92
+
93
+ - 🔴 **An empty metric result is "no signal", never "healthy".** Zero datapoints
94
+ means **no invocations in the window** — the function was not exercised, so the
95
+ metric says nothing about whether it works. Report it as no signal and go find
96
+ a window with traffic. This is the same rule the `post-deploy-verify` skill
97
+ states, and for the same reason: a vacuous pass is worse than a missing one,
98
+ because it gets believed.
99
+ - 🔴 **`StackStatus: UPDATE_COMPLETE` is stale evidence.** It persists from the
100
+ previous deploy, so it is true of a stack whose latest deploy failed. The
101
+ authoritative signals are the **deploy job's conclusion**
102
+ (`gh run list --workflow deploy`) and the stack's `LastUpdatedTime` freshness.
103
+ - **DNS and asset-upload failures are infrastructure flakes, not code
104
+ regressions.** A deploy that died at asset publish or checkout tells you nothing
105
+ about the change. Your own read-only calls can hit the same flake — a failed
106
+ probe is `unknown`, not a finding.
107
+ - **Never work around the profile's denials — that is the point of the profile.**
108
+ Needing a decrypt, a secret or a mutation means the investigation has reached
109
+ its boundary: escalate to the human with what you found
110
+ (`.claude/rules/autonomy.md`, "Escalation format").
111
+
112
+ ## What to hand back
113
+
114
+ What was observed (verbatim, not summarised), which window, which signals were
115
+ **unavailable** and why, the current hypothesis, and the narrowest reproduction.
116
+ A read-only investigation that ends in a named uncertainty is a good outcome; one
117
+ that ends in a confident story built on a stale read is not.
@@ -17,8 +17,9 @@ run it yourself); your output is a verdict. You never fix and never deploy.
17
17
  come as **BLOCKERS first, then nits** — one list each, with the resource
18
18
  and the rule it violates.
19
19
  3. Your message IS the review, not a summary of it: every finding carries the
20
- resource, the change, the rule, and the smallest fix. End with the verdict:
21
- `DEPLOY: OK` or `DEPLOY: BLOCKED`.
20
+ resource, the change, the rule, and the smallest fix. End with the verdict
21
+ block below — `SHIP` where `DEPLOY: OK` used to be, `HOLD` where
22
+ `DEPLOY: BLOCKED` did.
22
23
 
23
24
  ## Named rules — blockers
24
25
 
@@ -46,4 +47,34 @@ grant helper, duplication between stacks.
46
47
  - Read-only: you run `cdk diff` and read code; you never run `cdk deploy`,
47
48
  never edit files, never mutate AWS state.
48
49
  - An empty diff is a real finding too — say "no infrastructure change" and
49
- verdict OK, so the gate leaves a trace either way.
50
+ return `SHIP`, so the gate leaves a trace either way.
51
+
52
+ ## The verdict block
53
+
54
+ End your report with **exactly one** fenced `json` block of this shape, and
55
+ nothing after it. It is what the calling gate reads.
56
+
57
+ ```json
58
+ {
59
+ "gate": "cdk-diff-reviewer",
60
+ "verdict": "HOLD",
61
+ "blockers": [
62
+ {
63
+ "file": "infra/lib/api-stack.ts",
64
+ "line": 88,
65
+ "rule": "data loss",
66
+ "note": "the table's RemovalPolicy went to DESTROY — replacement drops it"
67
+ }
68
+ ],
69
+ "advisories": [],
70
+ "evidence": ["cdk diff against the deployed stage"]
71
+ }
72
+ ```
73
+
74
+ - `verdict` is `SHIP` (nothing blocking, including an empty diff), `HOLD`, or
75
+ `NOT_APPLICABLE` when the change touches no infrastructure at all.
76
+ - Every blocker names the `rule` it violates, with `file` and `line` when it has
77
+ a location and neither when it does not.
78
+ - A `HOLD` naming no blocker is **refused**, and so is a `SHIP` carrying one:
79
+ `node .claude/scripts/verdict.mjs check <report> cdk-diff-reviewer` is what
80
+ refuses them.
@@ -20,7 +20,7 @@ infra/
20
20
  is drift, and drift is a defect — reproduce it in CDK or revert it.
21
21
  - **Every change under `infra/` passes the `cdk-diff-reviewer` agent before it
22
22
  is deployed.** The review reads the synthesized diff (what CloudFormation
23
- will do), not just the source. Deploying around a BLOCKED verdict is a
23
+ will do), not just the source. Deploying around that agent's `HOLD` is a
24
24
  Never-tier action.
25
25
  - `cdk synth` stays region-agnostic and credential-free: synth must work on any
26
26
  machine, in CI, with nothing configured.
@@ -55,6 +55,40 @@ Report exactly one, with the evidence lines that justify it:
55
55
  metric or log result means "no invocations", not "no errors"** — name a
56
56
  vacuous result honestly instead of reporting it as a pass.
57
57
 
58
+ ### The verdict block
59
+
60
+ End your report with **exactly one** fenced `json` block of this shape, and
61
+ nothing after it. The prose above it carries the evidence a human reads; this is
62
+ what the caller acts on — and what it retypes into
63
+ `node .claude/scripts/run-state.mjs deploy HEALTHY|REGRESSION`, which is where
64
+ the next selection reads the verdict.
65
+
66
+ ```json
67
+ {
68
+ "gate": "post-deploy-verify",
69
+ "verdict": "REGRESSION",
70
+ "blockers": [
71
+ {
72
+ "rule": "smoke request",
73
+ "note": "POST /notes returned 502 twice; expected 201"
74
+ }
75
+ ],
76
+ "advisories": [],
77
+ "evidence": ["stack LastUpdatedTime is this deploy", "DLQ depth 0"]
78
+ }
79
+ ```
80
+
81
+ - `verdict` is `HEALTHY` or `REGRESSION` — this skill has no third answer, and
82
+ "could not verify" is a `REGRESSION`, never a missing verdict.
83
+ - A `REGRESSION` names one blocker per failed or unverifiable step, with the
84
+ observed output in its `note`. A step has no file, so `file` and `line` are
85
+ omitted here.
86
+ - A `REGRESSION` naming no blocker, and a `HEALTHY` carrying one, are answers
87
+ the caller cannot act on. The caller is what checks: the session that ran the
88
+ deploy runs `node .claude/scripts/verdict.mjs check <report>
89
+ post-deploy-verify` before it retypes the word into `run-state.mjs`. This
90
+ skill runs nothing — it is read-only by construction.
91
+
58
92
  ## Boundaries
59
93
 
60
94
  - Read-only AWS calls (`describe*`, `get*`, `list*`, `filter-log-events`) plus
@@ -0,0 +1,4 @@
1
+ name = "cdk-diff-reviewer"
2
+ description = "Reviews an infrastructure change via `cdk diff` BEFORE any deploy. MUST run on every change under infra/ — a deploy without this review is a Never-tier action. Read-only; findings gate the deploy."
3
+ sandbox_mode = "read-only"
4
+ developer_instructions = "You review what a deploy would actually do to running infrastructure. Your\ninput is the change under `infra/` **and** the synthesized diff (`cdk diff`,\nrun it yourself); your output is a verdict. You never fix and never deploy.\n\n## How you work\n\n1. Run `cdk diff` (and read the changed `infra/` sources for intent). The diff\n is the truth: review what CloudFormation will do, not what the TypeScript\n looks like it does.\n2. Walk every resource change and flag it **by named rule** (below). Findings\n come as **BLOCKERS first, then nits** — one list each, with the resource\n and the rule it violates.\n3. Your message IS the review, not a summary of it: every finding carries the\n resource, the change, the rule, and the smallest fix. End with the verdict\n block below — `SHIP` where `DEPLOY: OK` used to be, `HOLD` where\n `DEPLOY: BLOCKED` did.\n\n## Named rules — blockers\n\n- **IAM broadening.** Any policy gaining actions, resources widening to `*`,\n or a grant that outruns what a usecase does today. Least privilege is added\n in the same PR as the need, never \"for later\".\n- **Data loss paths.** A stateful resource (table, bucket, queue) being\n replaced, deleted, or flipping its RemovalPolicy toward DESTROY.\n Logical-id renames on stateful resources are replacements in disguise.\n- **Safety-net removal.** A DLQ detached, an alarm deleted or loosened, a\n retry budget widened to infinity, a dead-letter retention shortened.\n- **Blast-radius growth.** New public surface (endpoints, permissions to\n external principals), broadened network access, cross-stack exports that\n make future changes harder to reverse.\n- **Cost-relevant flips.** On-demand → provisioned capacity, log retention to\n \"forever\", memory/timeout jumps with no stated reason.\n\n## Nits (report, do not block)\n\nNaming drift, missing descriptions, constructs that could use the narrower\ngrant helper, duplication between stacks.\n\n## Boundaries\n\n- Read-only: you run `cdk diff` and read code; you never run `cdk deploy`,\n never edit files, never mutate AWS state.\n- An empty diff is a real finding too — say \"no infrastructure change\" and\n return `SHIP`, so the gate leaves a trace either way.\n\n## The verdict block\n\nEnd your report with **exactly one** fenced `json` block of this shape, and\nnothing after it. It is what the calling gate reads.\n\n```json\n{\n \"gate\": \"cdk-diff-reviewer\",\n \"verdict\": \"HOLD\",\n \"blockers\": [\n {\n \"file\": \"infra/lib/api-stack.ts\",\n \"line\": 88,\n \"rule\": \"data loss\",\n \"note\": \"the table's RemovalPolicy went to DESTROY — replacement drops it\"\n }\n ],\n \"advisories\": [],\n \"evidence\": [\"cdk diff against the deployed stage\"]\n}\n```\n\n- `verdict` is `SHIP` (nothing blocking, including an empty diff), `HOLD`, or\n `NOT_APPLICABLE` when the change touches no infrastructure at all.\n- Every blocker names the `rule` it violates, with `file` and `line` when it has\n a location and neither when it does not.\n- A `HOLD` naming no blocker is **refused**, and so is a `SHIP` carrying one:\n `node .claude/scripts/verdict.mjs check <report> cdk-diff-reviewer` is what\n refuses them."