@tekyzinc/gsd-t 2.50.12 → 2.53.10

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 (99) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +379 -372
  3. package/bin/component-registry.js +250 -0
  4. package/bin/graph-cgc.js +510 -510
  5. package/bin/graph-indexer.js +147 -147
  6. package/bin/graph-overlay.js +195 -195
  7. package/bin/graph-parsers.js +327 -327
  8. package/bin/graph-query.js +453 -452
  9. package/bin/graph-store.js +154 -154
  10. package/bin/qa-calibrator.js +194 -0
  11. package/bin/scan-data-collector.js +153 -153
  12. package/bin/scan-diagrams-generators.js +187 -187
  13. package/bin/scan-diagrams.js +79 -79
  14. package/bin/scan-renderer.js +92 -92
  15. package/bin/scan-report-sections.js +121 -121
  16. package/bin/scan-report.js +184 -184
  17. package/bin/scan-schema-parsers.js +199 -199
  18. package/bin/scan-schema.js +103 -103
  19. package/bin/token-budget.js +246 -0
  20. package/commands/Claude-md.md +10 -10
  21. package/commands/branch.md +15 -15
  22. package/commands/checkin.md +45 -45
  23. package/commands/global-change.md +209 -209
  24. package/commands/gsd-t-audit.md +199 -0
  25. package/commands/gsd-t-backlog-add.md +94 -94
  26. package/commands/gsd-t-backlog-edit.md +111 -111
  27. package/commands/gsd-t-backlog-list.md +63 -63
  28. package/commands/gsd-t-backlog-move.md +94 -94
  29. package/commands/gsd-t-backlog-promote.md +123 -123
  30. package/commands/gsd-t-backlog-remove.md +86 -86
  31. package/commands/gsd-t-backlog-settings.md +158 -158
  32. package/commands/gsd-t-complete-milestone.md +528 -515
  33. package/commands/gsd-t-debug.md +506 -399
  34. package/commands/gsd-t-discuss.md +174 -174
  35. package/commands/gsd-t-execute.md +758 -634
  36. package/commands/gsd-t-feature.md +276 -276
  37. package/commands/gsd-t-health.md +142 -142
  38. package/commands/gsd-t-help.md +465 -457
  39. package/commands/gsd-t-impact.md +302 -302
  40. package/commands/gsd-t-init.md +320 -280
  41. package/commands/gsd-t-integrate.md +365 -249
  42. package/commands/gsd-t-milestone.md +87 -87
  43. package/commands/gsd-t-partition.md +442 -361
  44. package/commands/gsd-t-pause.md +82 -82
  45. package/commands/gsd-t-plan.md +345 -344
  46. package/commands/gsd-t-populate.md +111 -111
  47. package/commands/gsd-t-prd.md +326 -326
  48. package/commands/gsd-t-project.md +211 -211
  49. package/commands/gsd-t-promote-debt.md +123 -123
  50. package/commands/gsd-t-prompt.md +137 -137
  51. package/commands/gsd-t-qa.md +266 -266
  52. package/commands/gsd-t-quick.md +357 -234
  53. package/commands/gsd-t-reflect.md +134 -134
  54. package/commands/gsd-t-resume.md +72 -72
  55. package/commands/gsd-t-scan.md +615 -615
  56. package/commands/gsd-t-setup.md +76 -0
  57. package/commands/gsd-t-status.md +192 -166
  58. package/commands/gsd-t-test-sync.md +381 -381
  59. package/commands/gsd-t-triage-and-merge.md +171 -171
  60. package/commands/gsd-t-verify.md +382 -382
  61. package/commands/gsd-t-visualize.md +118 -118
  62. package/commands/gsd-t-wave.md +401 -378
  63. package/docs/GSD-T-README.md +425 -422
  64. package/docs/architecture.md +385 -369
  65. package/docs/harness-design-analysis.md +371 -0
  66. package/docs/infrastructure.md +205 -205
  67. package/docs/prd-graph-engine.md +398 -398
  68. package/docs/prd-gsd2-hybrid.md +559 -559
  69. package/docs/prd-harness-evolution.md +583 -0
  70. package/docs/requirements.md +14 -0
  71. package/docs/workflows.md +226 -226
  72. package/examples/.gsd-t/domains/example-domain/scope.md +13 -13
  73. package/package.json +40 -40
  74. package/scripts/gsd-t-auto-route.js +39 -39
  75. package/scripts/gsd-t-dashboard-mockup.html +1143 -1143
  76. package/scripts/gsd-t-dashboard-server.js +171 -171
  77. package/scripts/gsd-t-dashboard.html +262 -262
  78. package/scripts/gsd-t-event-writer.js +128 -128
  79. package/scripts/gsd-t-statusline.js +94 -94
  80. package/scripts/gsd-t-tools.js +175 -175
  81. package/templates/CLAUDE-global.md +639 -614
  82. package/templates/CLAUDE-project.md +24 -0
  83. package/templates/backlog-settings.md +18 -18
  84. package/templates/backlog.md +1 -1
  85. package/templates/progress.md +40 -40
  86. package/templates/shared-services-contract.md +60 -60
  87. package/templates/stacks/desktop.ini +2 -2
  88. package/bin/desktop.ini +0 -2
  89. package/commands/desktop.ini +0 -2
  90. package/docs/ci-examples/desktop.ini +0 -2
  91. package/docs/desktop.ini +0 -2
  92. package/examples/.gsd-t/contracts/desktop.ini +0 -2
  93. package/examples/.gsd-t/desktop.ini +0 -2
  94. package/examples/.gsd-t/domains/desktop.ini +0 -2
  95. package/examples/.gsd-t/domains/example-domain/desktop.ini +0 -2
  96. package/examples/desktop.ini +0 -2
  97. package/examples/rules/desktop.ini +0 -2
  98. package/scripts/desktop.ini +0 -2
  99. package/templates/desktop.ini +0 -2
@@ -1,344 +1,345 @@
1
- # GSD-T: Plan — Create Domain Task Lists with Dependencies
2
-
3
- You are the lead agent creating atomic execution plans for each domain. This phase is ALWAYS single-session — one agent with full context across all domains to ensure consistency.
4
-
5
- ## Step 1: Load Full Context
6
-
7
- Read ALL of these:
8
- 1. `CLAUDE.md`
9
- 2. `.gsd-t/progress.md`
10
- 3. `.gsd-t/contracts/` — every contract file
11
- 4. `.gsd-t/domains/*/scope.md` — every domain scope
12
- 5. `.gsd-t/domains/*/constraints.md` — every domain constraint
13
- 6. `docs/` — requirements, architecture, schema, design
14
- 7. Existing source code (if any) — understand current state
15
- 8. `.gsd-t/CONTEXT.md` (if exists — from discuss phase) — **MANDATORY READ if present**
16
-
17
- **If CONTEXT.md exists:** Every Locked Decision listed in it MUST be mapped to at least one task in Step 2. Do NOT proceed to execute if any Locked Decision is unmapped.
18
-
19
- ## Step 1.5: Graph-Enhanced Dependency Detection
20
-
21
- If `.gsd-t/graph/meta.json` exists (graph index is available):
22
- 1. Query `findDuplicates` to detect when planned tasks would create duplicate functions across domains — flag for SharedCore extraction or deduplication
23
- 2. Query `getImporters` for key modules to identify implicit task dependencies that might not be obvious from contracts alone
24
- 3. Feed these findings into the Cross-Domain Duplicate Operation Scan and dependency mapping in Steps 2–3
25
-
26
- If graph is not available, skip this step.
27
-
28
- ## Step 1.7: Pre-Mortem — Historical Failure Analysis
29
-
30
- Before creating task lists, check historical task-metrics for domain-level failure patterns from previous milestones:
31
-
32
- 1. Run via Bash:
33
- `node -e "const c = require('./bin/metrics-collector.js'); const domains = [/* list domain names from scope files */]; domains.forEach(d => { const w = c.getPreFlightWarnings(d); if(w.length) w.forEach(x => console.log('⚠️ ' + x)); });" 2>/dev/null || true`
34
-
35
- 2. If any domain has `first_pass_rate < 0.6` historically:
36
- - Display warning inline: `⚠️ Domain {name} has historically low first-pass rate ({rate}%). Consider: smaller tasks, more explicit acceptance criteria, or additional contract detail.`
37
- - This is **non-blocking** — it informs task design, does not prevent planning.
38
-
39
- 3. If `.gsd-t/metrics/task-metrics.jsonl` does not exist: skip this step silently (first milestone, no historical data).
40
-
41
- 4. **Rule-based pre-mortem**: Run via Bash:
42
- `node -e "const re = require('./bin/rule-engine.js'); const domains = [/* list domain names */]; domains.forEach(d => { const rules = re.getPreMortemRules(d); if(rules.length) rules.forEach(r => console.log('RULE ' + r.id + ': ' + r.name + ' — historically triggered for domains like ' + d)); });" 2>/dev/null || true`
43
-
44
- If matching rules found: display warnings inline (non-blocking — informs task design). Falls back gracefully if rules.jsonl does not exist or is empty.
45
-
46
- ## Step 2: Create Task Lists Per Domain
47
-
48
- ### SharedCore-First Pre-Check
49
-
50
- Before writing any domain task lists:
51
- 1. Does `.gsd-t/contracts/shared-services-contract.md` exist?
52
- - **YES**: A `shared-core` domain has been identified. Plan its tasks first. All client-surface domains that consume SharedCore operations are BLOCKED BY shared-core until its tasks complete. Use `BLOCKED BY shared-core Task {N}` in the relevant client domain task lists.
53
- - **NO**: Proceed. The Cross-Domain Duplicate Operation Scan (below) will catch any shared operations missed during partition.
54
-
55
- For each domain, write `.gsd-t/domains/{domain-name}/tasks.md`:
56
-
57
- ```markdown
58
- # Tasks: {domain-name}
59
-
60
- ## Summary
61
- {1-2 sentence description of what this domain delivers when all tasks complete}
62
-
63
- ## Tasks
64
-
65
- ### Task 1: {descriptive name}
66
- - **Files**: {files to create or modify}
67
- - **Contract refs**: {which contracts this implements}
68
- - **Dependencies**: NONE | BLOCKED by {domain} Task {N}
69
- - **Acceptance criteria**:
70
- - {specific testable outcome}
71
- - {specific testable outcome}
72
-
73
- ### Task 2: {descriptive name}
74
- - **Files**: {files to create or modify}
75
- - **Contract refs**: {which contracts this implements}
76
- - **Dependencies**: Requires Task 1 (within domain)
77
- - **Acceptance criteria**:
78
- - {specific testable outcome}
79
- ```
80
-
81
- ### Task Design Rules:
82
- 1. **Atomic**: Each task produces a working, testable increment
83
- 2. **Self-contained context**: A fresh agent with only CLAUDE.md, the domain's scope/constraints, the relevant contracts, and the task description should be able to execute it
84
- 3. **File-scoped**: Each task lists exactly which files it touches no surprises
85
- 4. **Contract-bound**: Every task that crosses a domain boundary must reference the specific contract it implements
86
- 5. **Ordered**: Tasks within a domain are numbered in execution order
87
- 6. **No implicit knowledge**: Don't assume the executing agent remembers previous tasks — reference contracts and files explicitly
88
- 7. **Context-window fit**: Each task MUST be executable within a single context window. Apply the scope validation heuristics below.
89
-
90
- ### Task Scope Validation
91
-
92
- After writing each task, apply this heuristic check before finalizing:
93
-
94
- **Splitting candidates — flag if ANY of these are true:**
95
- - Task lists **more than 5 files** to modify or create
96
- - Task has **more than 3 complex dependencies** (other tasks, contracts, or external systems it must read and understand)
97
- - Task description spans multiple distinct concerns (e.g., "implement X and also refactor Y and update Z docs")
98
-
99
- **Warning threshold:** If a task is flagged, emit:
100
- > ⚠️ **Task scope warning {domain} Task {N}**: Estimated context load is high ({N} files, {N} dependencies). This task may approach the 70% context window threshold. Consider splitting into:
101
- > - Task {N}a: {first concern}
102
- > - Task {N}b: {second concern}
103
-
104
- **Auto-split rule (Level 3 Full Auto):** If a task has >5 files AND >3 dependencies, split it automatically. Renumber subsequent tasks. Document the split rationale in the task's Dependencies field.
105
-
106
- **Guidance for estimating context size:**
107
- - Each file to read ≈ 1–5% of context window (varies by file size)
108
- - CLAUDE.md + scope.md + constraints.md + contracts 1525% baseline overhead
109
- - Tasks with >5 files or >3 cross-domain contracts commonly exceed 70% total context
110
-
111
- This rule implements the "task must fit in one context window" constraint — a task that compacts its subagent is a task that produces incomplete or corrupt output.
112
-
113
- ### Cross-Domain Duplicate Operation Scan
114
-
115
- After creating all domain task lists, scan for operations that appear in more than one domain.
116
-
117
- **Check for duplicate task descriptions, function names, or operation verbs** across all `tasks.md` files:
118
-
119
- ```
120
- For each operation in each domain's task list:
121
- Does this operation appear (by name or clear equivalent) in another domain's task list?
122
- YES flag as duplicate candidate
123
- ```
124
-
125
- **If duplicates found:**
126
-
127
- > ⚠️ **Duplicate operations detected** — the following operations appear in multiple domains:
128
- > - `{operation}`found in: {domain-A} Task {N}, {domain-B} Task {N}
129
- > - `{operation}` — found in: {domain-A} Task {N}, {domain-C} Task {N}
130
- >
131
- > **Options:**
132
- > 1. If a `shared-core` domain exists → reassign these tasks to shared-core
133
- > 2. If no shared-core → extract to a new `shared-core` domain (go back to partition and add it)
134
- > 3. If the operations are truly surface-specific variants document the distinction explicitly in each domain's constraints.md to prevent future confusion
135
-
136
- **Level 3 (Full Auto)**: If shared-core exists, move the duplicates there automatically. If not, add a task to the first affected domain's list: "Extract `{operation}` to shared-core — coordinate with {domain-B} before implementing".
137
-
138
- **If no duplicates found:**
139
-
140
- > ✅ No duplicate operations detected across domains.
141
-
142
- ### SharedCore Contract Compliance Check
143
-
144
- If `.gsd-t/contracts/shared-services-contract.md` exists, run a second pass:
145
-
146
- For each client-surface domain's task list, compare task operations against the SharedCore contract's "Shared Operations" table. Flag any task that implements an operation already owned by SharedCore:
147
-
148
- > ⚠️ **SharedCore contract violation** — the following tasks reimplement operations owned by SharedCore:
149
- > - {domain} Task {N}: implements `{operation}` already owned by SharedCore per shared-services-contract.md
150
- >
151
- > Fix: Change these tasks to CALL the SharedCore function rather than implementing it independently.
152
-
153
- If no violations: `✅ All client domains reference SharedCore correctly.`
154
-
155
- ---
156
-
157
- ### REQ Traceability
158
-
159
- After creating task lists, append a traceability table to `docs/requirements.md`:
160
-
161
- ```markdown
162
- ## Requirements Traceability (updated by plan phase)
163
- | REQ-ID | Requirement Summary | Domain | Task(s) | Status |
164
- |--------|---------------------|--------|---------|--------|
165
- | REQ-001 | {summary} | {domain} | Task 1, Task 3 | pending |
166
- | REQ-002 | {summary} | {domain} | Task 2 | pending |
167
- ```
168
-
169
- - Every REQ-ID must map to at least one domain/task — orphaned requirements are a planning gap
170
- - Every task group should trace back to at least one REQ-IDtasks with no REQ reference may be scope creep
171
- - Report: orphaned requirements (no task) and unanchored tasks (no REQ)
172
-
173
- ## Step 3: Map Cross-Domain Dependencies
174
-
175
- Update `.gsd-t/contracts/integration-points.md` with the full dependency graph **and wave groupings**:
176
-
177
- ```markdown
178
- # Integration Points
179
-
180
- ## Dependency Graph
181
-
182
- ### Independent (can start immediately)
183
- - data-layer: Tasks 1-3
184
- - auth: Tasks 1-2
185
- - ui: Tasks 1-2
186
-
187
- ### First Checkpoint
188
- - GATE: data-layer Task 3 (schema migrations) must complete
189
- - UNLOCKS: auth Task 3 (user lookup), ui Task 3 (data fetching)
190
- - VERIFY: Lead confirms schema matches schema-contract.md
191
-
192
- ### Second Checkpoint
193
- - GATE: auth Task 4 (auth middleware) must complete
194
- - UNLOCKS: ui Task 5 (protected routes)
195
- - VERIFY: Lead confirms auth endpoints match api-contract.md
196
-
197
- ## Wave Execution Groups
198
-
199
- Waves allow parallel execution within a wave and sequential execution between waves.
200
- Each wave contains domains/tasks that can safely run in parallel (no shared files, no cross-domain dependencies within the wave).
201
-
202
- ### Wave 1 — Independent (parallel)
203
- - data-layer: Tasks 1-3
204
- - auth: Tasks 1-2
205
- - **Shared files**: NONE — safe to run in parallel
206
- - **Completes when**: All listed tasks done
207
-
208
- ### Wave 2 — After Wave 1 Checkpoint (parallel)
209
- - CHECKPOINT: Lead verifies schema-contract.md before Wave 2 starts
210
- - auth: Tasks 3-4
211
- - ui: Tasks 1-2
212
- - **Shared files**: NONE — safe to run in parallel
213
- - **Completes when**: All listed tasks done
214
-
215
- ### Wave 3 — After Wave 2 Checkpoint (sequential)
216
- - CHECKPOINT: Lead verifies api-contract.md before Wave 3 starts
217
- - ui: Tasks 3-5
218
- - **Note**: Sequential — each task depends on the previous
219
-
220
- ### Integration
221
- - INTEGRATION: Wire all domains together
222
-
223
- ## Execution Order (for solo mode)
224
- 1. data-layer Tasks 1-3
225
- 2. auth Tasks 1-2 (parallel-safe with data-layer)
226
- 3. CHECKPOINT: verify schema contract
227
- 4. auth Tasks 3-4
228
- 5. ui Tasks 1-2 (parallel-safe with auth 3-4)
229
- 6. CHECKPOINT: verify api contract
230
- 7. ui Tasks 3-5
231
- 8. INTEGRATION: wire everything together
232
- ```
233
-
234
- ### Wave Grouping Rules:
235
- 1. **Same wave** = no shared files, no dependency between them
236
- 2. **Different wave** = one depends on the other's output, OR they modify the same file
237
- 3. **CHECKPOINT between waves** = lead verifies contract compliance before unlocking next wave
238
- 4. Always check domain `scope.md` files for file ownership overlapping files → different waves
239
-
240
- ## Step 4: Estimate Scope
241
-
242
- Add to each domain's `tasks.md`:
243
- ```markdown
244
- ## Execution Estimate
245
- - Total tasks: {N}
246
- - Independent tasks (no blockers): {N}
247
- - Blocked tasks (waiting on other domains): {N}
248
- - Estimated checkpoints: {N}
249
- ```
250
-
251
- ## Step 5: Document Ripple
252
-
253
- After creating task lists and mapping dependencies, update affected documentation:
254
-
255
- ### Always update:
256
- 1. **`.gsd-t/progress.md`** — Updated in Step 5, but verify Decision Log includes planning decisions and rationale
257
-
258
- ### Check if affected:
259
- 2. **`docs/requirements.md`** If planning revealed missing, ambiguous, or conflicting requirements, update them
260
- 3. **`docs/architecture.md`** — If the task breakdown reveals new components or clarifies data flow, update it
261
- 4. **`.gsd-t/contracts/`** — If planning revealed contract gaps or needed additional detail, update them
262
- 5. **Domain `constraints.md`** — If planning revealed new constraints (task ordering, shared resources), add them
263
-
264
- ### Skip what's not affected.
265
-
266
- ## Step 6: Test Verification
267
-
268
- Before finalizing the plan:
269
-
270
- 1. **Run existing tests**: Execute the full test suite to confirm codebase state before execution begins
271
- 2. **Verify passing**: Document any pre-existing failures assign them to appropriate domain tasks
272
- 3. **Include test tasks**: Ensure each domain's task list includes test creation/update tasks where acceptance criteria require verification
273
-
274
- ## Step 7: Plan Validation
275
-
276
- Spawn a Task subagent to validate the plan before proceeding:
277
-
278
- ```
279
- Task subagent (general-purpose, model: haiku):
280
- "Validate this GSD-T plan. Read:
281
- - .gsd-t/domains/*/tasks.md (all task lists)
282
- - .gsd-t/contracts/ (all contracts)
283
- - docs/requirements.md (including traceability table)
284
- - .gsd-t/CONTEXT.md (if exists)
285
-
286
- Check:
287
- 1. REQ coverage: every REQ-ID in requirements.md maps to at least one task
288
- 2. Locked Decisions (from CONTEXT.md if present): every Locked Decision maps to at least one task
289
- 3. Task completeness: every task has files, contract refs, and acceptance criteria
290
- 4. Cross-domain dependencies: all BLOCKED-BY references point to real tasks
291
- 5. Contract existence: every task referencing a contract has that contract file present
292
-
293
- Report: PASS (all checks pass) or FAIL with specific gaps listed."
294
- ```
295
-
296
- **OBSERVABILITY LOGGING (MANDATORY):**
297
- Before spawning — run via Bash:
298
- `T_START=$(date +%s) && DT_START=$(date +"%Y-%m-%d %H:%M") && TOK_START=${CLAUDE_CONTEXT_TOKENS_USED:-0} && TOK_MAX=${CLAUDE_CONTEXT_TOKENS_MAX:-200000}`
299
- After subagent returns run via Bash:
300
- `T_END=$(date +%s) && DT_END=$(date +"%Y-%m-%d %H:%M") && TOK_END=${CLAUDE_CONTEXT_TOKENS_USED:-0} && DURATION=$((T_END-T_START))`
301
- Compute tokens and compaction:
302
- - No compaction (TOK_END >= TOK_START): `TOKENS=$((TOK_END-TOK_START))`, COMPACTED=null
303
- - Compaction detected (TOK_END < TOK_START): `TOKENS=$(((TOK_MAX-TOK_START)+TOK_END))`, COMPACTED=$DT_END
304
- Compute context utilization run via Bash:
305
- `if [ "${CLAUDE_CONTEXT_TOKENS_MAX:-0}" -gt 0 ]; then CTX_PCT=$(echo "scale=1; ${CLAUDE_CONTEXT_TOKENS_USED:-0} * 100 / ${CLAUDE_CONTEXT_TOKENS_MAX}" | bc); else CTX_PCT="N/A"; fi`
306
- Alert on context thresholds (display to user inline):
307
- - If CTX_PCT >= 85: `echo "🔴 CRITICAL: Context at ${CTX_PCT}% — compaction likely. Task MUST be split."`
308
- - If CTX_PCT >= 70: `echo "⚠️ WARNING: Context at ${CTX_PCT}% — approaching compaction threshold. Consider splitting in plan."`
309
- Append to `.gsd-t/token-log.md` (create with header `| Datetime-start | Datetime-end | Command | Step | Model | Duration(s) | Notes | Tokens | Compacted | Domain | Task | Ctx% |` if missing):
310
- `| {DT_START} | {DT_END} | gsd-t-plan | Step 7 | haiku | {DURATION}s | {PASS/FAIL}, iteration {N} | {TOKENS} | {COMPACTED} | | | {CTX_PCT} |`
311
- If validation FAIL, append each gap to `.gsd-t/qa-issues.md` (create with header `| Date | Command | Step | Model | Duration(s) | Severity | Finding |` if missing):
312
- `| {DT_START} | gsd-t-plan | Step 7 | haiku | {DURATION}s | medium | {gap description} |`
313
-
314
- **If FAIL**: Fix the identified gaps (up to 3 iterations). If still failing after 3 iterations, STOP and report to user with the specific gaps. Plan cannot proceed until validation PASSES.
315
-
316
- ## Step 8: Update Progress
317
-
318
- Update `.gsd-t/progress.md`:
319
- - Set status to `PLANNED`
320
- - Update domain table with task counts
321
- - Record any planning decisions in the Decision Log
322
-
323
- ## Step 9: Report
324
-
325
- ### Autonomy Behavior
326
-
327
- **Level 3 (Full Auto)**: Log a brief status line (e.g., "✅ Plan complete — {N} tasks across {N} domains, {execution mode}") and auto-advance to the next phase. Do NOT wait for user input.
328
-
329
- **Level 1–2**: Present to the user:
330
- 1. Task count per domain
331
- 2. Dependency graph (which domains block which)
332
- 3. Recommended execution mode:
333
- - **Solo sequential**: < 8 total tasks or heavily interdependent
334
- - **Solo interleaved**: 8-15 tasks with some independence
335
- - **Team parallel**: 15+ tasks with 3+ independent starting points
336
- 4. Any ambiguities found during planning that need user input
337
-
338
- Wait for confirmation before proceeding.
339
-
340
- $ARGUMENTS
341
-
342
- ## Auto-Clear
343
-
344
- All work is committed to project files. Execute `/clear` to free the context window for the next command.
1
+ # GSD-T: Plan — Create Domain Task Lists with Dependencies
2
+
3
+ You are the lead agent creating atomic execution plans for each domain. This phase is ALWAYS single-session — one agent with full context across all domains to ensure consistency.
4
+
5
+ ## Step 1: Load Full Context
6
+
7
+ Read ALL of these:
8
+ 1. `CLAUDE.md`
9
+ 2. `.gsd-t/progress.md`
10
+ 3. `.gsd-t/contracts/` — every contract file
11
+ 4. `.gsd-t/domains/*/scope.md` — every domain scope
12
+ 5. `.gsd-t/domains/*/constraints.md` — every domain constraint
13
+ 6. `docs/` — requirements, architecture, schema, design
14
+ 7. Existing source code (if any) — understand current state
15
+ 8. `.gsd-t/CONTEXT.md` (if exists — from discuss phase) — **MANDATORY READ if present**
16
+
17
+ **If CONTEXT.md exists:** Every Locked Decision listed in it MUST be mapped to at least one task in Step 2. Do NOT proceed to execute if any Locked Decision is unmapped.
18
+
19
+ ## Step 1.5: Graph-Enhanced Dependency Detection
20
+
21
+ If `.gsd-t/graph/meta.json` exists (graph index is available):
22
+ 1. Query `findDuplicates` to detect when planned tasks would create duplicate functions across domains — flag for SharedCore extraction or deduplication
23
+ 2. Query `getImporters` for key modules to identify implicit task dependencies that might not be obvious from contracts alone
24
+ 3. Feed these findings into the Cross-Domain Duplicate Operation Scan and dependency mapping in Steps 2–3
25
+
26
+ If graph is not available, skip this step.
27
+
28
+ ## Step 1.7: Pre-Mortem — Historical Failure Analysis
29
+
30
+ Before creating task lists, check historical task-metrics for domain-level failure patterns from previous milestones:
31
+
32
+ 1. Run via Bash:
33
+ `node -e "const c = require('./bin/metrics-collector.js'); const domains = [/* list domain names from scope files */]; domains.forEach(d => { const w = c.getPreFlightWarnings(d); if(w.length) w.forEach(x => console.log('⚠️ ' + x)); });" 2>/dev/null || true`
34
+
35
+ 2. If any domain has `first_pass_rate < 0.6` historically:
36
+ - Display warning inline: `⚠️ Domain {name} has historically low first-pass rate ({rate}%). Consider: smaller tasks, more explicit acceptance criteria, or additional contract detail.`
37
+ - This is **non-blocking** — it informs task design, does not prevent planning.
38
+
39
+ 3. If `.gsd-t/metrics/task-metrics.jsonl` does not exist: skip this step silently (first milestone, no historical data).
40
+
41
+ 4. **Rule-based pre-mortem**: Run via Bash:
42
+ `node -e "const re = require('./bin/rule-engine.js'); const domains = [/* list domain names */]; domains.forEach(d => { const rules = re.getPreMortemRules(d); if(rules.length) rules.forEach(r => console.log('RULE ' + r.id + ': ' + r.name + ' — historically triggered for domains like ' + d)); });" 2>/dev/null || true`
43
+
44
+ If matching rules found: display warnings inline (non-blocking — informs task design). Falls back gracefully if rules.jsonl does not exist or is empty.
45
+
46
+ ## Step 2: Create Task Lists Per Domain
47
+
48
+ ### SharedCore-First Pre-Check
49
+
50
+ Before writing any domain task lists:
51
+ 1. Does `.gsd-t/contracts/shared-services-contract.md` exist?
52
+ - **YES**: A `shared-core` domain has been identified. Plan its tasks first. All client-surface domains that consume SharedCore operations are BLOCKED BY shared-core until its tasks complete. Use `BLOCKED BY shared-core Task {N}` in the relevant client domain task lists.
53
+ - **NO**: Proceed. The Cross-Domain Duplicate Operation Scan (below) will catch any shared operations missed during partition.
54
+
55
+ For each domain, write `.gsd-t/domains/{domain-name}/tasks.md`:
56
+
57
+ ```markdown
58
+ # Tasks: {domain-name}
59
+
60
+ ## Summary
61
+ {1-2 sentence description of what this domain delivers when all tasks complete}
62
+
63
+ ## Tasks
64
+
65
+ ### Task 1: {descriptive name}
66
+ - **Files**: {files to create or modify}
67
+ - **Contract refs**: {which contracts this implements}
68
+ - **Dependencies**: NONE | BLOCKED by {domain} Task {N}
69
+ - **Acceptance criteria**:
70
+ - {specific testable outcome}
71
+ - {specific testable outcome}
72
+
73
+ ### Task 2: {descriptive name}
74
+ - **Files**: {files to create or modify}
75
+ - **Contract refs**: {which contracts this implements}
76
+ - **Dependencies**: Requires Task 1 (within domain)
77
+ - **Acceptance criteria**:
78
+ - {specific testable outcome}
79
+ ```
80
+
81
+ ### Task Design Rules:
82
+ 0. **UI tasks — reference the design brief**: If `.gsd-t/contracts/design-brief.md` exists, UI task descriptions must reference it. Include a note like: "Follow the color palette, typography, spacing, and component patterns defined in `.gsd-t/contracts/design-brief.md`." This ensures visual consistency without repeating spec details in every task.
83
+ 1. **Atomic**: Each task produces a working, testable increment
84
+ 2. **Self-contained context**: A fresh agent with only CLAUDE.md, the domain's scope/constraints, the relevant contracts, and the task description should be able to execute it
85
+ 3. **File-scoped**: Each task lists exactly which files it touches no surprises
86
+ 4. **Contract-bound**: Every task that crosses a domain boundary must reference the specific contract it implements
87
+ 5. **Ordered**: Tasks within a domain are numbered in execution order
88
+ 6. **No implicit knowledge**: Don't assume the executing agent remembers previous tasks reference contracts and files explicitly
89
+ 7. **Context-window fit**: Each task MUST be executable within a single context window. Apply the scope validation heuristics below.
90
+
91
+ ### Task Scope Validation
92
+
93
+ After writing each task, apply this heuristic check before finalizing:
94
+
95
+ **Splitting candidates flag if ANY of these are true:**
96
+ - Task lists **more than 5 files** to modify or create
97
+ - Task has **more than 3 complex dependencies** (other tasks, contracts, or external systems it must read and understand)
98
+ - Task description spans multiple distinct concerns (e.g., "implement X and also refactor Y and update Z docs")
99
+
100
+ **Warning threshold:** If a task is flagged, emit:
101
+ > ⚠️ **Task scope warning — {domain} Task {N}**: Estimated context load is high ({N} files, {N} dependencies). This task may approach the 70% context window threshold. Consider splitting into:
102
+ > - Task {N}a: {first concern}
103
+ > - Task {N}b: {second concern}
104
+
105
+ **Auto-split rule (Level 3 Full Auto):** If a task has >5 files AND >3 dependencies, split it automatically. Renumber subsequent tasks. Document the split rationale in the task's Dependencies field.
106
+
107
+ **Guidance for estimating context size:**
108
+ - Each file to read15% of context window (varies by file size)
109
+ - CLAUDE.md + scope.md + constraints.md + contracts 15–25% baseline overhead
110
+ - Tasks with >5 files or >3 cross-domain contracts commonly exceed 70% total context
111
+
112
+ This rule implements the "task must fit in one context window" constraint — a task that compacts its subagent is a task that produces incomplete or corrupt output.
113
+
114
+ ### Cross-Domain Duplicate Operation Scan
115
+
116
+ After creating all domain task lists, scan for operations that appear in more than one domain.
117
+
118
+ **Check for duplicate task descriptions, function names, or operation verbs** across all `tasks.md` files:
119
+
120
+ ```
121
+ For each operation in each domain's task list:
122
+ Does this operation appear (by name or clear equivalent) in another domain's task list?
123
+ → YES → flag as duplicate candidate
124
+ ```
125
+
126
+ **If duplicates found:**
127
+
128
+ > ⚠️ **Duplicate operations detected** the following operations appear in multiple domains:
129
+ > - `{operation}` — found in: {domain-A} Task {N}, {domain-B} Task {N}
130
+ > - `{operation}` — found in: {domain-A} Task {N}, {domain-C} Task {N}
131
+ >
132
+ > **Options:**
133
+ > 1. If a `shared-core` domain exists reassign these tasks to shared-core
134
+ > 2. If no shared-coreextract to a new `shared-core` domain (go back to partition and add it)
135
+ > 3. If the operations are truly surface-specific variants → document the distinction explicitly in each domain's constraints.md to prevent future confusion
136
+
137
+ **Level 3 (Full Auto)**: If shared-core exists, move the duplicates there automatically. If not, add a task to the first affected domain's list: "Extract `{operation}` to shared-core — coordinate with {domain-B} before implementing".
138
+
139
+ **If no duplicates found:**
140
+
141
+ > ✅ No duplicate operations detected across domains.
142
+
143
+ ### SharedCore Contract Compliance Check
144
+
145
+ If `.gsd-t/contracts/shared-services-contract.md` exists, run a second pass:
146
+
147
+ For each client-surface domain's task list, compare task operations against the SharedCore contract's "Shared Operations" table. Flag any task that implements an operation already owned by SharedCore:
148
+
149
+ > ⚠️ **SharedCore contract violation** the following tasks reimplement operations owned by SharedCore:
150
+ > - {domain} Task {N}: implements `{operation}` — already owned by SharedCore per shared-services-contract.md
151
+ >
152
+ > Fix: Change these tasks to CALL the SharedCore function rather than implementing it independently.
153
+
154
+ If no violations: `✅ All client domains reference SharedCore correctly.`
155
+
156
+ ---
157
+
158
+ ### REQ Traceability
159
+
160
+ After creating task lists, append a traceability table to `docs/requirements.md`:
161
+
162
+ ```markdown
163
+ ## Requirements Traceability (updated by plan phase)
164
+ | REQ-ID | Requirement Summary | Domain | Task(s) | Status |
165
+ |--------|---------------------|--------|---------|--------|
166
+ | REQ-001 | {summary} | {domain} | Task 1, Task 3 | pending |
167
+ | REQ-002 | {summary} | {domain} | Task 2 | pending |
168
+ ```
169
+
170
+ - Every REQ-ID must map to at least one domain/taskorphaned requirements are a planning gap
171
+ - Every task group should trace back to at least one REQ-ID — tasks with no REQ reference may be scope creep
172
+ - Report: orphaned requirements (no task) and unanchored tasks (no REQ)
173
+
174
+ ## Step 3: Map Cross-Domain Dependencies
175
+
176
+ Update `.gsd-t/contracts/integration-points.md` with the full dependency graph **and wave groupings**:
177
+
178
+ ```markdown
179
+ # Integration Points
180
+
181
+ ## Dependency Graph
182
+
183
+ ### Independent (can start immediately)
184
+ - data-layer: Tasks 1-3
185
+ - auth: Tasks 1-2
186
+ - ui: Tasks 1-2
187
+
188
+ ### First Checkpoint
189
+ - GATE: data-layer Task 3 (schema migrations) must complete
190
+ - UNLOCKS: auth Task 3 (user lookup), ui Task 3 (data fetching)
191
+ - VERIFY: Lead confirms schema matches schema-contract.md
192
+
193
+ ### Second Checkpoint
194
+ - GATE: auth Task 4 (auth middleware) must complete
195
+ - UNLOCKS: ui Task 5 (protected routes)
196
+ - VERIFY: Lead confirms auth endpoints match api-contract.md
197
+
198
+ ## Wave Execution Groups
199
+
200
+ Waves allow parallel execution within a wave and sequential execution between waves.
201
+ Each wave contains domains/tasks that can safely run in parallel (no shared files, no cross-domain dependencies within the wave).
202
+
203
+ ### Wave 1 — Independent (parallel)
204
+ - data-layer: Tasks 1-3
205
+ - auth: Tasks 1-2
206
+ - **Shared files**: NONE safe to run in parallel
207
+ - **Completes when**: All listed tasks done
208
+
209
+ ### Wave 2 After Wave 1 Checkpoint (parallel)
210
+ - CHECKPOINT: Lead verifies schema-contract.md before Wave 2 starts
211
+ - auth: Tasks 3-4
212
+ - ui: Tasks 1-2
213
+ - **Shared files**: NONE safe to run in parallel
214
+ - **Completes when**: All listed tasks done
215
+
216
+ ### Wave 3 After Wave 2 Checkpoint (sequential)
217
+ - CHECKPOINT: Lead verifies api-contract.md before Wave 3 starts
218
+ - ui: Tasks 3-5
219
+ - **Note**: Sequential — each task depends on the previous
220
+
221
+ ### Integration
222
+ - INTEGRATION: Wire all domains together
223
+
224
+ ## Execution Order (for solo mode)
225
+ 1. data-layer Tasks 1-3
226
+ 2. auth Tasks 1-2 (parallel-safe with data-layer)
227
+ 3. CHECKPOINT: verify schema contract
228
+ 4. auth Tasks 3-4
229
+ 5. ui Tasks 1-2 (parallel-safe with auth 3-4)
230
+ 6. CHECKPOINT: verify api contract
231
+ 7. ui Tasks 3-5
232
+ 8. INTEGRATION: wire everything together
233
+ ```
234
+
235
+ ### Wave Grouping Rules:
236
+ 1. **Same wave** = no shared files, no dependency between them
237
+ 2. **Different wave** = one depends on the other's output, OR they modify the same file
238
+ 3. **CHECKPOINT between waves** = lead verifies contract compliance before unlocking next wave
239
+ 4. Always check domain `scope.md` files for file ownership — overlapping files → different waves
240
+
241
+ ## Step 4: Estimate Scope
242
+
243
+ Add to each domain's `tasks.md`:
244
+ ```markdown
245
+ ## Execution Estimate
246
+ - Total tasks: {N}
247
+ - Independent tasks (no blockers): {N}
248
+ - Blocked tasks (waiting on other domains): {N}
249
+ - Estimated checkpoints: {N}
250
+ ```
251
+
252
+ ## Step 5: Document Ripple
253
+
254
+ After creating task lists and mapping dependencies, update affected documentation:
255
+
256
+ ### Always update:
257
+ 1. **`.gsd-t/progress.md`** — Updated in Step 5, but verify Decision Log includes planning decisions and rationale
258
+
259
+ ### Check if affected:
260
+ 2. **`docs/requirements.md`** — If planning revealed missing, ambiguous, or conflicting requirements, update them
261
+ 3. **`docs/architecture.md`** — If the task breakdown reveals new components or clarifies data flow, update it
262
+ 4. **`.gsd-t/contracts/`** — If planning revealed contract gaps or needed additional detail, update them
263
+ 5. **Domain `constraints.md`** — If planning revealed new constraints (task ordering, shared resources), add them
264
+
265
+ ### Skip what's not affected.
266
+
267
+ ## Step 6: Test Verification
268
+
269
+ Before finalizing the plan:
270
+
271
+ 1. **Run existing tests**: Execute the full test suite to confirm codebase state before execution begins
272
+ 2. **Verify passing**: Document any pre-existing failures assign them to appropriate domain tasks
273
+ 3. **Include test tasks**: Ensure each domain's task list includes test creation/update tasks where acceptance criteria require verification
274
+
275
+ ## Step 7: Plan Validation
276
+
277
+ Spawn a Task subagent to validate the plan before proceeding:
278
+
279
+ ```
280
+ Task subagent (general-purpose, model: haiku):
281
+ "Validate this GSD-T plan. Read:
282
+ - .gsd-t/domains/*/tasks.md (all task lists)
283
+ - .gsd-t/contracts/ (all contracts)
284
+ - docs/requirements.md (including traceability table)
285
+ - .gsd-t/CONTEXT.md (if exists)
286
+
287
+ Check:
288
+ 1. REQ coverage: every REQ-ID in requirements.md maps to at least one task
289
+ 2. Locked Decisions (from CONTEXT.md if present): every Locked Decision maps to at least one task
290
+ 3. Task completeness: every task has files, contract refs, and acceptance criteria
291
+ 4. Cross-domain dependencies: all BLOCKED-BY references point to real tasks
292
+ 5. Contract existence: every task referencing a contract has that contract file present
293
+
294
+ Report: PASS (all checks pass) or FAIL with specific gaps listed."
295
+ ```
296
+
297
+ **OBSERVABILITY LOGGING (MANDATORY):**
298
+ Before spawning run via Bash:
299
+ `T_START=$(date +%s) && DT_START=$(date +"%Y-%m-%d %H:%M") && TOK_START=${CLAUDE_CONTEXT_TOKENS_USED:-0} && TOK_MAX=${CLAUDE_CONTEXT_TOKENS_MAX:-200000}`
300
+ After subagent returns run via Bash:
301
+ `T_END=$(date +%s) && DT_END=$(date +"%Y-%m-%d %H:%M") && TOK_END=${CLAUDE_CONTEXT_TOKENS_USED:-0} && DURATION=$((T_END-T_START))`
302
+ Compute tokens and compaction:
303
+ - No compaction (TOK_END >= TOK_START): `TOKENS=$((TOK_END-TOK_START))`, COMPACTED=null
304
+ - Compaction detected (TOK_END < TOK_START): `TOKENS=$(((TOK_MAX-TOK_START)+TOK_END))`, COMPACTED=$DT_END
305
+ Compute context utilization run via Bash:
306
+ `if [ "${CLAUDE_CONTEXT_TOKENS_MAX:-0}" -gt 0 ]; then CTX_PCT=$(echo "scale=1; ${CLAUDE_CONTEXT_TOKENS_USED:-0} * 100 / ${CLAUDE_CONTEXT_TOKENS_MAX}" | bc); else CTX_PCT="N/A"; fi`
307
+ Alert on context thresholds (display to user inline):
308
+ - If CTX_PCT >= 85: `echo "🔴 CRITICAL: Context at ${CTX_PCT}% — compaction likely. Task MUST be split."`
309
+ - If CTX_PCT >= 70: `echo "⚠️ WARNING: Context at ${CTX_PCT}% approaching compaction threshold. Consider splitting in plan."`
310
+ Append to `.gsd-t/token-log.md` (create with header `| Datetime-start | Datetime-end | Command | Step | Model | Duration(s) | Notes | Tokens | Compacted | Domain | Task | Ctx% |` if missing):
311
+ `| {DT_START} | {DT_END} | gsd-t-plan | Step 7 | haiku | {DURATION}s | {PASS/FAIL}, iteration {N} | {TOKENS} | {COMPACTED} | | | {CTX_PCT} |`
312
+ If validation FAIL, append each gap to `.gsd-t/qa-issues.md` (create with header `| Date | Command | Step | Model | Duration(s) | Severity | Finding |` if missing):
313
+ `| {DT_START} | gsd-t-plan | Step 7 | haiku | {DURATION}s | medium | {gap description} |`
314
+
315
+ **If FAIL**: Fix the identified gaps (up to 3 iterations). If still failing after 3 iterations, STOP and report to user with the specific gaps. Plan cannot proceed until validation PASSES.
316
+
317
+ ## Step 8: Update Progress
318
+
319
+ Update `.gsd-t/progress.md`:
320
+ - Set status to `PLANNED`
321
+ - Update domain table with task counts
322
+ - Record any planning decisions in the Decision Log
323
+
324
+ ## Step 9: Report
325
+
326
+ ### Autonomy Behavior
327
+
328
+ **Level 3 (Full Auto)**: Log a brief status line (e.g., "✅ Plan complete — {N} tasks across {N} domains, {execution mode}") and auto-advance to the next phase. Do NOT wait for user input.
329
+
330
+ **Level 1–2**: Present to the user:
331
+ 1. Task count per domain
332
+ 2. Dependency graph (which domains block which)
333
+ 3. Recommended execution mode:
334
+ - **Solo sequential**: < 8 total tasks or heavily interdependent
335
+ - **Solo interleaved**: 8-15 tasks with some independence
336
+ - **Team parallel**: 15+ tasks with 3+ independent starting points
337
+ 4. Any ambiguities found during planning that need user input
338
+
339
+ Wait for confirmation before proceeding.
340
+
341
+ $ARGUMENTS
342
+
343
+ ## Auto-Clear
344
+
345
+ All work is committed to project files. Execute `/clear` to free the context window for the next command.