@tekyzinc/gsd-t 2.51.10 → 2.53.11

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 (100) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +379 -373
  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 -482
  34. package/commands/gsd-t-discuss.md +174 -174
  35. package/commands/gsd-t-execute.md +758 -715
  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-scan-setup.md +1 -5
  41. package/commands/gsd-t-init.md +314 -280
  42. package/commands/gsd-t-integrate.md +365 -333
  43. package/commands/gsd-t-milestone.md +87 -87
  44. package/commands/gsd-t-partition.md +442 -361
  45. package/commands/gsd-t-pause.md +82 -82
  46. package/commands/gsd-t-plan.md +345 -344
  47. package/commands/gsd-t-populate.md +111 -111
  48. package/commands/gsd-t-prd.md +326 -326
  49. package/commands/gsd-t-project.md +211 -211
  50. package/commands/gsd-t-promote-debt.md +123 -123
  51. package/commands/gsd-t-prompt.md +137 -137
  52. package/commands/gsd-t-qa.md +266 -266
  53. package/commands/gsd-t-quick.md +357 -315
  54. package/commands/gsd-t-reflect.md +134 -134
  55. package/commands/gsd-t-resume.md +72 -72
  56. package/commands/gsd-t-scan.md +615 -615
  57. package/commands/gsd-t-setup.md +76 -0
  58. package/commands/gsd-t-status.md +192 -166
  59. package/commands/gsd-t-test-sync.md +381 -381
  60. package/commands/gsd-t-triage-and-merge.md +171 -171
  61. package/commands/gsd-t-verify.md +382 -382
  62. package/commands/gsd-t-visualize.md +118 -118
  63. package/commands/gsd-t-wave.md +401 -378
  64. package/docs/GSD-T-README.md +425 -424
  65. package/docs/architecture.md +385 -369
  66. package/docs/harness-design-analysis.md +371 -0
  67. package/docs/infrastructure.md +205 -205
  68. package/docs/prd-graph-engine.md +398 -398
  69. package/docs/prd-gsd2-hybrid.md +559 -559
  70. package/docs/prd-harness-evolution.md +583 -0
  71. package/docs/requirements.md +14 -0
  72. package/docs/workflows.md +226 -226
  73. package/examples/.gsd-t/domains/example-domain/scope.md +13 -13
  74. package/package.json +40 -40
  75. package/scripts/gsd-t-auto-route.js +39 -39
  76. package/scripts/gsd-t-dashboard-mockup.html +1143 -1143
  77. package/scripts/gsd-t-dashboard-server.js +171 -171
  78. package/scripts/gsd-t-dashboard.html +262 -262
  79. package/scripts/gsd-t-event-writer.js +128 -128
  80. package/scripts/gsd-t-statusline.js +94 -94
  81. package/scripts/gsd-t-tools.js +175 -175
  82. package/templates/CLAUDE-global.md +638 -634
  83. package/templates/CLAUDE-project.md +24 -0
  84. package/templates/backlog-settings.md +18 -18
  85. package/templates/backlog.md +1 -1
  86. package/templates/progress.md +40 -40
  87. package/templates/shared-services-contract.md +60 -60
  88. package/templates/stacks/desktop.ini +2 -2
  89. package/bin/desktop.ini +0 -2
  90. package/commands/desktop.ini +0 -2
  91. package/docs/ci-examples/desktop.ini +0 -2
  92. package/docs/desktop.ini +0 -2
  93. package/examples/.gsd-t/contracts/desktop.ini +0 -2
  94. package/examples/.gsd-t/desktop.ini +0 -2
  95. package/examples/.gsd-t/domains/desktop.ini +0 -2
  96. package/examples/.gsd-t/domains/example-domain/desktop.ini +0 -2
  97. package/examples/desktop.ini +0 -2
  98. package/examples/rules/desktop.ini +0 -2
  99. package/scripts/desktop.ini +0 -2
  100. package/templates/desktop.ini +0 -2
@@ -1,634 +1,638 @@
1
- <!-- GSD-T:START — Do not remove this marker. Content between START/END is managed by gsd-t update. -->
2
- # Prime Directives
3
-
4
- 1. SIMPLICITY ABOVE ALL. Every change should be minimal and impact as little code as possible. No massive refactors.
5
- 2. ALWAYS check for unwanted downstream effects before writing any new code or changing existing code.
6
- 3. ALWAYS check for completeness that any code creation/change/deletion is implemented thoroughly in every relevant file.
7
- 4. ALWAYS work autonomously. ONLY ask for user input when truly blocked.
8
-
9
-
10
- # GSD-T: Contract-Driven Development
11
-
12
- ## Work Hierarchy
13
-
14
- ```
15
- PROJECT or FEATURE or SCAN
16
- └── MILESTONE (major deliverable)
17
- └── PARTITION → DISCUSS → PLAN → IMPACT → EXECUTE → TEST-SYNC → INTEGRATE → VERIFY → COMPLETE
18
- ```
19
-
20
- - **Project**: Full greenfield project → decomposed into milestones
21
- - **Feature**: Major new feature for existing codebase → impact analysis → milestones
22
- - **Scan**: Deep codebase analysis → techdebt.md → promotable to milestones
23
- - **Milestone**: A significant deliverable (e.g., "User Authentication Complete")
24
- - **Domain**: An independent area of responsibility within a milestone, with its own scope, tasks, and file boundaries
25
- - **Contract**: The documented interface between domains — API shapes, schemas, component props
26
-
27
- ## Commands Reference
28
-
29
- | Command | Purpose |
30
- |---------|---------|
31
- | `/user:gsd` | Smart router — describe what you need, auto-routes to the right command |
32
- | `/user:gsd-t-help` | List all commands or get detailed help |
33
- | `/user:gsd-t-prompt` | Help formulate your idea before committing |
34
- | `/user:gsd-t-brainstorm` | Creative exploration and idea generation |
35
- | `/user:gsd-t-prd` | Generate a GSD-T-optimized Product Requirements Document |
36
- | `/user:gsd-t-project` | Full project → milestone roadmap |
37
- | `/user:gsd-t-feature` | Major feature → impact analysis + milestones |
38
- | `/user:gsd-t-scan` | Deep codebase analysis → techdebt.md |
39
- | `/user:gsd-t-gap-analysis` | Requirements gap analysis — spec vs. existing code |
40
- | `/user:gsd-t-promote-debt` | Convert debt items to milestones |
41
- | `/user:gsd-t-setup` | Generate or restructure project CLAUDE.md |
42
- | `/user:gsd-t-init` | Initialize project structure |
43
- | `/user:gsd-t-init-scan-setup` | Full onboarding: git + init + scan + setup in one |
44
- | `/user:gsd-t-milestone` | Define new milestone |
45
- | `/user:gsd-t-partition` | Decompose into domains + contracts |
46
- | `/user:gsd-t-discuss` | Multi-perspective design exploration |
47
- | `/user:gsd-t-plan` | Create atomic task lists per domain (tasks auto-split to fit one context window) |
48
- | `/user:gsd-t-impact` | Analyze downstream effects before execution |
49
- | `/user:gsd-t-execute` | Run tasks — task-level fresh dispatch, worktree isolation, adaptive replanning, active rule injection |
50
- | `/user:gsd-t-test-sync` | Keep tests aligned with code changes |
51
- | `/user:gsd-t-qa` | QA agent — test generation, execution, gap reporting |
52
- | `/user:gsd-t-doc-ripple` | Automated document ripple — update downstream docs after code changes |
53
- | `/user:gsd-t-integrate` | Wire domains together |
54
- | `/user:gsd-t-verify` | Run quality gates + goal-backward behavior verification |
55
- | `/user:gsd-t-complete-milestone` | Archive milestone + git tag (goal-backward gate, rule engine distillation) |
56
- | `/user:gsd-t-wave` | Full cycle (auto-advances all phases) |
57
- | `/user:gsd-t-status` | Cross-domain progress view with token breakdown, global ELO and cross-project rankings |
58
- | `/user:gsd-t-debug` | Systematic debugging |
59
- | `/user:gsd-t-quick` | Fast task, respects contracts |
60
- | `/user:gsd-t-reflect` | Generate retrospective from event stream, propose memory updates |
61
- | `/user:gsd-t-visualize` | Launch browser dashboard |
62
- | `/user:gsd-t-metrics` | View task telemetry, process ELO, domain health, and cross-project comparison (`--cross-project`) |
63
- | `/user:gsd-t-health` | Validate .gsd-t/ structure, optionally repair |
64
- | `/user:gsd-t-pause` | Save exact position for reliable resume |
65
- | `/user:gsd-t-populate` | Auto-populate docs from existing codebase |
66
- | `/user:gsd-t-log` | Sync progress Decision Log with recent git activity |
67
- | `/user:gsd-t-resume` | Restore context, continue |
68
- | `/user:gsd-t-version-update` | Update GSD-T to latest version |
69
- | `/user:gsd-t-version-update-all` | Update GSD-T + all registered projects |
70
- | `/user:gsd-t-triage-and-merge` | Auto-review, merge, and publish GitHub branches |
71
- | `/user:gsd-t-backlog-add` | Capture item, auto-categorize, append to backlog |
72
- | `/user:gsd-t-backlog-list` | Filtered, ordered view of backlog items |
73
- | `/user:gsd-t-backlog-move` | Reorder items by position (priority) |
74
- | `/user:gsd-t-backlog-edit` | Modify backlog entry fields |
75
- | `/user:gsd-t-backlog-remove` | Drop item with optional reason |
76
- | `/user:gsd-t-backlog-promote` | Refine, classify, launch GSD-T workflow |
77
- | `/user:gsd-t-backlog-settings` | Manage types, apps, categories, defaults |
78
- | `/user:branch` | Create and switch to a new git branch |
79
- | `/user:checkin` | Auto-bump version, stage, commit, and push |
80
- | `/user:Claude-md` | Reload and apply CLAUDE.md directives |
81
- | `/global-change` | Apply file changes across all registered GSD-T projects |
82
-
83
-
84
- # Living Documents
85
-
86
- These documents MUST be maintained and referenced throughout development:
87
-
88
- | Document | Location | Purpose |
89
- |----------|----------|---------|
90
- | **Requirements** | `docs/requirements.md` | Functional and technical requirements |
91
- | **Architecture** | `docs/architecture.md` | System design, components, data flow, decisions |
92
- | **Workflows** | `docs/workflows.md` | User journeys and technical process flows |
93
- | **Infrastructure** | `docs/infrastructure.md` | Commands, DB setup, server access, creds |
94
- | **README** | `README.md` | Project overview, setup, features |
95
- | **Progress** | `.gsd-t/progress.md` | Current milestone/phase state + version |
96
- | **Contracts** | `.gsd-t/contracts/` | Interfaces between domains |
97
- | **Tech Debt** | `.gsd-t/techdebt.md` | Debt register from scans |
98
-
99
- ## The "No Re-Research" Rule
100
-
101
- **BEFORE researching how something works, CHECK THE DOCS FIRST.**
102
-
103
- ```
104
- NEED TO UNDERSTAND SOMETHING?
105
- ├── Is it about system structure/components? → Read docs/architecture.md
106
- ├── Is it about how a process flows? → Read docs/workflows.md
107
- ├── Is it about what to build? → Read docs/requirements.md
108
- ├── Is it about how to deploy/operate? → Read docs/infrastructure.md
109
- ├── Is it about domain interfaces? → Read .gsd-t/contracts/
110
- └── Not documented? → Research, then DOCUMENT IT
111
- ```
112
-
113
-
114
- # Versioning
115
-
116
- GSD-T tracks project version in `.gsd-t/progress.md` using semantic versioning: `Major.Minor.Patch`
117
-
118
- | Segment | Bumped When | Example |
119
- |---------|-------------|---------|
120
- | **Major** | Breaking changes, major rework, v1 launch | 1.0.10 → 2.0.10 |
121
- | **Minor** | New features, completed feature milestones | 1.10.10 → 1.11.10 |
122
- | **Patch** | Bug fixes, minor improvements, cleanup | 1.1.10 → 1.1.11 |
123
-
124
- **Patch convention**: Patch numbers are always 2 digits (≥10). When resetting after a minor or major bump, start at **10** (not 0). This keeps patches always 2 characters without leading zeros, so semver stays valid.
125
-
126
- - Version is set during `gsd-t-init`:
127
- - **New project** (no existing manifest version): starts at `0.1.00` — first `complete-milestone` resets patch to `0.1.10`
128
- - **Existing repo** (has `package.json`, `pyproject.toml`, `Cargo.toml`, etc. with a version): use that version as the starting point
129
- - Version is bumped during `gsd-t-complete-milestone` based on milestone scope
130
- - Version is reflected in: `progress.md`, `README.md`, package manifest (if any), and git tags (`v{version}`)
131
-
132
-
133
- # Destructive Action Guard (MANDATORY)
134
-
135
- **NEVER perform destructive or structural changes without explicit user approval.** This applies at ALL autonomy levels, including Level 3.
136
-
137
- ```
138
- BEFORE any of these actions, STOP and ask the user:
139
- ├── DROP TABLE, DROP COLUMN, DROP INDEX, TRUNCATE, DELETE without WHERE
140
- ├── Renaming or removing database tables or columns
141
- ├── Schema migrations that lose data or break existing queries
142
- ├── Replacing an existing architecture pattern (e.g., normalized denormalized)
143
- ├── Removing or replacing existing files/modules that contain working functionality
144
- ├── Changing ORM models in ways that conflict with the existing database schema
145
- ├── Removing API endpoints or changing response shapes that existing clients depend on
146
- ├── Replacing a dependency or framework with a different one
147
- └── Any change that would require other parts of the system to be rewritten
148
- ```
149
-
150
- ### How to handle schema/architecture mismatches:
151
- 1. **READ the existing schema/code first** — understand what exists before proposing changes
152
- 2. **Adapt new code to match existing structures** — not the other way around
153
- 3. **If restructuring is truly needed**, present the case to the user with:
154
- - What exists today and why it might have been designed that way
155
- - What you want to change and why
156
- - What will break if you make the change
157
- - What data or functionality will be lost
158
- - A migration path that preserves existing data
159
- 4. **Wait for explicit approval** before proceeding
160
-
161
- ### Why this matters:
162
- Even in development, the user may have:
163
- - Working functionality they've tested and rely on
164
- - Data they've carefully set up (seed data, test accounts, configuration)
165
- - Other code that depends on the current structure
166
- - Design decisions made for reasons not documented
167
-
168
- **"Adapt to what exists" is always safer than "replace what exists."**
169
-
170
-
171
- # Autonomous Execution Rules
172
-
173
- ## Update Notices
174
-
175
- On session start, a version check hook auto-updates GSD-T and outputs a status message. Show the result to the user at the **beginning** of your first response:
176
-
177
- - If `[GSD-T AUTO-UPDATE]` appears → GSD-T was just auto-updated. Show:
178
- ```
179
- ✅ GSD-T auto-updated: v{old} → v{new}
180
- Changelog: https://github.com/Tekyz-Inc/get-stuff-done-teams/blob/main/CHANGELOG.md
181
- ```
182
-
183
- - If `[GSD-T UPDATE]` appears → update available but auto-update failed. Show:
184
- ```
185
- ⬆️ GSD-T update available: v{installed} → v{latest} (auto-update failed)
186
- Run: /user:gsd-t-version-update-all
187
- Changelog: https://github.com/Tekyz-Inc/get-stuff-done-teams/blob/main/CHANGELOG.md
188
- ```
189
- Also repeat at the **end** of your first response.
190
-
191
- - If `[GSD-T]` appears → up to date. Show:
192
- ```
193
- GSD-T v{version} — up to date
194
- Changelog: https://github.com/Tekyz-Inc/get-stuff-done-teams/blob/main/CHANGELOG.md
195
- ```
196
-
197
- ## Conversation vs. Work
198
-
199
- Only execute GSD-T workflow behavior when a `/gsd-t-*` command is invoked or when actively mid-phase (resumed via `/gsd-t-resume`). **Plain text messages — especially questions — should be answered conversationally.** Do not launch into workflow execution, file reading, or phase advancement from a question or comment. If the user wants work done, they will invoke a command.
200
-
201
- **Exception — Auto-Route signal**: When `[GSD-T AUTO-ROUTE]` appears in your context (injected by the UserPromptSubmit hook), the user's plain text message should be treated as a `/user:gsd {message}` invocation. Execute the `/gsd` smart router with the user's full message as the argument instead of replying conversationally. The hook only fires in GSD-T projects (directories containing `.gsd-t/progress.md`) — it silently passes through in all other directories.
202
-
203
- ## Auto-Init Guard
204
-
205
- Before executing any GSD-T workflow command, check if **any** of these files are missing in the current project:
206
- - `.gsd-t/progress.md`, `.gsd-t/backlog.md`, `.gsd-t/backlog-settings.md`
207
- - `.gsd-t/contracts/`, `.gsd-t/domains/`
208
- - `.claude/settings.local.json` (if `~/.claude/settings.local` exists)
209
- - `CLAUDE.md`, `README.md`
210
- - `docs/requirements.md`, `docs/architecture.md`, `docs/workflows.md`, `docs/infrastructure.md`
211
-
212
- If any are missing:
213
- 1. Run `gsd-t-init` automatically (it skips files that already exist)
214
- 2. Then continue with the originally requested command
215
-
216
- **Exempt commands** (do not trigger auto-init): `gsd-t-init`, `gsd-t-init-scan-setup`, `gsd-t-help`, `gsd-t-version-update`, `gsd-t-version-update-all`.
217
-
218
- ## Playwright Readiness Guard
219
-
220
- Before any command that involves testing (`gsd-t-execute`, `gsd-t-test-sync`, `gsd-t-verify`, `gsd-t-quick`, `gsd-t-wave`, `gsd-t-milestone`, `gsd-t-complete-milestone`, `gsd-t-debug`), check if `playwright.config.*` exists in the project. If it does not:
221
- 1. Detect the package manager and install Playwright (`@playwright/test` + chromium)
222
- 2. Create a basic `playwright.config.ts` with sensible defaults
223
- 3. Create the E2E test directory with a placeholder spec
224
- 4. Then continue with the original command
225
-
226
- Playwright must always be ready before any testing occurs. Do not skip this check. Do not defer setup to "later."
227
-
228
- ### Playwright Cleanup
229
-
230
- After Playwright tests finish (pass or fail), **kill any app/server processes that were started for the tests**. Playwright often launches a dev server (via `webServer` config or manually). These processes must not be left running:
231
- 1. Check for any dev server processes spawned during the test run
232
- 2. Kill them (e.g., `npx kill-port`, or terminate the process directly)
233
- 3. Verify the port is free before proceeding
234
-
235
- This applies everywhere Playwright tests are executed: execute, test-sync, verify, quick, wave, debug, complete-milestone, and integrate.
236
-
237
- ### E2E Enforcement Rule (MANDATORY)
238
-
239
- **Running only unit tests when E2E tests exist is a test failure.** This is non-negotiable.
240
-
241
- ```
242
- BEFORE reporting "tests pass" for ANY task:
243
- ├── Does playwright.config.* or cypress.config.* exist?
244
- │ YES → You MUST run the full E2E suite. Unit-only results are INCOMPLETE.
245
- │ NO → Unit/integration tests are sufficient.
246
- ├── Did you run every detected test runner?
247
- │ NO → Run it now. Do not commit until ALL suites pass.
248
- └── Report format MUST include all suites:
249
- "Unit: X/Y pass | E2E: X/Y pass" (or "E2E: N/A — no config")
250
- ```
251
-
252
- The conditional "if UI/routes/flows changed" in command files applies to **writing new E2E specs**, not to **running existing ones**. You always run existing E2E specs. Always.
253
-
254
- ### E2E Test Quality Standard (MANDATORY)
255
-
256
- **E2E tests must be FUNCTIONAL tests, not LAYOUT tests.** This is non-negotiable.
257
-
258
- A layout test checks that elements exist (`isVisible`, `toBeAttached`, `toBeEnabled`, `toHaveCount`). A functional test checks that features work — actions produce correct outcomes.
259
-
260
- ```
261
- LAYOUT TEST (WRONG — passes even if every feature is broken):
262
- await expect(page.locator('#tab-sessions')).toBeVisible();
263
- await page.click('#tab-sessions');
264
- // ← No assertion that the tab's content actually loaded
265
-
266
- FUNCTIONAL TEST (RIGHT — fails if the feature is broken):
267
- await page.click('#tab-sessions');
268
- await expect(page.locator('.session-list')).toContainText('Session 1');
269
- // ← Proves clicking the tab loaded the session data
270
- ```
271
-
272
- Every Playwright assertion must verify one of:
273
- - **State changed**: After click/type/submit, the app state is different (new content, updated data, changed status)
274
- - **Data flowed**: User input → API call → response rendered (use `page.waitForResponse` or assert on rendered data)
275
- - **Content loaded**: Navigation/tab switch → destination content appeared (assert on text/data unique to destination)
276
- - **Widget responded**: Terminal accepted keystrokes and produced output, editor saved changes, form submitted and data persisted
277
-
278
- **If a test would pass on an empty HTML page with the correct element IDs and no JavaScript, it is not a functional test.** Rewrite it.
279
-
280
- ## QA Agent (Mandatory)
281
-
282
- Any GSD-T phase that produces or validates code **MUST run QA**. The QA agent's sole job is test generation, execution, and gap reporting. It never writes feature code.
283
-
284
- **QA method by command:**
285
- - `execute`, `integrate` → spawn QA via **Task subagent** (lightweight, no TeamCreate)
286
- - `test-sync`, `verify`, `complete-milestone` → perform contract testing and gap analysis **inline**
287
- - `quick`, `debug` → run the full test suite **inline** as part of the command's Test & Verify step
288
- - `wave` → each phase agent handles QA per the rules above
289
- - `partition`, `plan` → no QA spawn needed (no code produced yet)
290
-
291
- **Task subagent spawn instruction (execute/integrate):**
292
- ```
293
- Task subagent (general-purpose):
294
- "Run ALL configured test suites — detect and run every one:
295
- a. Unit tests (vitest/jest/mocha): run the full suite
296
- b. E2E tests: check for playwright.config.* or cypress.config.* — if found, run the FULL E2E suite
297
- c. NEVER skip E2E when a config file exists. Running only unit tests is a QA FAILURE.
298
- d. Read .gsd-t/contracts/ for contract definitions. Check contract compliance.
299
- e. AUDIT E2E test quality: Review each Playwright spec — if any test only checks element
300
- existence (isVisible, toBeAttached, toBeEnabled) without verifying functional behavior
301
- (state changes, data loaded, content updated after user actions), flag it as
302
- 'SHALLOW TEST — needs functional assertions'. A passing test suite that doesn't catch
303
- broken features is a QA FAILURE.
304
- Report format: 'Unit: X/Y pass | E2E: X/Y pass (or N/A if no config) | Contract: compliant/violations | Shallow tests: N'"
305
- ```
306
-
307
- **QA failure OR shallow tests found blocks phase completion.** Lead cannot proceed until QA reports PASS with zero shallow tests, or user explicitly overrides.
308
-
309
- ## Red Team Adversarial QA (Mandatory)
310
-
311
- After QA passes, every code-producing command spawns a **Red Team agent** an adversarial subagent whose success is measured by bugs found, not tests passed. This inverts the incentive structure: the Red Team's drive toward "task complete" means digging deeper and finding more bugs, not rubber-stamping.
312
-
313
- **Red Team method by command:**
314
- - `execute` → spawns Red Team after all domain tasks pass (Step 5.5)
315
- - `integrate` → spawns Red Team after integration tests pass (Step 7.5)
316
- - `quick` → spawns Red Team after Test & Verify passes (Step 5.5)
317
- - `debug` → spawns Red Team after fix verification passes (Step 5.3)
318
- - `wave` → each phase agent handles Red Team per the rules above
319
-
320
- **Key Red Team rules:**
321
- - **Inverted incentive**: More bugs found = more value. Zero bugs requires exhaustive proof of thoroughness.
322
- - **False positive penalty**: Reporting non-bugs destroys credibility. Every bug must be reproduced with proof.
323
- - **Exhaustive categories**: Contract violations, boundary inputs, state transitions, error paths, missing flows, regression, E2E functional gaps — all must be attempted.
324
- - **VERDICT**: `FAIL` (bugs found blocks completion) or `GRUDGING PASS` (exhaustive search, nothing found).
325
- - **Report**: Written to `.gsd-t/red-team-report.md`; bugs also appended to `.gsd-t/qa-issues.md`.
326
-
327
- **Red Team FAIL blocks phase completion.** CRITICAL/HIGH bugs must be fixed (up to 2 fix cycles). If bugs persist, they are logged to `.gsd-t/deferred-items.md` and presented to the user.
328
-
329
- ## Model Display (MANDATORY)
330
-
331
- **Before every subagent spawn, display the model being used to the user:**
332
- `⚙ [{model}] {command} → {brief description}` (e.g., `⚙ [sonnet] gsd-t-execute → domain: auth-service`, `⚙ [haiku] gsd-t-execute → QA validation`)
333
-
334
- This gives the user real-time visibility into which model is handling each operation.
335
-
336
- **Model assignments:**
337
- - `model: haiku` — mechanical tasks: run tests, count pass/fail, validate structure, check file existence, report status
338
- - `model: sonnet` — mid-tier reasoning: routine code changes, standard refactors, test writing, straightforward synthesis
339
- - `model: opus` — high-stakes reasoning: architecture decisions, security analysis, complex debugging, cross-module refactors, quality judgment on critical paths
340
-
341
- ## API Documentation Guard (Swagger/OpenAPI)
342
-
343
- **Every API endpoint MUST be documented in a Swagger/OpenAPI spec. No exceptions.**
344
-
345
- When any GSD-T command creates or modifies an API endpoint:
346
- 1. **If no Swagger/OpenAPI spec exists**: Set one up immediately
347
- - Detect the framework (Express, Fastify, Hono, Django, FastAPI, etc.)
348
- - Install the appropriate Swagger integration (e.g., `swagger-jsdoc` + `swagger-ui-express`, `@fastify/swagger`, FastAPI's built-in OpenAPI)
349
- - Create the OpenAPI spec file or configure auto-generation from code
350
- - Add a `/docs` or `/api-docs` route serving the Swagger UI
351
- 2. **Update the spec**: Every new or changed endpoint must be reflected in the Swagger/OpenAPI spec — routes, request/response schemas, auth requirements, error responses
352
- 3. **Publish the Swagger URL**: The Swagger/API docs URL MUST appear in:
353
- - `CLAUDE.md` under Documentation or Infrastructure section
354
- - `README.md` under API section or Getting Started
355
- - `docs/infrastructure.md`under API documentation
356
- 4. **Verify**: After any API change, confirm the Swagger UI loads and reflects the current endpoints
357
-
358
- This applies during: `gsd-t-execute`, `gsd-t-quick`, `gsd-t-integrate`, `gsd-t-wave`, and any command that touches API code.
359
-
360
- ## Prime Rule
361
- KEEP GOING. Only stop for:
362
- 1. Unrecoverable errors after 2 fix attempts (delegate to `gsd-t headless --debug-loop` first only stop if exit code 4)
363
- 2. Ambiguity that fundamentally changes project direction
364
- 3. Milestone completion (checkpoint for user review)
365
- 4. Destructive actions (see Destructive Action Guard above — ALWAYS stop)
366
-
367
- ## Pre-Commit Gate (MANDATORY)
368
-
369
- NEVER commit code without running this checklist. This is not optional.
370
-
371
- ```
372
- BEFORE EVERY COMMIT:
373
- ├── Am I on the correct branch?
374
- │ CHECK → Run `git branch --show-current`
375
- │ Compare against "Expected branch" in project CLAUDE.md
376
- │ WRONG BRANCH → STOP. Do NOT commit. Switch to the correct branch first.
377
- │ No guard set Proceed (but warn user to set one)
378
- ├── Did I create or change an API endpoint or response shape?
379
- YES Update .gsd-t/contracts/api-contract.md
380
- YESUpdate Swagger/OpenAPI spec (see API Documentation Guard below)
381
- YESVerify Swagger URL is in CLAUDE.md and README.md
382
- ├── Did I change the database schema?
383
- │ YES → Update .gsd-t/contracts/schema-contract.md AND docs/schema.md
384
- ├── Did I add/change a UI component interface?
385
- │ YES → Update .gsd-t/contracts/component-contract.md
386
- ├── Did I add new files or directories?
387
- │ YES → Update the owning domain's scope.md
388
- ├── Did I implement or change a requirement?
389
- │ YES → Update docs/requirements.md (mark complete or revise)
390
- ├── Did I add/change/remove a component or change data flow?
391
- │ YES → Update docs/architecture.md
392
- ├── Did I modify any document, script, or code file?
393
- │ YES → Add timestamped entry to .gsd-t/progress.md Decision Log
394
- │ Format: `- YYYY-MM-DD HH:MM: {what was done} {brief context or result}`
395
- This includes ALL file-modifying activities:
396
- │ project, feature, scan, gap-analysis, milestone, partition, discuss,
397
- plan, impact, execute, test-sync, integrate, verify, complete-milestone,
398
- wave, quick, debug, promote-debt, populate, setup, init, init-scan-setup,
399
- backlog-add/edit/move/remove/promote/settings, and any manual code changes
400
- ├── Did I make an architectural or design decision?
401
- YES Also include decision rationale in the progress.md entry
402
- ├── Did I discover or fix tech debt?
403
- YES Update .gsd-t/techdebt.md
404
- ├── Did I establish a pattern future work should follow?
405
- │ YES → Update CLAUDE.md or domain constraints.md
406
- ├── Did I add/change tests?
407
- │ YES → Verify test names and paths are referenced in requirements
408
- ├── Did I change UI, routes, or user flows?
409
- │ YES → Update affected E2E test specs (Playwright/Cypress)
410
- └── Did I run the affected tests?
411
- YES → Verify they pass. NO Run them now.
412
- ```
413
-
414
- If ANY answer is YES and the doc is NOT updated, update it BEFORE committing. No exceptions.
415
-
416
- ## Document Ripple Completion Gate (MANDATORY)
417
-
418
- **NEVER report a task as "done" or present a summary until ALL downstream documents are updated.** This is not optional.
419
-
420
- When a change affects multiple files (e.g., a new standard that applies across command files, a renamed API, a new convention), you MUST:
421
-
422
- 1. **Identify the full blast radius BEFORE starting**: List every file that needs the change
423
- 2. **Complete ALL updates in one pass**: Do not update 3 of 8 files and then present a summary
424
- 3. **Run the Pre-Commit Gate on the COMPLETE changeset**: Not on a partial subset
425
- 4. **Only THEN report completion**
426
-
427
- ```
428
- BEFORE reporting "done" or presenting a summary:
429
- ├── Did this change establish a new standard, rule, or convention?
430
- │ YES → Grep for every file that should enforce it. Update ALL of them.
431
- ├── Did this change modify a pattern used in multiple command files?
432
- │ YES Find and update EVERY command file that uses that pattern.
433
- ├── Did this change affect a template (CLAUDE-global, CLAUDE-project, etc.)?
434
- │ YES → The template AND the live equivalent (~/.claude/CLAUDE.md) must match.
435
- ├── Did this change add a new requirement?
436
- │ YES → Add to docs/requirements.md in the same pass.
437
- ├── Have I checked EVERY file in the blast radius?
438
- NOKeep going. Do not present partial work.
439
- └── Am I about to say "want me to also update X?" or "should I check Y?"
440
- YES → STOP. Just update X and check Y. Then report done.
441
- ```
442
-
443
- **The test for this gate**: If the user asks "did you update all the documents?" and the answer would be "no, I missed some" — you failed this gate. The user should never need to ask.
444
-
445
- ## Execution Behavior
446
- - ALWAYS check docs/architecture.md before adding or modifying components.
447
- - ALWAYS check docs/workflows.md before changing any multi-step process.
448
- - ALWAYS update docs as part of completing work — not as an afterthought.
449
- - ALWAYS self-verify work by running tests and verification commands.
450
- - NEVER re-research how something works if you built it — it should be documented.
451
- - NEVER pause to show verification steps execute them.
452
- - NEVER ask "should I continue?"just continue.
453
- - NEVER summarize what you're "about to do" just do it.
454
- - IF a test fails, fix it immediately (up to 2 attempts) before reporting. If both attempts fail, delegate to `gsd-t headless --debug-loop` before stopping.
455
-
456
- ## Autonomy Levels
457
-
458
- Projects can specify an autonomy level in their project CLAUDE.md:
459
-
460
- | Level | Behavior |
461
- |-------|----------|
462
- | **Level 1: Supervised** | Pause at each phase for confirmation |
463
- | **Level 2: Standard** | Pause only at milestones |
464
- | **Level 3: Full Auto** | Only pause for blockers or project completion (default) |
465
-
466
- If not specified, use Level 3.
467
-
468
- ## Workflow Preferences (Defaults override in project CLAUDE.md)
469
-
470
- ### Research Policy
471
- Before planning a phase, evaluate whether research is needed:
472
-
473
- **Run research when:**
474
- - Phase involves unfamiliar libraries, APIs, or services
475
- - Architectural decisions are required
476
- - Integrating external systems
477
- - Phase scope is ambiguous or complex
478
-
479
- **Skip research when:**
480
- - Patterns are already established from earlier phases
481
- - Straightforward CRUD, UI, or config work
482
- - Domain is well understood
483
- - Phase builds directly on existing code patterns
484
-
485
- If in doubt, skip research and proceed — research if execution reveals gaps.
486
-
487
- ### Phase Flow
488
- - Upon completing a phase, automatically proceed to the next phase
489
- - ONLY run Discussion phase if truly required (clear path skip to Plan)
490
- - ALWAYS self-verify work by running verification commands
491
- - NEVER pause to show verification steps — execute them
492
-
493
- ### Next Command Hint
494
-
495
- When a GSD-T command completes (and does NOT auto-advance to the next phase), display a "Next Up" block at the very end of your response. This format is designed to trigger Claude Code's prompt suggestion engine making the next command appear as ghost text in the user's input field.
496
-
497
- **MANDATORY format** use this exact structure:
498
-
499
- ```
500
- ───────────────────────────────────────────────────────────────
501
-
502
- ## ▶ Next Up
503
-
504
- **{Phase Name}** — {one-line description of what happens next}
505
-
506
- `/user:gsd-t-{command}`
507
-
508
- ───────────────────────────────────────────────────────────────
509
- ```
510
-
511
- If there are alternative commands that also make sense, add them:
512
-
513
- ```
514
- **Also available:**
515
- - `/user:gsd-t-{alt-1}` {description}
516
- - `/user:gsd-t-{alt-2}` — {description}
517
- ```
518
-
519
- Successor mapping:
520
- | Completed | Next | Also available |
521
- |-----------|------|----------------|
522
- | `project` | `milestone` | |
523
- | `feature` | `milestone` | |
524
- | `milestone` | `partition` | |
525
- | `partition` | `plan` | `discuss` (if complex) |
526
- | `discuss` | `plan` | |
527
- | `plan` | `execute` | `impact` (if risky) |
528
- | `impact` | `execute` | |
529
- | `execute` | `test-sync` | |
530
- | `test-sync` | `verify` | `integrate` (if multi-domain) |
531
- | `integrate` | `verify` | |
532
- | `verify` | *(auto-invokes complete-milestone)* | |
533
- | `complete-milestone` | `status` | |
534
- | `scan` | `promote-debt` | `milestone` |
535
- | `init` | `scan` | `milestone` |
536
- | `init-scan-setup` | `milestone` | |
537
- | `gap-analysis` | `milestone` | `feature` |
538
- | `populate` | `status` | |
539
- | `setup` | `status` | |
540
-
541
- Commands with no successor (standalone): `quick`, `debug`, `brainstorm`, `status`, `help`, `resume`, `prompt`, `log`, `health`, `pause`, backlog commands.
542
-
543
- Skip the hint if auto-advancing (Level 3 mid-wave) — only show when the user needs to manually invoke the next step.
544
-
545
-
546
- # Don't Do These Things
547
-
548
- - NEVER perform destructive or structural changes without explicit user approval (see Destructive Action Guard above).
549
- - NEVER drop database tables, remove columns, or run destructive SQL on an existing database — adapt new code to the existing schema.
550
- - NEVER replace existing architecture patterns (e.g., normalized → denormalized) without user approval — even if you think the new way is better.
551
- - NEVER commit code without running the Pre-Commit Gate checklist. EVERY commit.
552
- - NEVER batch doc updates for later update docs as part of the same commit as the code change.
553
- - NEVER start a phase without reading contracts and relevant docs first.
554
- - NEVER complete a phase without running document ripple on affected docs.
555
- - NEVER re-research how a component works read architecture.md and contracts.
556
- - NEVER let code and contract disagreefix one or the other immediately.
557
- - NEVER make changes that touch more than 3 files without pausing to confirm approach.
558
-
559
-
560
- # Code Standards (Defaultsoverride in project CLAUDE.md)
561
-
562
- ## Patterns
563
- - Type hints required on all function signatures
564
- - Dataclasses/interfaces for data models, not raw dicts
565
- - Functions under 30 lines — split if longer
566
- - Files under 200 lines — create new modules if needed
567
- - Enums for state management and fixed option sets
568
-
569
- ## Naming
570
- ```
571
- files: snake_case (user_service.py)
572
- classes: PascalCase (UserService)
573
- functions: snake_case (get_user)
574
- constants: UPPER_SNAKE_CASE (MAX_RETRIES)
575
- private: _underscore (_internal_method)
576
- ```
577
-
578
- ## Markdown Tables
579
-
580
- Emoji display as 2 characters wide in terminal/monospace but count as 1 in string length. This causes misaligned columns. **Always add one extra space after emoji in table cells** to compensate:
581
-
582
- ```
583
- WRONG — misaligned in terminal:
584
- | Channel | Support |
585
- |----------|---------|
586
- | Discord | ✅ |
587
- | LINE | |
588
-
589
- RIGHT — one extra space after emoji:
590
- | Channel | Support |
591
- |----------|---------|
592
- | Discord | ✅ |
593
- | LINE | ❌ |
594
- ```
595
-
596
- This extra space is invisible in rendered HTML (GitHub, VS Code preview) but restores alignment in terminal views. Apply to all GSD-T-generated docs that use emoji in tables.
597
-
598
- Also pad all cell values in a column to the width of the widest value:
599
- ```
600
- | iMessage (BlueBubbles) | ✅ |
601
- | Discord | ✅ |
602
- | QQ | ❌ |
603
- ```
604
-
605
-
606
- ## Stack Rules Engine
607
-
608
- GSD-T auto-detects project tech stack at subagent spawn time and injects mandatory best-practice rules into the subagent prompt.
609
-
610
- **Detection sources**: `package.json` (React, TypeScript, Node API), `requirements.txt`/`pyproject.toml` (Python), `go.mod` (Go), `Cargo.toml` (Rust).
611
-
612
- **Universal rules**: Templates prefixed with `_` (e.g., `_security.md`) are **always** injected, regardless of stack.
613
-
614
- **Stack-specific rules**: Injected only when the matching stack is detected (e.g., `react.md` when `"react"` is in `package.json`).
615
-
616
- **Enforcement**: Stack rule violations have the same weight as contract violations — they are task failures, not warnings.
617
-
618
- **Extensible**: Drop a `.md` file into `templates/stacks/` in the GSD-T package to add rules for a new stack. If the directory is missing, detection skips silently.
619
-
620
- **Commands that inject stack rules**: `gsd-t-execute`, `gsd-t-quick`, `gsd-t-integrate`, `gsd-t-wave`, `gsd-t-debug`.
621
-
622
-
623
- # Recovery After Interruption
624
-
625
- When resuming work (new session or after /clear):
626
- 1. Read `.gsd-t/progress.md` for current state
627
- 2. Read `docs/requirements.md` for what's left to build
628
- 3. Read `docs/architecture.md` for how the system is structured
629
- 4. Read `.gsd-t/contracts/` for domain interfaces
630
- 5. Verify last task's work is intact (files exist, tests pass)
631
- 6. Continue from current task — don't restart the phase
632
-
633
- **CRITICAL: Do NOT research how the system works. The docs tell you. Read them.**
634
- <!-- GSD-T:END Do not remove this marker. -->
1
+ <!-- GSD-T:START — Do not remove this marker. Content between START/END is managed by gsd-t update. -->
2
+ # Prime Directives
3
+
4
+ 1. SIMPLICITY ABOVE ALL. Every change should be minimal and impact as little code as possible. No massive refactors.
5
+ 2. ALWAYS check for unwanted downstream effects before writing any new code or changing existing code.
6
+ 3. ALWAYS check for completeness that any code creation/change/deletion is implemented thoroughly in every relevant file.
7
+ 4. ALWAYS work autonomously. ONLY ask for user input when truly blocked.
8
+
9
+
10
+ # GSD-T: Contract-Driven Development
11
+
12
+ ## Work Hierarchy
13
+
14
+ ```
15
+ PROJECT or FEATURE or SCAN
16
+ └── MILESTONE (major deliverable)
17
+ └── PARTITION → DISCUSS → PLAN → IMPACT → EXECUTE → TEST-SYNC → INTEGRATE → VERIFY → COMPLETE
18
+ ```
19
+
20
+ - **Project**: Full greenfield project → decomposed into milestones
21
+ - **Feature**: Major new feature for existing codebase → impact analysis → milestones
22
+ - **Scan**: Deep codebase analysis → techdebt.md → promotable to milestones
23
+ - **Milestone**: A significant deliverable (e.g., "User Authentication Complete")
24
+ - **Domain**: An independent area of responsibility within a milestone, with its own scope, tasks, and file boundaries
25
+ - **Contract**: The documented interface between domains — API shapes, schemas, component props
26
+
27
+ ## Commands Reference
28
+
29
+ | Command | Purpose |
30
+ |---------|---------|
31
+ | `/user:gsd` | Smart router — describe what you need, auto-routes to the right command |
32
+ | `/user:gsd-t-help` | List all commands or get detailed help |
33
+ | `/user:gsd-t-prompt` | Help formulate your idea before committing |
34
+ | `/user:gsd-t-brainstorm` | Creative exploration and idea generation |
35
+ | `/user:gsd-t-prd` | Generate a GSD-T-optimized Product Requirements Document |
36
+ | `/user:gsd-t-project` | Full project → milestone roadmap |
37
+ | `/user:gsd-t-feature` | Major feature → impact analysis + milestones |
38
+ | `/user:gsd-t-scan` | Deep codebase analysis → techdebt.md |
39
+ | `/user:gsd-t-gap-analysis` | Requirements gap analysis — spec vs. existing code |
40
+ | `/user:gsd-t-promote-debt` | Convert debt items to milestones |
41
+ | `/user:gsd-t-setup` | Generate or restructure project CLAUDE.md |
42
+ | `/user:gsd-t-init` | Initialize project structure |
43
+ | `/user:gsd-t-init-scan-setup` | Full onboarding: git + init + scan + setup in one |
44
+ | `/user:gsd-t-milestone` | Define new milestone |
45
+ | `/user:gsd-t-partition` | Decompose into domains + contracts |
46
+ | `/user:gsd-t-discuss` | Multi-perspective design exploration |
47
+ | `/user:gsd-t-plan` | Create atomic task lists per domain (tasks auto-split to fit one context window) |
48
+ | `/user:gsd-t-impact` | Analyze downstream effects before execution |
49
+ | `/user:gsd-t-execute` | Run tasks — task-level fresh dispatch, worktree isolation, adaptive replanning, active rule injection |
50
+ | `/user:gsd-t-test-sync` | Keep tests aligned with code changes |
51
+ | `/user:gsd-t-qa` | QA agent — test generation, execution, gap reporting |
52
+ | `/user:gsd-t-doc-ripple` | Automated document ripple — update downstream docs after code changes |
53
+ | `/user:gsd-t-integrate` | Wire domains together |
54
+ | `/user:gsd-t-verify` | Run quality gates + goal-backward behavior verification |
55
+ | `/user:gsd-t-complete-milestone` | Archive milestone + git tag (goal-backward gate, rule engine distillation) |
56
+ | `/user:gsd-t-wave` | Full cycle (auto-advances all phases) |
57
+ | `/user:gsd-t-status` | Cross-domain progress view with token breakdown, global ELO and cross-project rankings |
58
+ | `/user:gsd-t-debug` | Systematic debugging |
59
+ | `/user:gsd-t-quick` | Fast task, respects contracts |
60
+ | `/user:gsd-t-reflect` | Generate retrospective from event stream, propose memory updates |
61
+ | `/user:gsd-t-visualize` | Launch browser dashboard |
62
+ | `/user:gsd-t-metrics` | View task telemetry, process ELO, domain health, and cross-project comparison (`--cross-project`) |
63
+ | `/user:gsd-t-health` | Validate .gsd-t/ structure, optionally repair |
64
+ | `/user:gsd-t-pause` | Save exact position for reliable resume |
65
+ | `/user:gsd-t-populate` | Auto-populate docs from existing codebase |
66
+ | `/user:gsd-t-log` | Sync progress Decision Log with recent git activity |
67
+ | `/user:gsd-t-resume` | Restore context, continue |
68
+ | `/user:gsd-t-version-update` | Update GSD-T to latest version |
69
+ | `/user:gsd-t-version-update-all` | Update GSD-T + all registered projects |
70
+ | `/user:gsd-t-triage-and-merge` | Auto-review, merge, and publish GitHub branches |
71
+ | `/user:gsd-t-audit` | Harness self-audit analyze cost/benefit of enforcement components |
72
+ | `/user:gsd-t-backlog-add` | Capture item, auto-categorize, append to backlog |
73
+ | `/user:gsd-t-backlog-list` | Filtered, ordered view of backlog items |
74
+ | `/user:gsd-t-backlog-move` | Reorder items by position (priority) |
75
+ | `/user:gsd-t-backlog-edit` | Modify backlog entry fields |
76
+ | `/user:gsd-t-backlog-remove` | Drop item with optional reason |
77
+ | `/user:gsd-t-backlog-promote` | Refine, classify, launch GSD-T workflow |
78
+ | `/user:gsd-t-backlog-settings` | Manage types, apps, categories, defaults |
79
+ | `/user:branch` | Create and switch to a new git branch |
80
+ | `/user:checkin` | Auto-bump version, stage, commit, and push |
81
+ | `/user:Claude-md` | Reload and apply CLAUDE.md directives |
82
+ | `/global-change` | Apply file changes across all registered GSD-T projects |
83
+
84
+
85
+ # Living Documents
86
+
87
+ These documents MUST be maintained and referenced throughout development:
88
+
89
+ | Document | Location | Purpose |
90
+ |----------|----------|---------|
91
+ | **Requirements** | `docs/requirements.md` | Functional and technical requirements |
92
+ | **Architecture** | `docs/architecture.md` | System design, components, data flow, decisions |
93
+ | **Workflows** | `docs/workflows.md` | User journeys and technical process flows |
94
+ | **Infrastructure** | `docs/infrastructure.md` | Commands, DB setup, server access, creds |
95
+ | **README** | `README.md` | Project overview, setup, features |
96
+ | **Progress** | `.gsd-t/progress.md` | Current milestone/phase state + version |
97
+ | **Contracts** | `.gsd-t/contracts/` | Interfaces between domains |
98
+ | **Tech Debt** | `.gsd-t/techdebt.md` | Debt register from scans |
99
+
100
+ ## The "No Re-Research" Rule
101
+
102
+ **BEFORE researching how something works, CHECK THE DOCS FIRST.**
103
+
104
+ ```
105
+ NEED TO UNDERSTAND SOMETHING?
106
+ ├── Is it about system structure/components? → Read docs/architecture.md
107
+ ├── Is it about how a process flows? → Read docs/workflows.md
108
+ ├── Is it about what to build? → Read docs/requirements.md
109
+ ├── Is it about how to deploy/operate? → Read docs/infrastructure.md
110
+ ├── Is it about domain interfaces? → Read .gsd-t/contracts/
111
+ └── Not documented? → Research, then DOCUMENT IT
112
+ ```
113
+
114
+
115
+ # Versioning
116
+
117
+ GSD-T tracks project version in `.gsd-t/progress.md` using semantic versioning: `Major.Minor.Patch`
118
+
119
+ | Segment | Bumped When | Example |
120
+ |---------|-------------|---------|
121
+ | **Major** | Breaking changes, major rework, v1 launch | 1.0.10 → 2.0.10 |
122
+ | **Minor** | New features, completed feature milestones | 1.10.10 → 1.11.10 |
123
+ | **Patch** | Bug fixes, minor improvements, cleanup | 1.1.10 → 1.1.11 |
124
+
125
+ **Patch convention**: Patch numbers are always 2 digits (≥10). When resetting after a minor or major bump, start at **10** (not 0). This keeps patches always 2 characters without leading zeros, so semver stays valid.
126
+
127
+ - Version is set during `gsd-t-init`:
128
+ - **New project** (no existing manifest version): starts at `0.1.00` first `complete-milestone` resets patch to `0.1.10`
129
+ - **Existing repo** (has `package.json`, `pyproject.toml`, `Cargo.toml`, etc. with a version): use that version as the starting point
130
+ - Version is bumped during `gsd-t-complete-milestone` based on milestone scope
131
+ - Version is reflected in: `progress.md`, `README.md`, package manifest (if any), and git tags (`v{version}`)
132
+
133
+
134
+ # Destructive Action Guard (MANDATORY)
135
+
136
+ **NEVER perform destructive or structural changes without explicit user approval.** This applies at ALL autonomy levels, including Level 3.
137
+
138
+ ```
139
+ BEFORE any of these actions, STOP and ask the user:
140
+ ├── DROP TABLE, DROP COLUMN, DROP INDEX, TRUNCATE, DELETE without WHERE
141
+ ├── Renaming or removing database tables or columns
142
+ ├── Schema migrations that lose data or break existing queries
143
+ ├── Replacing an existing architecture pattern (e.g., normalized → denormalized)
144
+ ├── Removing or replacing existing files/modules that contain working functionality
145
+ ├── Changing ORM models in ways that conflict with the existing database schema
146
+ ├── Removing API endpoints or changing response shapes that existing clients depend on
147
+ ├── Replacing a dependency or framework with a different one
148
+ └── Any change that would require other parts of the system to be rewritten
149
+ ```
150
+
151
+ ### How to handle schema/architecture mismatches:
152
+ 1. **READ the existing schema/code first** — understand what exists before proposing changes
153
+ 2. **Adapt new code to match existing structures** not the other way around
154
+ 3. **If restructuring is truly needed**, present the case to the user with:
155
+ - What exists today and why it might have been designed that way
156
+ - What you want to change and why
157
+ - What will break if you make the change
158
+ - What data or functionality will be lost
159
+ - A migration path that preserves existing data
160
+ 4. **Wait for explicit approval** before proceeding
161
+
162
+ ### Why this matters:
163
+ Even in development, the user may have:
164
+ - Working functionality they've tested and rely on
165
+ - Data they've carefully set up (seed data, test accounts, configuration)
166
+ - Other code that depends on the current structure
167
+ - Design decisions made for reasons not documented
168
+
169
+ **"Adapt to what exists" is always safer than "replace what exists."**
170
+
171
+
172
+ # Autonomous Execution Rules
173
+
174
+ ## Update Notices
175
+
176
+ On session start, a version check hook auto-updates GSD-T and outputs a status message. Show the result to the user at the **beginning** of your first response:
177
+
178
+ - If `[GSD-T AUTO-UPDATE]` appears → GSD-T was just auto-updated. Show:
179
+ ```
180
+ GSD-T auto-updated: v{old} → v{new}
181
+ Changelog: https://github.com/Tekyz-Inc/get-stuff-done-teams/blob/main/CHANGELOG.md
182
+ ```
183
+
184
+ - If `[GSD-T UPDATE]` appears → update available but auto-update failed. Show:
185
+ ```
186
+ ⬆️ GSD-T update available: v{installed} → v{latest} (auto-update failed)
187
+ Run: /user:gsd-t-version-update-all
188
+ Changelog: https://github.com/Tekyz-Inc/get-stuff-done-teams/blob/main/CHANGELOG.md
189
+ ```
190
+ Also repeat at the **end** of your first response.
191
+
192
+ - If `[GSD-T]` appears → up to date. Show:
193
+ ```
194
+ GSD-T v{version} — up to date
195
+ Changelog: https://github.com/Tekyz-Inc/get-stuff-done-teams/blob/main/CHANGELOG.md
196
+ ```
197
+
198
+ ## Conversation vs. Work
199
+
200
+ Only execute GSD-T workflow behavior when a `/gsd-t-*` command is invoked or when actively mid-phase (resumed via `/gsd-t-resume`). **Plain text messages — especially questions — should be answered conversationally.** Do not launch into workflow execution, file reading, or phase advancement from a question or comment. If the user wants work done, they will invoke a command.
201
+
202
+ **Exception — Auto-Route signal**: When `[GSD-T AUTO-ROUTE]` appears in your context (injected by the UserPromptSubmit hook), the user's plain text message should be treated as a `/user:gsd {message}` invocation. Execute the `/gsd` smart router with the user's full message as the argument instead of replying conversationally. The hook only fires in GSD-T projects (directories containing `.gsd-t/progress.md`) — it silently passes through in all other directories.
203
+
204
+ ## Auto-Init Guard
205
+
206
+ Before executing any GSD-T workflow command, check if **any** of these files are missing in the current project:
207
+ - `.gsd-t/progress.md`, `.gsd-t/backlog.md`, `.gsd-t/backlog-settings.md`
208
+ - `.gsd-t/contracts/`, `.gsd-t/domains/`
209
+ - `CLAUDE.md`, `README.md`
210
+ - `docs/requirements.md`, `docs/architecture.md`, `docs/workflows.md`, `docs/infrastructure.md`
211
+
212
+ If any are missing:
213
+ 1. Run `gsd-t-init` automatically (it skips files that already exist)
214
+ 2. Then continue with the originally requested command
215
+
216
+ **Exempt commands** (do not trigger auto-init): `gsd-t-init`, `gsd-t-init-scan-setup`, `gsd-t-help`, `gsd-t-version-update`, `gsd-t-version-update-all`.
217
+
218
+ ## Playwright Readiness Guard
219
+
220
+ Before any command that involves testing (`gsd-t-execute`, `gsd-t-test-sync`, `gsd-t-verify`, `gsd-t-quick`, `gsd-t-wave`, `gsd-t-milestone`, `gsd-t-complete-milestone`, `gsd-t-debug`), check if `playwright.config.*` exists in the project. If it does not:
221
+ 1. Detect the package manager and install Playwright (`@playwright/test` + chromium)
222
+ 2. Create a basic `playwright.config.ts` with sensible defaults
223
+ 3. Create the E2E test directory with a placeholder spec
224
+ 4. Then continue with the original command
225
+
226
+ Playwright must always be ready before any testing occurs. Do not skip this check. Do not defer setup to "later."
227
+
228
+ ### Playwright Cleanup
229
+
230
+ After Playwright tests finish (pass or fail), **kill any app/server processes that were started for the tests**. Playwright often launches a dev server (via `webServer` config or manually). These processes must not be left running:
231
+ 1. Check for any dev server processes spawned during the test run
232
+ 2. Kill them (e.g., `npx kill-port`, or terminate the process directly)
233
+ 3. Verify the port is free before proceeding
234
+
235
+ This applies everywhere Playwright tests are executed: execute, test-sync, verify, quick, wave, debug, complete-milestone, and integrate.
236
+
237
+ ### E2E Enforcement Rule (MANDATORY)
238
+
239
+ **Running only unit tests when E2E tests exist is a test failure.** This is non-negotiable.
240
+
241
+ ```
242
+ BEFORE reporting "tests pass" for ANY task:
243
+ ├── Does playwright.config.* or cypress.config.* exist?
244
+ │ YES → You MUST run the full E2E suite. Unit-only results are INCOMPLETE.
245
+ │ NO → Unit/integration tests are sufficient.
246
+ ├── Did you run every detected test runner?
247
+ │ NO → Run it now. Do not commit until ALL suites pass.
248
+ └── Report format MUST include all suites:
249
+ "Unit: X/Y pass | E2E: X/Y pass" (or "E2E: N/A — no config")
250
+ ```
251
+
252
+ The conditional "if UI/routes/flows changed" in command files applies to **writing new E2E specs**, not to **running existing ones**. You always run existing E2E specs. Always.
253
+
254
+ ### E2E Test Quality Standard (MANDATORY)
255
+
256
+ **E2E tests must be FUNCTIONAL tests, not LAYOUT tests.** This is non-negotiable.
257
+
258
+ A layout test checks that elements exist (`isVisible`, `toBeAttached`, `toBeEnabled`, `toHaveCount`). A functional test checks that features work — actions produce correct outcomes.
259
+
260
+ ```
261
+ LAYOUT TEST (WRONG — passes even if every feature is broken):
262
+ await expect(page.locator('#tab-sessions')).toBeVisible();
263
+ await page.click('#tab-sessions');
264
+ // ← No assertion that the tab's content actually loaded
265
+
266
+ FUNCTIONAL TEST (RIGHT — fails if the feature is broken):
267
+ await page.click('#tab-sessions');
268
+ await expect(page.locator('.session-list')).toContainText('Session 1');
269
+ // ← Proves clicking the tab loaded the session data
270
+ ```
271
+
272
+ Every Playwright assertion must verify one of:
273
+ - **State changed**: After click/type/submit, the app state is different (new content, updated data, changed status)
274
+ - **Data flowed**: User input → API call → response rendered (use `page.waitForResponse` or assert on rendered data)
275
+ - **Content loaded**: Navigation/tab switch → destination content appeared (assert on text/data unique to destination)
276
+ - **Widget responded**: Terminal accepted keystrokes and produced output, editor saved changes, form submitted and data persisted
277
+
278
+ **If a test would pass on an empty HTML page with the correct element IDs and no JavaScript, it is not a functional test.** Rewrite it.
279
+
280
+ ## QA Agent (Mandatory)
281
+
282
+ Any GSD-T phase that produces or validates code **MUST run QA**. The QA agent's sole job is test generation, execution, and gap reporting. It never writes feature code.
283
+
284
+ **QA method by command:**
285
+ - `execute`, `integrate` → spawn QA via **Task subagent** (lightweight, no TeamCreate)
286
+ - `test-sync`, `verify`, `complete-milestone` → perform contract testing and gap analysis **inline**
287
+ - `quick`, `debug` → run the full test suite **inline** as part of the command's Test & Verify step
288
+ - `wave` → each phase agent handles QA per the rules above
289
+ - `partition`, `plan` → no QA spawn needed (no code produced yet)
290
+
291
+ **Task subagent spawn instruction (execute/integrate):**
292
+ ```
293
+ Task subagent (general-purpose):
294
+ "Run ALL configured test suites — detect and run every one:
295
+ a. Unit tests (vitest/jest/mocha): run the full suite
296
+ b. E2E tests: check for playwright.config.* or cypress.config.* — if found, run the FULL E2E suite
297
+ c. NEVER skip E2E when a config file exists. Running only unit tests is a QA FAILURE.
298
+ d. Read .gsd-t/contracts/ for contract definitions. Check contract compliance.
299
+ e. AUDIT E2E test quality: Review each Playwright spec — if any test only checks element
300
+ existence (isVisible, toBeAttached, toBeEnabled) without verifying functional behavior
301
+ (state changes, data loaded, content updated after user actions), flag it as
302
+ 'SHALLOW TEST — needs functional assertions'. A passing test suite that doesn't catch
303
+ broken features is a QA FAILURE.
304
+ Report format: 'Unit: X/Y pass | E2E: X/Y pass (or N/A if no config) | Contract: compliant/violations | Shallow tests: N'"
305
+ ```
306
+
307
+ **QA failure OR shallow tests found blocks phase completion.** Lead cannot proceed until QA reports PASS with zero shallow tests, or user explicitly overrides.
308
+
309
+ **QA Calibration Feedback Loop** — If `bin/qa-calibrator.js` exists in the project, the system tracks QA miss-rates (bugs found by Red Team that QA missed) and automatically injects targeted guidance into future QA prompts. Weak-spot categories (error paths, boundary inputs, state transitions) are detected from miss patterns and injected as a preamble before the QA subagent runs. Projects without `qa-miss-log.jsonl` data behave identically to baseline — calibration is fully opt-in and backward compatible.
310
+
311
+ ## Red Team — Adversarial QA (Mandatory)
312
+
313
+ After QA passes, every code-producing command spawns a **Red Team agent** — an adversarial subagent whose success is measured by bugs found, not tests passed. This inverts the incentive structure: the Red Team's drive toward "task complete" means digging deeper and finding more bugs, not rubber-stamping.
314
+
315
+ **Red Team method by command:**
316
+ - `execute` → spawns Red Team after all domain tasks pass (Step 5.5)
317
+ - `integrate` → spawns Red Team after integration tests pass (Step 7.5)
318
+ - `quick` → spawns Red Team after Test & Verify passes (Step 5.5)
319
+ - `debug` → spawns Red Team after fix verification passes (Step 5.3)
320
+ - `wave` → each phase agent handles Red Team per the rules above
321
+
322
+ **Key Red Team rules:**
323
+ - **Inverted incentive**: More bugs found = more value. Zero bugs requires exhaustive proof of thoroughness.
324
+ - **False positive penalty**: Reporting non-bugs destroys credibility. Every bug must be reproduced with proof.
325
+ - **Exhaustive categories**: Contract violations, boundary inputs, state transitions, error paths, missing flows, regression, E2E functional gaps — all must be attempted.
326
+ - **VERDICT**: `FAIL` (bugs found — blocks completion) or `GRUDGING PASS` (exhaustive search, nothing found).
327
+ - **Report**: Written to `.gsd-t/red-team-report.md`; bugs also appended to `.gsd-t/qa-issues.md`.
328
+
329
+ **Red Team FAIL blocks phase completion.** CRITICAL/HIGH bugs must be fixed (up to 2 fix cycles). If bugs persist, they are logged to `.gsd-t/deferred-items.md` and presented to the user.
330
+
331
+ ## Model Display (MANDATORY)
332
+
333
+ **Before every subagent spawn, display the model being used to the user:**
334
+ `⚙ [{model}] {command} {brief description}` (e.g., `⚙ [sonnet] gsd-t-execute domain: auth-service`, `⚙ [haiku] gsd-t-execute QA validation`)
335
+
336
+ This gives the user real-time visibility into which model is handling each operation.
337
+
338
+ **Model assignments:**
339
+ - `model: haiku` — strictly mechanical tasks: run test suites and report counts, check file existence, validate JSON structure, branch guard checks
340
+ - `model: sonnet` — mid-tier reasoning: routine code changes, standard refactors, test writing, QA evaluation, straightforward synthesis
341
+ - `model: opus` high-stakes reasoning: architecture decisions, security analysis, complex debugging, cross-module refactors, Red Team adversarial QA, quality judgment on critical paths
342
+
343
+ **Token-Aware Orchestration** If `bin/token-budget.js` exists, the system checks session token consumption before each subagent spawn in `execute`, `wave`, and `quick`. Graduated degradation: `downgrade` applies model overrides (opus→sonnet, sonnet→haiku), `conserve` checkpoints progress and skips non-essential phases, `stop` halts cleanly with a resume instruction. Projects without `token-budget.js` behave identically to baseline — token awareness is fully backward compatible.
344
+
345
+ ## API Documentation Guard (Swagger/OpenAPI)
346
+
347
+ **Every API endpoint MUST be documented in a Swagger/OpenAPI spec. No exceptions.**
348
+
349
+ When any GSD-T command creates or modifies an API endpoint:
350
+ 1. **If no Swagger/OpenAPI spec exists**: Set one up immediately
351
+ - Detect the framework (Express, Fastify, Hono, Django, FastAPI, etc.)
352
+ - Install the appropriate Swagger integration (e.g., `swagger-jsdoc` + `swagger-ui-express`, `@fastify/swagger`, FastAPI's built-in OpenAPI)
353
+ - Create the OpenAPI spec file or configure auto-generation from code
354
+ - Add a `/docs` or `/api-docs` route serving the Swagger UI
355
+ 2. **Update the spec**: Every new or changed endpoint must be reflected in the Swagger/OpenAPI spec routes, request/response schemas, auth requirements, error responses
356
+ 3. **Publish the Swagger URL**: The Swagger/API docs URL MUST appear in:
357
+ - `CLAUDE.md` — under Documentation or Infrastructure section
358
+ - `README.md` under API section or Getting Started
359
+ - `docs/infrastructure.md` — under API documentation
360
+ 4. **Verify**: After any API change, confirm the Swagger UI loads and reflects the current endpoints
361
+
362
+ This applies during: `gsd-t-execute`, `gsd-t-quick`, `gsd-t-integrate`, `gsd-t-wave`, and any command that touches API code.
363
+
364
+ ## Prime Rule
365
+ KEEP GOING. Only stop for:
366
+ 1. Unrecoverable errors after 2 fix attempts (delegate to `gsd-t headless --debug-loop` first — only stop if exit code 4)
367
+ 2. Ambiguity that fundamentally changes project direction
368
+ 3. Milestone completion (checkpoint for user review)
369
+ 4. Destructive actions (see Destructive Action Guard above ALWAYS stop)
370
+
371
+ ## Pre-Commit Gate (MANDATORY)
372
+
373
+ NEVER commit code without running this checklist. This is not optional.
374
+
375
+ ```
376
+ BEFORE EVERY COMMIT:
377
+ ├── Am I on the correct branch?
378
+ │ CHECK Run `git branch --show-current`
379
+ Compare against "Expected branch" in project CLAUDE.md
380
+ WRONG BRANCH STOP. Do NOT commit. Switch to the correct branch first.
381
+ No guard set Proceed (but warn user to set one)
382
+ ├── Did I create or change an API endpoint or response shape?
383
+ │ YES → Update .gsd-t/contracts/api-contract.md
384
+ │ YES Update Swagger/OpenAPI spec (see API Documentation Guard below)
385
+ │ YES → Verify Swagger URL is in CLAUDE.md and README.md
386
+ ├── Did I change the database schema?
387
+ │ YES → Update .gsd-t/contracts/schema-contract.md AND docs/schema.md
388
+ ├── Did I add/change a UI component interface?
389
+ │ YES → Update .gsd-t/contracts/component-contract.md
390
+ ├── Did I add new files or directories?
391
+ │ YES → Update the owning domain's scope.md
392
+ ├── Did I implement or change a requirement?
393
+ │ YES → Update docs/requirements.md (mark complete or revise)
394
+ ├── Did I add/change/remove a component or change data flow?
395
+ YES Update docs/architecture.md
396
+ ├── Did I modify any document, script, or code file?
397
+ YES Add timestamped entry to .gsd-t/progress.md Decision Log
398
+ Format: `- YYYY-MM-DD HH:MM: {what was done} — {brief context or result}`
399
+ This includes ALL file-modifying activities:
400
+ │ project, feature, scan, gap-analysis, milestone, partition, discuss,
401
+ plan, impact, execute, test-sync, integrate, verify, complete-milestone,
402
+ │ wave, quick, debug, promote-debt, populate, setup, init, init-scan-setup,
403
+ backlog-add/edit/move/remove/promote/settings, and any manual code changes
404
+ ├── Did I make an architectural or design decision?
405
+ │ YES → Also include decision rationale in the progress.md entry
406
+ ├── Did I discover or fix tech debt?
407
+ │ YES → Update .gsd-t/techdebt.md
408
+ ├── Did I establish a pattern future work should follow?
409
+ │ YES → Update CLAUDE.md or domain constraints.md
410
+ ├── Did I add/change tests?
411
+ YES → Verify test names and paths are referenced in requirements
412
+ ├── Did I change UI, routes, or user flows?
413
+ │ YES → Update affected E2E test specs (Playwright/Cypress)
414
+ └── Did I run the affected tests?
415
+ YES → Verify they pass. NO → Run them now.
416
+ ```
417
+
418
+ If ANY answer is YES and the doc is NOT updated, update it BEFORE committing. No exceptions.
419
+
420
+ ## Document Ripple Completion Gate (MANDATORY)
421
+
422
+ **NEVER report a task as "done" or present a summary until ALL downstream documents are updated.** This is not optional.
423
+
424
+ When a change affects multiple files (e.g., a new standard that applies across command files, a renamed API, a new convention), you MUST:
425
+
426
+ 1. **Identify the full blast radius BEFORE starting**: List every file that needs the change
427
+ 2. **Complete ALL updates in one pass**: Do not update 3 of 8 files and then present a summary
428
+ 3. **Run the Pre-Commit Gate on the COMPLETE changeset**: Not on a partial subset
429
+ 4. **Only THEN report completion**
430
+
431
+ ```
432
+ BEFORE reporting "done" or presenting a summary:
433
+ ├── Did this change establish a new standard, rule, or convention?
434
+ │ YES → Grep for every file that should enforce it. Update ALL of them.
435
+ ├── Did this change modify a pattern used in multiple command files?
436
+ │ YES → Find and update EVERY command file that uses that pattern.
437
+ ├── Did this change affect a template (CLAUDE-global, CLAUDE-project, etc.)?
438
+ YESThe template AND the live equivalent (~/.claude/CLAUDE.md) must match.
439
+ ├── Did this change add a new requirement?
440
+ YES → Add to docs/requirements.md in the same pass.
441
+ ├── Have I checked EVERY file in the blast radius?
442
+ │ NO → Keep going. Do not present partial work.
443
+ └── Am I about to say "want me to also update X?" or "should I check Y?"
444
+ YES → STOP. Just update X and check Y. Then report done.
445
+ ```
446
+
447
+ **The test for this gate**: If the user asks "did you update all the documents?" and the answer would be "no, I missed some" — you failed this gate. The user should never need to ask.
448
+
449
+ ## Execution Behavior
450
+ - ALWAYS check docs/architecture.md before adding or modifying components.
451
+ - ALWAYS check docs/workflows.md before changing any multi-step process.
452
+ - ALWAYS update docs as part of completing work not as an afterthought.
453
+ - ALWAYS self-verify work by running tests and verification commands.
454
+ - NEVER re-research how something works if you built it it should be documented.
455
+ - NEVER pause to show verification steps — execute them.
456
+ - NEVER ask "should I continue?" — just continue.
457
+ - NEVER summarize what you're "about to do" — just do it.
458
+ - IF a test fails, fix it immediately (up to 2 attempts) before reporting. If both attempts fail, delegate to `gsd-t headless --debug-loop` before stopping.
459
+
460
+ ## Autonomy Levels
461
+
462
+ Projects can specify an autonomy level in their project CLAUDE.md:
463
+
464
+ | Level | Behavior |
465
+ |-------|----------|
466
+ | **Level 1: Supervised** | Pause at each phase for confirmation |
467
+ | **Level 2: Standard** | Pause only at milestones |
468
+ | **Level 3: Full Auto** | Only pause for blockers or project completion (default) |
469
+
470
+ If not specified, use Level 3.
471
+
472
+ ## Workflow Preferences (Defaults — override in project CLAUDE.md)
473
+
474
+ ### Research Policy
475
+ Before planning a phase, evaluate whether research is needed:
476
+
477
+ **Run research when:**
478
+ - Phase involves unfamiliar libraries, APIs, or services
479
+ - Architectural decisions are required
480
+ - Integrating external systems
481
+ - Phase scope is ambiguous or complex
482
+
483
+ **Skip research when:**
484
+ - Patterns are already established from earlier phases
485
+ - Straightforward CRUD, UI, or config work
486
+ - Domain is well understood
487
+ - Phase builds directly on existing code patterns
488
+
489
+ If in doubt, skip research and proceed research if execution reveals gaps.
490
+
491
+ ### Phase Flow
492
+ - Upon completing a phase, automatically proceed to the next phase
493
+ - ONLY run Discussion phase if truly required (clear path → skip to Plan)
494
+ - ALWAYS self-verify work by running verification commands
495
+ - NEVER pause to show verification stepsexecute them
496
+
497
+ ### Next Command Hint
498
+
499
+ When a GSD-T command completes (and does NOT auto-advance to the next phase), display a "Next Up" block at the very end of your response. This format is designed to trigger Claude Code's prompt suggestion engine — making the next command appear as ghost text in the user's input field.
500
+
501
+ **MANDATORY format** — use this exact structure:
502
+
503
+ ```
504
+ ───────────────────────────────────────────────────────────────
505
+
506
+ ## ▶ Next Up
507
+
508
+ **{Phase Name}** — {one-line description of what happens next}
509
+
510
+ `/user:gsd-t-{command}`
511
+
512
+ ───────────────────────────────────────────────────────────────
513
+ ```
514
+
515
+ If there are alternative commands that also make sense, add them:
516
+
517
+ ```
518
+ **Also available:**
519
+ - `/user:gsd-t-{alt-1}` — {description}
520
+ - `/user:gsd-t-{alt-2}` {description}
521
+ ```
522
+
523
+ Successor mapping:
524
+ | Completed | Next | Also available |
525
+ |-----------|------|----------------|
526
+ | `project` | `milestone` | |
527
+ | `feature` | `milestone` | |
528
+ | `milestone` | `partition` | |
529
+ | `partition` | `plan` | `discuss` (if complex) |
530
+ | `discuss` | `plan` | |
531
+ | `plan` | `execute` | `impact` (if risky) |
532
+ | `impact` | `execute` | |
533
+ | `execute` | `test-sync` | |
534
+ | `test-sync` | `verify` | `integrate` (if multi-domain) |
535
+ | `integrate` | `verify` | |
536
+ | `verify` | *(auto-invokes complete-milestone)* | |
537
+ | `complete-milestone` | `status` | |
538
+ | `scan` | `promote-debt` | `milestone` |
539
+ | `init` | `scan` | `milestone` |
540
+ | `init-scan-setup` | `milestone` | |
541
+ | `gap-analysis` | `milestone` | `feature` |
542
+ | `populate` | `status` | |
543
+ | `setup` | `status` | |
544
+
545
+ Commands with no successor (standalone): `quick`, `debug`, `brainstorm`, `status`, `help`, `resume`, `prompt`, `log`, `health`, `pause`, backlog commands.
546
+
547
+ Skip the hint if auto-advancing (Level 3 mid-wave) — only show when the user needs to manually invoke the next step.
548
+
549
+
550
+ # Don't Do These Things
551
+
552
+ - NEVER perform destructive or structural changes without explicit user approval (see Destructive Action Guard above).
553
+ - NEVER drop database tables, remove columns, or run destructive SQL on an existing database — adapt new code to the existing schema.
554
+ - NEVER replace existing architecture patterns (e.g., normalized → denormalized) without user approval even if you think the new way is better.
555
+ - NEVER commit code without running the Pre-Commit Gate checklist. EVERY commit.
556
+ - NEVER batch doc updates for laterupdate docs as part of the same commit as the code change.
557
+ - NEVER start a phase without reading contracts and relevant docs first.
558
+ - NEVER complete a phase without running document ripple on affected docs.
559
+ - NEVER re-research how a component works — read architecture.md and contracts.
560
+ - NEVER let code and contract disagree fix one or the other immediately.
561
+ - NEVER make changes that touch more than 3 files without pausing to confirm approach.
562
+
563
+
564
+ # Code Standards (Defaults override in project CLAUDE.md)
565
+
566
+ ## Patterns
567
+ - Type hints required on all function signatures
568
+ - Dataclasses/interfaces for data models, not raw dicts
569
+ - Functions under 30 lines — split if longer
570
+ - Files under 200 lines — create new modules if needed
571
+ - Enums for state management and fixed option sets
572
+
573
+ ## Naming
574
+ ```
575
+ files: snake_case (user_service.py)
576
+ classes: PascalCase (UserService)
577
+ functions: snake_case (get_user)
578
+ constants: UPPER_SNAKE_CASE (MAX_RETRIES)
579
+ private: _underscore (_internal_method)
580
+ ```
581
+
582
+ ## Markdown Tables
583
+
584
+ Emoji display as 2 characters wide in terminal/monospace but count as 1 in string length. This causes misaligned columns. **Always add one extra space after emoji in table cells** to compensate:
585
+
586
+ ```
587
+ WRONG misaligned in terminal:
588
+ | Channel | Support |
589
+ |----------|---------|
590
+ | Discord | |
591
+ | LINE | ❌ |
592
+
593
+ RIGHT one extra space after emoji:
594
+ | Channel | Support |
595
+ |----------|---------|
596
+ | Discord | ✅ |
597
+ | LINE | ❌ |
598
+ ```
599
+
600
+ This extra space is invisible in rendered HTML (GitHub, VS Code preview) but restores alignment in terminal views. Apply to all GSD-T-generated docs that use emoji in tables.
601
+
602
+ Also pad all cell values in a column to the width of the widest value:
603
+ ```
604
+ | iMessage (BlueBubbles) | ✅ |
605
+ | Discord | ✅ |
606
+ | QQ | ❌ |
607
+ ```
608
+
609
+
610
+ ## Stack Rules Engine
611
+
612
+ GSD-T auto-detects project tech stack at subagent spawn time and injects mandatory best-practice rules into the subagent prompt.
613
+
614
+ **Detection sources**: `package.json` (React, TypeScript, Node API), `requirements.txt`/`pyproject.toml` (Python), `go.mod` (Go), `Cargo.toml` (Rust).
615
+
616
+ **Universal rules**: Templates prefixed with `_` (e.g., `_security.md`) are **always** injected, regardless of stack.
617
+
618
+ **Stack-specific rules**: Injected only when the matching stack is detected (e.g., `react.md` when `"react"` is in `package.json`).
619
+
620
+ **Enforcement**: Stack rule violations have the same weight as contract violations — they are task failures, not warnings.
621
+
622
+ **Extensible**: Drop a `.md` file into `templates/stacks/` in the GSD-T package to add rules for a new stack. If the directory is missing, detection skips silently.
623
+
624
+ **Commands that inject stack rules**: `gsd-t-execute`, `gsd-t-quick`, `gsd-t-integrate`, `gsd-t-wave`, `gsd-t-debug`.
625
+
626
+
627
+ # Recovery After Interruption
628
+
629
+ When resuming work (new session or after /clear):
630
+ 1. Read `.gsd-t/progress.md` for current state
631
+ 2. Read `docs/requirements.md` for what's left to build
632
+ 3. Read `docs/architecture.md` for how the system is structured
633
+ 4. Read `.gsd-t/contracts/` for domain interfaces
634
+ 5. Verify last task's work is intact (files exist, tests pass)
635
+ 6. Continue from current task — don't restart the phase
636
+
637
+ **CRITICAL: Do NOT research how the system works. The docs tell you. Read them.**
638
+ <!-- GSD-T:END — Do not remove this marker. -->