@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,634 +1,758 @@
1
- # GSD-T: Execute — Run Domain Tasks (Solo or Parallel)
2
-
3
- You are the lead agent coordinating task execution across domains. Choose solo or team mode based on the plan.
4
-
5
- ## Step 1: Load State
6
-
7
- Read:
8
- 1. `CLAUDE.md` — check for **Branch Guard** (`Expected branch` field)
9
- 2. `.gsd-t/progress.md`
10
- 3. `.gsd-t/contracts/` — all contracts
11
- 4. `.gsd-t/contracts/integration-points.md` — dependency graph
12
- 5. `.gsd-t/domains/*/tasks.md` — all task lists
13
-
14
- **Branch check (before any work):**
15
- Run `git branch --show-current`. If CLAUDE.md declares an expected branch and you're on a different branch, STOP and warn the user. Do NOT execute tasks on the wrong branch.
16
-
17
- Identify:
18
- - Which tasks are already complete (check progress.md)
19
- - Which tasks are unblocked (no pending dependencies)
20
- - Which tasks are blocked (waiting on checkpoints)
21
-
22
- ## Step 1.5: Graph-Enhanced Domain Isolation Check (if available)
23
-
24
- If `.gsd-t/graph/meta.json` exists, run graph queries before execution begins:
25
-
26
- 1. **Reindex** (if stale): `query('reindex', { force: false })` — ensure graph reflects current code
27
- 2. **Domain boundary check**: For each domain about to execute, `query('getEntitiesByDomain', { domain })` — verify the domain's entities match its scope.md
28
- 3. **Pre-execution snapshot**: Record entity counts per domain — after execution, compare to detect scope creep (domain agent modified entities outside its domain)
29
- 4. **Cross-domain dependencies**: `query('getDomainBoundaryViolations', {})` — flag existing violations before work begins so they aren't confused with new violations introduced during execution
30
-
31
- After each domain completes, re-run `getDomainBoundaryViolations` and diff against pre-execution snapshot. If new violations appear, flag them immediately before proceeding to the next domain.
32
-
33
- ## Step 2: QA Subagent
34
-
35
- In solo mode, QA runs inside each domain subagent (see Step 3). In team mode, the lead spawns QA subagents at each domain checkpoint using the pattern below.
36
-
37
- **QA subagent prompt:**
38
- ```
39
- Task subagent (general-purpose, model: haiku):
40
- "Run the full test suite for this project and report pass/fail counts.
41
- Read .gsd-t/contracts/ for contract definitions.
42
- Write edge case tests for any new code paths in this task: {task description}.
43
- Report: test pass/fail status and any coverage gaps found."
44
- ```
45
-
46
- If QA found issues, append each to `.gsd-t/qa-issues.md` (create with header `| Date | Command | Step | Model | Duration(s) | Severity | Finding |` if missing):
47
- `| {DT_START} | gsd-t-execute | Step 2 | haiku | {DURATION}s | {severity} | {finding} |`
48
-
49
- ## Step 3: Choose Execution Mode
50
-
51
- ### Wave Scheduling (read first)
52
-
53
- Before choosing solo or team mode, read the `## Wave Execution Groups` section in `.gsd-t/contracts/integration-points.md` (added by the plan phase).
54
-
55
- **If wave groups are present**:
56
- - Execute wave-by-wave: complete all tasks in Wave 1 before starting Wave 2
57
- - Within each wave, tasks marked as parallel-safe can run concurrently (team mode) or be interleaved (solo mode)
58
- - At each wave boundary: run the CHECKPOINT — verify contract compliance — before proceeding
59
- - File conflict detection: if two tasks in the same wave list the same file in their `scope.md` ownership, move one to the next wave
60
-
61
- **If no wave groups are defined** (older plans): fall back to the `Execution Order` list.
62
-
63
- ### Solo Mode (default) — Domain Task-Dispatcher Pattern
64
-
65
- Each domain's work runs via a lightweight domain task-dispatcher. The dispatcher spawns one Task subagent PER TASK within that domain, giving each task a completely fresh context window with only the minimum required context. The orchestrator (this agent) stays lightweight — it only spawns dispatchers, collects summaries, verifies checkpoints, and updates progress.
66
-
67
- **Context provided to each task subagent (fresh-dispatch-contract.md payload):**
68
- - `scope.md` for the domain
69
- - Relevant contracts (only those referenced by the task)
70
- - The single task from `tasks.md`
71
- - Graph context for the task's files (if available)
72
- - Up to 5 prior task summaries (10-20 lines each, most recent first)
73
- - Past failure/learning entries for this domain (max 5 lines)
74
-
75
- **OBSERVABILITY LOGGING (MANDATORY) repeat for every task subagent spawn:**
76
-
77
- Before spawning run via Bash:
78
- `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}`
79
-
80
- After subagent returns run via Bash:
81
- `T_END=$(date +%s) && DT_END=$(date +"%Y-%m-%d %H:%M") && TOK_END=${CLAUDE_CONTEXT_TOKENS_USED:-0} && DURATION=$((T_END-T_START))`
82
-
83
- Compute tokens and compaction:
84
- - No compaction (TOK_END >= TOK_START): `TOKENS=$((TOK_END-TOK_START))`, COMPACTED=null
85
- - Compaction detected (TOK_END < TOK_START): `TOKENS=$(((TOK_MAX-TOK_START)+TOK_END))`, COMPACTED=$DT_END
86
-
87
- Compute context utilization — run via Bash:
88
- `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`
89
-
90
- Alert on context thresholds (display to user inline):
91
- - If CTX_PCT is a number and >= 85: `echo "🔴 CRITICAL: Context at ${CTX_PCT}% — compaction likely. Task MUST be split."`
92
- - If CTX_PCT is a number and >= 70: `echo "⚠️ WARNING: Context at ${CTX_PCT}% — approaching compaction threshold. Consider splitting in plan."`
93
-
94
- 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):
95
- `| {DT_START} | {DT_END} | gsd-t-execute | task:{task-id} | sonnet | {DURATION}s | {pass/fail} | {TOKENS} | {COMPACTED} | {domain-name} | task-{task-id} | {CTX_PCT} |`
96
-
97
- **For each domain (in wave order), run the domain task-dispatcher:**
98
-
99
- **Pre-dispatch experience retrieval (before dispatching each domain's tasks):**
100
- Run via Bash:
101
- `grep -i "\[failure\]\|\[learning\]" .gsd-t/progress.md | grep -i "{domain-name}" | tail -5`
102
-
103
- If results found:
104
- - Store as `PAST_FAILURES` — prepend to each task subagent prompt (max 5 lines)
105
- - Write event via Bash: `node ~/.claude/scripts/gsd-t-event-writer.js --type experience_retrieval --command gsd-t-execute --reasoning "{N past failures found for {domain-name}}" --outcome null || true`
106
-
107
- If no results found: proceed normally (no warning block, no event write).
108
-
109
- **Pre-flight intelligence check (before dispatching each domain's tasks):**
110
- Run via Bash:
111
- `node -e "const m = require('./bin/metrics-collector.js'); const w = m.getPreFlightWarnings('{domain-name}'); if(w.length) w.forEach(x => console.log('⚠️ ' + x));" 2>/dev/null || true`
112
-
113
- Display any warnings inline (non-blocking execution proceeds regardless).
114
-
115
- **Active Rule Injection (before dispatching each domain's tasks):**
116
- Run via Bash:
117
- `node -e "const re = require('./bin/rule-engine.js'); const m = re.evaluateRules('{domain-name}', { projectDir: '.' }); if(m.length) m.forEach(x => console.log('RULE: ' + x.rule.name + ' — ' + x.rule.description + ' [' + x.severity + ']')); else console.log('No active rules for {domain-name}');" 2>/dev/null || true`
118
-
119
- If rules fire: inject up to 10 lines of rule warnings into each task subagent prompt (concise format: `RULE: {name} — {description}`). These inform the subagent of known patterns — non-blocking.
120
- If no rules fire: log "No active rules for {domain-name}" and continue.
121
-
122
- **Stack Rules Detection (before spawning subagent):**
123
-
124
- Run via Bash to detect project stack and collect matching rules. Local overrides in `.gsd-t/stacks/` take precedence over global templates if a project has `.gsd-t/stacks/react.md`, it replaces the global `react.md` for that project.
125
-
126
- ```bash
127
- GSD_T_DIR=$(npm root -g 2>/dev/null)/@tekyzinc/gsd-t
128
- STACKS_DIR="$GSD_T_DIR/templates/stacks"
129
- LOCAL_STACKS=".gsd-t/stacks"
130
- STACK_RULES=""
131
-
132
- # Helper: read local override if exists, else global
133
- _sf() { local n=$(basename "$1"); [ -f "$LOCAL_STACKS/$n" ] && cat "$LOCAL_STACKS/$n" || cat "$1"; }
134
-
135
- # Helper: append a stack file to STACK_RULES
136
- _add() { [ -f "$STACKS_DIR/$1" ] && STACK_RULES="${STACK_RULES}$(_sf "$STACKS_DIR/$1")"$'\n\n'; }
137
-
138
- if [ -d "$STACKS_DIR" ]; then
139
- # Universal rules (_ prefix always injected)
140
- for f in "$STACKS_DIR"/_*.md; do [ -f "$f" ] && STACK_RULES="${STACK_RULES}$(_sf "$f")"$'\n\n'; done
141
-
142
- # Package.json-based detection
143
- if [ -f "package.json" ]; then
144
- grep -q '"react-native"' package.json 2>/dev/null && _add react-native.md
145
- grep -q '"react"' package.json 2>/dev/null && ! grep -q '"react-native"' package.json 2>/dev/null && _add react.md
146
- grep -q '"next"' package.json 2>/dev/null && _add nextjs.md
147
- grep -q '"vue"' package.json 2>/dev/null && _add vue.md
148
- (grep -q '"typescript"' package.json 2>/dev/null || [ -f "tsconfig.json" ]) && _add typescript.md
149
- grep -qE '"(express|fastify|hono|koa)"' package.json 2>/dev/null && _add node-api.md && _add rest-api.md
150
- grep -q '"tailwindcss"' package.json 2>/dev/null && _add tailwind.md
151
- grep -q '"vite"' package.json 2>/dev/null && _add vite.md
152
- grep -q '"@supabase/supabase-js"' package.json 2>/dev/null && _add supabase.md
153
- grep -q '"firebase"' package.json 2>/dev/null && _add firebase.md
154
- grep -qE '"(graphql|@apollo/client|urql)"' package.json 2>/dev/null && _add graphql.md
155
- grep -q '"zustand"' package.json 2>/dev/null && _add zustand.md
156
- grep -q '"@reduxjs/toolkit"' package.json 2>/dev/null && _add redux.md
157
- grep -q '"neo4j-driver"' package.json 2>/dev/null && _add neo4j.md
158
- grep -qE '"(pg|prisma|drizzle-orm|knex)"' package.json 2>/dev/null && _add postgresql.md
159
- grep -qE '"(prisma|@prisma/client)"' package.json 2>/dev/null && _add prisma.md
160
- grep -qE '"(bullmq|bull|amqplib|@aws-sdk/client-sqs|bee-queue|agenda)"' package.json 2>/dev/null && _add queues.md
161
- grep -qE '"(openai|anthropic|@anthropic-ai/sdk|langchain|llama-index|@google/generative-ai)"' package.json 2>/dev/null && _add llm.md
162
- fi
163
-
164
- # File-based detection (no package.json needed)
165
- ([ -f "requirements.txt" ] || [ -f "pyproject.toml" ] || [ -f "Pipfile" ]) && _add python.md
166
- ([ -f "requirements.txt" ] && grep -q "psycopg" requirements.txt 2>/dev/null || [ -f "pyproject.toml" ] && grep -q "psycopg" pyproject.toml 2>/dev/null) && _add postgresql.md
167
- ([ -f "requirements.txt" ] && grep -q "neo4j" requirements.txt 2>/dev/null) && _add neo4j.md
168
- ([ -f "requirements.txt" ] && grep -q "fastapi" requirements.txt 2>/dev/null || [ -f "pyproject.toml" ] && grep -q "fastapi" pyproject.toml 2>/dev/null) && _add fastapi.md
169
- ([ -f "requirements.txt" ] && grep -qE "(celery|dramatiq|rq|arq)" requirements.txt 2>/dev/null || [ -f "pyproject.toml" ] && grep -qE "(celery|dramatiq|rq|arq)" pyproject.toml 2>/dev/null) && _add queues.md
170
- ([ -f "requirements.txt" ] && grep -qE "(openai|anthropic|langchain|llama.index)" requirements.txt 2>/dev/null || [ -f "pyproject.toml" ] && grep -qE "(openai|anthropic|langchain|llama.index)" pyproject.toml 2>/dev/null) && _add llm.md
171
- [ -f "pubspec.yaml" ] && _add flutter.md
172
- [ -f "Dockerfile" ] && _add docker.md
173
- [ -d ".github/workflows" ] && _add github-actions.md
174
- ([ -f "playwright.config.ts" ] || [ -f "playwright.config.js" ]) && _add playwright.md
175
- [ -f "go.mod" ] && _add go.md
176
- [ -f "Cargo.toml" ] && _add rust.md
177
- fi
178
- ```
179
-
180
- If STACK_RULES is non-empty, append to the subagent prompt:
181
- ```
182
- ## Stack Rules (MANDATORY — violations fail this task)
183
-
184
- {STACK_RULES}
185
-
186
- These standards have the same enforcement weight as contract compliance.
187
- Violations are task failures, not warnings.
188
- ```
189
-
190
- If STACK_RULES is empty (no templates/stacks/ dir or no matches), skip silently.
191
-
192
- **Domain task-dispatcher (lightweight sequences tasks, passes summaries):**
193
-
194
- For each task in `.gsd-t/domains/{domain-name}/tasks.md` (in order, skip completed):
195
-
196
- 1. Load prior summaries: Read up to 5 most recent `.gsd-t/domains/{domain-name}/task-*-summary.md` files (10-20 lines each)
197
- 2. Load graph context (if `.gsd-t/graph/meta.json` exists): query task's files for relevant graph context
198
- 3. Display: `⚙ [sonnet] gsd-t-execute → domain: {domain-name}, task-{task-id}`
199
- 4. Run observability Bash (T_START / DT_START / TOK_START / TOK_MAX)
200
- 5. Spawn task subagent:
201
-
202
- ```
203
- Task subagent (general-purpose, model: sonnet, mode: bypassPermissions):
204
- "You are executing a single task for the {domain-name} domain.
205
-
206
- {PAST_FAILURES block if any ## ⚠️ Past Failures (read before acting)\n{lines}}
207
-
208
- ## Your Task
209
- {full task block from tasks.md id, description, files, contract refs, dependencies, acceptance criteria}
210
-
211
- ## Domain Scope
212
- {contents of .gsd-t/domains/{domain-name}/scope.md}
213
-
214
- ## Relevant Contracts
215
- {contents of each contract file referenced by this task}
216
-
217
- ## Graph Context (if available)
218
- {graph query results for this task's files omit section if unavailable}
219
-
220
- ## Prior Task Summaries (most recent first, max 5)
221
- {contents of task-{N}-summary.md files — 10-20 lines each}
222
-
223
- ## Stack Rules
224
- {STACK_RULES if non-empty — omit entire section if empty}
225
-
226
- ## Instructions
227
-
228
- Execute the task above:
229
- 1. Read the task description, files list, and contract refs carefully
230
- 2. Read relevant contracts — implement EXACTLY what they specify
231
- 3. Destructive Action Guard: if the task involves DROP TABLE, schema changes that lose
232
- data, removing working modules, or replacing architecture patterns → write a
233
- NEEDS-APPROVAL entry to .gsd-t/deferred-items.md, skip the task, stop here
234
- 4. Implement the task
235
- 5. Verify acceptance criteria are met
236
- 6. Write comprehensive tests (MANDATORY — no feature code without test code):
237
- - Unit/integration: happy path + edge cases + error cases for every new/changed function
238
- - Playwright E2E (if UI/routes/flows changed): new specs for new features, cover
239
- all modes, form validation, empty/loading/error states, common edge cases
240
- - If no test framework exists: set one up as part of this task
241
- - If the project has a UI but no Playwright E2E specs exist for the features being
242
- touched: WRITE THEM. A placeholder spec is not sufficient — write real E2E tests
243
- that exercise the actual UI functionality being built or changed.
244
- - **FUNCTIONAL E2E TESTS — NOT LAYOUT TESTS (MANDATORY)**:
245
- E2E tests that only check element existence (isVisible, isEnabled, toBeAttached)
246
- are LAYOUT tests, not functional tests. Layout tests pass even when every feature
247
- is broken. Every Playwright spec MUST verify functional behavior:
248
- a. **State changes**: After an action (click, type, submit), assert the app STATE
249
- changed not just that the button was clickable. Example: clicking a tab must
250
- load different content; verify the content changed, not just that the tab exists.
251
- b. **Data flow**: Form submissions must verify data arrived (API call made, response
252
- rendered, list updated). Don't just assert the form rendered.
253
- c. **Navigation/routing**: Tab/page switches must verify the NEW content loaded.
254
- Assert on content unique to the destination, not the navigation element itself.
255
- d. **Interactive widgets**: Terminals must accept input and produce output. Editors
256
- must save changes. Panels must load their functional content after opening.
257
- e. **Network integration**: If a feature requires WebSocket/API connection, verify
258
- the connection status changes (e.g., "Disconnected" "Connected") and that
259
- messages flow through the connection.
260
- f. **Error recovery**: Don't just check error messages render verify the app
261
- recovers (retry button works, form can be resubmitted, etc.).
262
- A test that would pass on an empty HTML page with the right element IDs is useless.
263
- Every assertion must prove the FEATURE WORKS, not that the ELEMENT EXISTS.
264
- 7. Run ALL test suites this is NOT optional, not conditional, not "if applicable":
265
- a. Detect configured test runners: check for vitest/jest config, playwright.config.*, cypress.config.*
266
- b. Run EVERY detected suite. Unit tests alone are NEVER sufficient when E2E exists.
267
- c. If `playwright.config.*` exists run `npx playwright test` (full suite, not just affected specs)
268
- d. If E2E tests fail fix (up to 2 attempts) before proceeding
269
- e. Report ALL suite results: "Unit: X/Y pass | E2E: X/Y pass" — never report just one
270
- 8. Run Pre-Commit Gate checklist from CLAUDE.md update all affected docs BEFORE committing
271
- 9. Commit immediately: feat({domain-name}/task-{task-id}): {description}
272
- 10. Update .gsd-t/progress.md mark this task complete; prefix the Decision Log entry:
273
- - Completed successfully on first attempt prefix `[success]`
274
- - Completed after a fix prefix `[learning]`
275
- - Deferred to .gsd-t/deferred-items.md prefix `[deferred]`
276
- - Failed after 3 attempts prefix `[failure]`
277
- 11. Spawn QA subagent (model: haiku) after completing the task:
278
- 'Run ALL configured test suites — detect and run every one:
279
- a. Unit tests (vitest/jest/mocha): run the full suite, report pass/fail counts
280
- b. E2E tests: check for playwright.config.* or cypress.config.* — if found, run the FULL E2E suite
281
- c. NEVER skip E2E when a config file exists. Running only unit tests is a QA FAILURE.
282
- d. Read .gsd-t/contracts/ for contract definitions. Check contract compliance.
283
- e. AUDIT E2E test quality: Review each Playwright spec if any test only checks
284
- element existence (isVisible, toBeAttached, toBeEnabled) without verifying functional
285
- behavior (state changes, data loaded, content updated after actions), flag it as
286
- "SHALLOW TEST needs functional assertions" in the gap report. A test suite where
287
- every spec passes but no feature actually works is a QA FAILURE.
288
- Report format: "Unit: X/Y pass | E2E: X/Y pass (or N/A if no config) | Contract: compliant/violations | Shallow tests: N (list) | Stack rules: compliant/N violations"
289
- f. Validate compliance with Stack Rules (if injected in the work subagent's prompt).
290
- Stack rule violations have the same severity as contract violations — report as failures, not warnings.'
291
- If QA fails OR shallow tests are found, fix before proceeding. Append issues to .gsd-t/qa-issues.md.
292
- 12. Write task summary to .gsd-t/domains/{domain-name}/task-{task-id}-summary.md:
293
- ## Task {task-id} Summary {domain-name}
294
- - **Status**: PASS | FAIL
295
- - **Files modified**: {list}
296
- - **Constraints discovered**: {any new constraints or surprises}
297
- - **Tests**: {pass/fail count}
298
- - **Notes**: {10-20 lines max key decisions, patterns, warnings}
299
-
300
- Deviation rules:
301
- - Bug blocking progress fix, max 3 attempts; after fix attempt 2 fails:
302
- 1. Write current failure context to .gsd-t/debug-state.jsonl via appendEntry
303
- 2. Log: "Delegating to headless debug-loop (2 in-context attempts exhausted)"
304
- 3. Run: `gsd-t headless --debug-loop --max-iterations 15`
305
- 4. Check exit code:
306
- - 0: Tests pass, continue with task
307
- - 1/4: Log to .gsd-t/deferred-items.md and stop (report FAIL in summary)
308
- - 3: Report error, stop
309
- If still blocked after debug-loop, log to .gsd-t/deferred-items.md and stop (report FAIL in summary)
310
- - Missing dependency → add minimum needed, document in commit message
311
- - Non-trivial blocker log to .gsd-t/deferred-items.md
312
- - Architectural change required → write NEEDS-APPROVAL to .gsd-t/deferred-items.md,
313
- skip the task, stop here — never self-approve structural changes
314
-
315
- Report back:
316
- - Task: {task-id}
317
- - Status: PASS | FAIL
318
- - Files modified: {list}
319
- - Tests: {pass/fail count}
320
- - Commit: {hash}
321
- - Deferred items (if any)"
322
- ```
323
-
324
- 6. After task subagent returns:
325
- - Run observability Bash (T_END / TOK_END / DURATION / CTX_PCT)
326
- - Append to token-log.md (per-task row)
327
- - Alert on CTX_PCT thresholds (display to user inline)
328
- - **Emit task-metrics record** — run via Bash:
329
- `node bin/metrics-collector.js --milestone {milestone} --domain {domain-name} --task task-{task-id} --command execute --duration_s $DURATION --tokens_used $TOKENS --context_pct ${CTX_PCT:-0} --pass {true|false} --fix_cycles {0|N} --signal_type {pass-through|fix-cycle} --notes "{brief outcome}" 2>/dev/null || true`
330
- Signal type: `pass-through` if task passed on first attempt; `fix-cycle` if rework was needed.
331
- - **Emit task_complete event** — run via Bash:
332
- `node ~/.claude/scripts/gsd-t-event-writer.js --type task_complete --command gsd-t-execute --reasoning "signal_type={signal_type}, domain={domain-name}" --outcome {success|failure} || true`
333
- - Check `.gsd-t/deferred-items.md` for `NEEDS-APPROVAL` — if found, STOP and present to user before proceeding to the next task
334
- - Read the task summary from `.gsd-t/domains/{domain-name}/task-{task-id}-summary.md` to use as prior summary for the next task
335
-
336
- **After all tasks in a domain complete (orchestrator responsibilities):**
337
- 1. Check `.gsd-t/deferred-items.md` for any `NEEDS-APPROVAL` entries — if found, STOP and present to user before spawning the next domain
338
- 2. If a CHECKPOINT is reached per `integration-points.md`, verify contract compliance (see Step 4) before proceeding to the next wave/domain
339
- 3. Update `.gsd-t/progress.md` with domain completion status
340
- 4. **Adaptive Replan Check** (per `adaptive-replan-contract.md`) run after EVERY domain completes, before dispatching the next domain:
341
-
342
- a. **Read domain summaries**: Read all `.gsd-t/domains/{completed-domain}/task-*-summary.md` files. Extract every `**Constraints discovered**:` field. If ALL are empty or "none", skip to the next domain (fast path — no replan needed).
343
-
344
- b. **Assess affected domains**two modes:
345
- - **Graph available** (`.gsd-t/graph/meta.json` exists): For each changed module mentioned in the constraints, run `query('getImporters', { file })` to find which remaining domains import it. Also run `query('getDomainBoundaryViolations', {})` to check if constraint changes affect domain boundaries. Scope replan to ONLY those domains.
346
- - **Graph unavailable** (fallback): Check ALL remaining unexecuted domains' `tasks.md` files — less precise but functional.
347
-
348
- c. **Check for invalidated assumptions**: Read each affected remaining domain's `.gsd-t/domains/{domain}/tasks.md`. For each task, check whether any assumption is invalidated by the discovered constraints (e.g., wrong column name, deprecated API, wrong library, missing prerequisite, throughput limits).
349
-
350
- d. **If invalidated assumptions found**: Revise the affected domain's `tasks.md` on disk. Append a Revision block at the end of the file (do NOT overwrite existing tasks — append only):
351
- ```markdown
352
- ## Revision (Replan Cycle {N})
353
- - **Trigger**: {completed-domain} — constraint discovered during execution
354
- - **Constraint**: {exact constraint text from summary}
355
- - **Changes**: {what was revised in this domain's tasks — list specific task IDs and what changed}
356
- - **Rationale**: {why this revision is needed what would break without it}
357
- ```
358
-
359
- e. **Increment replan cycle counter** (track as `REPLAN_CYCLES` in orchestrator state, starting at 0).
360
-
361
- f. **Cycle guard**: If `REPLAN_CYCLES > 2`, STOP and pause for user input:
362
- "Replan cycle limit (2) exceeded. {N} constraints are still propagating. Please review `.gsd-t/domains/*/tasks.md` and resolve manually, then re-run execute."
363
-
364
- g. **Log to Decision Log** in `.gsd-t/progress.md`: `- {date}: [replan] Cycle {N} {completed-domain} constraint propagated to {list of affected domains}: {brief constraint summary}`
365
-
366
- h. The revised `tasks.md` files are now on disk — the next domain's dispatcher will read the updated version automatically (disk-based handoff, no in-memory state sharing needed).
367
-
368
- ### Team Mode (when agent teams are enabled)
369
- Spawn teammates for domains within the same wave. Only domains in the same wave can run in parallel — do not spawn teammates for domains in different waves simultaneously. Each teammate uses the **domain task-dispatcher pattern** — one subagent per task within their domain (same as solo mode).
370
-
371
- ```
372
- Create an agent team for execution:
373
-
374
- ALL TEAMMATES must read before starting:
375
- 1. CLAUDE.mdproject conventions (CRITICAL)
376
- 2. Your domain's scope.md what you own
377
- 3. Your domain's constraints.md — what you must/must not do
378
- 4. ALL files in .gsd-t/contracts/ — your interfaces
379
- 5. Your domain's tasks.md your work
380
-
381
- RULES FOR ALL TEAMMATES:
382
- - **Destructive Action Guard**: NEVER drop tables, remove columns, delete data, replace architecture patterns, or remove working modules without messaging the lead first. The lead must get user approval before any destructive action proceeds.
383
- - Only modify files listed in your domain's scope.md
384
- - Implement interfaces EXACTLY as specified in contracts
385
- - **Write comprehensive FUNCTIONAL tests with every task** — no feature code without test code:
386
- - Unit/integration tests: happy path + edge cases + error cases for every new/changed function
387
- - Playwright E2E specs (if UI/routes/flows/modes changed): new specs for new features, cover all modes/flags, form validation, empty/loading/error states, common edge cases
388
- - Tests are part of the deliverable, not a follow-up
389
- - **E2E tests MUST be functional, not layout tests**: Every assertion must verify an action produced the correct outcome (state changed, data loaded, content updated) — NOT just that an element is visible/clickable. A test that passes on an empty HTML shell with correct IDs is worthless. See the Functional E2E Test Requirements in the solo mode instructions above.
390
- - If a task is marked BLOCKED, message the lead and wait
391
- - Run the Pre-Commit Gate checklist from CLAUDE.md BEFORE every commit — update all affected docs
392
- - **Commit immediately after each task**: `feat({domain}/task-{N}): {description}` do NOT batch commits
393
- - **Deviation Rules**: (1) Bug blocking progress → fix, 3 attempts max; (2) Missing dependency add minimum needed; (3) Blocker → fix and log to deferred-items.md; (4) Architectural change → STOP, message lead, never self-approve
394
-
395
- **Task-dispatcher pattern per teammate:**
396
- For each task in your domain's tasks.md (in order, skip completed):
397
- 1. Load prior summaries: read up to 5 most recent `.gsd-t/domains/{your-domain}/task-*-summary.md` files
398
- 2. Load graph context for task's files (if .gsd-t/graph/meta.json exists)
399
- 3. Spawn one Task subagent (model: sonnet) with ONLY:
400
- - scope.md, relevant contracts, the single task, graph context, prior summaries
401
- - Instruction to write task summary to `.gsd-t/domains/{domain}/task-{id}-summary.md`
402
- (format per fresh-dispatch-contract.md Task Summary Format)
403
- 4. After task subagent returns, read the summary and pass it as prior context to the next task
404
- 5. After completing each task, message the lead with:
405
- "DONE: {domain} Task {N} - {summary of what was created/modified}"
406
- 6. If you need to deviate from a contract, STOP and message the lead
407
-
408
- Teammate assignments:
409
- - Teammate "{domain-1}": Execute .gsd-t/domains/{domain-1}/tasks.md (task-dispatcher pattern, isolated worktree)
410
- - Teammate "{domain-2}": Execute .gsd-t/domains/{domain-2}/tasks.md (task-dispatcher pattern, isolated worktree)
411
- - Teammate "{domain-3}": Execute .gsd-t/domains/{domain-3}/tasks.md (task-dispatcher pattern, isolated worktree)
412
-
413
- **Worktree isolation (per domain teammate):**
414
- Each domain teammate MUST be spawned with `isolation: "worktree"` on the Agent tool:
415
- ```
416
- Agent({
417
- prompt: "{domain execution prompt — include: 'You are working in an isolated git worktree. All your changes are isolated to this worktree branch. Do not push; the lead will merge your branch after all domains complete.'}",
418
- isolation: "worktree"
419
- })
420
- ```
421
- Each teammate works in its own isolated copy of the repository. Changes from one domain do not affect another domain's working tree. This is required for parallel safety — see `.gsd-t/contracts/worktree-isolation-contract.md`.
422
-
423
- Lead responsibilities (QA is handled via Task subagentspawn one after each domain checkpoint):
424
- - Use delegate mode (Shift+Tab)
425
- - Track completions from teammate messages
426
- - When a CHECKPOINT is reached:
427
- 1. Pause blocked teammates
428
- 2. Verify the gate condition (check contract compliance)
429
- 3. Unblock waiting teammates
430
- - Update .gsd-t/progress.md after each completion
431
- - Resolve any contract conflicts immediately
432
-
433
- **Sequential Merge Protocol (lead runs after ALL domain agents complete):**
434
-
435
- Once all domain teammates report completion, the lead performs sequential atomic merges. This is the critical integration step — see `.gsd-t/contracts/worktree-isolation-contract.md` for the full merge protocol.
436
-
437
- 1. **Determine merge order**: Read `.gsd-t/contracts/integration-points.md` — use the dependency graph to sort domains. Domains with no upstream dependencies merge first. Example: if domain-A has no deps and domain-B depends on domain-A's output, merge order is [domain-A, domain-B].
438
-
439
- 2. **For each domain (in dependency order)**:
440
-
441
- a. **File ownership validation (pre-merge)**: Check files the domain agent modified against the domain's `.gsd-t/domains/{domain}/scope.md`:
442
- - If `.gsd-t/graph/meta.json` exists: run `query('getDomainBoundaryViolations', { domain })` — flag any files modified outside the domain's declared ownership
443
- - If graph unavailable: list files changed in the worktree branch via `git diff --name-only` and compare against scope.md manually
444
- - If violations found: log them in `.gsd-t/progress.md` as `[violation] {domain}: modified {file} outside scope`, but do NOT block merge — flag for immediate review after merge
445
-
446
- b. **Merge the domain's worktree branch**:
447
- ```bash
448
- # The worktree branch name is returned by the Agent tool when isolation: "worktree" is used
449
- git merge --no-ff {domain-worktree-branch} -m "integrate({domain}): merge worktree branch"
450
- ```
451
-
452
- c. **Contract validation (post-merge)**: Read each contract in `.gsd-t/contracts/` verify the merged code still satisfies all contract shapes (API shapes, schemas, interfaces). If a contract is violated, log it immediately.
453
-
454
- d. **Run integration tests**:
455
- ```bash
456
- node --test test/
457
- # or project's test command from package.json
458
- ```
459
-
460
- e. **If tests PASS**: Continue to the next domain in merge order.
461
-
462
- f. **If tests FAIL**: Roll back this domain's merge:
463
- ```bash
464
- git reset --hard HEAD~1
465
- # or: git revert HEAD --no-edit
466
- ```
467
- Log failure: `[rollback] {domain}: merge rolled back — integration tests failed after merge`
468
- Record in `.gsd-t/progress.md` Decision Log.
469
- Continue with remaining domains (other domains' merges are not affected).
470
-
471
- 3. **Post-merge ownership report**: After all merges complete (successful or rolled back), log a summary in `.gsd-t/progress.md`:
472
- ```
473
- ## Worktree Merge Summary {date}
474
- - {domain-1}: MERGED | tests: PASS | violations: {N}
475
- - {domain-2}: ROLLED BACK | reason: integration tests failed
476
- - {domain-3}: MERGED | tests: PASS | violations: 0
477
- ```
478
-
479
- **Worktree Cleanup (MANDATORY run after merge protocol, success or failure):**
480
-
481
- After all merges complete (whether all passed, some rolled back, or errors occurred):
482
-
483
- 1. List all worktree branches created during this execution run:
484
- ```bash
485
- git worktree list
486
- git branch --list "gsd-t-worktree-*"
487
- ```
488
-
489
- 2. Remove each domain worktree:
490
- ```bash
491
- git worktree remove --force {worktree-path}
492
- git branch -D {worktree-branch}
493
- ```
494
-
495
- 3. **Orphaned worktree detection**: If any worktrees remain after cleanup (can happen if an agent crashed):
496
- ```bash
497
- git worktree prune
498
- ```
499
- Log: `[cleanup] Pruned {N} orphaned worktrees via git worktree prune`
500
-
501
- 4. Verify no worktrees remain except the main working tree:
502
- ```bash
503
- git worktree list
504
- # should show only: {main-path} {commit} [branch]
505
- ```
506
-
507
- Cleanup is not optional orphaned worktrees waste disk space and can confuse subsequent executions. Always run cleanup, even if earlier steps failed.
508
- ```
509
-
510
- ## Step 3.5: Orchestrator Context Self-Check (MANDATORY)
511
-
512
- After EVERY domain completes (and after every checkpoint), the orchestrator MUST check its own context utilization:
513
-
514
- Run via Bash:
515
- `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 && echo "Orchestrator context: ${CTX_PCT}%"`
516
-
517
- **If CTX_PCT >= 70:**
518
- 1. **Save checkpoint to disk** — update `.gsd-t/progress.md` with:
519
- - Which domains are complete, which remain
520
- - Current wave, next domain to execute
521
- - Any checkpoint results
522
- 2. **Instruct user**: Output exactly:
523
- ```
524
- ⚠️ Orchestrator context at {CTX_PCT}% — approaching limit.
525
- Progress saved. Run `/clear` then `/user:gsd-t-execute` to continue from the next domain.
526
- ```
527
- 3. **STOP execution.** Do NOT spawn another domain subagent. The next session will resume from saved state.
528
-
529
- **If CTX_PCT < 70:** Continue normally to the next domain/wave.
530
-
531
- This prevents the orchestrator from running out of context mid-milestone, which causes session breaks and summary-based recovery.
532
-
533
- ## Step 4: Checkpoint Handling
534
-
535
- When a checkpoint is reached (solo or team):
536
-
537
- 1. **Stop** execution of blocked tasks
538
- 2. **Read** the relevant contract
539
- 3. **Verify** the implemented code matches the contract:
540
- - API response shapes match?
541
- - Schema matches?
542
- - Component interfaces match?
543
- - Error handling matches?
544
- 4. **If mismatch**: Fix the implementation to match the contract, OR update the contract and notify affected domains
545
- 5. **Log** in progress.md: `CHECKPOINT {name}: PASSED/FAILED — {details}`
546
- 6. **Unblock** downstream tasks
547
-
548
- ## Step 5: Error Handling
549
-
550
- ### Contract Violation
551
- A teammate implements something that doesn't match a contract:
552
- 1. Stop the teammate
553
- 2. Identify the deviation
554
- 3. Decide: fix implementation or update contract?
555
- 4. If updating contract, message ALL affected teammates with the change
556
- 5. Log the decision
557
-
558
- ### Merge Conflict / File Conflict
559
- Two teammates modified the same file (shouldn't happen with good partitioning):
560
- 1. Stop both teammates
561
- 2. Identify which domain owns the file (check scope.md)
562
- 3. Non-owner reverts their changes
563
- 4. Determine if the contract needs updating to prevent recurrence
564
- 5. Log the incident
565
-
566
- ### Blocked Teammate Idle
567
- A teammate finishes independent tasks and is waiting on a checkpoint:
568
- 1. Check if checkpoint can be expedited
569
- 2. If not, have the teammate work on documentation, tests, or code cleanup within their domain
570
- 3. Or shut down the teammate and respawn when unblocked
571
-
572
- ## Step 6: Completion
573
-
574
- When all tasks in all domains are complete:
575
- 1. Update `.gsd-t/progress.md` all tasks marked complete
576
- 2. Set status to `EXECUTED`
577
- 3. List any contract deviations or decisions made during execution
578
-
579
- ### Autonomy Behavior
580
-
581
- **Level 3 (Full Auto)**: Log a brief status line (e.g., "✅ Execute complete — {N}/{N} tasks done") and auto-advance to the next phase. Do NOT wait for user input.
582
-
583
- **Level 1–2**: Report completion summary and recommend proceeding to integrate phase. Wait for confirmation.
584
-
585
- ## Step 7: Doc-Ripple (Automated)
586
-
587
- After all work is committed but before reporting completion:
588
-
589
- 1. Run threshold check read `git diff --name-only HEAD~1` and evaluate against doc-ripple-contract.md trigger conditions
590
- 2. If SKIP: log "Doc-ripple: SKIP {reason}" and proceed to completion
591
- 3. If FIRE: spawn doc-ripple agent:
592
-
593
- [{model}] gsd-t-doc-ripple blast radius analysis + parallel updates
594
-
595
- Task subagent (general-purpose, model: sonnet):
596
- "Execute the doc-ripple workflow per commands/gsd-t-doc-ripple.md.
597
- Git diff context: {files changed list}
598
- Command that triggered: execute
599
- Produce manifest at .gsd-t/doc-ripple-manifest.md.
600
- Update all affected documents.
601
- Report: 'Doc-ripple: {N} checked, {N} updated, {N} skipped'"
602
-
603
- 4. After doc-ripple returns, verify manifest exists and report summary inline
604
-
605
- ## Document Ripple
606
-
607
- Execute modifies source code, so the Pre-Commit Gate (referenced in Step 9) covers document updates. For clarity, the key documents affected by execution:
608
-
609
- ### Always update:
610
- 1. **`.gsd-t/progress.md`**Mark tasks complete, update domain status, log execution summary
611
-
612
- ### Check if affected (per task):
613
- 2. **`.gsd-t/contracts/`** — Did a task change an API endpoint, schema, or component interface? Update the contract
614
- 3. **`docs/requirements.md`** Did a task implement or change a requirement? Mark it complete or revise
615
- 4. **`docs/architecture.md`** Did a task add/change a component or data flow? Update it
616
- 5. **`.gsd-t/techdebt.md`** — Did a task resolve a debt item? Mark it done. Did it reveal new debt? Add it
617
-
618
- ### Scan Doc Micro-Update (if `.gsd-t/scan/` exists):
619
- After all tasks complete, patch structural metadata in scan docs so they stay fresh between full scans. This is near-zero cost — no LLM re-analysis, just updating counts and lists from code.
620
-
621
- For each scan doc that exists, apply only the relevant patches:
622
- - **`.gsd-t/scan/architecture.md`** — Update file/directory counts, add new files/modules created during execution
623
- - **`.gsd-t/scan/quality.md`** Mark resolved TODOs/FIXMEs, update test counts (run `grep -rc "test\|it\|describe" tests/` or equivalent), append new files to Consumer Surfaces table if applicable
624
- - **`.gsd-t/scan/security.md`** — If a security finding was fixed during execution, mark it `[RESOLVED]`
625
- - **`.gsd-t/scan/business-rules.md`** Append any new validation/auth/workflow rules added during execution
626
- - **`.gsd-t/scan/contract-drift.md`** If contracts were updated, mark resolved drift items
627
-
628
- Skip any scan doc that wasn't affected by the executed tasks. Skip analytical sections (assessments, recommendations) — those require a full scan to update.
629
-
630
- $ARGUMENTS
631
-
632
- ## Auto-Clear
633
-
634
- All work is committed to project files. Execute `/clear` to free the context window for the next command.
1
+ # GSD-T: Execute — Run Domain Tasks (Solo or Parallel)
2
+
3
+ You are the lead agent coordinating task execution across domains. Choose solo or team mode based on the plan.
4
+
5
+ ## Step 1: Load State
6
+
7
+ Read:
8
+ 1. `CLAUDE.md` — check for **Branch Guard** (`Expected branch` field)
9
+ 2. `.gsd-t/progress.md`
10
+ 3. `.gsd-t/contracts/` — all contracts
11
+ 4. `.gsd-t/contracts/integration-points.md` — dependency graph
12
+ 5. `.gsd-t/domains/*/tasks.md` — all task lists
13
+
14
+ **Branch check (before any work):**
15
+ Run `git branch --show-current`. If CLAUDE.md declares an expected branch and you're on a different branch, STOP and warn the user. Do NOT execute tasks on the wrong branch.
16
+
17
+ Identify:
18
+ - Which tasks are already complete (check progress.md)
19
+ - Which tasks are unblocked (no pending dependencies)
20
+ - Which tasks are blocked (waiting on checkpoints)
21
+
22
+ ## Step 1.5: Graph-Enhanced Domain Isolation Check (if available)
23
+
24
+ If `.gsd-t/graph/meta.json` exists, run graph queries before execution begins:
25
+
26
+ 1. **Reindex** (if stale): `query('reindex', { force: false })` — ensure graph reflects current code
27
+ 2. **Domain boundary check**: For each domain about to execute, `query('getEntitiesByDomain', { domain })` — verify the domain's entities match its scope.md
28
+ 3. **Pre-execution snapshot**: Record entity counts per domain — after execution, compare to detect scope creep (domain agent modified entities outside its domain)
29
+ 4. **Cross-domain dependencies**: `query('getDomainBoundaryViolations', {})` — flag existing violations before work begins so they aren't confused with new violations introduced during execution
30
+
31
+ After each domain completes, re-run `getDomainBoundaryViolations` and diff against pre-execution snapshot. If new violations appear, flag them immediately before proceeding to the next domain.
32
+
33
+ ## Step 2: QA Subagent
34
+
35
+ In solo mode, QA runs inside each domain subagent (see Step 3). In team mode, the lead spawns QA subagents at each domain checkpoint using the pattern below.
36
+
37
+ **QA Calibration Injection** — Before spawning QA, check for known weak spots:
38
+
39
+ Run via Bash:
40
+ `node -e "const qc = require('./bin/qa-calibrator.js'); const inj = qc.generateQAInjection('.'); if(inj) process.stdout.write(inj);" 2>/dev/null`
41
+
42
+ If the command produces output (non-empty), store it as `QA_INJECTION` and prepend it to the QA subagent prompt below. If the file doesn't exist or produces no output, skip silently and proceed normally.
43
+
44
+ **QA subagent prompt:**
45
+ ```
46
+ Task subagent (general-purpose, model: sonnet):
47
+ "{QA_INJECTION if non-empty, insert here as a preamble section before the instructions below}
48
+ Run the full test suite for this project and report pass/fail counts.
49
+ Read .gsd-t/contracts/ for contract definitions.
50
+ Write edge case tests for any new code paths in this task: {task description}.
51
+ Report: test pass/fail status and any coverage gaps found."
52
+ ```
53
+
54
+ If QA found issues, append each to `.gsd-t/qa-issues.md` (create with header `| Date | Command | Step | Model | Duration(s) | Severity | Finding |` if missing):
55
+ `| {DT_START} | gsd-t-execute | Step 2 | haiku | {DURATION}s | {severity} | {finding} |`
56
+
57
+ ## Step 3: Choose Execution Mode
58
+
59
+ ### Wave Scheduling (read first)
60
+
61
+ Before choosing solo or team mode, read the `## Wave Execution Groups` section in `.gsd-t/contracts/integration-points.md` (added by the plan phase).
62
+
63
+ **If wave groups are present**:
64
+ - Execute wave-by-wave: complete all tasks in Wave 1 before starting Wave 2
65
+ - Within each wave, tasks marked as parallel-safe can run concurrently (team mode) or be interleaved (solo mode)
66
+ - At each wave boundary: run the CHECKPOINT — verify contract compliance — before proceeding
67
+ - File conflict detection: if two tasks in the same wave list the same file in their `scope.md` ownership, move one to the next wave
68
+
69
+ **If no wave groups are defined** (older plans): fall back to the `Execution Order` list.
70
+
71
+ ### Solo Mode (default) Domain Task-Dispatcher Pattern
72
+
73
+ Each domain's work runs via a lightweight domain task-dispatcher. The dispatcher spawns one Task subagent PER TASK within that domain, giving each task a completely fresh context window with only the minimum required context. The orchestrator (this agent) stays lightweight — it only spawns dispatchers, collects summaries, verifies checkpoints, and updates progress.
74
+
75
+ **Context provided to each task subagent (fresh-dispatch-contract.md payload):**
76
+ - `scope.md` for the domain
77
+ - Relevant contracts (only those referenced by the task)
78
+ - The single task from `tasks.md`
79
+ - Graph context for the task's files (if available)
80
+ - Up to 5 prior task summaries (10-20 lines each, most recent first)
81
+ - Past failure/learning entries for this domain (max 5 lines)
82
+
83
+ **OBSERVABILITY LOGGING (MANDATORY) — repeat for every task subagent spawn:**
84
+
85
+ Before spawning run via Bash:
86
+ `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}`
87
+
88
+ After subagent returns run via Bash:
89
+ `T_END=$(date +%s) && DT_END=$(date +"%Y-%m-%d %H:%M") && TOK_END=${CLAUDE_CONTEXT_TOKENS_USED:-0} && DURATION=$((T_END-T_START))`
90
+
91
+ Compute tokens and compaction:
92
+ - No compaction (TOK_END >= TOK_START): `TOKENS=$((TOK_END-TOK_START))`, COMPACTED=null
93
+ - Compaction detected (TOK_END < TOK_START): `TOKENS=$(((TOK_MAX-TOK_START)+TOK_END))`, COMPACTED=$DT_END
94
+
95
+ Compute context utilization run via Bash:
96
+ `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`
97
+
98
+ Alert on context thresholds (display to user inline):
99
+ - If CTX_PCT is a number and >= 85: `echo "🔴 CRITICAL: Context at ${CTX_PCT}% — compaction likely. Task MUST be split."`
100
+ - If CTX_PCT is a number and >= 70: `echo "⚠️ WARNING: Context at ${CTX_PCT}% — approaching compaction threshold. Consider splitting in plan."`
101
+
102
+ 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):
103
+ `| {DT_START} | {DT_END} | gsd-t-execute | task:{task-id} | sonnet | {DURATION}s | {pass/fail} | {TOKENS} | {COMPACTED} | {domain-name} | task-{task-id} | {CTX_PCT} |`
104
+
105
+ **For each domain (in wave order), run the domain task-dispatcher:**
106
+
107
+ **Token Budget Check (before dispatching each domain's tasks):**
108
+
109
+ Run via Bash:
110
+ `node -e "const tb = require('./bin/token-budget.js'); const s = tb.getSessionStatus('.'); const d = tb.getDegradationActions(s.threshold, '.'); process.stdout.write(JSON.stringify({threshold: s.threshold, actions: d}));" 2>/dev/null`
111
+
112
+ Apply the result:
113
+ - `threshold: 'normal'` or file missing skip silently, proceed with standard model assignments
114
+ - `threshold: 'downgrade'` → apply model overrides from `actions.modelOverride` (e.g., downgrade opus tasks to sonnet)
115
+ - `threshold: 'conserve'` → checkpoint progress to `.gsd-t/progress.md` and skip non-essential operations (Red Team, doc-ripple) for this domain
116
+ - `threshold: 'stop'` → checkpoint all progress, output: "Token budget exhausted — progress saved. Resume after session reset.", and halt execution for remaining domains
117
+
118
+ **Pre-dispatch experience retrieval (before dispatching each domain's tasks):**
119
+ Run via Bash:
120
+ `grep -i "\[failure\]\|\[learning\]" .gsd-t/progress.md | grep -i "{domain-name}" | tail -5`
121
+
122
+ If results found:
123
+ - Store as `PAST_FAILURES` — prepend to each task subagent prompt (max 5 lines)
124
+ - Write event via Bash: `node ~/.claude/scripts/gsd-t-event-writer.js --type experience_retrieval --command gsd-t-execute --reasoning "{N past failures found for {domain-name}}" --outcome null || true`
125
+
126
+ If no results found: proceed normally (no warning block, no event write).
127
+
128
+ **Pre-flight intelligence check (before dispatching each domain's tasks):**
129
+ Run via Bash:
130
+ `node -e "const m = require('./bin/metrics-collector.js'); const w = m.getPreFlightWarnings('{domain-name}'); if(w.length) w.forEach(x => console.log('⚠️ ' + x));" 2>/dev/null || true`
131
+
132
+ Display any warnings inline (non-blocking execution proceeds regardless).
133
+
134
+ **Active Rule Injection (before dispatching each domain's tasks):**
135
+ Run via Bash:
136
+ `node -e "const re = require('./bin/rule-engine.js'); const m = re.evaluateRules('{domain-name}', { projectDir: '.' }); if(m.length) m.forEach(x => console.log('RULE: ' + x.rule.name + ' — ' + x.rule.description + ' [' + x.severity + ']')); else console.log('No active rules for {domain-name}');" 2>/dev/null || true`
137
+
138
+ If rules fire: inject up to 10 lines of rule warnings into each task subagent prompt (concise format: `RULE: {name} — {description}`). These inform the subagent of known patterns — non-blocking.
139
+ If no rules fire: log "No active rules for {domain-name}" and continue.
140
+
141
+ **Stack Rules Detection (before spawning subagent):**
142
+
143
+ Run via Bash to detect project stack and collect matching rules. Local overrides in `.gsd-t/stacks/` take precedence over global templates — if a project has `.gsd-t/stacks/react.md`, it replaces the global `react.md` for that project.
144
+
145
+ ```bash
146
+ GSD_T_DIR=$(npm root -g 2>/dev/null)/@tekyzinc/gsd-t
147
+ STACKS_DIR="$GSD_T_DIR/templates/stacks"
148
+ LOCAL_STACKS=".gsd-t/stacks"
149
+ STACK_RULES=""
150
+
151
+ # Helper: read local override if exists, else global
152
+ _sf() { local n=$(basename "$1"); [ -f "$LOCAL_STACKS/$n" ] && cat "$LOCAL_STACKS/$n" || cat "$1"; }
153
+
154
+ # Helper: append a stack file to STACK_RULES
155
+ _add() { [ -f "$STACKS_DIR/$1" ] && STACK_RULES="${STACK_RULES}$(_sf "$STACKS_DIR/$1")"$'\n\n'; }
156
+
157
+ if [ -d "$STACKS_DIR" ]; then
158
+ # Universal rules (_ prefix always injected)
159
+ for f in "$STACKS_DIR"/_*.md; do [ -f "$f" ] && STACK_RULES="${STACK_RULES}$(_sf "$f")"$'\n\n'; done
160
+
161
+ # Package.json-based detection
162
+ if [ -f "package.json" ]; then
163
+ grep -q '"react-native"' package.json 2>/dev/null && _add react-native.md
164
+ grep -q '"react"' package.json 2>/dev/null && ! grep -q '"react-native"' package.json 2>/dev/null && _add react.md
165
+ grep -q '"next"' package.json 2>/dev/null && _add nextjs.md
166
+ grep -q '"vue"' package.json 2>/dev/null && _add vue.md
167
+ (grep -q '"typescript"' package.json 2>/dev/null || [ -f "tsconfig.json" ]) && _add typescript.md
168
+ grep -qE '"(express|fastify|hono|koa)"' package.json 2>/dev/null && _add node-api.md && _add rest-api.md
169
+ grep -q '"tailwindcss"' package.json 2>/dev/null && _add tailwind.md
170
+ grep -q '"vite"' package.json 2>/dev/null && _add vite.md
171
+ grep -q '"@supabase/supabase-js"' package.json 2>/dev/null && _add supabase.md
172
+ grep -q '"firebase"' package.json 2>/dev/null && _add firebase.md
173
+ grep -qE '"(graphql|@apollo/client|urql)"' package.json 2>/dev/null && _add graphql.md
174
+ grep -q '"zustand"' package.json 2>/dev/null && _add zustand.md
175
+ grep -q '"@reduxjs/toolkit"' package.json 2>/dev/null && _add redux.md
176
+ grep -q '"neo4j-driver"' package.json 2>/dev/null && _add neo4j.md
177
+ grep -qE '"(pg|prisma|drizzle-orm|knex)"' package.json 2>/dev/null && _add postgresql.md
178
+ grep -qE '"(prisma|@prisma/client)"' package.json 2>/dev/null && _add prisma.md
179
+ grep -qE '"(bullmq|bull|amqplib|@aws-sdk/client-sqs|bee-queue|agenda)"' package.json 2>/dev/null && _add queues.md
180
+ grep -qE '"(openai|anthropic|@anthropic-ai/sdk|langchain|llama-index|@google/generative-ai)"' package.json 2>/dev/null && _add llm.md
181
+ fi
182
+
183
+ # File-based detection (no package.json needed)
184
+ ([ -f "requirements.txt" ] || [ -f "pyproject.toml" ] || [ -f "Pipfile" ]) && _add python.md
185
+ ([ -f "requirements.txt" ] && grep -q "psycopg" requirements.txt 2>/dev/null || [ -f "pyproject.toml" ] && grep -q "psycopg" pyproject.toml 2>/dev/null) && _add postgresql.md
186
+ ([ -f "requirements.txt" ] && grep -q "neo4j" requirements.txt 2>/dev/null) && _add neo4j.md
187
+ ([ -f "requirements.txt" ] && grep -q "fastapi" requirements.txt 2>/dev/null || [ -f "pyproject.toml" ] && grep -q "fastapi" pyproject.toml 2>/dev/null) && _add fastapi.md
188
+ ([ -f "requirements.txt" ] && grep -qE "(celery|dramatiq|rq|arq)" requirements.txt 2>/dev/null || [ -f "pyproject.toml" ] && grep -qE "(celery|dramatiq|rq|arq)" pyproject.toml 2>/dev/null) && _add queues.md
189
+ ([ -f "requirements.txt" ] && grep -qE "(openai|anthropic|langchain|llama.index)" requirements.txt 2>/dev/null || [ -f "pyproject.toml" ] && grep -qE "(openai|anthropic|langchain|llama.index)" pyproject.toml 2>/dev/null) && _add llm.md
190
+ [ -f "pubspec.yaml" ] && _add flutter.md
191
+ [ -f "Dockerfile" ] && _add docker.md
192
+ [ -d ".github/workflows" ] && _add github-actions.md
193
+ ([ -f "playwright.config.ts" ] || [ -f "playwright.config.js" ]) && _add playwright.md
194
+ [ -f "go.mod" ] && _add go.md
195
+ [ -f "Cargo.toml" ] && _add rust.md
196
+ fi
197
+ ```
198
+
199
+ If STACK_RULES is non-empty, append to the subagent prompt:
200
+ ```
201
+ ## Stack Rules (MANDATORY — violations fail this task)
202
+
203
+ {STACK_RULES}
204
+
205
+ These standards have the same enforcement weight as contract compliance.
206
+ Violations are task failures, not warnings.
207
+ ```
208
+
209
+ If STACK_RULES is empty (no templates/stacks/ dir or no matches), skip silently.
210
+
211
+ **Domain task-dispatcher (lightweight — sequences tasks, passes summaries):**
212
+
213
+ For each task in `.gsd-t/domains/{domain-name}/tasks.md` (in order, skip completed):
214
+
215
+ 1. Load prior summaries: Read up to 5 most recent `.gsd-t/domains/{domain-name}/task-*-summary.md` files (10-20 lines each)
216
+ 2. Load graph context (if `.gsd-t/graph/meta.json` exists): query task's files for relevant graph context
217
+ 3. Display: `⚙ [sonnet] gsd-t-execute → domain: {domain-name}, task-{task-id}`
218
+ 4. Run observability Bash (T_START / DT_START / TOK_START / TOK_MAX)
219
+ 5. Spawn task subagent:
220
+
221
+ ```
222
+ Task subagent (general-purpose, model: sonnet, mode: bypassPermissions):
223
+ "You are executing a single task for the {domain-name} domain.
224
+
225
+ {PAST_FAILURES block if any — ## ⚠️ Past Failures (read before acting)\n{lines}}
226
+
227
+ ## Your Task
228
+ {full task block from tasks.md — id, description, files, contract refs, dependencies, acceptance criteria}
229
+
230
+ ## Domain Scope
231
+ {contents of .gsd-t/domains/{domain-name}/scope.md}
232
+
233
+ ## Relevant Contracts
234
+ {contents of each contract file referenced by this task}
235
+
236
+ ## Graph Context (if available)
237
+ {graph query results for this task's files omit section if unavailable}
238
+
239
+ ## Prior Task Summaries (most recent first, max 5)
240
+ {contents of task-{N}-summary.md files 10-20 lines each}
241
+
242
+ ## Stack Rules
243
+ {STACK_RULES if non-empty omit entire section if empty}
244
+
245
+ ## Instructions
246
+
247
+ Execute the task above:
248
+ 1. Read the task description, files list, and contract refs carefully
249
+ 2. Read relevant contracts implement EXACTLY what they specify
250
+ 3. Destructive Action Guard: if the task involves DROP TABLE, schema changes that lose
251
+ data, removing working modules, or replacing architecture patterns write a
252
+ NEEDS-APPROVAL entry to .gsd-t/deferred-items.md, skip the task, stop here
253
+ 4. Implement the task
254
+ 5. Verify acceptance criteria are met
255
+ 6. Write comprehensive tests (MANDATORY no feature code without test code):
256
+ - Unit/integration: happy path + edge cases + error cases for every new/changed function
257
+ - Playwright E2E (if UI/routes/flows changed): new specs for new features, cover
258
+ all modes, form validation, empty/loading/error states, common edge cases
259
+ - If no test framework exists: set one up as part of this task
260
+ - If the project has a UI but no Playwright E2E specs exist for the features being
261
+ touched: WRITE THEM. A placeholder spec is not sufficient — write real E2E tests
262
+ that exercise the actual UI functionality being built or changed.
263
+ - **FUNCTIONAL E2E TESTS NOT LAYOUT TESTS (MANDATORY)**:
264
+ E2E tests that only check element existence (isVisible, isEnabled, toBeAttached)
265
+ are LAYOUT tests, not functional tests. Layout tests pass even when every feature
266
+ is broken. Every Playwright spec MUST verify functional behavior:
267
+ a. **State changes**: After an action (click, type, submit), assert the app STATE
268
+ changed not just that the button was clickable. Example: clicking a tab must
269
+ load different content; verify the content changed, not just that the tab exists.
270
+ b. **Data flow**: Form submissions must verify data arrived (API call made, response
271
+ rendered, list updated). Don't just assert the form rendered.
272
+ c. **Navigation/routing**: Tab/page switches must verify the NEW content loaded.
273
+ Assert on content unique to the destination, not the navigation element itself.
274
+ d. **Interactive widgets**: Terminals must accept input and produce output. Editors
275
+ must save changes. Panels must load their functional content after opening.
276
+ e. **Network integration**: If a feature requires WebSocket/API connection, verify
277
+ the connection status changes (e.g., "Disconnected" "Connected") and that
278
+ messages flow through the connection.
279
+ f. **Error recovery**: Don't just check error messages render verify the app
280
+ recovers (retry button works, form can be resubmitted, etc.).
281
+ A test that would pass on an empty HTML page with the right element IDs is useless.
282
+ Every assertion must prove the FEATURE WORKS, not that the ELEMENT EXISTS.
283
+ 7. Run ALL test suites this is NOT optional, not conditional, not "if applicable":
284
+ a. Detect configured test runners: check for vitest/jest config, playwright.config.*, cypress.config.*
285
+ b. Run EVERY detected suite. Unit tests alone are NEVER sufficient when E2E exists.
286
+ c. If `playwright.config.*` exists run `npx playwright test` (full suite, not just affected specs)
287
+ d. If E2E tests fail fix (up to 2 attempts) before proceeding
288
+ e. Report ALL suite results: "Unit: X/Y pass | E2E: X/Y pass" never report just one
289
+ 8. Run Pre-Commit Gate checklist from CLAUDE.md update all affected docs BEFORE committing
290
+ 9. Commit immediately: feat({domain-name}/task-{task-id}): {description}
291
+ 10. Update .gsd-t/progress.md mark this task complete; prefix the Decision Log entry:
292
+ - Completed successfully on first attempt → prefix `[success]`
293
+ - Completed after a fix → prefix `[learning]`
294
+ - Deferred to .gsd-t/deferred-items.md → prefix `[deferred]`
295
+ - Failed after 3 attempts → prefix `[failure]`
296
+ 11. Spawn QA subagent (model: sonnet) after completing the task:
297
+ 'Run ALL configured test suites — detect and run every one:
298
+ a. Unit tests (vitest/jest/mocha): run the full suite, report pass/fail counts
299
+ b. E2E tests: check for playwright.config.* or cypress.config.* — if found, run the FULL E2E suite
300
+ c. NEVER skip E2E when a config file exists. Running only unit tests is a QA FAILURE.
301
+ d. Read .gsd-t/contracts/ for contract definitions. Check contract compliance.
302
+ e. AUDIT E2E test quality: Review each Playwright spec — if any test only checks
303
+ element existence (isVisible, toBeAttached, toBeEnabled) without verifying functional
304
+ behavior (state changes, data loaded, content updated after actions), flag it as
305
+ "SHALLOW TEST — needs functional assertions" in the gap report. A test suite where
306
+ every spec passes but no feature actually works is a QA FAILURE.
307
+ Report format: "Unit: X/Y pass | E2E: X/Y pass (or N/A if no config) | Contract: compliant/violations | Shallow tests: N (list) | Stack rules: compliant/N violations"
308
+ f. Validate compliance with Stack Rules (if injected in the work subagent's prompt).
309
+ Stack rule violations have the same severity as contract violations report as failures, not warnings.
310
+
311
+ ## Exploratory Testing (if Playwright MCP available)
312
+
313
+ After all scripted tests pass:
314
+ 1. Check if Playwright MCP is registered in Claude Code settings (look for "playwright" in mcpServers)
315
+ 2. If available: spend 3 minutes on interactive exploration using Playwright MCP
316
+ - Try variations of happy paths with unexpected inputs
317
+ - Probe for race conditions, double-submits, empty states
318
+ - Test accessibility (keyboard navigation, screen reader flow)
319
+ 3. Tag all findings [EXPLORATORY] in your report and append to .gsd-t/qa-issues.md with [EXPLORATORY] prefix
320
+ 4. If Playwright MCP is not available: skip this section silently
321
+ Note: Exploratory findings do NOT count against the scripted test pass/fail ratio.'
322
+ If QA fails OR shallow tests are found, fix before proceeding. Append issues to .gsd-t/qa-issues.md.
323
+ 12. Write task summary to .gsd-t/domains/{domain-name}/task-{task-id}-summary.md:
324
+ ## Task {task-id} Summary — {domain-name}
325
+ - **Status**: PASS | FAIL
326
+ - **Files modified**: {list}
327
+ - **Constraints discovered**: {any new constraints or surprises}
328
+ - **Tests**: {pass/fail count}
329
+ - **Notes**: {10-20 lines max key decisions, patterns, warnings}
330
+
331
+ Deviation rules:
332
+ - Bug blocking progress fix, max 3 attempts; after fix attempt 2 fails:
333
+ 1. Write current failure context to .gsd-t/debug-state.jsonl via appendEntry
334
+ 2. Log: "Delegating to headless debug-loop (2 in-context attempts exhausted)"
335
+ 3. Run: `gsd-t headless --debug-loop --max-iterations 15`
336
+ 4. Check exit code:
337
+ - 0: Tests pass, continue with task
338
+ - 1/4: Log to .gsd-t/deferred-items.md and stop (report FAIL in summary)
339
+ - 3: Report error, stop
340
+ If still blocked after debug-loop, log to .gsd-t/deferred-items.md and stop (report FAIL in summary)
341
+ - Missing dependency → add minimum needed, document in commit message
342
+ - Non-trivial blocker log to .gsd-t/deferred-items.md
343
+ - Architectural change required → write NEEDS-APPROVAL to .gsd-t/deferred-items.md,
344
+ skip the task, stop here never self-approve structural changes
345
+
346
+ Report back:
347
+ - Task: {task-id}
348
+ - Status: PASS | FAIL
349
+ - Files modified: {list}
350
+ - Tests: {pass/fail count}
351
+ - Commit: {hash}
352
+ - Deferred items (if any)"
353
+ ```
354
+
355
+ 6. After task subagent returns:
356
+ - Run observability Bash (T_END / TOK_END / DURATION / CTX_PCT)
357
+ - Append to token-log.md (per-task row)
358
+ - Alert on CTX_PCT thresholds (display to user inline)
359
+ - **Emit task-metrics record** run via Bash:
360
+ `node bin/metrics-collector.js --milestone {milestone} --domain {domain-name} --task task-{task-id} --command execute --duration_s $DURATION --tokens_used $TOKENS --context_pct ${CTX_PCT:-0} --pass {true|false} --fix_cycles {0|N} --signal_type {pass-through|fix-cycle} --notes "{brief outcome}" 2>/dev/null || true`
361
+ Signal type: `pass-through` if task passed on first attempt; `fix-cycle` if rework was needed.
362
+ - **Emit task_complete event** run via Bash:
363
+ `node ~/.claude/scripts/gsd-t-event-writer.js --type task_complete --command gsd-t-execute --reasoning "signal_type={signal_type}, domain={domain-name}" --outcome {success|failure} || true`
364
+ - Check `.gsd-t/deferred-items.md` for `NEEDS-APPROVAL` if found, STOP and present to user before proceeding to the next task
365
+ - Read the task summary from `.gsd-t/domains/{domain-name}/task-{task-id}-summary.md` to use as prior summary for the next task
366
+
367
+ **After all tasks in a domain complete (orchestrator responsibilities):**
368
+ 1. Check `.gsd-t/deferred-items.md` for any `NEEDS-APPROVAL` entries — if found, STOP and present to user before spawning the next domain
369
+ 2. If a CHECKPOINT is reached per `integration-points.md`, verify contract compliance (see Step 4) before proceeding to the next wave/domain
370
+ 3. Update `.gsd-t/progress.md` with domain completion status
371
+ 4. **Adaptive Replan Check** (per `adaptive-replan-contract.md`) — run after EVERY domain completes, before dispatching the next domain:
372
+
373
+ a. **Read domain summaries**: Read all `.gsd-t/domains/{completed-domain}/task-*-summary.md` files. Extract every `**Constraints discovered**:` field. If ALL are empty or "none", skip to the next domain (fast path — no replan needed).
374
+
375
+ b. **Assess affected domains** two modes:
376
+ - **Graph available** (`.gsd-t/graph/meta.json` exists): For each changed module mentioned in the constraints, run `query('getImporters', { file })` to find which remaining domains import it. Also run `query('getDomainBoundaryViolations', {})` to check if constraint changes affect domain boundaries. Scope replan to ONLY those domains.
377
+ - **Graph unavailable** (fallback): Check ALL remaining unexecuted domains' `tasks.md` files less precise but functional.
378
+
379
+ c. **Check for invalidated assumptions**: Read each affected remaining domain's `.gsd-t/domains/{domain}/tasks.md`. For each task, check whether any assumption is invalidated by the discovered constraints (e.g., wrong column name, deprecated API, wrong library, missing prerequisite, throughput limits).
380
+
381
+ d. **If invalidated assumptions found**: Revise the affected domain's `tasks.md` on disk. Append a Revision block at the end of the file (do NOT overwrite existing tasks — append only):
382
+ ```markdown
383
+ ## Revision (Replan Cycle {N})
384
+ - **Trigger**: {completed-domain} constraint discovered during execution
385
+ - **Constraint**: {exact constraint text from summary}
386
+ - **Changes**: {what was revised in this domain's tasks list specific task IDs and what changed}
387
+ - **Rationale**: {why this revision is needed what would break without it}
388
+ ```
389
+
390
+ e. **Increment replan cycle counter** (track as `REPLAN_CYCLES` in orchestrator state, starting at 0).
391
+
392
+ f. **Cycle guard**: If `REPLAN_CYCLES > 2`, STOP and pause for user input:
393
+ "Replan cycle limit (2) exceeded. {N} constraints are still propagating. Please review `.gsd-t/domains/*/tasks.md` and resolve manually, then re-run execute."
394
+
395
+ g. **Log to Decision Log** in `.gsd-t/progress.md`: `- {date}: [replan] Cycle {N} — {completed-domain} constraint propagated to {list of affected domains}: {brief constraint summary}`
396
+
397
+ h. The revised `tasks.md` files are now on disk — the next domain's dispatcher will read the updated version automatically (disk-based handoff, no in-memory state sharing needed).
398
+
399
+ ### Team Mode (when agent teams are enabled)
400
+ Spawn teammates for domains within the same wave. Only domains in the same wave can run in parallel — do not spawn teammates for domains in different waves simultaneously. Each teammate uses the **domain task-dispatcher pattern** one subagent per task within their domain (same as solo mode).
401
+
402
+ ```
403
+ Create an agent team for execution:
404
+
405
+ ALL TEAMMATES must read before starting:
406
+ 1. CLAUDE.md project conventions (CRITICAL)
407
+ 2. Your domain's scope.md — what you own
408
+ 3. Your domain's constraints.md — what you must/must not do
409
+ 4. ALL files in .gsd-t/contracts/ your interfaces
410
+ 5. Your domain's tasks.md your work
411
+
412
+ RULES FOR ALL TEAMMATES:
413
+ - **Destructive Action Guard**: NEVER drop tables, remove columns, delete data, replace architecture patterns, or remove working modules without messaging the lead first. The lead must get user approval before any destructive action proceeds.
414
+ - Only modify files listed in your domain's scope.md
415
+ - Implement interfaces EXACTLY as specified in contracts
416
+ - **Write comprehensive FUNCTIONAL tests with every task** — no feature code without test code:
417
+ - Unit/integration tests: happy path + edge cases + error cases for every new/changed function
418
+ - Playwright E2E specs (if UI/routes/flows/modes changed): new specs for new features, cover all modes/flags, form validation, empty/loading/error states, common edge cases
419
+ - Tests are part of the deliverable, not a follow-up
420
+ - **E2E tests MUST be functional, not layout tests**: Every assertion must verify an action produced the correct outcome (state changed, data loaded, content updated) — NOT just that an element is visible/clickable. A test that passes on an empty HTML shell with correct IDs is worthless. See the Functional E2E Test Requirements in the solo mode instructions above.
421
+ - If a task is marked BLOCKED, message the lead and wait
422
+ - Run the Pre-Commit Gate checklist from CLAUDE.md BEFORE every commit — update all affected docs
423
+ - **Commit immediately after each task**: `feat({domain}/task-{N}): {description}`do NOT batch commits
424
+ - **Deviation Rules**: (1) Bug blocking progress → fix, 3 attempts max; (2) Missing dependency → add minimum needed; (3) Blocker → fix and log to deferred-items.md; (4) Architectural change → STOP, message lead, never self-approve
425
+
426
+ **Task-dispatcher pattern per teammate:**
427
+ For each task in your domain's tasks.md (in order, skip completed):
428
+ 1. Load prior summaries: read up to 5 most recent `.gsd-t/domains/{your-domain}/task-*-summary.md` files
429
+ 2. Load graph context for task's files (if .gsd-t/graph/meta.json exists)
430
+ 3. Spawn one Task subagent (model: sonnet) with ONLY:
431
+ - scope.md, relevant contracts, the single task, graph context, prior summaries
432
+ - Instruction to write task summary to `.gsd-t/domains/{domain}/task-{id}-summary.md`
433
+ (format per fresh-dispatch-contract.md Task Summary Format)
434
+ 4. After task subagent returns, read the summary and pass it as prior context to the next task
435
+ 5. After completing each task, message the lead with:
436
+ "DONE: {domain} Task {N} - {summary of what was created/modified}"
437
+ 6. If you need to deviate from a contract, STOP and message the lead
438
+
439
+ Teammate assignments:
440
+ - Teammate "{domain-1}": Execute .gsd-t/domains/{domain-1}/tasks.md (task-dispatcher pattern, isolated worktree)
441
+ - Teammate "{domain-2}": Execute .gsd-t/domains/{domain-2}/tasks.md (task-dispatcher pattern, isolated worktree)
442
+ - Teammate "{domain-3}": Execute .gsd-t/domains/{domain-3}/tasks.md (task-dispatcher pattern, isolated worktree)
443
+
444
+ **Worktree isolation (per domain teammate):**
445
+ Each domain teammate MUST be spawned with `isolation: "worktree"` on the Agent tool:
446
+ ```
447
+ Agent({
448
+ prompt: "{domain execution prompt — include: 'You are working in an isolated git worktree. All your changes are isolated to this worktree branch. Do not push; the lead will merge your branch after all domains complete.'}",
449
+ isolation: "worktree"
450
+ })
451
+ ```
452
+ Each teammate works in its own isolated copy of the repository. Changes from one domain do not affect another domain's working tree. This is required for parallel safety see `.gsd-t/contracts/worktree-isolation-contract.md`.
453
+
454
+ Lead responsibilities (QA is handled via Task subagent — spawn one after each domain checkpoint):
455
+ - Use delegate mode (Shift+Tab)
456
+ - Track completions from teammate messages
457
+ - When a CHECKPOINT is reached:
458
+ 1. Pause blocked teammates
459
+ 2. Verify the gate condition (check contract compliance)
460
+ 3. Unblock waiting teammates
461
+ - Update .gsd-t/progress.md after each completion
462
+ - Resolve any contract conflicts immediately
463
+
464
+ **Sequential Merge Protocol (lead runs after ALL domain agents complete):**
465
+
466
+ Once all domain teammates report completion, the lead performs sequential atomic merges. This is the critical integration step — see `.gsd-t/contracts/worktree-isolation-contract.md` for the full merge protocol.
467
+
468
+ 1. **Determine merge order**: Read `.gsd-t/contracts/integration-points.md` use the dependency graph to sort domains. Domains with no upstream dependencies merge first. Example: if domain-A has no deps and domain-B depends on domain-A's output, merge order is [domain-A, domain-B].
469
+
470
+ 2. **For each domain (in dependency order)**:
471
+
472
+ a. **File ownership validation (pre-merge)**: Check files the domain agent modified against the domain's `.gsd-t/domains/{domain}/scope.md`:
473
+ - If `.gsd-t/graph/meta.json` exists: run `query('getDomainBoundaryViolations', { domain })` — flag any files modified outside the domain's declared ownership
474
+ - If graph unavailable: list files changed in the worktree branch via `git diff --name-only` and compare against scope.md manually
475
+ - If violations found: log them in `.gsd-t/progress.md` as `[violation] {domain}: modified {file} outside scope`, but do NOT block merge — flag for immediate review after merge
476
+
477
+ b. **Merge the domain's worktree branch**:
478
+ ```bash
479
+ # The worktree branch name is returned by the Agent tool when isolation: "worktree" is used
480
+ git merge --no-ff {domain-worktree-branch} -m "integrate({domain}): merge worktree branch"
481
+ ```
482
+
483
+ c. **Contract validation (post-merge)**: Read each contract in `.gsd-t/contracts/` — verify the merged code still satisfies all contract shapes (API shapes, schemas, interfaces). If a contract is violated, log it immediately.
484
+
485
+ d. **Run integration tests**:
486
+ ```bash
487
+ node --test test/
488
+ # or project's test command from package.json
489
+ ```
490
+
491
+ e. **If tests PASS**: Continue to the next domain in merge order.
492
+
493
+ f. **If tests FAIL**: Roll back this domain's merge:
494
+ ```bash
495
+ git reset --hard HEAD~1
496
+ # or: git revert HEAD --no-edit
497
+ ```
498
+ Log failure: `[rollback] {domain}: merge rolled back — integration tests failed after merge`
499
+ Record in `.gsd-t/progress.md` Decision Log.
500
+ Continue with remaining domains (other domains' merges are not affected).
501
+
502
+ 3. **Post-merge ownership report**: After all merges complete (successful or rolled back), log a summary in `.gsd-t/progress.md`:
503
+ ```
504
+ ## Worktree Merge Summary {date}
505
+ - {domain-1}: MERGED | tests: PASS | violations: {N}
506
+ - {domain-2}: ROLLED BACK | reason: integration tests failed
507
+ - {domain-3}: MERGED | tests: PASS | violations: 0
508
+ ```
509
+
510
+ **Worktree Cleanup (MANDATORY run after merge protocol, success or failure):**
511
+
512
+ After all merges complete (whether all passed, some rolled back, or errors occurred):
513
+
514
+ 1. List all worktree branches created during this execution run:
515
+ ```bash
516
+ git worktree list
517
+ git branch --list "gsd-t-worktree-*"
518
+ ```
519
+
520
+ 2. Remove each domain worktree:
521
+ ```bash
522
+ git worktree remove --force {worktree-path}
523
+ git branch -D {worktree-branch}
524
+ ```
525
+
526
+ 3. **Orphaned worktree detection**: If any worktrees remain after cleanup (can happen if an agent crashed):
527
+ ```bash
528
+ git worktree prune
529
+ ```
530
+ Log: `[cleanup] Pruned {N} orphaned worktrees via git worktree prune`
531
+
532
+ 4. Verify no worktrees remain except the main working tree:
533
+ ```bash
534
+ git worktree list
535
+ # should show only: {main-path} {commit} [branch]
536
+ ```
537
+
538
+ Cleanup is not optional — orphaned worktrees waste disk space and can confuse subsequent executions. Always run cleanup, even if earlier steps failed.
539
+ ```
540
+
541
+ ## Step 3.5: Orchestrator Context Self-Check (MANDATORY)
542
+
543
+ After EVERY domain completes (and after every checkpoint), the orchestrator MUST check its own context utilization:
544
+
545
+ Run via Bash:
546
+ `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 && echo "Orchestrator context: ${CTX_PCT}%"`
547
+
548
+ **If CTX_PCT >= 70:**
549
+ 1. **Save checkpoint to disk** — update `.gsd-t/progress.md` with:
550
+ - Which domains are complete, which remain
551
+ - Current wave, next domain to execute
552
+ - Any checkpoint results
553
+ 2. **Instruct user**: Output exactly:
554
+ ```
555
+ ⚠️ Orchestrator context at {CTX_PCT}% approaching limit.
556
+ Progress saved. Run `/clear` then `/user:gsd-t-execute` to continue from the next domain.
557
+ ```
558
+ 3. **STOP execution.** Do NOT spawn another domain subagent. The next session will resume from saved state.
559
+
560
+ **If CTX_PCT < 70:** Continue normally to the next domain/wave.
561
+
562
+ This prevents the orchestrator from running out of context mid-milestone, which causes session breaks and summary-based recovery.
563
+
564
+ ## Step 4: Checkpoint Handling
565
+
566
+ When a checkpoint is reached (solo or team):
567
+
568
+ 1. **Stop** execution of blocked tasks
569
+ 2. **Read** the relevant contract
570
+ 3. **Verify** the implemented code matches the contract:
571
+ - API response shapes match?
572
+ - Schema matches?
573
+ - Component interfaces match?
574
+ - Error handling matches?
575
+ 4. **If mismatch**: Fix the implementation to match the contract, OR update the contract and notify affected domains
576
+ 5. **Log** in progress.md: `CHECKPOINT {name}: PASSED/FAILED — {details}`
577
+ 6. **Unblock** downstream tasks
578
+
579
+ ## Step 5: Error Handling
580
+
581
+ ### Contract Violation
582
+ A teammate implements something that doesn't match a contract:
583
+ 1. Stop the teammate
584
+ 2. Identify the deviation
585
+ 3. Decide: fix implementation or update contract?
586
+ 4. If updating contract, message ALL affected teammates with the change
587
+ 5. Log the decision
588
+
589
+ ### Merge Conflict / File Conflict
590
+ Two teammates modified the same file (shouldn't happen with good partitioning):
591
+ 1. Stop both teammates
592
+ 2. Identify which domain owns the file (check scope.md)
593
+ 3. Non-owner reverts their changes
594
+ 4. Determine if the contract needs updating to prevent recurrence
595
+ 5. Log the incident
596
+
597
+ ### Blocked Teammate Idle
598
+ A teammate finishes independent tasks and is waiting on a checkpoint:
599
+ 1. Check if checkpoint can be expedited
600
+ 2. If not, have the teammate work on documentation, tests, or code cleanup within their domain
601
+ 3. Or shut down the teammate and respawn when unblocked
602
+
603
+ ## Step 5.5: Red Team Adversarial QA (MANDATORY)
604
+
605
+ After all domain tasks pass their tests, spawn an adversarial Red Team agent. This agent's sole purpose is to BREAK the code that was just built. It operates with inverted incentives — its success is measured by bugs found, not tests passed.
606
+
607
+ [{model}] Red Team adversarial validation of executed domains
608
+
609
+ **OBSERVABILITY LOGGING (MANDATORY):**
610
+ Before spawningrun via Bash:
611
+ `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}`
612
+
613
+ ```
614
+ Task subagent (general-purpose, model: opus):
615
+ "You are a Red Team QA adversary. Your job is to BREAK the code that was just written.
616
+
617
+ Your value is measured by REAL bugs found. More bugs = more value.
618
+ If you find zero bugs, you must prove you were thorough — list every
619
+ attack vector you tried and why it didn't break. A short list means
620
+ you didn't try hard enough.
621
+
622
+ Rules:
623
+ - False positives DESTROY your credibility. If you report something
624
+ as a bug and it's actually correct behavior, that's worse than
625
+ missing a real bug. Never report something you haven't reproduced.
626
+ - Style opinions are not bugs. Theoretical concerns are not bugs.
627
+ A bug is: 'I did X, expected Y, got Z.' With proof.
628
+ - You are done ONLY when you have exhausted every category below
629
+ and either found a bug or documented exactly what you tried.
630
+
631
+ ## Attack Categories (exhaust ALL of these)
632
+
633
+ 1. **Contract Violations**: Read .gsd-t/contracts/. Does the code EXACTLY
634
+ match every contract? Test each endpoint/interface/schema shape.
635
+ 2. **Boundary Inputs**: Empty strings, null, undefined, huge payloads,
636
+ special characters, SQL injection attempts, XSS payloads, path traversal.
637
+ 3. **State Transitions**: What happens when actions are performed out of
638
+ order? Double-submit? Concurrent access? Refresh mid-flow?
639
+ 4. **Error Paths**: Remove env vars. Kill the database. Send malformed
640
+ requests. Does the code handle failures gracefully or crash?
641
+ 5. **Missing Flows**: Read docs/requirements.md. Are there user flows that
642
+ exist in requirements but have NO test coverage? Write tests for them.
643
+ 6. **Regression**: Run the FULL test suite. Did any existing tests break?
644
+ 7. **E2E Functional Gaps**: Review ALL Playwright specs. Do they test actual
645
+ behavior (state changes, data loaded, navigation works) or just check
646
+ that elements exist? Flag and rewrite any shallow/layout tests.
647
+
648
+ ## Exploratory Testing (if Playwright MCP available)
649
+
650
+ After all scripted tests pass:
651
+ 1. Check if Playwright MCP is registered in Claude Code settings (look for "playwright" in mcpServers)
652
+ 2. If available: spend 5 minutes on adversarial interactive exploration using Playwright MCP
653
+ - Attempt race conditions, double-submits, concurrent access patterns
654
+ - Try unexpected input sequences, boundary values, rapid state transitions
655
+ - Probe error recovery: does the app recover after failures or get stuck?
656
+ 3. Tag all findings [EXPLORATORY] in your report
657
+ 4. If Playwright MCP is not available: skip this section silently
658
+ Note: Exploratory findings are additive — they do not replace scripted test results.
659
+
660
+ ## Report Format
661
+
662
+ For each bug found:
663
+ - **BUG-{N}**: {severity: CRITICAL/HIGH/MEDIUM/LOW}
664
+ - **Reproduction**: {exact steps to reproduce}
665
+ - **Expected**: {what should happen}
666
+ - **Actual**: {what actually happens}
667
+ - **Proof**: {test file or command that demonstrates the bug}
668
+
669
+ Summary:
670
+ - BUGS FOUND: {count} (with severity breakdown)
671
+ - COVERAGE GAPS: {untested flows from requirements}
672
+ - SHALLOW TESTS REWRITTEN: {count}
673
+ - CONTRACTS VERIFIED: {N}/{total}
674
+ - ATTACK VECTORS TRIED: {list every category attempted and results}
675
+ - VERDICT: FAIL ({N} bugs found) | GRUDGING PASS (exhaustive search, nothing found)
676
+
677
+ Write all findings to .gsd-t/red-team-report.md.
678
+ If bugs found, also append to .gsd-t/qa-issues.md."
679
+ ```
680
+
681
+ After subagent returns — run via Bash:
682
+ `T_END=$(date +%s) && DT_END=$(date +"%Y-%m-%d %H:%M") && TOK_END=${CLAUDE_CONTEXT_TOKENS_USED:-0} && DURATION=$((T_END-T_START))`
683
+ Compute tokens and compaction:
684
+ - No compaction (TOK_END >= TOK_START): `TOKENS=$((TOK_END-TOK_START))`, COMPACTED=null
685
+ - Compaction detected (TOK_END < TOK_START): `TOKENS=$(((TOK_MAX-TOK_START)+TOK_END))`, COMPACTED=$DT_END
686
+ Append to `.gsd-t/token-log.md`:
687
+ `| {DT_START} | {DT_END} | gsd-t-execute | Red Team | sonnet | {DURATION}s | {VERDICT} — {N} bugs found | {TOKENS} | {COMPACTED} | | | {CTX_PCT} |`
688
+
689
+ **If Red Team VERDICT is FAIL:**
690
+ 1. Fix all CRITICAL and HIGH bugs immediately (up to 2 fix attempts per bug)
691
+ 2. Re-run Red Team after fixes
692
+ 3. If bugs persist after 2 fix cycles, log to `.gsd-t/deferred-items.md` and present to user
693
+
694
+ **If Red Team VERDICT is GRUDGING PASS:** Proceed to completion.
695
+
696
+ ## Step 6: Completion
697
+
698
+ When all tasks in all domains are complete:
699
+ 1. Update `.gsd-t/progress.md` — all tasks marked complete
700
+ 2. Set status to `EXECUTED`
701
+ 3. List any contract deviations or decisions made during execution
702
+
703
+ ### Autonomy Behavior
704
+
705
+ **Level 3 (Full Auto)**: Log a brief status line (e.g., "✅ Execute complete — {N}/{N} tasks done") and auto-advance to the next phase. Do NOT wait for user input.
706
+
707
+ **Level 1–2**: Report completion summary and recommend proceeding to integrate phase. Wait for confirmation.
708
+
709
+ ## Step 7: Doc-Ripple (Automated)
710
+
711
+ After all work is committed but before reporting completion:
712
+
713
+ 1. Run threshold check — read `git diff --name-only HEAD~1` and evaluate against doc-ripple-contract.md trigger conditions
714
+ 2. If SKIP: log "Doc-ripple: SKIP — {reason}" and proceed to completion
715
+ 3. If FIRE: spawn doc-ripple agent:
716
+
717
+ ⚙ [{model}] gsd-t-doc-ripple → blast radius analysis + parallel updates
718
+
719
+ Task subagent (general-purpose, model: sonnet):
720
+ "Execute the doc-ripple workflow per commands/gsd-t-doc-ripple.md.
721
+ Git diff context: {files changed list}
722
+ Command that triggered: execute
723
+ Produce manifest at .gsd-t/doc-ripple-manifest.md.
724
+ Update all affected documents.
725
+ Report: 'Doc-ripple: {N} checked, {N} updated, {N} skipped'"
726
+
727
+ 4. After doc-ripple returns, verify manifest exists and report summary inline
728
+
729
+ ## Document Ripple
730
+
731
+ Execute modifies source code, so the Pre-Commit Gate (referenced in Step 9) covers document updates. For clarity, the key documents affected by execution:
732
+
733
+ ### Always update:
734
+ 1. **`.gsd-t/progress.md`** — Mark tasks complete, update domain status, log execution summary
735
+
736
+ ### Check if affected (per task):
737
+ 2. **`.gsd-t/contracts/`** — Did a task change an API endpoint, schema, or component interface? Update the contract
738
+ 3. **`docs/requirements.md`** — Did a task implement or change a requirement? Mark it complete or revise
739
+ 4. **`docs/architecture.md`** — Did a task add/change a component or data flow? Update it
740
+ 5. **`.gsd-t/techdebt.md`** — Did a task resolve a debt item? Mark it done. Did it reveal new debt? Add it
741
+
742
+ ### Scan Doc Micro-Update (if `.gsd-t/scan/` exists):
743
+ After all tasks complete, patch structural metadata in scan docs so they stay fresh between full scans. This is near-zero cost — no LLM re-analysis, just updating counts and lists from code.
744
+
745
+ For each scan doc that exists, apply only the relevant patches:
746
+ - **`.gsd-t/scan/architecture.md`** — Update file/directory counts, add new files/modules created during execution
747
+ - **`.gsd-t/scan/quality.md`** — Mark resolved TODOs/FIXMEs, update test counts (run `grep -rc "test\|it\|describe" tests/` or equivalent), append new files to Consumer Surfaces table if applicable
748
+ - **`.gsd-t/scan/security.md`** — If a security finding was fixed during execution, mark it `[RESOLVED]`
749
+ - **`.gsd-t/scan/business-rules.md`** — Append any new validation/auth/workflow rules added during execution
750
+ - **`.gsd-t/scan/contract-drift.md`** — If contracts were updated, mark resolved drift items
751
+
752
+ Skip any scan doc that wasn't affected by the executed tasks. Skip analytical sections (assessments, recommendations) — those require a full scan to update.
753
+
754
+ $ARGUMENTS
755
+
756
+ ## Auto-Clear
757
+
758
+ All work is committed to project files. Execute `/clear` to free the context window for the next command.