@engramm/dev-workflow 0.1.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 (234) hide show
  1. package/dist/agents/context-builder.d.ts +11 -0
  2. package/dist/agents/context-builder.d.ts.map +1 -0
  3. package/dist/agents/context-builder.js +62 -0
  4. package/dist/agents/context-builder.js.map +1 -0
  5. package/dist/agents/loader.d.ts +3 -0
  6. package/dist/agents/loader.d.ts.map +1 -0
  7. package/dist/agents/loader.js +54 -0
  8. package/dist/agents/loader.js.map +1 -0
  9. package/dist/agents/registry.d.ts +10 -0
  10. package/dist/agents/registry.d.ts.map +1 -0
  11. package/dist/agents/registry.js +35 -0
  12. package/dist/agents/registry.js.map +1 -0
  13. package/dist/agents/types.d.ts +20 -0
  14. package/dist/agents/types.d.ts.map +1 -0
  15. package/dist/agents/types.js +2 -0
  16. package/dist/agents/types.js.map +1 -0
  17. package/dist/cli/agent.d.ts +2 -0
  18. package/dist/cli/agent.d.ts.map +1 -0
  19. package/dist/cli/agent.js +101 -0
  20. package/dist/cli/agent.js.map +1 -0
  21. package/dist/cli/config.d.ts +2 -0
  22. package/dist/cli/config.d.ts.map +1 -0
  23. package/dist/cli/config.js +100 -0
  24. package/dist/cli/config.js.map +1 -0
  25. package/dist/cli/doctor.d.ts +2 -0
  26. package/dist/cli/doctor.d.ts.map +1 -0
  27. package/dist/cli/doctor.js +123 -0
  28. package/dist/cli/doctor.js.map +1 -0
  29. package/dist/cli/index.d.ts +3 -0
  30. package/dist/cli/index.d.ts.map +1 -0
  31. package/dist/cli/index.js +94 -0
  32. package/dist/cli/index.js.map +1 -0
  33. package/dist/cli/init.d.ts +7 -0
  34. package/dist/cli/init.d.ts.map +1 -0
  35. package/dist/cli/init.js +177 -0
  36. package/dist/cli/init.js.map +1 -0
  37. package/dist/cli/run.d.ts +4 -0
  38. package/dist/cli/run.d.ts.map +1 -0
  39. package/dist/cli/run.js +191 -0
  40. package/dist/cli/run.js.map +1 -0
  41. package/dist/cli/search.d.ts +2 -0
  42. package/dist/cli/search.d.ts.map +1 -0
  43. package/dist/cli/search.js +75 -0
  44. package/dist/cli/search.js.map +1 -0
  45. package/dist/cli/serve.d.ts +2 -0
  46. package/dist/cli/serve.d.ts.map +1 -0
  47. package/dist/cli/serve.js +34 -0
  48. package/dist/cli/serve.js.map +1 -0
  49. package/dist/cli/status.d.ts +2 -0
  50. package/dist/cli/status.d.ts.map +1 -0
  51. package/dist/cli/status.js +89 -0
  52. package/dist/cli/status.js.map +1 -0
  53. package/dist/cli/task.d.ts +2 -0
  54. package/dist/cli/task.d.ts.map +1 -0
  55. package/dist/cli/task.js +153 -0
  56. package/dist/cli/task.js.map +1 -0
  57. package/dist/cli/vault-io.d.ts +3 -0
  58. package/dist/cli/vault-io.d.ts.map +1 -0
  59. package/dist/cli/vault-io.js +75 -0
  60. package/dist/cli/vault-io.js.map +1 -0
  61. package/dist/hooks/post-edit.d.ts +3 -0
  62. package/dist/hooks/post-edit.d.ts.map +1 -0
  63. package/dist/hooks/post-edit.js +43 -0
  64. package/dist/hooks/post-edit.js.map +1 -0
  65. package/dist/hooks/post-task.d.ts +3 -0
  66. package/dist/hooks/post-task.d.ts.map +1 -0
  67. package/dist/hooks/post-task.js +25 -0
  68. package/dist/hooks/post-task.js.map +1 -0
  69. package/dist/hooks/pre-compact.d.ts +7 -0
  70. package/dist/hooks/pre-compact.d.ts.map +1 -0
  71. package/dist/hooks/pre-compact.js +34 -0
  72. package/dist/hooks/pre-compact.js.map +1 -0
  73. package/dist/hooks/session-end.d.ts +3 -0
  74. package/dist/hooks/session-end.d.ts.map +1 -0
  75. package/dist/hooks/session-end.js +80 -0
  76. package/dist/hooks/session-end.js.map +1 -0
  77. package/dist/hooks/session-start.d.ts +3 -0
  78. package/dist/hooks/session-start.d.ts.map +1 -0
  79. package/dist/hooks/session-start.js +108 -0
  80. package/dist/hooks/session-start.js.map +1 -0
  81. package/dist/index.d.ts +33 -0
  82. package/dist/index.d.ts.map +1 -0
  83. package/dist/index.js +27 -0
  84. package/dist/index.js.map +1 -0
  85. package/dist/intelligence/collector.d.ts +12 -0
  86. package/dist/intelligence/collector.d.ts.map +1 -0
  87. package/dist/intelligence/collector.js +93 -0
  88. package/dist/intelligence/collector.js.map +1 -0
  89. package/dist/intelligence/ranker.d.ts +5 -0
  90. package/dist/intelligence/ranker.d.ts.map +1 -0
  91. package/dist/intelligence/ranker.js +107 -0
  92. package/dist/intelligence/ranker.js.map +1 -0
  93. package/dist/intelligence/store.d.ts +17 -0
  94. package/dist/intelligence/store.d.ts.map +1 -0
  95. package/dist/intelligence/store.js +75 -0
  96. package/dist/intelligence/store.js.map +1 -0
  97. package/dist/intelligence/sync.d.ts +3 -0
  98. package/dist/intelligence/sync.d.ts.map +1 -0
  99. package/dist/intelligence/sync.js +83 -0
  100. package/dist/intelligence/sync.js.map +1 -0
  101. package/dist/intelligence/types.d.ts +35 -0
  102. package/dist/intelligence/types.d.ts.map +1 -0
  103. package/dist/intelligence/types.js +2 -0
  104. package/dist/intelligence/types.js.map +1 -0
  105. package/dist/lib/context.d.ts +3 -0
  106. package/dist/lib/context.d.ts.map +1 -0
  107. package/dist/lib/context.js +56 -0
  108. package/dist/lib/context.js.map +1 -0
  109. package/dist/lib/conventions-detect.d.ts +12 -0
  110. package/dist/lib/conventions-detect.d.ts.map +1 -0
  111. package/dist/lib/conventions-detect.js +337 -0
  112. package/dist/lib/conventions-detect.js.map +1 -0
  113. package/dist/lib/frontmatter.d.ts +7 -0
  114. package/dist/lib/frontmatter.d.ts.map +1 -0
  115. package/dist/lib/frontmatter.js +45 -0
  116. package/dist/lib/frontmatter.js.map +1 -0
  117. package/dist/lib/fs-helpers.d.ts +6 -0
  118. package/dist/lib/fs-helpers.d.ts.map +1 -0
  119. package/dist/lib/fs-helpers.js +24 -0
  120. package/dist/lib/fs-helpers.js.map +1 -0
  121. package/dist/lib/interpolate.d.ts +2 -0
  122. package/dist/lib/interpolate.d.ts.map +1 -0
  123. package/dist/lib/interpolate.js +4 -0
  124. package/dist/lib/interpolate.js.map +1 -0
  125. package/dist/lib/output.d.ts +27 -0
  126. package/dist/lib/output.d.ts.map +1 -0
  127. package/dist/lib/output.js +85 -0
  128. package/dist/lib/output.js.map +1 -0
  129. package/dist/lib/reader.d.ts +14 -0
  130. package/dist/lib/reader.d.ts.map +1 -0
  131. package/dist/lib/reader.js +75 -0
  132. package/dist/lib/reader.js.map +1 -0
  133. package/dist/lib/stack-detect.d.ts +12 -0
  134. package/dist/lib/stack-detect.d.ts.map +1 -0
  135. package/dist/lib/stack-detect.js +302 -0
  136. package/dist/lib/stack-detect.js.map +1 -0
  137. package/dist/lib/statusline.d.ts +3 -0
  138. package/dist/lib/statusline.d.ts.map +1 -0
  139. package/dist/lib/statusline.js +40 -0
  140. package/dist/lib/statusline.js.map +1 -0
  141. package/dist/lib/templates.d.ts +3 -0
  142. package/dist/lib/templates.d.ts.map +1 -0
  143. package/dist/lib/templates.js +174 -0
  144. package/dist/lib/templates.js.map +1 -0
  145. package/dist/lib/types.d.ts +44 -0
  146. package/dist/lib/types.d.ts.map +1 -0
  147. package/dist/lib/types.js +2 -0
  148. package/dist/lib/types.js.map +1 -0
  149. package/dist/lib/writer.d.ts +13 -0
  150. package/dist/lib/writer.d.ts.map +1 -0
  151. package/dist/lib/writer.js +97 -0
  152. package/dist/lib/writer.js.map +1 -0
  153. package/dist/mcp/handlers.d.ts +34 -0
  154. package/dist/mcp/handlers.d.ts.map +1 -0
  155. package/dist/mcp/handlers.js +256 -0
  156. package/dist/mcp/handlers.js.map +1 -0
  157. package/dist/mcp/server.d.ts +20 -0
  158. package/dist/mcp/server.d.ts.map +1 -0
  159. package/dist/mcp/server.js +89 -0
  160. package/dist/mcp/server.js.map +1 -0
  161. package/dist/mcp/tools.d.ts +11 -0
  162. package/dist/mcp/tools.d.ts.map +1 -0
  163. package/dist/mcp/tools.js +148 -0
  164. package/dist/mcp/tools.js.map +1 -0
  165. package/dist/tasks/manager.d.ts +14 -0
  166. package/dist/tasks/manager.d.ts.map +1 -0
  167. package/dist/tasks/manager.js +151 -0
  168. package/dist/tasks/manager.js.map +1 -0
  169. package/dist/tasks/tracker.d.ts +11 -0
  170. package/dist/tasks/tracker.d.ts.map +1 -0
  171. package/dist/tasks/tracker.js +31 -0
  172. package/dist/tasks/tracker.js.map +1 -0
  173. package/dist/tasks/types.d.ts +19 -0
  174. package/dist/tasks/types.d.ts.map +1 -0
  175. package/dist/tasks/types.js +2 -0
  176. package/dist/tasks/types.js.map +1 -0
  177. package/dist/workflow/builtin.d.ts +4 -0
  178. package/dist/workflow/builtin.d.ts.map +1 -0
  179. package/dist/workflow/builtin.js +93 -0
  180. package/dist/workflow/builtin.js.map +1 -0
  181. package/dist/workflow/engine.d.ts +38 -0
  182. package/dist/workflow/engine.d.ts.map +1 -0
  183. package/dist/workflow/engine.js +217 -0
  184. package/dist/workflow/engine.js.map +1 -0
  185. package/dist/workflow/loader.d.ts +4 -0
  186. package/dist/workflow/loader.d.ts.map +1 -0
  187. package/dist/workflow/loader.js +106 -0
  188. package/dist/workflow/loader.js.map +1 -0
  189. package/dist/workflow/state.d.ts +11 -0
  190. package/dist/workflow/state.d.ts.map +1 -0
  191. package/dist/workflow/state.js +49 -0
  192. package/dist/workflow/state.js.map +1 -0
  193. package/dist/workflow/types.d.ts +36 -0
  194. package/dist/workflow/types.d.ts.map +1 -0
  195. package/dist/workflow/types.js +2 -0
  196. package/dist/workflow/types.js.map +1 -0
  197. package/package.json +54 -0
  198. package/templates/agents/architect.md +46 -0
  199. package/templates/agents/coder.md +46 -0
  200. package/templates/agents/committer.md +29 -0
  201. package/templates/agents/debugger.md +54 -0
  202. package/templates/agents/planner.md +45 -0
  203. package/templates/agents/reader.md +48 -0
  204. package/templates/agents/reviewer.md +48 -0
  205. package/templates/agents/tester.md +41 -0
  206. package/templates/claude/agents/researcher.md +47 -0
  207. package/templates/claude/agents/writer.md +29 -0
  208. package/templates/claude/commands/git/changelog.md +41 -0
  209. package/templates/claude/commands/git/merge.md +37 -0
  210. package/templates/claude/commands/git/new-branch.md +34 -0
  211. package/templates/claude/commands/git/pr-review.md +64 -0
  212. package/templates/claude/commands/session/handover.md +49 -0
  213. package/templates/claude/commands/session/resume.md +43 -0
  214. package/templates/claude/commands/session/review.md +81 -0
  215. package/templates/claude/commands/task.md +52 -0
  216. package/templates/claude/commands/vault/adr.md +39 -0
  217. package/templates/claude/commands/vault/analyze.md +110 -0
  218. package/templates/claude/commands/vault/bug.md +31 -0
  219. package/templates/claude/commands/vault/debt.md +28 -0
  220. package/templates/claude/commands/vault/deps.md +36 -0
  221. package/templates/claude/commands/vault/from-spec.md +306 -0
  222. package/templates/claude/commands/vault/search.md +31 -0
  223. package/templates/claude/commands/vault/security-scan.md +50 -0
  224. package/templates/claude/commands/vault/test-gaps.md +38 -0
  225. package/templates/claude/commands/workflow/dev.md +913 -0
  226. package/templates/claude/commands/workflow.md +47 -0
  227. package/templates/claude/settings.json +52 -0
  228. package/templates/claude/skills/obsidian-markdown/SKILL.md +196 -0
  229. package/templates/claude/skills/obsidian-markdown/references/CALLOUTS.md +58 -0
  230. package/templates/claude/skills/obsidian-markdown/references/EMBEDS.md +63 -0
  231. package/templates/claude/skills/obsidian-markdown/references/PROPERTIES.md +61 -0
  232. package/templates/workflows/deploy.yaml +21 -0
  233. package/templates/workflows/release.yaml +26 -0
  234. package/templates/workflows/spike.yaml +14 -0
@@ -0,0 +1,913 @@
1
+ # /workflow:dev — Multi-agent development cycle
2
+
3
+ ## Output language
4
+
5
+ All user-facing output (display blocks, verdicts, summaries, questions) MUST be in Russian (ru-RU).
6
+ Internal protocol blocks (CONTEXT, PLAN, CODE_DONE, REVIEW, VERIFY) stay in English — they are machine-readable and parsed by the orchestrator.
7
+
8
+ Orchestrates agents in a 10-step quality pipeline:
9
+ read → plan (with pseudo-code) → plan-review → coder ↔ review×3 (loop) → test → verify → commit.
10
+ Each agent has strict permission boundaries. Context passes between agents as blocks.
11
+ Steps 4-6 form an iterative CODER↔REVIEW loop (max 3 iterations).
12
+
13
+ ## Arguments
14
+
15
+ `/workflow:dev <task>` — interactive mode (default, asks before commit).
16
+ `/workflow:dev <path>` — task from file (.md, .txt).
17
+ `/workflow:dev <task> --auto-commit` — autonomous mode (commits automatically, for swarm use).
18
+
19
+ ### Commit mode
20
+
21
+ | Mode | Flag | Commit | Gates on limit |
22
+ |------|------|--------|---------------|
23
+ | **Interactive** (default) | — | Ask user | Ask user |
24
+ | **Autonomous** | `--auto-commit` | Auto-commit | Stop without commit |
25
+
26
+ **Autonomous safety:** will NOT commit if any quality gate exhausts its retry limit.
27
+ Better to leave changes uncommitted than commit broken code.
28
+
29
+ ## Mode detection
30
+
31
+ If argument is a file path, read the file and detect mode:
32
+
33
+ - **Single task** (no `## Tasks` section or only 1 task) → **Normal mode** (Steps 1-8 below)
34
+ - **Phase file** (has `## Tasks` with 2+ items, or has `phase:` in frontmatter) → **Phase mode**
35
+
36
+ ### Phase mode
37
+
38
+ Phase mode plans the entire phase, then codes each subtask separately for focused quality.
39
+
40
+ ```
41
+ READ (full phase) → PLAN (full phase, outputs subtasks) → PLAN_REVIEW
42
+ → for each subtask:
43
+ CODER(subtask) → REVIEW×3(subtask) → fix loop → TEST (all tests)
44
+ → VERIFY (full phase against spec)
45
+ → COMMIT (all changes, one commit)
46
+ → Summary
47
+ ```
48
+
49
+ **Step 2 (PLAN) in phase mode** — add to agent prompt:
50
+
51
+ ```
52
+ You are planning a PHASE with multiple subtasks.
53
+ Break this into ordered implementation steps.
54
+ Each step must be completable in one CODER iteration.
55
+
56
+ Output format:
57
+ PLAN:
58
+ Summary: [phase goal]
59
+ Scope: large
60
+
61
+ Subtasks:
62
+ 1. [name]
63
+ Files: [list]
64
+ Tests: [list]
65
+ Depends on: [previous subtask number or "none"]
66
+
67
+ 2. [name]
68
+ Files: [list]
69
+ Tests: [list]
70
+ Depends on: 1
71
+
72
+ ...
73
+ END_PLAN
74
+ ```
75
+
76
+ **Steps 4-6 in phase mode** — loop over subtasks:
77
+
78
+ ```
79
+ for each subtask in PLAN.Subtasks:
80
+ display: ── SUBTASK [N/total]: [name] ──
81
+
82
+ CODER receives:
83
+ - Current subtask from PLAN
84
+ - Accumulated context from previous subtasks (CODE_DONE blocks)
85
+ - Vault context
86
+
87
+ REVIEW×3 receives (parallel):
88
+ - Current subtask from PLAN
89
+ - CODE_DONE for this subtask
90
+ - Vault context
91
+
92
+ fix loop (max 3 iterations per subtask)
93
+
94
+ TEST after each subtask:
95
+ - Run ALL tests (not just new ones) — catches regressions
96
+ - If fail → CODER fix → re-test
97
+ ```
98
+
99
+ **Step 7 (COMMIT) in phase mode** — one commit for the entire phase:
100
+
101
+ ```
102
+ feat(<scope>): implement Phase N — <phase name>
103
+
104
+ <summary of all subtasks completed>
105
+
106
+ Subtasks:
107
+ - <subtask 1>: <files>
108
+ - <subtask 2>: <files>
109
+ ...
110
+ ```
111
+
112
+ **Step 8 (Summary) in phase mode** — show subtask breakdown:
113
+
114
+ ```
115
+ ═══════════════════════════════
116
+ PHASE [N] COMPLETE
117
+ ═══════════════════════════════
118
+
119
+ Phase: [name]
120
+ Subtasks: [completed]/[total]
121
+
122
+ ✅ 1. [subtask name] — [N] files
123
+ ✅ 2. [subtask name] — [N] files
124
+ ...
125
+
126
+ Agents:
127
+ ✅ READ [Explore] — [N] files
128
+ ✅ PLAN [Explore] — [N] subtasks
129
+ ✅ PLAN_REVIEW [Explore] — APPROVED
130
+ ✅ CODER [Full] — [total] changed, [total] created
131
+ ✅ REVIEW [Explore] — [total iterations] across subtasks
132
+ ✅ COMMIT [git] — [hash]
133
+
134
+ ═══════════════════════════════
135
+ ```
136
+
137
+ ## Normal mode
138
+
139
+ Steps below describe normal mode (single task). Phase mode follows the same agents and permission matrix but with the subtask loop described above.
140
+
141
+ ## Permission matrix (violation = ABORT)
142
+
143
+ ```
144
+ Agent Read Write Bash Subagent
145
+ ───────────── ───── ────── ──────────────── ────────
146
+ READ ✅ ❌ ❌ Explore
147
+ PLAN ✅ ❌ ❌ Explore
148
+ PLAN_REVIEW ✅ ❌ ❌ Explore
149
+ CODER ✅ ✅ ✅ build/test Full
150
+ REVIEW×3 ✅ ❌ ❌ Explore
151
+ TEST ❌ ❌ ✅ build/test Orchestrator (bash)
152
+ VERIFY ✅ ❌ ❌ Explore
153
+ COMMIT ❌ ❌ ✅ git only Full
154
+ ```
155
+
156
+ TEST is not a subagent — orchestrator runs bash commands directly.
157
+
158
+ These rules are law. The orchestrator MUST launch each agent with the correct subagent type.
159
+
160
+ ## Engineering principles (shared across all agents)
161
+
162
+ Every agent in this pipeline receives these principles as baseline quality bar.
163
+ Project-specific conventions (.dev-vault/conventions.md) override where they conflict.
164
+
165
+ ```
166
+ PRINCIPLES:
167
+
168
+ Architecture:
169
+ - Single Responsibility: one module/file = one reason to change
170
+ - Dependency Rule: inner layers never import from outer layers
171
+ - Explicit dependencies: constructor/parameter injection, no hidden globals or singletons
172
+ - Boundaries: validate and sanitize at system entry points, trust internal code
173
+
174
+ Error handling:
175
+ - Fail fast at boundaries, recover gracefully inside
176
+ - Every error path must be tested
177
+ - No silent swallowing: catch → handle or propagate, never empty catch
178
+ - External calls (network, FS, DB) always have error handling and timeouts
179
+
180
+ Production readiness:
181
+ - No TODO/FIXME/HACK in committed code
182
+ - No debug logging (console.log/print) — use structured logging
183
+ - No hardcoded values that should be config or constants
184
+ - Idempotent operations where possible
185
+
186
+ Code structure:
187
+ - Max 300 lines per file, max 30 lines per function
188
+ - Extract when reused 2+ times OR > 5 lines of non-trivial logic
189
+ - Composition over inheritance
190
+ - No god objects, no utility dumps (helpers/, utils/, misc/)
191
+ - Types and names replace comments — if code needs a comment, rename or extract
192
+
193
+ Testing:
194
+ - Test behaviour, not implementation details
195
+ - One logical assertion per test
196
+ - No shared mutable state between tests
197
+ - Cover: happy path, edge cases (empty, null, boundary), error paths
198
+
199
+ END_PRINCIPLES
200
+ ```
201
+
202
+ ## Procedure
203
+
204
+ ### Step 0: PREFLIGHT
205
+
206
+ Orchestrator runs directly (no subagent):
207
+
208
+ ```bash
209
+ git status -s # check for uncommitted changes
210
+ npm run build 2>&1 || true # baseline build (or cargo build, go build)
211
+ npm test 2>&1 || true # baseline tests
212
+ ```
213
+
214
+ Save results as BASELINE block:
215
+
216
+ ```
217
+ BASELINE:
218
+ Git: [clean / N uncommitted files]
219
+ Build: [pass / fail]
220
+ Tests: [N passed, M failed / no test command]
221
+ Lint: [pass / N warnings / no lint command]
222
+ END_BASELINE
223
+ ```
224
+
225
+ Display:
226
+
227
+ ```
228
+ ── PREFLIGHT ──
229
+ Git: ✅ clean / ⚠️ N uncommitted files
230
+ Build: ✅ / ❌ (baseline failure)
231
+ Tests: ✅ N passed / ⚠️ M already failing
232
+ ```
233
+
234
+ **If uncommitted changes:**
235
+ - **Interactive:** ask: stash / continue / abort
236
+ - **Autonomous:** continue (don't touch existing work)
237
+
238
+ **If tests already failing:** record failing test names in BASELINE. TEST step (Step 7) will compare against this — only NEW failures are coder's responsibility.
239
+
240
+ ### Step 1: READ
241
+
242
+ Read vault context files (if they exist):
243
+ - `.dev-vault/stack.md`
244
+ - `.dev-vault/conventions.md`
245
+ - `.dev-vault/knowledge.md`
246
+ - `.dev-vault/gameplan.md`
247
+
248
+ Launch Explore subagent:
249
+
250
+ ```
251
+ You are a reader agent. Gather context for the task below.
252
+
253
+ ## Task
254
+ [task from user]
255
+
256
+ ## Project Context
257
+ [vault sections read above]
258
+
259
+ ## Procedure
260
+ 1. Read CLAUDE.md for project instructions
261
+ 2. Find files relevant to the task (Glob/Grep)
262
+ 3. Read relevant files (max 10 files, 500 lines each)
263
+ 4. Find dependencies and tests for those files
264
+ 5. Find how similar things are done in the project
265
+
266
+ ## Output Format
267
+ CONTEXT:
268
+ Task: [reformulated task with project context]
269
+ Files to change: [file list with what to change]
270
+ Dependencies: [files depending on changes]
271
+ Tests: [existing tests for those files]
272
+ Patterns found: [how similar things are solved]
273
+ Relevant code: [key fragments]
274
+ END_CONTEXT
275
+ ```
276
+
277
+ Save CONTEXT block. Display:
278
+
279
+ ```
280
+ ── READ ──
281
+ Files to change: [N]
282
+ Dependencies: [N]
283
+ Tests: [N]
284
+ ```
285
+
286
+ ### Step 2: PLAN
287
+
288
+ Launch Explore subagent:
289
+
290
+ ```
291
+ You are a planner agent. Create a detailed implementation plan.
292
+
293
+ ## Task
294
+ [task from user]
295
+
296
+ ## Context (from READ)
297
+ [CONTEXT block from Step 1]
298
+
299
+ ## Project Conventions
300
+ [.dev-vault/conventions.md or "Not defined"]
301
+
302
+ ## Architecture
303
+ [.dev-vault/knowledge.md — Architecture section, or "Not defined"]
304
+
305
+ ## Stack
306
+ [.dev-vault/stack.md or "Not defined"]
307
+
308
+ ## Gameplan
309
+ [.dev-vault/gameplan.md — current phase, or "Not defined"]
310
+
311
+ ## Engineering Principles
312
+ [PRINCIPLES block from above]
313
+
314
+ ## Rules
315
+ - STRICTLY follow project conventions (naming, structure, error handling)
316
+ - Each change tied to a specific file and location
317
+ - New files placed according to architecture
318
+ - Deviation from conventions — mark as DEVIATION with justification
319
+ - Include PSEUDO-CODE for each change — concrete enough for CODER to implement without guessing
320
+ - When adding dependencies: use context7 MCP (resolve-library-id → query-docs) to get current stable version. Specify exact version, not range
321
+
322
+ ## Output Format
323
+ PLAN:
324
+ Summary: [what we're doing — 1-2 sentences]
325
+ Scope: [small: 1-4 files / large: 5+ files]
326
+
327
+ Architecture:
328
+ Layer: [domain / infrastructure / presentation / API]
329
+ Boundaries: [where this change sits, what calls it, what it calls]
330
+ Dependencies: [new dependencies with direction →, justify each]
331
+ Error boundaries: [external calls, user input, invariants]
332
+
333
+ Changes:
334
+ 1. [file] — [what to change]
335
+ ```[language]
336
+ // after [anchor: function/line/class]
337
+ [pseudo-code or signature sketch]
338
+ ```
339
+
340
+ 2. [file] — [what to change]
341
+ ```[language]
342
+ // modify [function/block]
343
+ [pseudo-code showing the change]
344
+ ```
345
+
346
+ New files:
347
+ - [file] — [purpose]
348
+ ```[language]
349
+ [structure sketch: exports, key functions, types]
350
+ ```
351
+
352
+ Tests:
353
+ - [test file] — [what to test]
354
+ - happy path: [scenario]
355
+ - edge case: [scenario]
356
+ - error: [scenario]
357
+
358
+ Order:
359
+ 1. [file] — [why first]
360
+ 2. [file] — [depends on previous]
361
+
362
+ Deviations:
363
+ - [deviation + justification, or "None"]
364
+ END_PLAN
365
+ ```
366
+
367
+ Save PLAN block. Display:
368
+
369
+ ```
370
+ ── PLAN ──
371
+ [Summary]
372
+ Files: [N] change, [N] create, [N] tests
373
+ Scope: [small / large]
374
+ ```
375
+
376
+ ### Step 3: PLAN_REVIEW
377
+
378
+ Launch Explore subagent:
379
+
380
+ ```
381
+ You are a plan reviewer. Check the plan for completeness, correctness, and risks.
382
+
383
+ ## Plan
384
+ [PLAN block from Step 2]
385
+
386
+ ## Context
387
+ [CONTEXT block from Step 1]
388
+
389
+ ## Conventions
390
+ [.dev-vault/conventions.md if exists]
391
+
392
+ ## Engineering Principles
393
+ [PRINCIPLES block]
394
+
395
+ ## Check criteria
396
+ 1. Completeness — all files accounted for? Missing dependencies?
397
+ 2. Conventions — matches project conventions?
398
+ 3. Order — correct sequence of changes?
399
+ 4. Tests — cover the changes?
400
+ 5. Deviations — justified?
401
+ 6. Risks — what could break? Edge cases?
402
+ 7. Architecture — correct layer? dependency direction inward? single responsibility?
403
+ 8. Production readiness — error handling for external calls? no TODOs? no hardcoded config?
404
+ 9. Simplicity — simpler approach that achieves the same? over-engineered?
405
+
406
+ ## Output Format
407
+ PLAN_REVIEW:
408
+ Verdict: [APPROVED / NEEDS_REVISION]
409
+ Issues:
410
+ - [issue + how to fix]
411
+ Missing:
412
+ - [what's missing]
413
+ Risks:
414
+ - [potential risk]
415
+ END_PLAN_REVIEW
416
+ ```
417
+
418
+ **Result:**
419
+
420
+ - APPROVED → Step 4
421
+ - NEEDS_REVISION → pass remarks to PLAN agent, re-run Step 2 with remarks.
422
+
423
+ **Max revisions: 2.** After limit:
424
+ - **Interactive:** show warnings, ask user whether to proceed
425
+ - **Autonomous:** accept plan with warnings, proceed to Step 4
426
+
427
+ Display:
428
+
429
+ ```
430
+ ── PLAN_REVIEW ──
431
+ Verdict: ✅ APPROVED / ⚠️ NEEDS_REVISION
432
+ ```
433
+
434
+ ### Step 4: CODER
435
+
436
+ Launch Full subagent:
437
+
438
+ ```
439
+ You are a coder agent. The ONLY agent allowed to modify files.
440
+
441
+ ## Plan
442
+ [PLAN block (final)]
443
+
444
+ ## Context
445
+ [CONTEXT block from Step 1]
446
+
447
+ ## Conventions
448
+ [.dev-vault/conventions.md or "Follow existing code conventions"]
449
+
450
+ ## Stack
451
+ [.dev-vault/stack.md — summary]
452
+
453
+ ## Engineering Principles
454
+ [PRINCIPLES block]
455
+
456
+ ## Rules
457
+ - Follow the plan. No changes outside the plan. Scope creep FORBIDDEN.
458
+ - Follow project conventions: naming, error handling, file structure.
459
+ - If plan has DEVIATION — implement as described.
460
+ - git commit/push FORBIDDEN.
461
+ - git checkout/reset/rebase FORBIDDEN.
462
+ - Allowed bash: build, test, lint commands only.
463
+
464
+ ## Implementation order (test-first)
465
+ 1. Write test files FIRST (from Tests section of the plan)
466
+ 2. Run tests — they MUST FAIL (proves tests are meaningful, not vacuous)
467
+ 3. Write implementation code
468
+ 4. Run tests — they MUST PASS
469
+ 5. If a test passes before implementation exists — the test is wrong, rewrite it
470
+
471
+ ## Production checklist (verify EVERY file before CODE_DONE)
472
+ - [ ] Single responsibility: file/function does one thing
473
+ - [ ] Error handling: every external call has error path with timeout
474
+ - [ ] No TODO/FIXME/HACK in code
475
+ - [ ] No console.log/print for debugging
476
+ - [ ] No hardcoded values that should be config/constants
477
+ - [ ] Types explicit (no `any`, no implicit `unknown`)
478
+ - [ ] Edge cases handled: null, empty, boundary
479
+ - [ ] File under 300 lines, functions under 30 lines
480
+ - [ ] Names self-documenting: if you wrote a comment, rename or extract instead
481
+
482
+ ## Output Format
483
+ CODE_DONE:
484
+ Files changed:
485
+ - [file] — [what was done]
486
+ Files created:
487
+ - [file] — [purpose]
488
+ Tests written:
489
+ - [file] — [what it covers]
490
+ Notes:
491
+ - [notes if any]
492
+ END_CODE_DONE
493
+ ```
494
+
495
+ Save CODE_DONE block. Display:
496
+
497
+ ```
498
+ ── CODER (iteration 1) ──
499
+ Changed: [N], Created: [N], Tests: [N]
500
+ ```
501
+
502
+ ### Step 5: REVIEW (3 specialized reviewers in parallel)
503
+
504
+ Before launching reviewers, orchestrator runs `git diff` to capture actual changes.
505
+ Pass BOTH the CODE_DONE summary AND the real diff to each reviewer.
506
+
507
+ Launch **3 Explore subagents in parallel** (one Agent call with 3 tool uses):
508
+
509
+ **REVIEW:security** — Explore subagent:
510
+
511
+ ```
512
+ You are a SECURITY reviewer. NEVER modify code — only report issues.
513
+ Focus EXCLUSIVELY on security. Ignore style, naming, structure.
514
+
515
+ ## What coder did
516
+ [CODE_DONE or CODE_FIX block — summary]
517
+
518
+ ## Actual diff
519
+ [git diff output — the real changes, not just coder's self-report]
520
+
521
+ ## Security guidelines
522
+ [.dev-vault/knowledge.md — Security section, or OWASP Top 10 defaults]
523
+
524
+ ## Check (security ONLY)
525
+ - Injection (SQL, command, path traversal)
526
+ - XSS (unescaped user input)
527
+ - Hardcoded secrets, API keys, credentials
528
+ - Missing authentication/authorization
529
+ - Insecure deserialization
530
+ - Missing input validation at system boundaries
531
+ - Timing attacks, race conditions
532
+
533
+ ## Severity
534
+ CRITICAL: vulnerability, data loss
535
+ HIGH: missing auth, missing validation on boundary
536
+ MEDIUM: defense-in-depth improvement
537
+ LOW: theoretical risk
538
+
539
+ ## Output Format
540
+ REVIEW_SECURITY:
541
+ Verdict: [PASS / FAIL]
542
+ Issues:
543
+ - [SEVERITY]: [file]:[line] — [issue + fix]
544
+ END_REVIEW_SECURITY
545
+ ```
546
+
547
+ **REVIEW:quality** — Explore subagent:
548
+
549
+ ```
550
+ You are a QUALITY reviewer. NEVER modify code — only report issues.
551
+ Focus EXCLUSIVELY on code quality and conventions. Ignore security.
552
+
553
+ ## Plan
554
+ [PLAN block]
555
+
556
+ ## What coder did
557
+ [CODE_DONE or CODE_FIX block — summary]
558
+
559
+ ## Actual diff
560
+ [git diff output — the real changes, not just coder's self-report]
561
+
562
+ ## Conventions
563
+ [.dev-vault/conventions.md if exists]
564
+
565
+ ## Engineering Principles
566
+ [PRINCIPLES block]
567
+
568
+ ## Check (quality ONLY)
569
+ - Plan adherence — everything implemented? Nothing extra?
570
+ - Conventions — naming, error handling, structure per project
571
+ - Architecture — single responsibility? correct layer? dependency direction inward?
572
+ - God objects — does any file/class know too much or do too many things?
573
+ - Abstractions — premature (interface with one impl)? missing (pattern repeated 3+ times)?
574
+ - Production readiness — TODOs? debug logging? hardcoded config? missing timeouts?
575
+ - Duplication — DRY violations
576
+ - Complexity — unnecessary abstractions, over-engineering
577
+ - Dead code — unused imports, unreachable branches
578
+ - Edge cases — null/undefined, empty arrays, boundary values
579
+
580
+ ## Severity
581
+ CRITICAL: logic bug, data loss
582
+ HIGH: convention violation, plan deviation
583
+ MEDIUM: quality improvement
584
+ LOW: style nit
585
+
586
+ ## Output Format
587
+ REVIEW_QUALITY:
588
+ Verdict: [PASS / FAIL]
589
+ Issues:
590
+ - [SEVERITY]: [file]:[line] — [issue + fix]
591
+ END_REVIEW_QUALITY
592
+ ```
593
+
594
+ **REVIEW:coverage** — Explore subagent:
595
+
596
+ ```
597
+ You are a TEST COVERAGE reviewer. NEVER modify code — only report issues.
598
+ Focus EXCLUSIVELY on test adequacy. Ignore security and style.
599
+
600
+ ## Plan
601
+ [PLAN block — Tests section]
602
+
603
+ ## What coder did
604
+ [CODE_DONE or CODE_FIX block — summary]
605
+
606
+ ## Actual diff
607
+ [git diff output — the real changes, not just coder's self-report]
608
+
609
+ ## Check (coverage ONLY)
610
+ - All planned tests written?
611
+ - Happy path covered?
612
+ - Edge cases covered? (empty input, boundary values, null)
613
+ - Error paths covered? (network failure, invalid input, permissions)
614
+ - Assertions meaningful? (not just "no throw")
615
+ - Test isolation? (no shared state between tests)
616
+
617
+ ## Severity
618
+ CRITICAL: core logic untested
619
+ HIGH: missing edge case test for public API
620
+ MEDIUM: missing error path test
621
+ LOW: test could be more descriptive
622
+
623
+ ## Output Format
624
+ REVIEW_COVERAGE:
625
+ Verdict: [PASS / FAIL]
626
+ Issues:
627
+ - [SEVERITY]: [file]:[line] — [issue + fix]
628
+ END_REVIEW_COVERAGE
629
+ ```
630
+
631
+ **Aggregate results:**
632
+
633
+ Merge all 3 REVIEW blocks into one verdict:
634
+ - Any CRITICAL or HIGH from ANY reviewer → **CHANGES_REQUESTED**
635
+ - All PASS with only MEDIUM/LOW → **APPROVED**
636
+
637
+ Display:
638
+
639
+ ```
640
+ ── REVIEW (iteration [N]) ──
641
+ Security: ✅ PASS / ❌ FAIL [Critical: N, High: N]
642
+ Quality: ✅ PASS / ❌ FAIL [Critical: N, High: N]
643
+ Coverage: ✅ PASS / ❌ FAIL [Critical: N, High: N]
644
+ Verdict: ✅ APPROVED / ❌ CHANGES_REQUESTED
645
+ ```
646
+
647
+ ### Step 6: CODER↔REVIEW loop
648
+
649
+ **APPROVED** → Step 7.
650
+
651
+ **CHANGES_REQUESTED** → launch CODER in fix mode (Full subagent):
652
+
653
+ ```
654
+ You are a coder agent in FIX mode. Fix review issues.
655
+
656
+ ## Plan
657
+ [PLAN block]
658
+
659
+ ## Review issues
660
+ [REVIEW block with Issues]
661
+
662
+ ## Conventions
663
+ [.dev-vault/conventions.md]
664
+
665
+ ## Rules
666
+ - CRITICAL and HIGH — fix required.
667
+ - MEDIUM — fix if simple. If complex — explain in Skipped.
668
+ - LOW — ignore.
669
+ - Do NOT touch code outside review issues.
670
+
671
+ ## Output Format
672
+ CODE_FIX:
673
+ Fixed:
674
+ - [file]:[line] — [fix] — addresses [issue]
675
+ Skipped:
676
+ - [issue] — [reason]
677
+ END_CODE_FIX
678
+ ```
679
+
680
+ Then re-run REVIEW (Step 5).
681
+
682
+ **Limit: 3 iterations.**
683
+
684
+ After limit:
685
+
686
+ **Interactive:**
687
+ ```
688
+ ⚠️ Review iteration limit (3).
689
+
690
+ Remaining issues:
691
+ [list]
692
+
693
+ 1. Accept and commit
694
+ 2. Stop without commit
695
+ ```
696
+
697
+ **Autonomous:** stop without commit. Stash changes for recovery.
698
+ ```
699
+ 🛑 STOPPED: review limit reached with unresolved CRITICAL/HIGH issues.
700
+ Changes stashed → git stash push -m "workflow:dev — stopped at review"
701
+ ```
702
+
703
+ **Rollback on pipeline stop (all stop points):**
704
+ - **Interactive:** ask: keep changes / stash / discard (`git restore .`)
705
+ - **Autonomous:** always stash (`git stash push -m "workflow:dev — stopped at [step]"`)
706
+
707
+ ### Step 7: TEST (mandatory gate)
708
+
709
+ Orchestrator runs build and test commands directly (no subagent):
710
+
711
+ ```bash
712
+ npm run build # or cargo build, go build — must pass
713
+ npm run lint # if configured — must pass
714
+ npm test # must pass
715
+ ```
716
+
717
+ Detect test command from `.dev-vault/stack.md` or `package.json` / `Cargo.toml` / `Makefile`.
718
+
719
+ **Compare against BASELINE from Step 0:** if a test was already failing before pipeline started, it is NOT a new failure. Only count failures that are NOT in BASELINE as coder's responsibility.
720
+
721
+ **If any command fails:**
722
+
723
+ ```
724
+ ── TEST ──
725
+ ❌ FAIL: [command]
726
+
727
+ [error output — last 50 lines]
728
+
729
+ Sending to CODER for fix...
730
+ ```
731
+
732
+ Pass error output to CODER as a fix iteration (same as REVIEW CHANGES_REQUESTED).
733
+ After CODER fix → re-run TEST. **Max 3 TEST iterations.**
734
+
735
+ After limit:
736
+ - **Interactive:** show error, ask user whether to commit anyway or stop
737
+ - **Autonomous:** stop without commit. Failing tests = no commit.
738
+
739
+ **If all pass:**
740
+
741
+ ```
742
+ ── TEST ──
743
+ ✅ Build: passed
744
+ ✅ Lint: passed (or skipped)
745
+ ✅ Tests: passed (N tests)
746
+ ```
747
+
748
+ ### Step 8: VERIFY (task compliance check)
749
+
750
+ Launch Explore subagent:
751
+
752
+ ```
753
+ You are a verification agent. Check if the implementation matches the ORIGINAL TASK.
754
+ Do NOT check code quality or security — that was already done.
755
+ Check ONLY: does the code do what was asked?
756
+
757
+ ## Original task
758
+ [task from user — the ORIGINAL request, not the plan]
759
+
760
+ ## Plan
761
+ [PLAN block]
762
+
763
+ ## What was implemented
764
+ [final CODE_DONE or CODE_FIX block]
765
+
766
+ ## Check
767
+ - Every requirement from the original task addressed?
768
+ - Any requirement missed or partially implemented?
769
+ - Any drift from the task? (implemented something not asked for)
770
+ - Acceptance criteria met? (if task specifies them)
771
+
772
+ ## Output Format
773
+ VERIFY:
774
+ Verdict: [COMPLETE / INCOMPLETE]
775
+ Addressed:
776
+ - [requirement] — ✅ implemented
777
+ Missing:
778
+ - [requirement not implemented — how to fix]
779
+ Drift:
780
+ - [implementation not in original task — flag for user]
781
+ END_VERIFY
782
+ ```
783
+
784
+ **COMPLETE** → Step 9.
785
+
786
+ **INCOMPLETE** → pass missing items to CODER. **Max 2 iterations.** After limit:
787
+ - **Interactive:** show gaps, ask user whether to commit partial or stop
788
+ - **Autonomous:** stop without commit. Incomplete implementation = no commit.
789
+
790
+ Display:
791
+
792
+ ```
793
+ ── VERIFY ──
794
+ Verdict: ✅ COMPLETE / ⚠️ INCOMPLETE
795
+ [If incomplete:] Missing: [N] requirements
796
+ ```
797
+
798
+ ### Step 9: COMMIT
799
+
800
+ Orchestrator forms commit message:
801
+
802
+ ```
803
+ [type](scope): [brief from PLAN Summary]
804
+
805
+ [What was done from PLAN Summary]
806
+
807
+ Files:
808
+ [from CODE_DONE — file list]
809
+ ```
810
+
811
+ Stage changes and show diff.
812
+
813
+ **Interactive mode (default):**
814
+
815
+ ```
816
+ ── COMMIT ──
817
+
818
+ [commit message]
819
+
820
+ Staged:
821
+ [abbreviated diff]
822
+
823
+ Commit? (yes / no / edit message)
824
+ ```
825
+
826
+ **"yes"** → `git add` relevant files, `git commit`
827
+ **"no"** → cancel, changes remain staged
828
+ **"edit"** → user edits, then commit
829
+
830
+ **Autonomous mode (--auto-commit):**
831
+
832
+ ```
833
+ ── COMMIT (auto) ──
834
+
835
+ [commit message]
836
+
837
+ Staged:
838
+ [abbreviated diff]
839
+
840
+ ✅ Auto-committed: [hash]
841
+ ```
842
+
843
+ `git add` relevant files, `git commit` immediately. No user prompt.
844
+
845
+ **Autonomous safety — will NOT auto-commit if any of these occurred:**
846
+ - TEST failed and fix limit reached
847
+ - VERIFY incomplete and fix limit reached
848
+ - Any unresolved CRITICAL review issue
849
+
850
+ In these cases the pipeline already stopped at the failing gate.
851
+
852
+ ### Step 10: Summary
853
+
854
+ ```
855
+ ═══════════════════════════════
856
+ DEV COMPLETE
857
+ ═══════════════════════════════
858
+
859
+ Task: [description]
860
+ Mode: [interactive / autonomous]
861
+ Scope: [small / large]
862
+
863
+ Agents:
864
+ ✅ READ [Explore] — [N] files
865
+ ✅ PLAN [Explore] — [N] files, pseudo-code
866
+ ✅ PLAN_REVIEW [Explore] — [verdict]
867
+ ✅ CODER [Full] — [N] changed, [N] created
868
+ ✅ REVIEW:security [Explore] — [verdict]
869
+ ✅ REVIEW:quality [Explore] — [verdict]
870
+ ✅ REVIEW:coverage [Explore] — [verdict]
871
+ ✅ TEST [bash] — [N] tests passed
872
+ ✅ VERIFY [Explore] — [verdict]
873
+ ✅ COMMIT [git] — [hash]
874
+
875
+ [If deviations:] ⚠️ Convention deviations
876
+ [If unresolved:] ⚠️ Known issues
877
+ [If verify incomplete:] ⚠️ Missing requirements
878
+
879
+ ═══════════════════════════════
880
+ ```
881
+
882
+ ## Enforcement
883
+
884
+ Before launching each subagent — verify type:
885
+
886
+ | Agent | Subagent type | On violation |
887
+ |-------|--------------|--------------|
888
+ | READ | Explore | Write/Bash in response → ABORT |
889
+ | PLAN | Explore | Write/Bash in response → ABORT |
890
+ | PLAN_REVIEW | Explore | Write/Bash in response → ABORT |
891
+ | CODER | Full | git commit/push in response → ABORT |
892
+ | REVIEW×3 | Explore | Write/Bash in response → ABORT |
893
+ | TEST | Orchestrator bash | N/A — orchestrator runs directly |
894
+ | VERIFY | Explore | Write/Bash in response → ABORT |
895
+ | COMMIT | Full | Read/Write/non-git bash → ABORT |
896
+
897
+ ```
898
+ 🚨 PERMISSION VIOLATION: [agent] attempted [action].
899
+ Allowed: [permissions].
900
+ Process stopped.
901
+ ```
902
+
903
+ ## Rules
904
+
905
+ - Orchestrator reads vault files ONCE (Step 1), passes CONTENT (not paths) to agents
906
+ - Placeholders like `[.dev-vault/conventions.md]` mean "insert file content here"
907
+ - Context passes as arguments (CONTEXT, PLAN, CODE_DONE, REVIEW blocks)
908
+ - Agent response blocks (CONTEXT, PLAN, CODE_DONE, REVIEW, PLAN_REVIEW) have mandatory format
909
+ - No intermediate files — everything in orchestrator context
910
+ - Permission matrix is law. Explore agents ONLY read
911
+ - CODER is the only one who touches files
912
+ - REVIEWER never fixes code — only reports issues
913
+ - COMMIT — git add + git diff + git commit, nothing else