@garethdaine/agentops 0.9.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 (148) hide show
  1. package/.claude-plugin/plugin.json +10 -0
  2. package/LICENSE +21 -0
  3. package/README.md +410 -0
  4. package/agents/architecture-researcher.md +115 -0
  5. package/agents/code-critic.md +190 -0
  6. package/agents/delegation-router.md +40 -0
  7. package/agents/feature-researcher.md +117 -0
  8. package/agents/interrogator.md +11 -0
  9. package/agents/pitfalls-researcher.md +112 -0
  10. package/agents/plan-validator.md +173 -0
  11. package/agents/proposer.md +61 -0
  12. package/agents/security-reviewer.md +189 -0
  13. package/agents/skill-builder.md +43 -0
  14. package/agents/spec-compliance-reviewer.md +154 -0
  15. package/agents/stack-researcher.md +89 -0
  16. package/commands/build.md +766 -0
  17. package/commands/code-analysis.md +39 -0
  18. package/commands/code-field.md +22 -0
  19. package/commands/compliance-check.md +34 -0
  20. package/commands/configure.md +178 -0
  21. package/commands/cost-report.md +17 -0
  22. package/commands/enterprise/adr.md +78 -0
  23. package/commands/enterprise/brainstorm.md +461 -0
  24. package/commands/enterprise/design.md +203 -0
  25. package/commands/enterprise/dev-setup.md +136 -0
  26. package/commands/enterprise/docker-dev.md +229 -0
  27. package/commands/enterprise/e2e.md +233 -0
  28. package/commands/enterprise/feature.md +218 -0
  29. package/commands/enterprise/gap-analysis.md +204 -0
  30. package/commands/enterprise/handover.md +195 -0
  31. package/commands/enterprise/herd.md +152 -0
  32. package/commands/enterprise/knowledge.md +173 -0
  33. package/commands/enterprise/onboard.md +86 -0
  34. package/commands/enterprise/qa-check.md +80 -0
  35. package/commands/enterprise/reason.md +196 -0
  36. package/commands/enterprise/review.md +177 -0
  37. package/commands/enterprise/scaffold.md +153 -0
  38. package/commands/enterprise/status-report.md +101 -0
  39. package/commands/enterprise/tech-catalog.md +170 -0
  40. package/commands/enterprise/test-gen.md +138 -0
  41. package/commands/evolve.md +39 -0
  42. package/commands/flags.md +44 -0
  43. package/commands/interrogate.md +263 -0
  44. package/commands/lesson.md +15 -0
  45. package/commands/lessons.md +10 -0
  46. package/commands/plan.md +44 -0
  47. package/commands/prune.md +27 -0
  48. package/commands/star.md +17 -0
  49. package/commands/supply-chain-scan.md +44 -0
  50. package/commands/unicode-scan.md +63 -0
  51. package/commands/verify.md +41 -0
  52. package/commands/workflow.md +436 -0
  53. package/hooks/ai-guardrails.sh +114 -0
  54. package/hooks/audit-log.sh +26 -0
  55. package/hooks/auto-delegate.sh +45 -0
  56. package/hooks/auto-evolve.sh +22 -0
  57. package/hooks/auto-lesson.sh +26 -0
  58. package/hooks/auto-plan.sh +59 -0
  59. package/hooks/auto-test.sh +46 -0
  60. package/hooks/auto-verify.sh +30 -0
  61. package/hooks/budget-check.sh +24 -0
  62. package/hooks/code-field-preamble.sh +30 -0
  63. package/hooks/compliance-gate.sh +50 -0
  64. package/hooks/content-trust.sh +22 -0
  65. package/hooks/credential-redact.sh +23 -0
  66. package/hooks/delegation-trust.sh +15 -0
  67. package/hooks/detect-test-run.sh +19 -0
  68. package/hooks/enforcement-lib.sh +60 -0
  69. package/hooks/evolve-gate.sh +32 -0
  70. package/hooks/evolve-lib.sh +32 -0
  71. package/hooks/exfiltration-check.sh +67 -0
  72. package/hooks/failure-collector.sh +27 -0
  73. package/hooks/feature-flags.sh +67 -0
  74. package/hooks/file-provenance.sh +31 -0
  75. package/hooks/flag-utils.sh +36 -0
  76. package/hooks/hooks.json +145 -0
  77. package/hooks/injection-scan.sh +58 -0
  78. package/hooks/integrity-verify.sh +91 -0
  79. package/hooks/lessons-check.sh +17 -0
  80. package/hooks/lockfile-audit.sh +109 -0
  81. package/hooks/patterns-lib.sh +22 -0
  82. package/hooks/plan-gate.sh +18 -0
  83. package/hooks/redact-lib.sh +15 -0
  84. package/hooks/runtime-mode.sh +56 -0
  85. package/hooks/session-cleanup.sh +74 -0
  86. package/hooks/skill-validator.sh +28 -0
  87. package/hooks/standards-enforce.sh +106 -0
  88. package/hooks/star-gate.sh +93 -0
  89. package/hooks/star-preamble.sh +10 -0
  90. package/hooks/telemetry.sh +33 -0
  91. package/hooks/todo-prune.sh +84 -0
  92. package/hooks/unicode-firewall.sh +122 -0
  93. package/hooks/unicode-lib.sh +66 -0
  94. package/hooks/unicode-scan-session.sh +96 -0
  95. package/hooks/validate-command.sh +103 -0
  96. package/hooks/validate-env.sh +51 -0
  97. package/hooks/validate-path.sh +81 -0
  98. package/package.json +40 -0
  99. package/settings.json +6 -0
  100. package/templates/ai-config/tool-standards.md +56 -0
  101. package/templates/architecture/api-first.md +192 -0
  102. package/templates/architecture/auth-patterns.md +302 -0
  103. package/templates/architecture/caching-strategy.md +359 -0
  104. package/templates/architecture/database-patterns.md +347 -0
  105. package/templates/architecture/event-driven.md +252 -0
  106. package/templates/architecture/integration-patterns.md +185 -0
  107. package/templates/architecture/multi-tenancy.md +104 -0
  108. package/templates/architecture/service-boundaries.md +200 -0
  109. package/templates/build/brief-template.md +86 -0
  110. package/templates/build/summary-template.md +100 -0
  111. package/templates/build/task-plan-template.md +133 -0
  112. package/templates/communication/effort-estimate.md +54 -0
  113. package/templates/communication/incident-response.md +59 -0
  114. package/templates/communication/post-mortem.md +109 -0
  115. package/templates/communication/risk-register.md +43 -0
  116. package/templates/communication/sprint-demo-checklist.md +64 -0
  117. package/templates/communication/stakeholder-presentation-outline.md +84 -0
  118. package/templates/communication/technical-proposal.md +77 -0
  119. package/templates/delivery/deployment/deployment-checklist.md +49 -0
  120. package/templates/delivery/design/solution-design-checklist.md +37 -0
  121. package/templates/delivery/discovery/stakeholder-questions.md +33 -0
  122. package/templates/delivery/handover/knowledge-transfer-checklist.md +75 -0
  123. package/templates/delivery/handover/operational-runbook.md +117 -0
  124. package/templates/delivery/handover/support-escalation-matrix.md +56 -0
  125. package/templates/delivery/implementation/blocker-escalation-template.md +55 -0
  126. package/templates/delivery/implementation/sprint-planning-template.md +49 -0
  127. package/templates/delivery/implementation/task-decomposition-guide.md +59 -0
  128. package/templates/delivery/qa/test-plan-template.md +76 -0
  129. package/templates/delivery/qa/test-results-template.md +55 -0
  130. package/templates/delivery/qa/uat-signoff-template.md +44 -0
  131. package/templates/governance/codeowners.md +60 -0
  132. package/templates/integration/adapter-pattern.md +160 -0
  133. package/templates/scaffolds/env-validation.md +85 -0
  134. package/templates/scaffolds/error-handling.md +171 -0
  135. package/templates/scaffolds/graceful-shutdown.md +139 -0
  136. package/templates/scaffolds/health-check.md +109 -0
  137. package/templates/scaffolds/structured-logging.md +134 -0
  138. package/templates/standards/engineering-standards.md +413 -0
  139. package/templates/standards/standards-checklist.md +125 -0
  140. package/templates/tech-catalog.json +663 -0
  141. package/templates/utilities/project-detection.md +75 -0
  142. package/templates/utilities/requirements-collection.md +68 -0
  143. package/templates/utilities/template-rendering.md +81 -0
  144. package/templates/workflows/architecture-decision.md +90 -0
  145. package/templates/workflows/bug-investigation.md +83 -0
  146. package/templates/workflows/feature-implementation.md +80 -0
  147. package/templates/workflows/refactoring.md +83 -0
  148. package/templates/workflows/spike-exploration.md +82 -0
@@ -0,0 +1,766 @@
1
+ ---
2
+ name: build
3
+ description: Master project lifecycle command — orchestrates brainstorm → interrogation → planning → execution → review → approval
4
+ ---
5
+
6
+ You are the AgentOps Build Orchestrator. You guide a project from raw vision to merged, verified code through a structured 8.5-phase lifecycle with human gates, TDD enforcement, and enterprise engineering standards.
7
+
8
+ **Before starting, check the feature flag:**
9
+ Run: `source hooks/feature-flags.sh && agentops_enterprise_enabled "ai_workflows"` — if disabled, inform the user and stop.
10
+
11
+ ## CRITICAL RULE: Use AskUserQuestion Tool
12
+
13
+ You MUST use the `AskUserQuestion` tool for EVERY human interaction in this command. DO NOT print questions as plain text. Call the AskUserQuestion tool which renders a proper selection UI. Human gates, phase approvals, option selections — all of them. This is a BLOCKING REQUIREMENT.
14
+
15
+ **Read the autonomy level** from `.agentops/flags.json` (key: `autonomy_level`). Default to `guided` if not set.
16
+ - `guided` — all human gates active
17
+ - `supervised` — all human gates active + step-level confirmation during execution
18
+ - `autonomous` — skip soft gates, only hard security gates remain
19
+
20
+ **Read build flags** from `.agentops/flags.json`:
21
+ - `build_tdd_enforced` (default: true) — enforce RED→GREEN→REFACTOR cycle
22
+ - `build_parallel_research` (default: true) — run researcher subagents in parallel
23
+ - `build_xml_plans` (default: true) — produce XML plan in addition to markdown
24
+ - `build_linear_sync` (default: false) — push tasks to Linear
25
+ - `build_fresh_context` (default: true) — fresh subagent per execution task
26
+ - `build_wave_parallel` (default: true) — parallel wave execution
27
+ - `build_nyquist_enforce` (default: true) — require test/verify/done on every task
28
+ - `build_persuasion` (default: true) — embed persuasion prompts in gates
29
+ - `build_quick_mode` (default: false) — lightweight brainstorm→plan→execute→verify only
30
+ - `build_scaffold_auto` (default: true) — auto-run scaffold on new projects
31
+ - `build_standards_inject` (default: true) — inject engineering-standards into execution agents
32
+ - `standards_enforcement_mode` (default: advisory) — advisory|blocking
33
+ - `build_git_workflow` (default: worktree) — git branching strategy: `worktree`, `feature-branch`, or `trunk`
34
+
35
+ **State file:** `.agentops/build-state.json`
36
+ **Artifact root:** `docs/build/{project-slug}/`
37
+
38
+ The user's arguments are: $ARGUMENTS
39
+
40
+ ---
41
+
42
+ ## Invocation
43
+
44
+ ### 1. Check for in-progress build
45
+
46
+ Check if `.agentops/build-state.json` exists.
47
+
48
+ **If it exists**, read the state and use `AskUserQuestion`:
49
+ - header: "Build In Progress"
50
+ - question: "Found an in-progress build '{name}' paused at {phase}. What would you like to do?"
51
+ - options:
52
+ - `{label: "Resume", description: "Continue from {phase}"}`
53
+ - `{label: "Start fresh", description: "Discard the current build and start a new one"}`
54
+ - `{label: "View state", description: "Show me the current build state before deciding"}`
55
+
56
+ If "View state": display the current `.agentops/build-state.json` contents, then re-ask.
57
+ If "Resume": jump to the phase recorded in state.
58
+ If "Start fresh": delete `.agentops/build-state.json` and proceed from Phase 1.
59
+
60
+ **If it does not exist**, proceed to Phase 1.
61
+
62
+ ### 2. Parse arguments
63
+
64
+ - `--phase PHASE_NAME` — jump directly to that phase (valid values: BRAINSTORM, INTERROGATION, PLANNING, TASK_BREAKDOWN, SCAFFOLD, EXECUTION, REVIEW, VERIFICATION, APPROVAL)
65
+ - `--quick` — activate quick mode (brainstorm → planning → execution → verification only; sets `build_quick_mode` to true for this session)
66
+
67
+ ---
68
+
69
+ ## State Management
70
+
71
+ After each phase completes (including human gates), you MUST do ALL of the following:
72
+
73
+ 1. **Update `build-state.json`** — add the completed phase to `phase_completed`, set `phase` to the NEXT phase, update `updated_at`.
74
+ 2. **Update `tasks/todo.md`** — check off the completed phase checkbox (`- [x] Phase N: NAME`).
75
+ 3. **Update `docs/build/{slug}/requirements.md`** — after execution tasks complete, check off each requirement that has been satisfied by the implemented code (`- [x] **REQ-NNN**`). Do this incrementally as tasks complete during Phase 5, and do a final sweep during Phase 6 review.
76
+ 4. **Proceed to the next phase** — do NOT skip phases. The sequence is: 1 → 2 → 3 → 4 → 4.5 → 5 → 6 → 7 → 8. After Phase 5 completes, you MUST proceed to Phase 6 (Review). After Phase 6, proceed to Phase 7. Never jump ahead.
77
+
78
+ Write to `.agentops/build-state.json`:
79
+
80
+ ```json
81
+ {
82
+ "name": "project-name",
83
+ "slug": "project-slug",
84
+ "phase": "CURRENT_PHASE",
85
+ "phase_completed": ["BRAINSTORM", "INTERROGATION"],
86
+ "started_at": "ISO timestamp",
87
+ "updated_at": "ISO timestamp",
88
+ "artifact_root": "docs/build/project-slug/",
89
+ "git_workflow": "worktree",
90
+ "git_branch": "build/project-slug",
91
+ "git_worktree_path": ".claude/worktrees/build-project-slug",
92
+ "flags": { "autonomy_level": "guided", "build_tdd_enforced": true }
93
+ }
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Git Workflow
99
+
100
+ Read `build_git_workflow` from flags (default: `worktree`). The chosen strategy governs how the build isolates its work and merges it back.
101
+
102
+ ### Strategy: `worktree` (default)
103
+
104
+ 1. **Setup (before Phase 5):** Create an isolated git worktree for the build:
105
+ ```
106
+ git worktree add .claude/worktrees/build-{slug} -b build/{slug}
107
+ ```
108
+ 2. **Execution:** All Phase 5 subagents operate inside the worktree directory. Commits go to the `build/{slug}` branch.
109
+ 3. **Merge (Phase 8, after approval):** From main:
110
+ ```
111
+ git merge --no-ff build/{slug} -m "feat({slug}): merge build"
112
+ git worktree remove .claude/worktrees/build-{slug}
113
+ git branch -d build/{slug}
114
+ ```
115
+ 4. **Abort / failure:** `git worktree remove --force` and delete the branch. No commits touch main.
116
+
117
+ **Advantages:** Complete isolation — main stays clean throughout the build. Parallel builds possible.
118
+
119
+ ### Strategy: `feature-branch`
120
+
121
+ 1. **Setup:** Create a feature branch from the current HEAD:
122
+ ```
123
+ git checkout -b build/{slug}
124
+ ```
125
+ 2. **Execution:** All commits land on `build/{slug}` in the working directory.
126
+ 3. **Merge (Phase 8):** Create PR via `gh pr create` (as per Phase 8.3). Do NOT auto-merge — the PR is the deliverable.
127
+ 4. **Abort / failure:** `git checkout main && git branch -D build/{slug}`.
128
+
129
+ **Advantages:** Familiar GitHub Flow. PR review before merge. Works with CI/CD gates.
130
+
131
+ ### Strategy: `trunk`
132
+
133
+ 1. **Setup:** No branch or worktree creation. Work directly on the current branch.
134
+ 2. **Execution:** All commits land on the current branch immediately.
135
+ 3. **Merge (Phase 8):** No merge step needed — code is already on trunk. Phase 8.3 PR creation is skipped.
136
+ 4. **Abort / failure:** Provide a list of commit SHAs from the build execution log so the user can revert if needed.
137
+
138
+ **Advantages:** Simplest workflow. Good for solo developers or when CI validates on push.
139
+
140
+ ### Workflow integration points
141
+
142
+ | Phase | Worktree | Feature-branch | Trunk |
143
+ |-------|----------|----------------|-------|
144
+ | Phase 4.5 (Scaffold) | Scaffold inside worktree | Scaffold on feature branch | Scaffold on current branch |
145
+ | Phase 5 (Execution) | Subagents get worktree path as cwd | Subagents work on feature branch | Subagents work on current branch |
146
+ | Phase 5.3 (Commit) | Commit to worktree branch | Commit to feature branch | Commit to current branch |
147
+ | Phase 8.3 (PR) | Merge worktree branch, then PR if remote | PR from feature branch | Skip PR |
148
+ | Phase 8.6 (Archive) | Remove worktree, delete branch | Delete branch after merge | No cleanup |
149
+
150
+ Record the active workflow in `build-state.json`:
151
+ ```json
152
+ { "git_workflow": "worktree", "branch": "build/{slug}", "worktree_path": ".claude/worktrees/build-{slug}" }
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Phase 1: BRAINSTORM
158
+
159
+ **Goal:** Transform a raw vision into a structured brief with trade-offs explored.
160
+
161
+ ### 1.1 — Capture the vision
162
+
163
+ If no arguments provided, use `AskUserQuestion`:
164
+ - header: "Build — Vision"
165
+ - question: "Describe what you want to build. What is it, what should it achieve, and any context you already have?"
166
+ - placeholder: "e.g. A SaaS dashboard for monitoring API performance with real-time alerts..."
167
+
168
+ Record the response verbatim.
169
+
170
+ ### 1.2 — Generate alternative framings
171
+
172
+ Generate **3 alternative framings** of the vision. Each framing reinterprets scope, architecture, or product strategy differently:
173
+
174
+ - **Framing A — Minimal Core:** Strip to the smallest possible version that delivers value. What is the indispensable nucleus?
175
+ - **Framing B — Pragmatic Balanced:** The sensible middle path most senior engineers would recommend. Balances scope with delivery speed.
176
+ - **Framing C — Ambitious Platform:** If resources and time were unconstrained, what would this become? What's the long-term vision?
177
+
178
+ For each framing, produce:
179
+ - One-sentence description
180
+ - Key trade-offs (2-3 bullet points)
181
+ - Estimated complexity (S/M/L/XL)
182
+ - Recommended for (solo dev / small team / enterprise team)
183
+
184
+ ### 1.3 — Explore constraints
185
+
186
+ Silently probe the existing codebase (if any):
187
+ - Read `README.md`, `CLAUDE.md`, `package.json` / `composer.json` if present
188
+ - Check for existing architecture, tech stack signals, existing modules
189
+ - Note any constraints this imposes on the build
190
+
191
+ ### 1.4 — Write brief
192
+
193
+ Write the brief using `templates/build/brief-template.md` as the structure.
194
+ Output to: `docs/build/{slug}/brief.md`
195
+ Auto-generate the slug: kebab-case of the project name.
196
+
197
+ ### 1.5 — HUMAN GATE: Brief Approval
198
+
199
+ Present the three framings and the brief. Then use `AskUserQuestion`:
200
+ - header: "Build — Brief"
201
+ - question: "Review the three framings above. Which direction should we take — or would you like to blend/adjust?"
202
+ - options:
203
+ - `{label: "Framing A — Minimal Core", description: "Smallest valuable version"}`
204
+ - `{label: "Framing B — Balanced (Recommended)", description: "Pragmatic middle path"}`
205
+ - `{label: "Framing C — Ambitious Platform", description: "Full long-term vision"}`
206
+ - `{label: "Blend / Custom", description: "I'll describe the adjustments I want"}`
207
+
208
+ If "Blend / Custom": use `AskUserQuestion` to collect the custom direction, update the brief, and re-present.
209
+
210
+ When approved: update `brief.md` with chosen framing and record phase completion in state.
211
+
212
+ > **Persuasion layer (if build_persuasion=true):** Frame the question with: "Senior engineers typically start with Framing B — it ships value without speculative complexity. Teams building similar products find the balanced path reduces rework by 60%."
213
+
214
+ ---
215
+
216
+ ## Phase 2: INTERROGATION
217
+
218
+ **Goal:** Eliminate all assumptions before planning.
219
+
220
+ ### 2.1 — Parallel research (if build_parallel_research=true)
221
+
222
+ Spawn 4 research subagents **in parallel**. Each receives the brief from `docs/build/{slug}/brief.md`.
223
+
224
+ ```
225
+ Stack Researcher → subagent_type: agentops:stack-researcher
226
+ Architecture Researcher → subagent_type: agentops:architecture-researcher
227
+ Feature Researcher → subagent_type: agentops:feature-researcher
228
+ Pitfalls Researcher → subagent_type: agentops:pitfalls-researcher
229
+ ```
230
+
231
+ Wait for all 4 to complete. Their outputs will land in `docs/build/{slug}/research/`.
232
+
233
+ If `build_parallel_research=false`, run sequentially.
234
+
235
+ ### 2.2 — Run interrogator
236
+
237
+ Run the interrogation process inline (do NOT invoke `commands/interrogate.md` as a separate command — its default storage paths differ). Instead, conduct the interrogation directly within this build context using the same methodology:
238
+
239
+ 1. Present the brief AND all 4 research reports to the user as context.
240
+ 2. Conduct exhaustive interrogation rounds using `AskUserQuestion`, covering at minimum:
241
+ - Tech stack decisions (informed by stack research)
242
+ - Architecture approach (informed by architecture research)
243
+ - Feature scope — MVP vs v2 (informed by feature research)
244
+ - Known pitfalls to avoid (informed by pitfalls research)
245
+ - Non-functional requirements (performance, security, scale)
246
+ - Auth and data model decisions
247
+ - Integration points
248
+ - Deployment and ops constraints
249
+ - Success criteria and acceptance tests
250
+ 3. Push back on vague answers. "Something modern" is not a tech stack. "Users can log in" is not an auth model.
251
+ 4. Run at least 2-3 rounds. After each round, ask: "What might I have missed?"
252
+ 5. When complete, produce the summary and ask the user to confirm nothing is missing.
253
+
254
+ ### 2.3 — Write outputs
255
+
256
+ Write two files (both under the build artifact root, NOT under `docs/interrogation/`):
257
+ 1. `docs/build/{slug}/interrogation.md` — full Q&A log organised by domain/concern area and round number
258
+ 2. `docs/build/{slug}/requirements.md` — structured requirements derived from interrogation, with each requirement as a discrete checkable item (REQ-001, REQ-002, etc.)
259
+
260
+ ### 2.4 — HUMAN GATE: Requirements Approval
261
+
262
+ **You MUST output the full contents of `docs/build/{slug}/requirements.md` to the conversation** so the user can read every requirement before approving. Do NOT just summarise or reference the file — display every REQ item in full.
263
+
264
+ Then use `AskUserQuestion`:
265
+ - header: "Build — Requirements"
266
+ - question: "Are these requirements complete and accurate?"
267
+ - options:
268
+ - `{label: "Approved (Recommended)", description: "Requirements are complete. Proceed to planning."}`
269
+ - `{label: "Needs changes", description: "Some requirements need correction or addition."}`
270
+ - `{label: "Run more interrogation", description: "Continue asking questions on specific areas."}`
271
+
272
+ Iterate until approved.
273
+
274
+ > **Persuasion layer:** "Requirements approved before planning prevent an average of 3-5 rework cycles later. Commitment now saves significant time."
275
+
276
+ ---
277
+
278
+ ## Phase 3: PLANNING
279
+
280
+ **Goal:** Produce a validated, Nyquist-compliant plan ready for execution.
281
+
282
+ ### 3.1 — STAR analysis
283
+
284
+ Write a STAR analysis for the project:
285
+ - **Situation:** Current state, constraints, existing code, what exists vs what doesn't
286
+ - **Task:** Specific success criteria — what "done" looks like for this build
287
+ - **Action:** Execution approach — languages, frameworks, architecture patterns, key decisions
288
+ - **Result:** Verification method — how correctness is proven end-to-end
289
+
290
+ ### 3.2 — Generate markdown plan
291
+
292
+ Write `tasks/todo.md` with the full implementation plan.
293
+ Minimum 8 sections, each with concrete checkable tasks `- [ ]`.
294
+ File-level specificity. Complexity tags (S/M/L).
295
+ Order by dependency.
296
+
297
+ ### 3.3 — Generate XML plan (if build_xml_plans=true)
298
+
299
+ Write `docs/build/{slug}/plan.xml` with this structure:
300
+
301
+ ```xml
302
+ <?xml version="1.0" encoding="UTF-8"?>
303
+ <build-plan name="{project-name}" slug="{slug}" created="{ISO date}">
304
+ <star>
305
+ <situation>{text}</situation>
306
+ <task>{text}</task>
307
+ <action>{text}</action>
308
+ <result>{text}</result>
309
+ </star>
310
+
311
+ <wave id="0" name="Foundation" parallel="false">
312
+ <task id="T001" complexity="M" wave="0">
313
+ <title>Set up project structure</title>
314
+ <description>...</description>
315
+ <files>
316
+ <file action="create">src/index.ts</file>
317
+ </files>
318
+ <dependencies />
319
+ <test>Write failing test for entry point</test>
320
+ <verify>npm test -- --grep "entry point"</verify>
321
+ <done>Entry point test passes; file exists; imports resolve</done>
322
+ <commit>feat: bootstrap project entry point</commit>
323
+ </task>
324
+ </wave>
325
+
326
+ <wave id="1" name="Core Domain" parallel="true">
327
+ <!-- Tasks in this wave can run in parallel -->
328
+ </wave>
329
+ </build-plan>
330
+ ```
331
+
332
+ **Nyquist rule:** Every `<task>` MUST have `<test>`, `<verify>`, and `<done>` elements. A plan without these is invalid.
333
+
334
+ ### 3.4 — Validate plan
335
+
336
+ Spawn `agentops:plan-validator` subagent with `docs/build/{slug}/plan.xml`.
337
+
338
+ The validator checks 8 dimensions:
339
+ 1. Completeness — all requirements from requirements.md have at least one task
340
+ 2. Dependency graph — no circular dependencies between tasks
341
+ 3. File ownership — no two tasks write to the same file in the same wave
342
+ 4. Task size — no task is larger than L complexity
343
+ 5. Nyquist compliance — every task has test/verify/done
344
+ 6. Wave ordering — foundation tasks precede feature tasks
345
+ 7. TDD compliance — test tasks precede implementation tasks within each wave
346
+ 8. Commit message quality — all commit messages follow conventional commit format
347
+
348
+ If validator returns FAIL, fix the specific issues and re-validate.
349
+
350
+ ### 3.5 — HUMAN GATE: Plan Approval
351
+
352
+ Present the full plan. Use `AskUserQuestion`:
353
+ - header: "Build — Plan"
354
+ - question: "The implementation plan is ready. How would you like to proceed?"
355
+ - options:
356
+ - `{label: "Approve (Recommended)", description: "Proceed to task breakdown and execution."}`
357
+ - `{label: "Modify plan", description: "Request changes before proceeding."}`
358
+ - `{label: "Reject", description: "Cancel this build."}`
359
+
360
+ If `autonomy_level=autonomous`: skip this gate and proceed.
361
+
362
+ > **Persuasion layer (if build_persuasion=true):** "A validated plan with Nyquist compliance means every task has a clear done condition. Teams that approve plans before execution complete 40% faster with fewer blockers."
363
+
364
+ ---
365
+
366
+ ## Phase 4: TASK_BREAKDOWN
367
+
368
+ **Goal:** Parse the XML plan into atomic, actionable mini-plans with TDD specifications.
369
+
370
+ ### 4.1 — Parse XML tasks
371
+
372
+ Read `docs/build/{slug}/plan.xml` and extract all `<task>` elements.
373
+ Create `docs/build/{slug}/tasks/` directory.
374
+
375
+ ### 4.2 — Per-task mini-plans
376
+
377
+ For each task, generate a mini-plan file using `templates/build/task-plan-template.md`.
378
+ Output to: `docs/build/{slug}/tasks/{task-id}.md`
379
+
380
+ Each mini-plan includes:
381
+ - Context (which files to read first, which dependencies are already satisfied)
382
+ - TDD specification:
383
+ - RED: The exact failing test to write first (file path + test name + assertion)
384
+ - GREEN: The minimal implementation to make it pass
385
+ - REFACTOR: Specific improvements to apply after green
386
+ - Verification command and expected output
387
+ - Commit message (conventional commit format)
388
+
389
+ ### 4.3 — Linear sync (if build_linear_sync=true)
390
+
391
+ For each task, create a Linear issue with:
392
+ - Title from `<title>`
393
+ - Description from mini-plan
394
+ - Estimate from complexity (S=1pt, M=2pt, L=3pt)
395
+ - Status: "To Do"
396
+ - Label: "build/{slug}"
397
+
398
+ ### 4.4 — HUMAN GATE: Task Breakdown Approval
399
+
400
+ **You MUST output a summary table of all tasks** before asking for approval. Display:
401
+
402
+ | Task | Wave | Title | Complexity | Dependencies |
403
+ |------|------|-------|------------|--------------|
404
+ | T001 | 0 | ... | M | — |
405
+
406
+ Then use `AskUserQuestion`:
407
+ - header: "Build — Task Breakdown"
408
+ - question: "Generated {N} task mini-plans across {W} waves. Review the tasks above. Ready to begin execution?"
409
+ - options:
410
+ - `{label: "Begin execution (Recommended)", description: "Start Wave 0 immediately."}`
411
+ - `{label: "Review task plans first", description: "I want to review individual mini-plans before execution."}`
412
+ - `{label: "Adjust task breakdown", description: "Some tasks need modification."}`
413
+
414
+ **IMPORTANT:** This gate approves the task breakdown only. After the user approves, proceed to Phase 4.5 (Scaffold) if applicable, then Phase 5 (Execution). Do NOT skip any phases.
415
+
416
+ > **Persuasion layer (if build_persuasion=true):** "Each task is scoped to under 200 lines of change with a clear done condition. The standard approach is to approve the breakdown now — adjusting mid-execution costs 3x more than adjusting the plan."
417
+
418
+ ---
419
+
420
+ ## Phase 4.5: SCAFFOLD (conditional — new projects only)
421
+
422
+ **Skip this phase if an existing codebase is detected.**
423
+
424
+ ### Detection
425
+
426
+ Check if any of these exist: `package.json`, `composer.json`, `pyproject.toml`, `go.mod`, `Cargo.toml`.
427
+ If any exist → skip to Phase 5.
428
+
429
+ ### Execution (if build_scaffold_auto=true)
430
+
431
+ 1. Generate a standards profile based on the interrogation answers (language, framework, patterns)
432
+ 2. Invoke the scaffold process from `commands/enterprise/scaffold.md` with the pre-selected answers from interrogation (do not re-ask questions that were already answered)
433
+ 3. Commit all scaffolded files as Wave 0: `chore: scaffold project structure (Wave 0)`
434
+
435
+ If `build_scaffold_auto=false`, use `AskUserQuestion` to ask whether to scaffold before proceeding.
436
+
437
+ ---
438
+
439
+ ## Phase 5: EXECUTION
440
+
441
+ **Goal:** Implement every task with TDD, atomic commits, and wave-based parallelism.
442
+
443
+ ### 5.1 — Wave execution
444
+
445
+ Execute tasks wave by wave. Within a wave, tasks run in parallel if `build_wave_parallel=true`.
446
+
447
+ **For each task:**
448
+
449
+ 1. Announce: `**Wave {W} / Task {ID}: {title}**`
450
+
451
+ 2. If `build_fresh_context=true`: spawn a fresh subagent (subagent_type: general-purpose) with:
452
+ - The mini-plan from `docs/build/{slug}/tasks/{task-id}.md`
453
+ - The requirements from `docs/build/{slug}/requirements.md`
454
+ - The engineering standards from `templates/standards/engineering-standards.md` (if `build_standards_inject=true`)
455
+ - The standards checklist from `templates/standards/standards-checklist.md` (if `build_standards_inject=true`)
456
+
457
+ **Subagent prompt (include verbatim):**
458
+
459
+ > You are an execution agent implementing a single task from a build plan.
460
+ >
461
+ > **Your inputs:**
462
+ > - `docs/build/{slug}/tasks/{task-id}.md` — your task mini-plan. This is your primary instruction. Follow it exactly.
463
+ > - `docs/build/{slug}/requirements.md` — the approved requirements. Your task must satisfy the requirements it maps to.
464
+ > - `templates/standards/engineering-standards.md` — mandatory coding standards. All code you produce must comply.
465
+ > - `templates/standards/standards-checklist.md` — quick-reference checklist. Verify your code against this before committing.
466
+ >
467
+ > **Process — follow this order strictly:**
468
+ >
469
+ > 1. **Read all inputs.** Read the mini-plan first, then requirements, then standards. Understand the task fully before writing any code.
470
+ > 2. **Read existing code.** The mini-plan lists files to read under "Context → Files to read first." Read all of them. Understand the patterns, naming conventions, and project structure before writing anything.
471
+ > 3. **RED — Write the failing test.** Follow the mini-plan's "TDD Specification → RED Phase" exactly. Write the test file. Run it. It MUST fail. If it passes without implementation, the test is wrong — fix the test, do not proceed.
472
+ > 4. **GREEN — Minimal implementation.** Write the minimum code to make the test pass. Follow the mini-plan's "GREEN Phase." Run the test. It MUST pass.
473
+ > 5. **REFACTOR — Improve without changing behaviour.** Apply the improvements listed in the mini-plan's "REFACTOR Phase." Run tests after each change. They must stay green. Verify against the standards checklist.
474
+ > 6. **Verify.** Run the verification command from the mini-plan's "Verification" section. Confirm expected output matches.
475
+ > 7. **Commit.** Stage ONLY the files listed in the mini-plan's "Commit" section. Use the exact commit message specified. Do NOT use `git add -A`.
476
+ >
477
+ > **Rules:**
478
+ > - Do NOT modify files outside the scope of this task unless a dependency requires it.
479
+ > - Do NOT skip the RED phase. Code without a failing test first violates TDD and will be caught in review.
480
+ > - Do NOT add features, abstractions, or "improvements" beyond what the mini-plan specifies. Implement exactly what is asked.
481
+ > - If the test framework or dependencies are missing, install them as part of the task and include them in the commit.
482
+ > - If you encounter a blocking issue (missing dependency from a prior wave, ambiguous requirement, broken existing code), STOP and return a failure report with: task ID, what blocked you, what you tried, and what the orchestrator needs to resolve.
483
+ >
484
+ > **Reporting — return this when done:**
485
+ > ```json
486
+ > {"task_id": "{task-id}", "status": "completed|failed|blocked", "tdd_phases_completed": ["RED","GREEN","REFACTOR"], "test_count": N, "tests_passing": N, "commit_sha": "abc1234", "files_changed": ["path/to/file"], "notes": "any issues or deviations"}
487
+ > ```
488
+ > If `status` is `failed` or `blocked`, include `"error"` and `"attempted"` fields describing what went wrong and what you tried.
489
+
490
+ 3. If `build_fresh_context=false`: implement directly in the current context using the mini-plan. Follow the same process as above (steps 1-7) without spawning a subagent.
491
+
492
+ ### 5.2 — TDD enforcement (if build_tdd_enforced=true)
493
+
494
+ Every task MUST follow this cycle. Do NOT skip the RED phase.
495
+
496
+ **RED:** Write the failing test as specified in the mini-plan. Run it. Confirm it fails with the expected error. Log: `[RED] {task-id}: test written, failing as expected`
497
+
498
+ **GREEN:** Write the minimal implementation to make the test pass. Run tests. Confirm passing. Log: `[GREEN] {task-id}: test passing`
499
+
500
+ **REFACTOR:** Apply the refactor phase from the mini-plan. Re-run tests. Confirm still passing. Log: `[REFACTOR] {task-id}: refactored, tests still passing`
501
+
502
+ > **Persuasion layer (if build_persuasion=true):** "Code without tests will be caught in Phase 6 review and generate fix tasks. Senior engineers write the test first — it defines the contract."
503
+
504
+ ### 5.3 — Commit
505
+
506
+ After each task: `git add` relevant files and commit using the message from the mini-plan.
507
+ Follow conventional commit format: `type(scope): description`
508
+
509
+ Commits target the branch/worktree determined by the active `build_git_workflow` strategy (see Git Workflow section above).
510
+
511
+ ### 5.4 — Execution log
512
+
513
+ After each task, append to `.agentops/build-execution.jsonl`:
514
+
515
+ ```json
516
+ {"task_id": "T001", "wave": 0, "status": "completed", "tdd_phases": ["RED", "GREEN", "REFACTOR"], "commit": "abc1234", "timestamp": "ISO", "duration_ms": 12000}
517
+ ```
518
+
519
+ ### 5.5 — Failure handling
520
+
521
+ If a task fails:
522
+ - The existing `auto-lesson` hook captures the lesson automatically
523
+ - If the same task fails 3 times: the `evolve-gate` hook triggers EvoSkill
524
+ - Do NOT retry the same approach. Modify the mini-plan and try again.
525
+ - Log failure to `.agentops/build-execution.jsonl` with `"status": "failed"`
526
+
527
+ ### 5.6 — Linear update (if build_linear_sync=true)
528
+
529
+ Update each Linear issue to "In Progress" when a task starts, "Done" when it completes.
530
+
531
+ ### 5.7 — Supervised gates (if autonomy_level=supervised)
532
+
533
+ After each task, use `AskUserQuestion`:
534
+ - header: "Execution — Step Complete"
535
+ - question: "Task {ID} ({title}) complete. Continue?"
536
+ - options:
537
+ - `{label: "Continue (Recommended)", description: "Proceed to next task"}`
538
+ - `{label: "Review changes", description: "Show me git diff before continuing"}`
539
+ - `{label: "Modify plan", description: "Adjust remaining tasks"}`
540
+ - `{label: "Pause build", description: "Save state and stop for now"}`
541
+
542
+ ### 5.8 — Execution complete
543
+
544
+ When all waves have finished:
545
+ 1. Update state: add `EXECUTION` to `phase_completed`, set `phase` to `REVIEW`.
546
+ 2. Check off `Phase 5: EXECUTION` in `tasks/todo.md`.
547
+ 3. Check off all satisfied requirements in `docs/build/{slug}/requirements.md`.
548
+ 4. **Proceed immediately to Phase 6 (Review).** Do NOT skip to Phase 7 or Phase 8.
549
+
550
+ ---
551
+
552
+ ## Phase 6: REVIEW
553
+
554
+ **Goal:** Two-stage review — spec compliance then code quality.
555
+
556
+ ### Stage 1: Spec Compliance
557
+
558
+ Spawn `agentops:spec-compliance-reviewer` with:
559
+ - `docs/build/{slug}/requirements.md`
560
+ - `docs/build/{slug}/plan.xml`
561
+ - Output of `git diff main...HEAD`
562
+ - `templates/standards/engineering-standards.md`
563
+
564
+ The reviewer produces: `docs/build/{slug}/reviews/spec-compliance.md`
565
+
566
+ ### Stage 2: Code Quality
567
+
568
+ Run the existing review process from `commands/enterprise/review.md` on `git diff main...HEAD --name-only`.
569
+
570
+ The output lands in the standard review report format.
571
+
572
+ ### Stage 3: Aggregate and triage
573
+
574
+ Merge findings from both stages:
575
+ - **CRITICAL** findings → block progression. Must fix before Phase 7.
576
+ - **HIGH** findings → generate fix tasks. A fix wave is inserted before Phase 7.
577
+ - **MEDIUM** findings → logged, recommended but non-blocking.
578
+ - **LOW/INFO** findings → logged.
579
+
580
+ ### Fix wave (if HIGH findings exist)
581
+
582
+ Generate fix tasks from HIGH findings. Assign IDs: `FIX-001`, `FIX-002`, etc.
583
+ Execute fix wave using the same TDD process as Phase 5.
584
+ After fixes, re-run Stage 1 spec compliance only (no need for full Stage 2).
585
+
586
+ ### HUMAN GATE: Review Approval
587
+
588
+ Present the consolidated review report. Use `AskUserQuestion`:
589
+ - header: "Build — Review"
590
+ - question: "Review complete. {N} findings: {C} critical, {H} high, {M} medium, {L} low. How would you like to proceed?"
591
+ - options:
592
+ - `{label: "Approve (all issues addressed)", description: "Proceed to verification."}`
593
+ - `{label: "Fix critical/high issues first", description: "Address blocking findings before proceeding."}`
594
+ - `{label: "Accept with known issues", description: "Proceed despite medium/low findings (they'll be logged)."}`
595
+
596
+ If CRITICAL findings remain unaddressed: do NOT allow progression. Re-present the option to fix.
597
+
598
+ > **Persuasion layer (if build_persuasion=true):** "Fixing findings now takes minutes. Fixing them after merge takes hours — and the review team will flag the same issues. Senior engineers address all critical and high findings before proceeding."
599
+
600
+ ---
601
+
602
+ ## Phase 7: VERIFICATION
603
+
604
+ **Goal:** Prove correctness via Nyquist audit, full test suite, and E2E checks.
605
+
606
+ ### 7.1 — Nyquist audit
607
+
608
+ For every task in `docs/build/{slug}/plan.xml`, run its `<verify>` command.
609
+ Log: PASS or FAIL per task.
610
+ If any FAIL: surface as a blocking issue. Do not proceed until resolved.
611
+
612
+ ### 7.2 — Full test suite
613
+
614
+ Run the project test command (detect from `package.json` scripts: `test`, `test:ci`, `test:all`; or `composer test`, `pytest`, etc.).
615
+ All tests must pass. If they don't: fix the failures before proceeding.
616
+
617
+ ### 7.3 — E2E (if applicable)
618
+
619
+ If an E2E test suite exists (`cypress`, `playwright`, `puppeteer`), run it.
620
+ If it fails: treat as a blocking issue.
621
+
622
+ ### 7.4 — Compliance gates
623
+
624
+ The existing `compliance-gate.sh` hook runs automatically on Stop. Ensure it passes.
625
+
626
+ ### 7.5 — HUMAN GATE: Verification Sign-off
627
+
628
+ Use `AskUserQuestion`:
629
+ - header: "Build — Verification"
630
+ - question: "All verification checks passed. Ready to proceed to approval and PR creation?"
631
+ - options:
632
+ - `{label: "Proceed to approval (Recommended)", description: "Move to final summary and PR."}`
633
+ - `{label: "Run additional checks", description: "I want to run more tests before approving."}`
634
+
635
+ > **Persuasion layer (if build_persuasion=true):** "Every task's verify command has passed and the full test suite is green. Delaying approval now doesn't reduce risk — it increases context rot. The window for a clean merge is now."
636
+
637
+ ---
638
+
639
+ ## Phase 8: APPROVAL
640
+
641
+ **Goal:** Final human approval, PR creation, and build archival.
642
+
643
+ ### 8.1 — Generate summary
644
+
645
+ Write `docs/build/{slug}/summary.md` using `templates/build/summary-template.md`.
646
+
647
+ Include:
648
+ - Metrics: total duration, tasks completed, waves, commits, tests added, HIGH findings fixed, lessons captured, estimated tokens used
649
+ - What was built (narrative)
650
+ - Architecture decisions made (with rationale)
651
+ - Known limitations (from MEDIUM findings)
652
+ - Lessons learned (from `.agentops/build-execution.jsonl` failure entries)
653
+
654
+ ### 8.2 — HUMAN GATE: Final Approval
655
+
656
+ Present the full summary. Use `AskUserQuestion`:
657
+ - header: "Build — Final Approval"
658
+ - question: "Build complete. Review the summary above. How would you like to proceed?"
659
+ - options:
660
+ - `{label: "Approve and create PR (Recommended)", description: "Create the pull request and close out the build."}`
661
+ - `{label: "Request changes", description: "Something needs adjustment before I approve."}`
662
+ - `{label: "Approve without PR", description: "Mark complete but skip PR creation."}`
663
+
664
+ If `autonomy_level=autonomous`: skip this gate.
665
+
666
+ > **Persuasion layer (if build_persuasion=true):** "This build has passed planning validation, TDD enforcement, two-stage review, and full verification. Every task has a commit and every commit has a test. Approving now captures the momentum — teams that delay approval after passing verification lose an average of 2 hours to context switching."
667
+
668
+ ### 8.3 — PR creation
669
+
670
+ **Behaviour depends on `build_git_workflow`:**
671
+
672
+ - **worktree:** Merge the worktree branch into main (`git merge --no-ff build/{slug}`), then create PR if a remote is configured. Clean up worktree and branch.
673
+ - **feature-branch:** Create PR from `build/{slug}` → main using `gh pr create`. Do not auto-merge.
674
+ - **trunk:** Skip this step — code is already on trunk.
675
+
676
+ PR details (when created):
677
+ - Title: `feat({slug}): {project name}`
678
+ - Body: contents of `docs/build/{slug}/summary.md` (truncated to 4000 chars if needed)
679
+ - Label: `build`, `agentops`
680
+
681
+ ### 8.4 — Linear cleanup (if build_linear_sync=true)
682
+
683
+ Move all Linear issues in `label: build/{slug}` to "Done".
684
+
685
+ ### 8.5 — Lesson capture
686
+
687
+ Run EvoSkill to consolidate lessons from this build into reusable patterns.
688
+ Append a session summary to `.agentops/build-execution.jsonl`:
689
+
690
+ ```json
691
+ {"type": "build_complete", "slug": "{slug}", "phases_completed": 8, "total_tasks": N, "pr_url": "...", "timestamp": "ISO"}
692
+ ```
693
+
694
+ ### 8.6 — Archive
695
+
696
+ Move `.agentops/build-state.json` to `docs/build/{slug}/build-state.archive.json`.
697
+ Delete the active state file to allow new builds.
698
+
699
+ ---
700
+
701
+ ## Error Recovery
702
+
703
+ - If any phase fails unexpectedly: save state with `"phase": "ERROR_{PHASE}"`, present the error to the user, and offer: Resume (retry the phase), Skip (mark phase as complete with warnings), or Abort.
704
+ - Never leave the codebase in a broken state. If aborting mid-execution, ensure all written files are syntactically valid.
705
+ - If a subagent fails to return: log the failure, surface it to the user, and offer fallback: run the equivalent step manually in the current context.
706
+
707
+ ---
708
+
709
+ ## Quick Mode (--quick or build_quick_mode=true)
710
+
711
+ Runs a condensed lifecycle:
712
+ 1. BRAINSTORM (abbreviated — single framing, no alternatives)
713
+ 2. PLANNING (skip interrogation; plan from brief directly)
714
+ 3. EXECUTION (all waves, TDD still enforced)
715
+ 4. VERIFICATION (Nyquist audit + test suite only)
716
+
717
+ No PR creation. No Linear sync. Suitable for solo exploration builds.
718
+
719
+ ---
720
+
721
+ ## Hook Interaction During Builds
722
+
723
+ The AgentOps hook system runs during builds. This is by design — builds benefit from the same guardrails as normal sessions. Key interactions:
724
+
725
+ | Hook | Phase | Behaviour |
726
+ |------|-------|-----------|
727
+ | `auto-test.sh` | 5 (Execution) | Will nudge for tests after 3 writes — redundant when `build_tdd_enforced=true` since TDD is already mandatory. Harmless. |
728
+ | `auto-plan.sh` | 5 (Execution) | Detects Write/Edit without a plan. During builds a plan always exists in `tasks/todo.md`. Harmless. |
729
+ | `standards-enforce.sh` | 5 (Execution) | Enforces coding standards on writes. Complements the build's own standards injection. Desired behaviour. |
730
+ | `auto-verify.sh` | Stop | Checks `tasks/todo.md` completion. During a multi-phase build, this fires if the user stops mid-build. It will report unchecked items — this is correct, since the build is incomplete. |
731
+ | `compliance-gate.sh` | Stop | Runs compliance checks. Safe during builds. Fires on pause/stop. |
732
+ | `auto-evolve.sh` | Stop | Checks for unprocessed failures. Works correctly with build failure tracking. |
733
+ | `unicode-firewall.sh` | 5 (Execution) | Scans writes for invisible Unicode. Desired behaviour — protects build output. |
734
+ | `injection-scan.sh` | 5 (Execution) | Scans for prompt injection. Desired behaviour — protects subagent inputs. |
735
+
736
+ **No hooks need to be disabled during builds.** The hook system and build system are complementary. If a hook blocks a legitimate build operation, the issue is in the hook, not the build.
737
+
738
+ ---
739
+
740
+ ## Linear Integration (build_linear_sync=true)
741
+
742
+ **Default: disabled.** Enable via `/agentops:flags` or `.agentops/flags.json`.
743
+
744
+ **Prerequisites:**
745
+ - The `linear` CLI must be installed and authenticated (`linear auth`)
746
+ - Alternatively, set `LINEAR_API_KEY` in your environment for API-based access
747
+
748
+ **How it works:**
749
+
750
+ Phase 4 (Task Breakdown):
751
+ ```bash
752
+ # Create issues via CLI
753
+ linear issue create --title "{task title}" --description "{mini-plan content}" \
754
+ --estimate {1|2|3} --label "build/{slug}" --status "Todo"
755
+ ```
756
+
757
+ Phase 5 (Execution):
758
+ - On task start: update Linear status to "In Progress"
759
+ - On task complete: update Linear status to "Done"
760
+ - On task failure: update Linear status to "Blocked" with failure reason in a comment
761
+
762
+ Phase 8 (Approval):
763
+ - Move all `build/{slug}` issues to "Done"
764
+ - Add PR URL as a comment on each issue
765
+
766
+ If `linear` CLI is not available or authentication fails, log a warning and continue without sync. Linear sync is advisory — it must never block the build.