sdlc-framework 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +321 -0
  3. package/bin/install.js +193 -0
  4. package/package.json +39 -0
  5. package/src/commands/close.md +200 -0
  6. package/src/commands/debug.md +124 -0
  7. package/src/commands/fast.md +149 -0
  8. package/src/commands/fix.md +104 -0
  9. package/src/commands/help.md +144 -0
  10. package/src/commands/hotfix.md +99 -0
  11. package/src/commands/impl.md +142 -0
  12. package/src/commands/init.md +93 -0
  13. package/src/commands/milestone.md +136 -0
  14. package/src/commands/pause.md +115 -0
  15. package/src/commands/research.md +136 -0
  16. package/src/commands/resume.md +103 -0
  17. package/src/commands/review.md +195 -0
  18. package/src/commands/spec.md +164 -0
  19. package/src/commands/status.md +118 -0
  20. package/src/commands/verify.md +153 -0
  21. package/src/references/clarification-strategy.md +352 -0
  22. package/src/references/engineering-laws.md +374 -0
  23. package/src/references/loop-phases.md +331 -0
  24. package/src/references/playwright-testing.md +298 -0
  25. package/src/references/prompt-detection.md +264 -0
  26. package/src/references/sub-agent-strategy.md +260 -0
  27. package/src/rules/commands.md +180 -0
  28. package/src/rules/style.md +354 -0
  29. package/src/rules/templates.md +238 -0
  30. package/src/rules/workflows.md +314 -0
  31. package/src/templates/HANDOFF.md +121 -0
  32. package/src/templates/LAWS.md +521 -0
  33. package/src/templates/PROJECT.md +112 -0
  34. package/src/templates/REVIEW.md +145 -0
  35. package/src/templates/ROADMAP.md +101 -0
  36. package/src/templates/SPEC.md +231 -0
  37. package/src/templates/STATE.md +106 -0
  38. package/src/templates/SUMMARY.md +126 -0
  39. package/src/workflows/close-phase.md +189 -0
  40. package/src/workflows/debug-flow.md +302 -0
  41. package/src/workflows/fast-forward.md +340 -0
  42. package/src/workflows/fix-findings.md +235 -0
  43. package/src/workflows/hotfix-flow.md +190 -0
  44. package/src/workflows/impl-phase.md +229 -0
  45. package/src/workflows/init-project.md +249 -0
  46. package/src/workflows/milestone-management.md +169 -0
  47. package/src/workflows/pause-work.md +153 -0
  48. package/src/workflows/research.md +219 -0
  49. package/src/workflows/resume-project.md +159 -0
  50. package/src/workflows/review-phase.md +337 -0
  51. package/src/workflows/spec-phase.md +379 -0
  52. package/src/workflows/transition-phase.md +203 -0
  53. package/src/workflows/verify-phase.md +280 -0
@@ -0,0 +1,264 @@
1
+ # Prompt Detection Reference
2
+
3
+ This document explains how the `/sdlc:fast` command classifies task types from natural language prompts. It covers keyword patterns, complexity estimation, routing logic, and override mechanisms.
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ When a developer types `/sdlc:fast "add a login page"`, the framework must determine:
10
+
11
+ 1. **What type of work is this?** (feature, bug, critical, research, test, refactor, docs)
12
+ 2. **How complex is it?** (simple, medium, complex)
13
+ 3. **Where should it route?** (inline execution, /sdlc:spec, /sdlc:debug, /sdlc:hotfix, /sdlc:research)
14
+
15
+ `/sdlc:fast` is the **default entry point** for all work — not just small tasks. It is a universal router that classifies intent and complexity, then either handles work inline (simple) or routes to the appropriate specialized command (complex, bugs, research, emergencies).
16
+
17
+ This classification happens automatically. The developer can override it with flags if the automatic classification is wrong.
18
+
19
+ ---
20
+
21
+ ## Keyword Patterns by Type
22
+
23
+ Each task type has a set of keyword patterns that signal its classification. Patterns are checked in order — the first match wins.
24
+
25
+ ### Feature (new functionality)
26
+
27
+ **Strong signals:**
28
+ - "add", "create", "build", "implement", "new"
29
+ - "page", "endpoint", "API", "component", "service"
30
+ - "support for", "ability to"
31
+
32
+ **Phrase patterns:**
33
+ - "add a {{thing}}"
34
+ - "create {{thing}} that {{behavior}}"
35
+ - "build a {{thing}} for {{purpose}}"
36
+ - "implement {{feature_name}}"
37
+ - "new {{thing}}"
38
+
39
+ **Examples:**
40
+ - "add a login page" → feature
41
+ - "create a user registration API" → feature
42
+ - "build a dashboard component" → feature
43
+ - "implement password reset" → feature
44
+
45
+ ### Bug Fix (correcting behavior)
46
+
47
+ **Strong signals:**
48
+ - "fix", "bug", "broken", "error", "crash"
49
+ - "doesn't work", "not working", "fails", "incorrect"
50
+ - "wrong", "should be", "expected", "instead of"
51
+
52
+ **Phrase patterns:**
53
+ - "fix {{thing}} that {{bad_behavior}}"
54
+ - "{{thing}} is broken"
55
+ - "{{thing}} returns wrong {{result}}"
56
+ - "{{thing}} crashes when {{condition}}"
57
+ - "{{thing}} doesn't {{expected_behavior}}"
58
+
59
+ **Examples:**
60
+ - "fix the login form that crashes on empty email" → bugfix
61
+ - "user search returns wrong results" → bugfix
62
+ - "signup page doesn't validate email" → bugfix
63
+ - "API returns 500 instead of 404" → bugfix
64
+
65
+ ### Test (adding or improving tests)
66
+
67
+ **Strong signals:**
68
+ - "test", "spec", "coverage", "assert", "mock"
69
+ - "unit test", "integration test", "e2e test"
70
+ - "add tests for", "test coverage"
71
+
72
+ **Phrase patterns:**
73
+ - "add tests for {{thing}}"
74
+ - "write unit tests for {{thing}}"
75
+ - "increase test coverage for {{thing}}"
76
+ - "add e2e tests for {{flow}}"
77
+
78
+ **Examples:**
79
+ - "add tests for the UserService" → test
80
+ - "write unit tests for password validation" → test
81
+ - "add e2e tests for checkout flow" → test
82
+
83
+ ### Refactor (restructuring without behavior change)
84
+
85
+ **Strong signals:**
86
+ - "refactor", "restructure", "reorganize", "clean up"
87
+ - "extract", "split", "move", "rename"
88
+ - "simplify", "reduce complexity", "DRY up"
89
+
90
+ **Phrase patterns:**
91
+ - "refactor {{thing}}"
92
+ - "extract {{thing}} from {{other_thing}}"
93
+ - "split {{thing}} into {{parts}}"
94
+ - "clean up {{thing}}"
95
+ - "rename {{thing}} to {{new_name}}"
96
+
97
+ **Examples:**
98
+ - "refactor the OrderService" → refactor
99
+ - "extract validation logic into a shared utility" → refactor
100
+ - "split the UserController into separate controllers" → refactor
101
+ - "clean up the database query builders" → refactor
102
+
103
+ ### Documentation (docs-only changes)
104
+
105
+ **Strong signals:**
106
+ - "document", "docs", "README", "JSDoc", "comment"
107
+ - "API docs", "guide", "tutorial", "changelog"
108
+ - "update docs", "add documentation"
109
+
110
+ **Phrase patterns:**
111
+ - "document {{thing}}"
112
+ - "add docs for {{thing}}"
113
+ - "update the README"
114
+ - "write a guide for {{thing}}"
115
+
116
+ **Examples:**
117
+ - "document the authentication API" → docs
118
+ - "add JSDoc comments to the UserService" → docs
119
+ - "update the README with setup instructions" → docs
120
+
121
+ ---
122
+
123
+ ## Complexity Estimation Heuristics
124
+
125
+ After determining the type, estimate the complexity to decide the SDLC path.
126
+
127
+ ### Complexity Signals
128
+
129
+ | Signal | Simple | Moderate | Complex |
130
+ |--------|--------|----------|---------|
131
+ | Files affected | 1-2 | 3-5 | 6+ |
132
+ | Concepts involved | 1 | 2-3 | 4+ |
133
+ | Dependencies mentioned | 0 | 1-2 | 3+ |
134
+ | Words in prompt | 5-15 | 15-30 | 30+ |
135
+ | Contains "and" | 0-1 times | 2 times | 3+ times |
136
+ | Mentions integration | no | partial | yes |
137
+ | Mentions testing explicitly | no | yes | yes + e2e |
138
+ | Mentions multiple components | no | no | yes |
139
+
140
+ ### Complexity Scoring
141
+
142
+ Each signal contributes a score. Total score determines complexity:
143
+
144
+ - **0-3 points:** Simple — Fast-track path
145
+ - **4-7 points:** Moderate — Standard loop
146
+ - **8+ points:** Complex — Full loop with sub-agents
147
+
148
+ ### Examples
149
+
150
+ **"fix typo in login page"**
151
+ - Files: 1 (simple, 0 points)
152
+ - Concepts: 1 (simple, 0 points)
153
+ - Words: 5 (simple, 0 points)
154
+ - Total: 0 → **Simple**
155
+
156
+ **"add user search with filtering by role and status"**
157
+ - Files: 2-3 (moderate, 2 points)
158
+ - Concepts: 3 — search, filtering, roles (moderate, 2 points)
159
+ - "and": 1 time (simple, 0 points)
160
+ - Contains filtering logic (moderate, 1 point)
161
+ - Total: 5 → **Moderate**
162
+
163
+ **"implement OAuth2 login with Google and GitHub providers, including token refresh, account linking, and role-based access control"**
164
+ - Files: 6+ (complex, 3 points)
165
+ - Concepts: 5+ — OAuth, providers, tokens, linking, RBAC (complex, 3 points)
166
+ - "and": 3 times (complex, 2 points)
167
+ - Mentions integration (complex, 2 points)
168
+ - Total: 10 → **Complex**
169
+
170
+ ---
171
+
172
+ ## Routing Logic
173
+
174
+ Based on type and complexity, the framework routes to the appropriate SDLC path.
175
+
176
+ ### Routing Table
177
+
178
+ | Complexity | Action |
179
+ |------------|--------|
180
+ | Simple | Skip spec phase. Generate minimal spec inline. Go directly to implementation. Quick verification. No sub-agents. |
181
+ | Moderate | Standard SDLC loop. Spec phase with 1-2 clarification questions. Single-agent implementation. Full verification. Full review. |
182
+ | Complex | Full SDLC loop. Spec phase with multiple clarification rounds. Sub-agent implementation with task dependency graph. Full verification including Playwright where applicable. Full review. |
183
+
184
+ ### Type-Specific Routing Adjustments
185
+
186
+ | Type | Adjustment |
187
+ |------|------------|
188
+ | bugfix | Always include verification of the fix AND regression testing. |
189
+ | refactor | Always include before/after behavior comparison. Skip UI verification. |
190
+ | test | Skip implementation phase (tests ARE the implementation). Go directly to verification (run the tests). |
191
+ | docs | Skip verification and review phases. Docs do not need engineering law review. |
192
+
193
+ ### Routing Decision Tree
194
+
195
+ ```
196
+ Type = docs?
197
+ Yes → Write docs, skip verify/review, close
198
+ No → Complexity = simple?
199
+ Yes → Fast-track: minimal spec, implement, quick verify, close
200
+ No → Complexity = moderate?
201
+ Yes → Standard: spec, implement, verify, review, close
202
+ No → Full: spec (with clarifications), implement (with sub-agents),
203
+ verify (with Playwright), review, close
204
+ ```
205
+
206
+ ---
207
+
208
+ ## Override Mechanism
209
+
210
+ The automatic classification is a best guess. Developers can override it.
211
+
212
+ ### Force Flags
213
+
214
+ | Flag | Effect |
215
+ |------|--------|
216
+ | `--type feature` | Force task type to feature |
217
+ | `--type bugfix` | Force task type to bugfix |
218
+ | `--type refactor` | Force task type to refactor |
219
+ | `--type test` | Force task type to test |
220
+ | `--type docs` | Force task type to docs |
221
+ | `--complexity simple` | Force simple complexity (fast-track) |
222
+ | `--complexity moderate` | Force moderate complexity (standard loop) |
223
+ | `--complexity complex` | Force complex complexity (full loop) |
224
+ | `--full` | Force full SDLC loop regardless of detection |
225
+ | `--fast` | Force fast-track regardless of detection |
226
+
227
+ ### Override Examples
228
+
229
+ ```bash
230
+ # Detected as simple, but developer knows it is complex
231
+ /sdlc:fast "update the user model" --complexity complex
232
+
233
+ # Detected as feature, but it is actually a refactor
234
+ /sdlc:fast "restructure the auth module" --type refactor
235
+
236
+ # Skip all detection, use full loop
237
+ /sdlc:fast "add email notifications" --full
238
+ ```
239
+
240
+ ### When to Override
241
+
242
+ - **The prompt is ambiguous:** "update the user page" could be a feature, bugfix, or refactor.
243
+ - **The complexity is underestimated:** "add a button" sounds simple, but the button triggers a complex workflow.
244
+ - **The complexity is overestimated:** "implement OAuth with Google, GitHub, and GitLab" sounds complex, but the library handles everything and it is actually moderate.
245
+ - **You want the full loop for learning:** Even simple tasks benefit from the full loop when training junior developers.
246
+
247
+ ---
248
+
249
+ ## Classification Examples
250
+
251
+ A comprehensive set of examples showing how detection works in practice.
252
+
253
+ | Prompt | Detected Type | Detected Complexity | Route |
254
+ |--------|---------------|--------------------|----|
255
+ | "fix typo in header" | bugfix | simple | fast-track |
256
+ | "add dark mode toggle" | feature | simple | fast-track |
257
+ | "refactor UserService to use repository pattern" | refactor | moderate | standard |
258
+ | "add user search with pagination and sorting" | feature | moderate | standard |
259
+ | "fix race condition in payment processing" | bugfix | complex | full |
260
+ | "implement real-time notifications with WebSocket" | feature | complex | full |
261
+ | "add unit tests for OrderService" | test | moderate | standard (skip impl) |
262
+ | "document the REST API endpoints" | docs | simple | fast-track (skip verify) |
263
+ | "build a multi-tenant auth system with RBAC, SSO, and audit logging" | feature | complex | full |
264
+ | "rename getUserById to findUserById" | refactor | simple | fast-track |
@@ -0,0 +1,260 @@
1
+ # Sub-Agent Strategy Reference
2
+
3
+ This document explains how sub-agent driven development works within the SDLC framework. It is loaded via `@references/sub-agent-strategy.md` when planning implementation or when understanding how tasks are parallelized.
4
+
5
+ ---
6
+
7
+ ## When to Use Sub-Agents
8
+
9
+ Sub-agents are separate AI execution contexts that work on tasks in parallel. They are powerful but not free — each agent consumes tokens, requires instructions, and produces output that must be integrated.
10
+
11
+ ### Use Sub-Agents For
12
+
13
+ - **Independent implementation tasks:** Two services that do not share files can be built in parallel.
14
+ - **Test writing:** Tests for existing code can be written in parallel with new feature code.
15
+ - **Research tasks:** Investigating a library, reading documentation, or analyzing existing code while another agent implements.
16
+ - **File creation:** When multiple new files need to be created and they do not depend on each other.
17
+
18
+ ### Do NOT Use Sub-Agents For
19
+
20
+ - **Simple edits:** Changing a single line, adding an import, fixing a typo. The overhead of spawning an agent exceeds the work.
21
+ - **Sequential debugging:** Debugging requires reading output, thinking, trying something, reading output again. This is inherently sequential.
22
+ - **Tasks that modify the same file:** Two agents editing the same file creates merge conflicts.
23
+ - **Tasks with tight coupling:** If Task B needs to know what Task A decided, they must be sequential.
24
+ - **Tasks under 50 lines of code:** The agent instruction overhead is not worth it for small changes.
25
+
26
+ ### Decision Framework
27
+
28
+ ```
29
+ Is the task independent of other tasks?
30
+ No → Run sequentially, do not use a sub-agent
31
+ Yes → Is the task substantial (50+ lines or multiple files)?
32
+ No → Do it inline, no sub-agent needed
33
+ Yes → Does it modify files another task touches?
34
+ Yes → Run sequentially after the other task
35
+ No → Use a sub-agent
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Task Dependency Analysis
41
+
42
+ Before spawning agents, build a directed acyclic graph (DAG) of task dependencies. The DAG determines which tasks can run in parallel and which must wait.
43
+
44
+ ### How to Build the DAG
45
+
46
+ 1. **List all tasks** from the spec (T-001 through T-NNN).
47
+ 2. **For each task, identify inputs:** What files does it read? What interfaces does it implement? What data structures does it consume?
48
+ 3. **For each task, identify outputs:** What files does it create or modify? What interfaces does it define? What data structures does it produce?
49
+ 4. **Draw edges:** If Task B's inputs include Task A's outputs, draw an edge from A to B (B depends on A).
50
+ 5. **Check for cycles:** If you find a cycle (A depends on B depends on A), the tasks need to be restructured. Cycles usually mean the tasks are not properly decomposed.
51
+
52
+ ### Example DAG Construction
53
+
54
+ Spec tasks:
55
+ - T-001: Define `User` interface in `types/user.ts`
56
+ - T-002: Define `Order` interface in `types/order.ts`
57
+ - T-003: Implement `UserService` (imports `User` interface)
58
+ - T-004: Implement `OrderService` (imports `Order` and `User` interfaces)
59
+ - T-005: Write tests for `UserService`
60
+ - T-006: Write tests for `OrderService`
61
+
62
+ Dependency analysis:
63
+ ```
64
+ T-001 (User interface) → T-003 (UserService), T-004 (OrderService)
65
+ T-002 (Order interface) → T-004 (OrderService)
66
+ T-003 (UserService) → T-005 (UserService tests)
67
+ T-004 (OrderService) → T-006 (OrderService tests)
68
+ ```
69
+
70
+ DAG:
71
+ ```
72
+ T-001 ─┬─→ T-003 ──→ T-005
73
+
74
+ └─→ T-004 ──→ T-006
75
+
76
+ T-002 ─────┘
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Parallel Group Formation
82
+
83
+ Once the DAG is built, group tasks into parallel execution waves. A wave is a set of tasks with no dependencies on each other (all dependencies are in prior waves).
84
+
85
+ ### Algorithm
86
+
87
+ 1. Tasks with no dependencies form Wave 1.
88
+ 2. Remove Wave 1 tasks from the DAG.
89
+ 3. Tasks whose dependencies are now all satisfied form Wave 2.
90
+ 4. Repeat until all tasks are assigned to a wave.
91
+
92
+ ### Example (from the DAG above)
93
+
94
+ - **Wave 1:** T-001, T-002 (no dependencies)
95
+ - **Wave 2:** T-003, T-004 (depend on Wave 1 tasks which are now done — but T-004 depends on T-001 AND T-002, so both must be in a prior wave, which they are)
96
+ - **Wave 3:** T-005, T-006 (depend on Wave 2 tasks)
97
+
98
+ This means:
99
+ - First, spawn 2 agents for T-001 and T-002 in parallel.
100
+ - When both complete, spawn 2 agents for T-003 and T-004 in parallel.
101
+ - When both complete, spawn 2 agents for T-005 and T-006 in parallel.
102
+
103
+ Total: 3 sequential waves instead of 6 sequential tasks. Time savings depend on task size.
104
+
105
+ ---
106
+
107
+ ## Agent Instruction Template
108
+
109
+ Each sub-agent receives a focused instruction set. The instruction must be self-contained — the agent does not have access to the full conversation history.
110
+
111
+ ### Required Elements
112
+
113
+ Every agent instruction must include:
114
+
115
+ 1. **Role:** What the agent is (e.g., "You are implementing the UserService")
116
+ 2. **Task:** Exactly what to do, copied from the spec task
117
+ 3. **Files to read:** Which existing files to read for context
118
+ 4. **Files to create/modify:** Which files the agent owns
119
+ 5. **Interfaces/types to use:** Exact signatures the agent must conform to
120
+ 6. **Constraints:** What NOT to do (do not modify files outside your scope)
121
+ 7. **Verification:** How the agent confirms its work is correct
122
+ 8. **Output format:** What the agent should report when done
123
+
124
+ ### Template
125
+
126
+ ```
127
+ ## Role
128
+ You are a sub-agent implementing {{TASK_NAME}}.
129
+
130
+ ## Task
131
+ {{TASK_DESCRIPTION from spec}}
132
+
133
+ ## Context Files (read-only)
134
+ - {{FILE_PATH}} — {{WHY_IT_IS_RELEVANT}}
135
+
136
+ ## Your Files (create or modify)
137
+ - {{FILE_PATH}} — {{WHAT_TO_DO_WITH_IT}}
138
+
139
+ ## Interfaces to Conform To
140
+ ```typescript
141
+ {{INTERFACE_DEFINITIONS_THE_AGENT_MUST_IMPLEMENT}}
142
+ ```
143
+
144
+ ## Constraints
145
+ - Do NOT modify any file not listed in "Your Files"
146
+ - Do NOT add dependencies not listed in the spec
147
+ - Do NOT create abstractions not required by the task
148
+ - Follow engineering laws: {{RELEVANT_LAWS}}
149
+
150
+ ## Verification
151
+ - {{HOW_TO_CONFIRM_TASK_IS_DONE}}
152
+
153
+ ## Report
154
+ When done, report:
155
+ 1. Files created/modified
156
+ 2. Any decisions made
157
+ 3. Any issues encountered
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Error Handling: When an Agent Fails
163
+
164
+ Agents can fail for several reasons: ambiguous instructions, missing context, file conflicts, or runtime errors.
165
+
166
+ ### Failure Categories and Responses
167
+
168
+ **Ambiguous instructions:**
169
+ - Symptom: Agent asks for clarification or makes an incorrect assumption.
170
+ - Response: Rewrite the instruction with more specificity. Add explicit examples.
171
+
172
+ **Missing context:**
173
+ - Symptom: Agent cannot find a required interface, type, or utility.
174
+ - Response: Add the missing file to the agent's context files. If the file does not exist yet (it is another agent's output), the task dependency graph is wrong — fix the ordering.
175
+
176
+ **File conflict:**
177
+ - Symptom: Two agents modified the same file.
178
+ - Response: This should never happen if the task dependency graph is correct. If it does, one agent's changes take priority (the one later in the dependency chain). The earlier agent's changes to that file must be manually merged.
179
+
180
+ **Runtime error:**
181
+ - Symptom: Agent's code does not compile or tests fail.
182
+ - Response: Review the error, fix the issue, and re-verify. Do not re-run the entire wave — fix the specific failure.
183
+
184
+ ### Retry Strategy
185
+
186
+ - **First failure:** Review agent output, fix the instruction, re-run the single task.
187
+ - **Second failure:** Bring the task back to the main context and implement it directly.
188
+ - **Never:** Retry more than twice. If an agent fails twice, the task is too ambiguous for sub-agent execution.
189
+
190
+ ---
191
+
192
+ ## Integration: Merging Agent Outputs
193
+
194
+ After all agents in a wave complete, their outputs must be integrated before the next wave starts.
195
+
196
+ ### Integration Checklist
197
+
198
+ 1. **File conflicts:** Verify no two agents modified the same file. If they did, merge manually.
199
+ 2. **Interface compliance:** Verify each agent's output conforms to the interfaces specified in its instructions.
200
+ 3. **Import resolution:** Verify that cross-file imports between agent outputs resolve correctly.
201
+ 4. **Type checking:** Run the type checker (if applicable) to catch interface mismatches.
202
+ 5. **Test execution:** Run existing tests to confirm nothing broke.
203
+
204
+ ### When Integration Fails
205
+
206
+ If integration reveals a mismatch between agents (e.g., Agent A defined an interface differently than Agent B expected), the problem is in the spec. The spec did not define the shared interface precisely enough. Fix the spec, then re-run the affected agents.
207
+
208
+ ---
209
+
210
+ ## Anti-Patterns
211
+
212
+ ### Agents Modifying the Same File
213
+ Never assign two agents to modify the same file. Even with different sections, the merge is error-prone and the conflict detection overhead negates the parallelism benefit.
214
+
215
+ **Fix:** Split the file into separate concerns, or make one task sequential.
216
+
217
+ ### Agents Without Clear Scope
218
+ An agent instruction that says "implement the authentication system" is too broad. The agent will make architectural decisions that conflict with other agents or with the project's conventions.
219
+
220
+ **Fix:** Break it into specific tasks: "implement password hashing in auth/password.service.ts using bcrypt," "implement JWT token generation in auth/token.service.ts using jsonwebtoken."
221
+
222
+ ### Too Many Agents
223
+ Spawning 10 agents for 10 tiny tasks creates more overhead than doing them sequentially. Each agent has startup cost (reading context, understanding instructions) and integration cost (verifying output, resolving imports).
224
+
225
+ **Fix:** Group small related tasks into a single agent. An agent that creates 3 related files is more efficient than 3 agents creating 1 file each.
226
+
227
+ ### Agents That Need Human Input
228
+ A sub-agent cannot ask the user questions. If a task requires a decision that was not made during the spec phase, the agent will guess — and usually guess wrong.
229
+
230
+ **Fix:** All decisions must be made during `/sdlc:spec`. If a task has an open question, it is not ready for sub-agent execution.
231
+
232
+ ---
233
+
234
+ ## Cost Awareness
235
+
236
+ Sub-agents consume tokens. Before spawning, estimate the cost.
237
+
238
+ ### Estimation Heuristic
239
+
240
+ - **Context files:** Count tokens in the files the agent needs to read. Typical code file is 200-500 tokens.
241
+ - **Instructions:** The agent instruction template is roughly 300-500 tokens.
242
+ - **Output:** The agent's generated code is roughly proportional to the task complexity. A 50-line function is about 300-400 tokens.
243
+ - **Total per agent:** Context + Instructions + Output + Reasoning overhead (2-3x the output).
244
+
245
+ ### Example
246
+
247
+ An agent that reads 3 files (1500 tokens), receives instructions (400 tokens), and produces 100 lines of code (600 tokens with reasoning overhead of 1800 tokens):
248
+ - Input: ~1900 tokens
249
+ - Output: ~2400 tokens
250
+ - Cost: varies by model, but roughly $0.01-0.05 per agent
251
+
252
+ For a wave of 4 agents, that is $0.04-0.20. For a full implementation with 3 waves and 4 agents each, that is $0.12-0.60. This is usually far cheaper than the developer time saved.
253
+
254
+ ### When Cost Exceeds Benefit
255
+
256
+ - Tasks that require reading enormous files (>1000 lines each) for a small change.
257
+ - Tasks that will likely fail and need retries (ambiguous specs).
258
+ - Tasks that could be done in 2 minutes inline.
259
+
260
+ In these cases, skip the sub-agent and do the work directly.