@nklisch/pi-agile-workflow 0.15.3

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 (203) hide show
  1. package/.claude-plugin/plugin.json +10 -0
  2. package/.codex-plugin/plugin.json +28 -0
  3. package/CHANGELOG.md +591 -0
  4. package/README.md +107 -0
  5. package/docs/ARCHITECTURE.md +716 -0
  6. package/docs/MIGRATION.md +419 -0
  7. package/docs/PRINCIPLES.md +464 -0
  8. package/docs/ROADMAP.md +95 -0
  9. package/docs/SPEC.md +855 -0
  10. package/docs/VISION.md +106 -0
  11. package/extensions/agile-workflow.test.ts +419 -0
  12. package/extensions/agile-workflow.ts +467 -0
  13. package/hooks/hooks.json +52 -0
  14. package/hooks/scripts/prompt-context.py +628 -0
  15. package/hooks/scripts/substrate-maintainer.py +359 -0
  16. package/hooks/scripts/test_prompt_context.py +757 -0
  17. package/package.json +30 -0
  18. package/scripts/install-work-view.sh +165 -0
  19. package/scripts/tests/agent-metadata.test.sh +75 -0
  20. package/scripts/tests/bump-version.test.sh +552 -0
  21. package/scripts/tests/channel-parity.test.sh +117 -0
  22. package/scripts/tests/convert-content-integrity.test.sh +246 -0
  23. package/scripts/tests/convert-install-routing.test.sh +159 -0
  24. package/scripts/tests/install-work-view.test.sh +411 -0
  25. package/scripts/tests/pi-package-metadata.test.sh +119 -0
  26. package/scripts/tests/work-board-shim.test.sh +239 -0
  27. package/scripts/tests/work-view-dist-version.test.sh +105 -0
  28. package/scripts/work-board.sh +64 -0
  29. package/scripts/work-view.sh +423 -0
  30. package/skills/autopilot/SKILL.md +330 -0
  31. package/skills/autopilot/agents/openai.yaml +6 -0
  32. package/skills/board/SKILL.md +62 -0
  33. package/skills/board/agents/openai.yaml +6 -0
  34. package/skills/bold-refactor/SKILL.md +244 -0
  35. package/skills/bold-refactor/agents/openai.yaml +6 -0
  36. package/skills/bug-scan/SKILL.md +378 -0
  37. package/skills/bug-scan/agents/openai.yaml +6 -0
  38. package/skills/bug-scan/references/async-promises.md +119 -0
  39. package/skills/bug-scan/references/concurrency-races.md +148 -0
  40. package/skills/bug-scan/references/data-layer.md +167 -0
  41. package/skills/bug-scan/references/error-handling.md +197 -0
  42. package/skills/bug-scan/references/gate-item-template.md +94 -0
  43. package/skills/bug-scan/references/language-footguns.md +219 -0
  44. package/skills/bug-scan/references/parked-item-template.md +103 -0
  45. package/skills/bug-scan/references/report-template.md +115 -0
  46. package/skills/bug-scan/references/resource-leaks.md +199 -0
  47. package/skills/bug-scan/references/state-closures.md +148 -0
  48. package/skills/bug-scan/references/time-numbers.md +158 -0
  49. package/skills/convert/SKILL.md +1463 -0
  50. package/skills/convert/agents/openai.yaml +6 -0
  51. package/skills/convert/references/legacy-overlap-migration.md +179 -0
  52. package/skills/deep-code-scan/SKILL.md +378 -0
  53. package/skills/deep-code-scan/agents/openai.yaml +6 -0
  54. package/skills/deep-code-scan/references/artifact-ledger.md +148 -0
  55. package/skills/deep-code-scan/references/consolidation.md +91 -0
  56. package/skills/deep-code-scan/references/decomposition.md +127 -0
  57. package/skills/deep-code-scan/references/item-templates.md +263 -0
  58. package/skills/deep-code-scan/references/lane-catalog.md +129 -0
  59. package/skills/deep-code-scan/references/review-gauntlet.md +108 -0
  60. package/skills/deep-code-scan/references/scanner-brief.md +152 -0
  61. package/skills/e2e-test-design/SKILL.md +517 -0
  62. package/skills/e2e-test-design/references/anti-tautology.md +261 -0
  63. package/skills/e2e-test-design/references/service-mocks.md +234 -0
  64. package/skills/e2e-test-design/references/test-taxonomy.md +211 -0
  65. package/skills/epic-design/SKILL.md +476 -0
  66. package/skills/epicize/SKILL.md +210 -0
  67. package/skills/epicize/agents/openai.yaml +6 -0
  68. package/skills/feature-design/SKILL.md +472 -0
  69. package/skills/fix/SKILL.md +173 -0
  70. package/skills/gate-cruft/SKILL.md +258 -0
  71. package/skills/gate-docs/SKILL.md +278 -0
  72. package/skills/gate-patterns/SKILL.md +389 -0
  73. package/skills/gate-refactor/SKILL.md +408 -0
  74. package/skills/gate-security/SKILL.md +275 -0
  75. package/skills/gate-tests/SKILL.md +367 -0
  76. package/skills/groom/SKILL.md +162 -0
  77. package/skills/groom/agents/openai.yaml +6 -0
  78. package/skills/ideate/SKILL.md +185 -0
  79. package/skills/ideate/agents/openai.yaml +6 -0
  80. package/skills/implement/SKILL.md +288 -0
  81. package/skills/implement-orchestrator/SKILL.md +604 -0
  82. package/skills/park/SKILL.md +111 -0
  83. package/skills/perf-design/SKILL.md +427 -0
  84. package/skills/perf-scout/SKILL.md +404 -0
  85. package/skills/perf-scout/agents/openai.yaml +6 -0
  86. package/skills/perf-scout/references/algorithmic-and-data-structures.md +126 -0
  87. package/skills/perf-scout/references/approximation-and-precomputation.md +136 -0
  88. package/skills/perf-scout/references/caching-and-memoization.md +123 -0
  89. package/skills/perf-scout/references/compiler-runtime-and-language.md +136 -0
  90. package/skills/perf-scout/references/database-and-storage-internals.md +144 -0
  91. package/skills/perf-scout/references/distributed-systems.md +150 -0
  92. package/skills/perf-scout/references/game-engine-and-realtime.md +136 -0
  93. package/skills/perf-scout/references/gpu-and-accelerators.md +130 -0
  94. package/skills/perf-scout/references/idea-ranking.md +75 -0
  95. package/skills/perf-scout/references/io-and-batching.md +135 -0
  96. package/skills/perf-scout/references/memory-and-data-locality.md +137 -0
  97. package/skills/perf-scout/references/parallelism-and-vectorization.md +126 -0
  98. package/skills/perf-scout/references/parked-item-template.md +117 -0
  99. package/skills/perf-scout/references/peer-review-pass.md +150 -0
  100. package/skills/perf-scout/references/report-template.md +148 -0
  101. package/skills/principles/SKILL.md +678 -0
  102. package/skills/principles/references/models.md +191 -0
  103. package/skills/principles/references/subagents.md +158 -0
  104. package/skills/prose-author/SKILL.md +185 -0
  105. package/skills/refactor-conventions-creator/SKILL.md +359 -0
  106. package/skills/refactor-conventions-creator/agents/openai.yaml +6 -0
  107. package/skills/refactor-conventions-creator/references/common-structures.md +91 -0
  108. package/skills/refactor-conventions-creator/references/common-styles.md +90 -0
  109. package/skills/refactor-design/SKILL.md +384 -0
  110. package/skills/release-deploy/SKILL.md +667 -0
  111. package/skills/release-deploy/agents/openai.yaml +6 -0
  112. package/skills/research/SKILL.md +166 -0
  113. package/skills/research/agents/openai.yaml +6 -0
  114. package/skills/review/SKILL.md +267 -0
  115. package/skills/review/references/deep-review.md +98 -0
  116. package/skills/review/references/review-lenses.md +68 -0
  117. package/skills/review/references/substrate-side-effects.md +161 -0
  118. package/skills/review/references/target-resolution.md +52 -0
  119. package/skills/scope/SKILL.md +486 -0
  120. package/work-view/Cargo.lock +486 -0
  121. package/work-view/Cargo.toml +9 -0
  122. package/work-view/crates/cli/.work-view-version +1 -0
  123. package/work-view/crates/cli/Cargo.toml +18 -0
  124. package/work-view/crates/cli/src/actionable.rs +500 -0
  125. package/work-view/crates/cli/src/args.rs +792 -0
  126. package/work-view/crates/cli/src/board/assets/board.css +855 -0
  127. package/work-view/crates/cli/src/board/assets/board.js +259 -0
  128. package/work-view/crates/cli/src/board/assets/card.js +139 -0
  129. package/work-view/crates/cli/src/board/assets/components.css +290 -0
  130. package/work-view/crates/cli/src/board/assets/dependency.js +1193 -0
  131. package/work-view/crates/cli/src/board/assets/detail.js +256 -0
  132. package/work-view/crates/cli/src/board/assets/filters.js +389 -0
  133. package/work-view/crates/cli/src/board/assets/index.html +77 -0
  134. package/work-view/crates/cli/src/board/assets/kanban.js +231 -0
  135. package/work-view/crates/cli/src/board/assets/markdown.js +260 -0
  136. package/work-view/crates/cli/src/board/assets/motion.css +131 -0
  137. package/work-view/crates/cli/src/board/assets/state.js +245 -0
  138. package/work-view/crates/cli/src/board/assets/table.js +304 -0
  139. package/work-view/crates/cli/src/board/assets/tokens.css +602 -0
  140. package/work-view/crates/cli/src/board/assets/views.js +41 -0
  141. package/work-view/crates/cli/src/board/assets.rs +162 -0
  142. package/work-view/crates/cli/src/board/feed.rs +204 -0
  143. package/work-view/crates/cli/src/board/mod.rs +246 -0
  144. package/work-view/crates/cli/src/board/open.rs +144 -0
  145. package/work-view/crates/cli/src/board/server.rs +407 -0
  146. package/work-view/crates/cli/src/main.rs +195 -0
  147. package/work-view/crates/cli/src/render.rs +354 -0
  148. package/work-view/crates/cli/src/scope.rs +157 -0
  149. package/work-view/crates/cli/src/stale.rs +581 -0
  150. package/work-view/crates/cli/tests/board-js/dependency-table.test.mjs +64 -0
  151. package/work-view/crates/cli/tests/board-js/expanded-browsing.test.mjs +79 -0
  152. package/work-view/crates/cli/tests/board-js/harness-smoke.test.mjs +11 -0
  153. package/work-view/crates/cli/tests/board-js/harness.mjs +437 -0
  154. package/work-view/crates/cli/tests/board-js/kanban-detail.test.mjs +75 -0
  155. package/work-view/crates/cli/tests/board-js/markdown-filter.test.mjs +60 -0
  156. package/work-view/crates/cli/tests/fixtures/golden/.work/CONVENTIONS.md +3 -0
  157. package/work-view/crates/cli/tests/fixtures/golden/.work/active/epics/epic-alpha.md +16 -0
  158. package/work-view/crates/cli/tests/fixtures/golden/.work/active/features/feat-a.md +16 -0
  159. package/work-view/crates/cli/tests/fixtures/golden/.work/active/features/feat-b.md +16 -0
  160. package/work-view/crates/cli/tests/fixtures/golden/.work/active/stories/story-alpha-1.md +16 -0
  161. package/work-view/crates/cli/tests/fixtures/golden/.work/active/stories/story-research-1.md +19 -0
  162. package/work-view/crates/cli/tests/fixtures/golden/.work/archive/feat-done.md +16 -0
  163. package/work-view/crates/cli/tests/fixtures/golden/.work/archive/feat-shipped.md +18 -0
  164. package/work-view/crates/cli/tests/fixtures/golden/.work/backlog/idea-backlog.md +7 -0
  165. package/work-view/crates/cli/tests/fixtures/golden/.work/releases/v1.0/v1.0.md +16 -0
  166. package/work-view/crates/cli/tests/fixtures/ready-drafting/.work/CONVENTIONS.md +6 -0
  167. package/work-view/crates/cli/tests/fixtures/ready-drafting/.work/active/features/feat-dep-done.md +17 -0
  168. package/work-view/crates/cli/tests/fixtures/ready-drafting/.work/active/features/feat-design-ready.md +17 -0
  169. package/work-view/crates/cli/tests/fixtures/ready-drafting/.work/active/features/feat-impl-ready.md +17 -0
  170. package/work-view/crates/cli/tests/fixtures/ready-drafting/.work/active/stories/story-review-ready.md +17 -0
  171. package/work-view/crates/cli/tests/fixtures/with-malformed/.work/CONVENTIONS.md +4 -0
  172. package/work-view/crates/cli/tests/fixtures/with-malformed/.work/active/epics/malformed-no-closing-fence.md +8 -0
  173. package/work-view/crates/cli/tests/fixtures/with-malformed/.work/active/features/good-item.md +16 -0
  174. package/work-view/crates/cli/tests/integration.rs +2833 -0
  175. package/work-view/crates/core/Cargo.toml +13 -0
  176. package/work-view/crates/core/src/error.rs +61 -0
  177. package/work-view/crates/core/src/filter.rs +804 -0
  178. package/work-view/crates/core/src/graph.rs +324 -0
  179. package/work-view/crates/core/src/index.rs +590 -0
  180. package/work-view/crates/core/src/lib.rs +54 -0
  181. package/work-view/crates/core/src/model.rs +202 -0
  182. package/work-view/crates/core/src/parse.rs +494 -0
  183. package/work-view/crates/core/tests/fixtures/golden/.work/CONVENTIONS.md +15 -0
  184. package/work-view/crates/core/tests/fixtures/golden/.work/active/epics/epic-core.md +16 -0
  185. package/work-view/crates/core/tests/fixtures/golden/.work/active/features/feat-parser.md +16 -0
  186. package/work-view/crates/core/tests/fixtures/golden/.work/active/features/feat-query.md +16 -0
  187. package/work-view/crates/core/tests/fixtures/golden/.work/active/stories/malformed-no-id.md +15 -0
  188. package/work-view/crates/core/tests/fixtures/golden/.work/active/stories/story-parse-unit.md +16 -0
  189. package/work-view/crates/core/tests/fixtures/golden/.work/active/stories/story-security-gate.md +16 -0
  190. package/work-view/crates/core/tests/fixtures/golden/.work/archive/feat-old.md +16 -0
  191. package/work-view/crates/core/tests/fixtures/golden/.work/archive/feat-parser.md +17 -0
  192. package/work-view/crates/core/tests/fixtures/golden/.work/backlog/idea-future-board.md +7 -0
  193. package/work-view/crates/core/tests/fixtures/golden/.work/releases/v1.0/v1.0.md +16 -0
  194. package/work-view/crates/core/tests/fixtures/precedence/.work/CONVENTIONS.md +10 -0
  195. package/work-view/crates/core/tests/fixtures/precedence/.work/archive/dup-item.md +18 -0
  196. package/work-view/crates/core/tests/fixtures/precedence/.work/releases/v2.0/dup-item.md +18 -0
  197. package/work-view/crates/core/tests/integration.rs +541 -0
  198. package/work-view/dist/.gitattributes +1 -0
  199. package/work-view/dist/README.md +42 -0
  200. package/work-view/dist/aarch64-apple-darwin/work-view +0 -0
  201. package/work-view/dist/aarch64-unknown-linux-musl/work-view +0 -0
  202. package/work-view/dist/x86_64-apple-darwin/work-view +0 -0
  203. package/work-view/dist/x86_64-unknown-linux-musl/work-view +0 -0
@@ -0,0 +1,278 @@
1
+ ---
2
+ name: gate-docs
3
+ description: >
4
+ Documentation gate that enforces the rolling-foundation principle. Delegates the full drift
5
+ detection to a deep documentation scanner agent which scans the bundle's changes for
6
+ foundation-doc drift (assertions in docs/ that no longer match implementation), changelog gaps,
7
+ README staleness, and skill/pattern-skill staleness. The orchestrator converts findings into items
8
+ in .work/active/ with gate_origin:docs and tags:[documentation]. Auto-triggers during
9
+ /agile-workflow:release-deploy.
10
+ ---
11
+
12
+ # Gate-Docs
13
+
14
+ You orchestrate a documentation gate that enforces the **rolling-foundation
15
+ principle**: foundation docs in `docs/` describe current truth or intended
16
+ future state, never past state. After implementation work, foundation-doc
17
+ assertions can drift from reality or from the intended state they are meant to
18
+ describe.
19
+
20
+ The actual drift detection runs inside a **deep documentation scanner agent**
21
+ (a generic sub-agent prompted with the scanner posture from `../principles/references/subagents.md`); your role is to
22
+ prepare the bundle context, dispatch the scanner, and convert the findings it
23
+ returns into items that will roll the docs forward.
24
+
25
+ Scanner strength is explicit: spawn exactly one source-read-only deep
26
+ documentation scanner with the strongest inspection/reviewer setting the host
27
+ exposes. Use a generic sub-agent prompted with the scanner posture from `../principles/references/subagents.md`. Use
28
+ extra-high reasoning for large documentation surfaces or broad API drift. If the
29
+ host has no scanner path, run the audit inline and record the reduced
30
+ isolation in the release body.
31
+
32
+ ## Trigger
33
+
34
+ - `/agile-workflow:release-deploy` invokes during `quality-gate` stage
35
+ - User can invoke manually: `/agile-workflow:gate-docs <release-version>`
36
+
37
+ ## Workflow
38
+
39
+ ### Phase 1: Identify bundle and changed files
40
+
41
+ ```bash
42
+ # Bound non-release items. `--release` auto-widens to ALL tiers (active + archive + releases).
43
+ # Include late-bound archived stubs; their bodies may be pruned, but their item id is still
44
+ # present and can recover the bundle commits/files. Ignore only the release orchestration item.
45
+ .work/bin/work-view --release <version> --paths | while IFS= read -r item; do
46
+ kind=$(grep -m1 '^kind:' "$item" | awk '{print $2}')
47
+ [ "$kind" = "release" ] && continue
48
+ echo "$item"
49
+ done > /tmp/bundle-items-<version>.txt
50
+
51
+ # Files changed by the bundle. For archived stubs, the body is pruned on disk by design; use the
52
+ # item id to find implementation commits instead of treating the missing body as a skip reason.
53
+ while IFS= read -r item; do
54
+ id=$(grep -m1 '^id:' "$item" | awk '{print $2}')
55
+ git log --grep "$id" --format='%H' | xargs -I{} git diff-tree --no-commit-id --name-only -r {}
56
+ done < /tmp/bundle-items-<version>.txt | sort -u > /tmp/bundle-files-<version>.txt
57
+ ```
58
+
59
+ ### Phase 2: Read existing gate items (idempotency prep)
60
+
61
+ ```bash
62
+ .work/bin/work-view --release <version> --gate docs --paths
63
+ ```
64
+
65
+ Capture the set of `(doc-file:line, drift-category)` already-tracked findings.
66
+
67
+ ### Phase 3: Dispatch the drift-detection scanner
68
+
69
+ Spawn ONE source-read-only deep scanner agent with the full drift-detection
70
+ brief. Use a generic sub-agent prompted with the scanner posture from `../principles/references/subagents.md` and the
71
+ strongest inspection/reviewer setting the host exposes, escalating for large
72
+ documentation surfaces. If scanner agents are unavailable, run the audit
73
+ inline and record the reduced isolation in the release body. The scanner maps
74
+ the doc structure, classifies the bundle's changes, runs drift-check passes, and
75
+ returns structured findings.
76
+
77
+ **Brief template**:
78
+
79
+ > You are conducting a documentation drift audit for release `<version>` as an
80
+ > agile-workflow scanner. The principle: docs in `docs/` describe current truth
81
+ > or intended future state, never past state. Drift = doc says X, but the
82
+ > completed bundle now does Y or the intended future state has changed to Y. Use
83
+ > read/search/shell tools as needed, but do not spawn nested sub-agents or fix docs.
84
+ >
85
+ > **Bundle scope** (the changes that may have caused drift):
86
+ > ```
87
+ > <bundle-files>
88
+ > ```
89
+ >
90
+ > **Bound items** (read each item's body to classify the change type; an
91
+ > archived stub's body is pruned on disk — hydrate it from the stub's
92
+ > `git_ref` frontmatter via `git show <git_ref>:<path>`, trying the item's
93
+ > former `.work/active/` path at that ref):
94
+ > `<bound-item-ids>`
95
+ >
96
+ > **Already-tracked findings to skip**:
97
+ > ```
98
+ > <already-tracked doc:line / category pairs>
99
+ > ```
100
+ >
101
+ > **Methodology**:
102
+ >
103
+ > 1. **Map the doc structure**:
104
+ > - Foundation docs at `docs/`: VISION.md, SPEC.md, ARCHITECTURE.md,
105
+ > PRINCIPLES.md, domain-specific (UX.md, CONTRACT.md, GAMEPLAY.md, etc.)
106
+ > - README.md at repo root
107
+ > - CHANGELOG.md
108
+ > - Repo-specific skills at `.agents/skills/` or legacy `.claude/skills/`
109
+ > - Pattern skills at `.agents/skills/patterns/` or legacy `.claude/skills/patterns/`
110
+ > - Generated files (look for `# generated`, `llms-full.txt` — never
111
+ > edit; flag for regeneration)
112
+ >
113
+ > 2. **Classify each bound item's change type**:
114
+ > | Change type | Doc owners |
115
+ > |---|---|
116
+ > | New feature / behavior | SPEC.md, ARCHITECTURE.md, relevant guide pages |
117
+ > | New CLI command or flag | CLI reference, SPEC.md, guide pages |
118
+ > | New config key | Config reference, SPEC.md |
119
+ > | Prompt / UX flow change | UX.md, guide pages |
120
+ > | New module or interface | ARCHITECTURE.md, API reference |
121
+ > | Bug fix with behavior impact | SPEC.md (if behavior was mis-documented), CHANGELOG.md |
122
+ > | New stable pattern | Pattern skills under `.agents/skills/patterns/` |
123
+ > | Changed interface used by repo skills | Repo-specific skills referencing it |
124
+ >
125
+ > 3. **Drift-check passes** — run each relevant pass yourself:
126
+ > - **Foundation-doc drift** — for VISION.md, SPEC.md, ARCHITECTURE.md,
127
+ > for each assertion (interface, contract, component, behavior), grep
128
+ > the bundle's changed files. Flag any assertion where the doc says X
129
+ > but the code now does Y. Cite file:line for the doc and the code.
130
+ > - **README staleness** — verify quick-start, install steps, examples,
131
+ > command names match the codebase post-bundle.
132
+ > - **CHANGELOG gap** — for each item bound to release `<version>`,
133
+ > verify a changelog entry exists.
134
+ > - **Repo skill staleness** — for each `.agents/skills/<name>/SKILL.md`
135
+ > or legacy `.claude/skills/<name>/SKILL.md`,
136
+ > grep for terms used in the skill against the bundle's changed files.
137
+ > Flag references to terms that no longer exist or signatures that
138
+ > changed.
139
+ > - **Pattern skill staleness** — for each `.agents/skills/patterns/*.md`
140
+ > or legacy `.claude/skills/patterns/*.md`,
141
+ > verify example file:line references still resolve and code still
142
+ > matches.
143
+ > - **Doc misplacement** — scan `docs/` for files that are item-shaped
144
+ > (contain `## Acceptance Criteria`, `## Implementation Units`, or
145
+ > `feature-`/`story-` prefixes). These belong in `.work/`.
146
+ >
147
+ > **Output format** — return a single markdown document with:
148
+ >
149
+ > ```
150
+ > ## Findings
151
+ >
152
+ > ### Finding 1
153
+ > - **Title**: <one-line: which doc, what drift>
154
+ > - **Drift category**: foundation-doc-assertion | readme-staleness |
155
+ > changelog-gap | repo-skill-staleness | pattern-skill-staleness |
156
+ > generated-file-needs-regen | doc-misplacement
157
+ > - **Confidence**: High | Medium
158
+ > - **Doc location**: `<file>:<line>`
159
+ > - **Code location**: `<file>:<line>` (for assertion drift; omit for gaps)
160
+ > - **Current doc text**:
161
+ > > <quote — what the doc currently says>
162
+ > - **Reality**: <what the code now does, post-bundle>
163
+ > - **Required edit**: <roll the doc forward to match the new active truth.
164
+ > Apply rolling-foundation: no "previously" prose, no "in v1.x" notes.
165
+ > Replace the assertion in place. For generated files, give the
166
+ > regeneration command.>
167
+ >
168
+ > ### Finding 2
169
+ > ...
170
+ > ```
171
+ >
172
+ > Followed by:
173
+ >
174
+ > ```
175
+ > ## Audit summary
176
+ > - Doc structure: <one-line>
177
+ > - Drift checks run: <list>
178
+ > - Findings by category: <breakdown>
179
+ > ```
180
+ >
181
+ > **Rules**:
182
+ > - Scan only the bundle's changes plus the docs that own those areas.
183
+ > Don't audit every doc in the repo.
184
+ > - Cite file:line for every finding.
185
+ > - Required edits ENFORCE rolling-foundation: replace stale assertions in
186
+ > place. Do NOT propose adding "previously" or "in v1.x" prose. Git is the
187
+ > audit trail; the doc carries the active truth.
188
+ > - For generated files, the required edit is the regeneration command, not
189
+ > a manual edit.
190
+ > - Skip already-tracked findings.
191
+ > - Don't fix the docs in the scanner. Findings only.
192
+
193
+ ### Phase 4: Convert findings to items
194
+
195
+ For each finding the scanner returned:
196
+
197
+ Read `gate_finding_routing` from `.work/CONVENTIONS.md` before writing items.
198
+ If absent, use the default routing below. Normalize documentation confidence to
199
+ routing keys as: `High -> high` and `Medium -> medium`. If a normalized key maps
200
+ to `skip`, do not emit an item for that finding; include the skipped count in
201
+ the gate output. If it maps to `backlog`, write a `.work/backlog/` item instead
202
+ of an active story.
203
+
204
+ ```yaml
205
+ ---
206
+ id: gate-docs-<short-slug>
207
+ kind: story
208
+ stage: implementing # high-confidence drift
209
+ # OR drafting for medium
210
+ tags: [documentation]
211
+ parent: null
212
+ depends_on: []
213
+ release_binding: <version>
214
+ gate_origin: docs
215
+ created: YYYY-MM-DD
216
+ updated: YYYY-MM-DD
217
+ ---
218
+
219
+ # <one-line: which doc, what drift>
220
+
221
+ ## Drift category
222
+ <category>
223
+
224
+ ## Location
225
+ - Doc: `<file>:<line>`
226
+ - Code: `<file>:<line>` (for assertion drift)
227
+
228
+ ## Current doc text
229
+ > <quote the doc — what it currently says>
230
+
231
+ ## Reality
232
+ <what the code now does, post-bundle>
233
+
234
+ ## Required edit
235
+ <roll the doc forward to match the new active truth. Apply rolling-foundation:
236
+ no "previously" prose, no "in v1.x" notes. Replace the assertion in place.>
237
+ ```
238
+
239
+ For generated files needing regeneration, the item describes the regeneration
240
+ command rather than a manual edit.
241
+
242
+ Default confidence -> placement mapping:
243
+ - **High** → `stage: implementing` in `.work/active/stories/`
244
+ - **Medium** → `stage: drafting` in `.work/active/stories/`
245
+
246
+ ### Phase 5: Commit
247
+
248
+ ```bash
249
+ git add .work/active/stories/ .work/backlog/
250
+ git commit -m "gate-docs: <N> rolling-foundation findings for <version>"
251
+ ```
252
+
253
+ ## Output
254
+
255
+ In conversation:
256
+ - **Bundle**: `<version>` — `<N>` items audited
257
+ - **Drift found**: count by category
258
+ - **Items created**: count, with new ids
259
+ - **Generated files needing regen**: list (if any)
260
+ - **Goal reminder**: rolling-foundation enforces docs describing current truth
261
+ or intended future state, never past state. Findings here become items the
262
+ release flow drains to `done` before shipping.
263
+
264
+ ## Guardrails
265
+
266
+ - **The drift detection happens in the scanner agent, not here.** Your job is
267
+ bundle prep, dispatch, and item-writing. Don't replicate the scanner's
268
+ analysis in the orchestrator's context.
269
+ - Foundation-doc drift is the gate's primary job. The scanner surfaces it;
270
+ you turn it into items.
271
+ - Required edits ENFORCE rolling-foundation: replace stale assertions in
272
+ place. Do NOT propose adding "previously" or "in v1.x" prose.
273
+ - Don't fix the docs in this skill — produce items only. Implementation of
274
+ the fixes happens via `/agile-workflow:implement` on each item.
275
+ - Audit only the bundle's changes plus the docs that own those areas — the
276
+ scanner enforces this; don't override.
277
+ - Generated files get items describing the regeneration command, not manual
278
+ edits.
@@ -0,0 +1,389 @@
1
+ ---
2
+ name: gate-patterns
3
+ description: >
4
+ Patterns gate that scans the bundle's changes for reusable code structures. Delegates the full
5
+ discovery to a deep pattern scanner agent which identifies recurring shapes (3+ occurrences)
6
+ introduced or revealed by the bundle, names them, documents them with concrete file:line examples,
7
+ and returns pattern drafts. The orchestrator writes detailed pattern skills to
8
+ .agents/skills/patterns/ (the single source of truth) with optional Claude mirrors, updates the
9
+ index, also generates the hook-loaded .agents/rules/patterns.md digest (a do-not-hand-edit
10
+ slug+one-liner index that points back at the patterns skill for detail), and produces a tracking
11
+ item with gate_origin:patterns. Auto-triggers during /agile-workflow:release-deploy as the final
12
+ gate.
13
+ ---
14
+
15
+ # Gate-Patterns
16
+
17
+ You orchestrate a patterns gate over the bundle's code changes. The actual
18
+ pattern discovery runs inside a **deep pattern scanner agent** (a generic sub-agent prompted with the scanner posture from `../principles/references/subagents.md`); your role is to prepare the
19
+ bundle context, dispatch the scanner, and write the pattern files + index it
20
+ returns.
21
+
22
+ Scanner strength is explicit: spawn exactly one source-read-only deep pattern
23
+ scanner with the strongest inspection/reviewer setting the host exposes. Use a generic sub-agent prompted with the scanner posture from `../principles/references/subagents.md`. Use extra-high reasoning
24
+ only for large/polyglot bundles, architecture-wide pattern extraction, or
25
+ conflicting pattern catalogs. If the host has no scanner path, run
26
+ discovery inline and record the reduced isolation in the release body.
27
+
28
+ This is NOT about coding style or naming conventions (that's `AGENTS.md` /
29
+ `CLAUDE.md`'s job). This is about identifying structural patterns for
30
+ consistency and reuse.
31
+
32
+ ## Trigger
33
+
34
+ - `/agile-workflow:release-deploy` invokes during `quality-gate` stage
35
+ (typically last in the gate sequence)
36
+ - User can invoke manually: `/agile-workflow:gate-patterns <release-version>`
37
+
38
+ ## Workflow
39
+
40
+ ### Phase 1: Read existing patterns
41
+
42
+ ```bash
43
+ ls .agents/skills/patterns/ 2>/dev/null
44
+ cat .agents/skills/patterns/SKILL.md 2>/dev/null
45
+ ls .claude/skills/patterns/ 2>/dev/null
46
+ cat AGENTS.md 2>/dev/null
47
+ cat .agents/AGENTS.md 2>/dev/null
48
+ cat .claude/AGENTS.md 2>/dev/null
49
+ ```
50
+
51
+ Capture the existing pattern catalog and project rules context so the scanner
52
+ doesn't redocument existing patterns or mistake project conventions for
53
+ structural patterns. Prefer `.agents/skills/patterns/` as the source of truth;
54
+ read `.claude/skills/patterns/` only as a legacy mirror. Project-level rules
55
+ belong in the selected `AGENTS.md` target. If an older repo still has
56
+ `.claude/rules/patterns.md`, that content should be migrated by
57
+ `/agile-workflow:convert --update`; do not treat it as a gate input or source
58
+ of truth.
59
+
60
+ **Rules folder directive.** The detailed pattern bodies in
61
+ `.agents/skills/patterns/` are the single, hand-maintained source of truth. The
62
+ hook-loaded rules digest lives at `.agents/rules/patterns.md` — a **generated**
63
+ slug+one-liner index that this gate writes in Phase 5 alongside the skill index,
64
+ pointing back at the patterns skill for full detail. `.agents/rules/patterns.md`
65
+ is **not hand-editable**: any change made there is overwritten on the next gate
66
+ run. Edit patterns by editing `.agents/skills/patterns/<slug>.md` and re-running
67
+ the gate; never edit the digest directly.
68
+
69
+ ### Phase 2: Identify bundle scope
70
+
71
+ ```bash
72
+ # Bound non-release items. `--release` auto-widens to ALL tiers (active + archive + releases).
73
+ # Include late-bound archived stubs; their bodies may be pruned, but their item id is still
74
+ # present and can recover the bundle commits/files. Ignore only the release orchestration item.
75
+ .work/bin/work-view --release <version> --paths | while IFS= read -r item; do
76
+ kind=$(grep -m1 '^kind:' "$item" | awk '{print $2}')
77
+ [ "$kind" = "release" ] && continue
78
+ echo "$item"
79
+ done > /tmp/bundle-items-<version>.txt
80
+
81
+ # Files changed by the bundle. For archived stubs, the body is pruned on disk by design; use the
82
+ # item id to find implementation commits instead of treating the missing body as a skip reason.
83
+ while IFS= read -r item; do
84
+ id=$(grep -m1 '^id:' "$item" | awk '{print $2}')
85
+ git log --grep "$id" --format='%H' | xargs -I{} git diff-tree --no-commit-id --name-only -r {}
86
+ done < /tmp/bundle-items-<version>.txt | sort -u > /tmp/bundle-files-<version>.txt
87
+ ```
88
+
89
+ ### Phase 3: Dispatch the pattern scanner
90
+
91
+ Spawn ONE source-read-only deep scanner agent with the full discovery brief. Use
92
+ a generic sub-agent prompted with the scanner posture from `../principles/references/subagents.md` and the strongest
93
+ inspection/reviewer setting the host exposes, escalating for large/polyglot
94
+ bundles, architecture-wide pattern extraction, or conflicting catalogs. If
95
+ scanner agents are unavailable, run discovery inline and record the reduced
96
+ isolation in the release body. The scanner runs pattern-search passes, filters
97
+ to genuine 3+ occurrences, drafts pattern documentation, and returns structured
98
+ output.
99
+
100
+ **Brief template**:
101
+
102
+ > You are conducting pattern discovery for release `<version>`. Identify
103
+ > reusable code structures the bundle introduces or reveals — recurring
104
+ > shapes that appear 3+ times. NOT coding style or naming conventions
105
+ > (that's AGENTS.md / CLAUDE.md's job); structural patterns for consistency and reuse.
106
+ >
107
+ > Use read/search/shell tools as needed. Do not spawn nested sub-agents or modify
108
+ > source files.
109
+ >
110
+ > **Bundle scope**:
111
+ > ```
112
+ > <bundle-files>
113
+ > ```
114
+ >
115
+ > **Existing pattern catalog** (do NOT redocument these; flag inconsistencies
116
+ > against them):
117
+ > ```
118
+ > <existing-patterns-listing>
119
+ > ```
120
+ >
121
+ > **Methodology**:
122
+ >
123
+ > 1. **Pattern discovery passes** — inspect the bundle's changed files plus
124
+ > their immediate consumers (since reuse implies multiple call sites):
125
+ > - **Shared abstractions & utilities** — find new shared/reusable code
126
+ > introduced in the bundle: utility functions, base classes, common
127
+ > helpers, types used across multiple modules. List each with
128
+ > file:line and which modules use it.
129
+ > - **Architectural patterns** — identify recurring structural
130
+ > approaches: how modules are organized, how services are composed,
131
+ > how data flows between layers, how config and async/error
132
+ > propagation are handled. Concrete file:line examples.
133
+ > - **Testing infrastructure** — find new reusable test patterns:
134
+ > shared fixtures, test utilities, common setup/teardown, mocking
135
+ > approaches, assertion helpers.
136
+ >
137
+ > Read 3-4 key files yourself to verify the candidate patterns.
138
+ >
139
+ > 2. **Filter to genuine patterns.** A finding is a genuine pattern only if
140
+ > it has **3+ occurrences** in the codebase (not just in the bundle —
141
+ > count across the whole repo). Single-use shapes are not patterns.
142
+ > Two-use shapes are coincidence. Three+ is a pattern.
143
+ >
144
+ > For each candidate, also check: does this contradict an existing
145
+ > documented pattern? If so, it's a divergence to flag (not a new
146
+ > pattern to document).
147
+ >
148
+ > 3. **Draft pattern files** for each genuine new pattern.
149
+ >
150
+ > **Output format** — return a single markdown document with:
151
+ >
152
+ > ```
153
+ > ## New patterns
154
+ >
155
+ > ### Pattern: <Pattern Name> (slug: <slug>)
156
+ >
157
+ > <one-line description>
158
+ >
159
+ > #### Rationale
160
+ > <why this pattern exists in this project>
161
+ >
162
+ > #### Examples
163
+ >
164
+ > ##### Example 1: <description>
165
+ > **File**: `src/path/file.ext:42`
166
+ > ```<lang>
167
+ > <concrete code example>
168
+ > ```
169
+ >
170
+ > ##### Example 2: <description>
171
+ > **File**: `src/path/other.ext:18`
172
+ > ```<lang>
173
+ > <concrete code example>
174
+ > ```
175
+ >
176
+ > ##### Example 3: <description>
177
+ > **File**: `src/path/third.ext:55`
178
+ > ```<lang>
179
+ > <concrete code example>
180
+ > ```
181
+ >
182
+ > #### When to Use
183
+ > - <circumstance>
184
+ >
185
+ > #### When NOT to Use
186
+ > - <circumstance>
187
+ >
188
+ > #### Common Violations
189
+ > - <violation and why it's wrong>
190
+ >
191
+ > #### Index entry
192
+ > - **<name>**: <terse rule, one line, suitable for the patterns index>
193
+ >
194
+ > ### Pattern: <next pattern>
195
+ > ...
196
+ > ```
197
+ >
198
+ > Followed by:
199
+ >
200
+ > ```
201
+ > ## Inconsistencies
202
+ >
203
+ > ### Inconsistency 1
204
+ > - **Existing pattern**: <slug or name>
205
+ > - **Bundle code that violates it**: `<file>:<line>`
206
+ > - **Nature of divergence**: <one-line>
207
+ >
208
+ > ### Inconsistency 2
209
+ > ...
210
+ >
211
+ > ## Discovery summary
212
+ > - Files scanned: <count>
213
+ > - Pattern candidates evaluated: <count>
214
+ > - Genuine patterns (3+ occurrences): <count>
215
+ > - Inconsistencies with existing patterns: <count>
216
+ > ```
217
+ >
218
+ > **Rules**:
219
+ > - 3+ occurrences required. Single-use is not a pattern. Two-use is
220
+ > coincidence.
221
+ > - Don't document style conventions — that's AGENTS.md / CLAUDE.md's job.
222
+ > - Every pattern needs concrete file:line examples — abstract descriptions
223
+ > don't serve agents.
224
+ > - Don't propose patterns that contradict existing documented ones; flag
225
+ > the divergence instead.
226
+ > - Don't fabricate patterns. If discovery yields nothing, return an empty
227
+ > "New patterns" section.
228
+
229
+ ### Phase 4: Write pattern files
230
+
231
+ For each new pattern the scanner returned, write
232
+ `.agents/skills/patterns/<slug>.md` with the pattern content (everything
233
+ under the `### Pattern:` heading except the `Index entry` block).
234
+
235
+ ### Phase 5: Regenerate the index and the rules digest
236
+
237
+ First, compute the per-pattern entries **once**. For each pattern (existing
238
+ entries combined with the new ones from the scanner's output), you have a
239
+ `<slug>` and a `<one-line rule>` — for new patterns the one-liner is the terse
240
+ rule from the scanner's `#### Index entry` block. Order by relevance (most
241
+ commonly applicable first) and keep the list concise. These same entries feed
242
+ both files below, so they cannot drift.
243
+
244
+ **5a. Regenerate the skill index** `.agents/skills/patterns/SKILL.md` (the
245
+ single source of truth for the detailed pattern bodies):
246
+
247
+ ```markdown
248
+ ---
249
+ name: patterns
250
+ description: "Project code patterns and conventions. Auto-loads when implementing,
251
+ designing, verifying, or reviewing code. Provides detailed pattern definitions
252
+ with code examples."
253
+ user-invocable: false
254
+ allowed-tools: Read, Glob, Grep
255
+ ---
256
+
257
+ # Project Patterns Reference
258
+
259
+ This skill contains detailed pattern documentation for this project.
260
+ See individual pattern files for full details with code examples.
261
+
262
+ Available patterns:
263
+ - [<slug>.md](<slug>.md) — <one-line rule>
264
+ ```
265
+
266
+ **5b. Generate the rules digest** `.agents/rules/patterns.md`. This is the
267
+ concise, hook-loaded digest — NOT a source of truth. Reuse the exact same
268
+ `<slug>` + `<one-line rule>` pairs you wrote to the skill index (do not
269
+ recompute them), so the two files cannot drift. Compute `src-sha256` as the
270
+ SHA-256 of the index entry lines (the `<slug> — <one-line rule>` block, the same
271
+ text you emit below) so a consumer can detect drift from the skill index:
272
+
273
+ ```bash
274
+ mkdir -p .agents/rules
275
+ ```
276
+
277
+ Write `.agents/rules/patterns.md` with this exact shape:
278
+
279
+ ```markdown
280
+ <!-- generated by agile-workflow gate-patterns — do not hand-edit -->
281
+ <!-- agile-workflow:patterns-digest src-sha256=<sha256 of the slug+one-liner entry block> -->
282
+ ## Project Code Patterns
283
+ - <slug> — <one-line rule>
284
+ - ...
285
+
286
+ Load the `patterns` skill (read `.agents/skills/patterns/<slug>.md`) for full
287
+ rationale, examples, and common violations.
288
+ ```
289
+
290
+ The banner marks the file as generated; the `src-sha256` marker hashes the entry
291
+ block so drift from `.agents/skills/patterns/SKILL.md` is detectable; the entries
292
+ are the same slug+one-liner pairs written to the skill index; the pointer line
293
+ sends agents to the patterns skill for full detail. If discovery produced no
294
+ patterns and the catalog is empty, still write the banner + marker + pointer with
295
+ an empty entry list so the digest reflects the current (empty) state.
296
+
297
+ ### Phase 6: Maintain Claude mirror
298
+
299
+ If `.claude/skills/` exists, keep Claude compatibility by symlinking the
300
+ canonical skill:
301
+
302
+ ```bash
303
+ mkdir -p .claude/skills
304
+ ln -sfn ../../.agents/skills/patterns .claude/skills/patterns
305
+ ```
306
+
307
+ If symlinks are unavailable, copy `.agents/skills/patterns/` into
308
+ `.claude/skills/patterns/` as a mirror and note that `.agents/skills/patterns/`
309
+ is canonical.
310
+
311
+ Only `.agents/skills/patterns/` is mirrored to `.claude/`. The
312
+ `.agents/rules/patterns.md` digest is **generated** (Phase 5b) and is NOT a
313
+ `.claude` mirror target — the hook loads it from `.agents/rules/` directly in
314
+ both Claude Code and Codex. Do not symlink or copy it into `.claude/`.
315
+
316
+ ### Phase 7: Produce tracking item
317
+
318
+ Create one item summarizing what was extracted:
319
+
320
+ ```yaml
321
+ ---
322
+ id: gate-patterns-<release-version>
323
+ kind: story
324
+ stage: done # this gate's "work" is done when it writes the patterns
325
+ tags: [patterns]
326
+ parent: null
327
+ depends_on: []
328
+ release_binding: <version>
329
+ gate_origin: patterns
330
+ created: YYYY-MM-DD
331
+ updated: YYYY-MM-DD
332
+ ---
333
+
334
+ # Patterns extracted for <version>
335
+
336
+ ## New patterns codified
337
+ - `<slug>` — <one-line summary>
338
+ - `<slug>` — <one-line summary>
339
+
340
+ ## Inconsistencies flagged
341
+ <patterns the bundle introduces that contradict existing documented patterns>
342
+
343
+ ## Pattern files written
344
+ - `.agents/skills/patterns/<slug>.md`
345
+ - `.agents/skills/patterns/SKILL.md` (updated index)
346
+ - `.agents/rules/patterns.md` (generated hook-loaded digest)
347
+ ```
348
+
349
+ This item is at `stage: done` because the gate's work IS the writing of the
350
+ pattern files. No further implementation needed.
351
+
352
+ For each inconsistency the scanner flagged, ALSO produce a `[refactor]`
353
+ story (`stage: drafting`) so the divergence gets reconciled in a subsequent
354
+ release.
355
+
356
+ ### Phase 8: Commit
357
+
358
+ ```bash
359
+ git add .agents/skills/patterns/ .agents/rules/patterns.md .claude/skills/patterns .work/active/stories/gate-patterns-<version>.md .work/active/stories/gate-patterns-inconsistency-*.md
360
+ git commit -m "gate-patterns: <N> patterns extracted for <version>"
361
+ ```
362
+
363
+ ## Output
364
+
365
+ In conversation:
366
+ - **Bundle**: `<version>`
367
+ - **New patterns extracted**: list with slugs
368
+ - **Inconsistencies flagged**: count, with new story ids
369
+ - **Index updated**: `.agents/skills/patterns/SKILL.md`
370
+ - **Rules digest regenerated**: `.agents/rules/patterns.md`
371
+ - **Tracking item**: `gate-patterns-<version>` at `stage: done`
372
+
373
+ ## Guardrails
374
+
375
+ - **The discovery happens in the scanner agent, not here.** Your job is bundle
376
+ prep, dispatch, and writing the pattern files + index + tracking item.
377
+ Don't replicate the scanner's analysis.
378
+ - A pattern requires 3+ occurrences. The scanner enforces this; trust it.
379
+ - Don't document style conventions — that's AGENTS.md / CLAUDE.md's job.
380
+ - Every pattern needs concrete file:line examples — the scanner provides
381
+ them; don't write a pattern file without them.
382
+ - Inconsistencies with existing patterns become `[refactor]` stories, not
383
+ new pattern files.
384
+ - The tracking item is `stage: done` because the gate's deliverable is the
385
+ pattern files themselves, not deferred work.
386
+ - `.agents/skills/patterns/` is the single source of truth.
387
+ `.agents/rules/patterns.md` is a generated digest — compute the slug+one-liner
388
+ entries once in Phase 5 and write both files from them so they cannot drift;
389
+ never hand-edit the digest.