@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,234 +1,357 @@
1
- # GSD-T: Quick — Fast Task Execution with Contract Awareness
2
-
3
- You are executing a small, focused task that doesn't need full phase planning. This is for bug fixes, config changes, small features, and ad-hoc work.
4
-
5
- ## Step 0: Launch via Subagent
6
-
7
- To give this task a fresh context window and prevent compaction during consecutive quick runs, always execute via a Task subagent.
8
-
9
- **If you are the orchestrating agent** (you received the slash command directly):
10
-
11
- **OBSERVABILITY LOGGING (MANDATORY):**
12
- Before spawning — run via Bash:
13
- `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}`
14
-
15
- **Stack Rules Detection (before spawning subagent):**
16
-
17
- Run via Bash to detect project stack and collect matching rules. Local overrides in `.gsd-t/stacks/` take precedence over global templates.
18
-
19
- ```bash
20
- GSD_T_DIR=$(npm root -g 2>/dev/null)/@tekyzinc/gsd-t
21
- STACKS_DIR="$GSD_T_DIR/templates/stacks"
22
- LOCAL_STACKS=".gsd-t/stacks"
23
- STACK_RULES=""
24
- _sf() { local n=$(basename "$1"); [ -f "$LOCAL_STACKS/$n" ] && cat "$LOCAL_STACKS/$n" || cat "$1"; }
25
- _add() { [ -f "$STACKS_DIR/$1" ] && STACK_RULES="${STACK_RULES}$(_sf "$STACKS_DIR/$1")"$'\n\n'; }
26
- if [ -d "$STACKS_DIR" ]; then
27
- for f in "$STACKS_DIR"/_*.md; do [ -f "$f" ] && STACK_RULES="${STACK_RULES}$(_sf "$f")"$'\n\n'; done
28
- if [ -f "package.json" ]; then
29
- grep -q '"react-native"' package.json 2>/dev/null && _add react-native.md
30
- grep -q '"react"' package.json 2>/dev/null && ! grep -q '"react-native"' package.json 2>/dev/null && _add react.md
31
- grep -q '"next"' package.json 2>/dev/null && _add nextjs.md
32
- grep -q '"vue"' package.json 2>/dev/null && _add vue.md
33
- (grep -q '"typescript"' package.json 2>/dev/null || [ -f "tsconfig.json" ]) && _add typescript.md
34
- grep -qE '"(express|fastify|hono|koa)"' package.json 2>/dev/null && _add node-api.md && _add rest-api.md
35
- grep -q '"tailwindcss"' package.json 2>/dev/null && _add tailwind.md
36
- grep -q '"vite"' package.json 2>/dev/null && _add vite.md
37
- grep -q '"@supabase/supabase-js"' package.json 2>/dev/null && _add supabase.md
38
- grep -q '"firebase"' package.json 2>/dev/null && _add firebase.md
39
- grep -qE '"(graphql|@apollo/client|urql)"' package.json 2>/dev/null && _add graphql.md
40
- grep -q '"zustand"' package.json 2>/dev/null && _add zustand.md
41
- grep -q '"@reduxjs/toolkit"' package.json 2>/dev/null && _add redux.md
42
- grep -q '"neo4j-driver"' package.json 2>/dev/null && _add neo4j.md
43
- grep -qE '"(pg|prisma|drizzle-orm|knex)"' package.json 2>/dev/null && _add postgresql.md
44
- grep -qE '"(prisma|@prisma/client)"' package.json 2>/dev/null && _add prisma.md
45
- grep -qE '"(bullmq|bull|amqplib|@aws-sdk/client-sqs|bee-queue|agenda)"' package.json 2>/dev/null && _add queues.md
46
- grep -qE '"(openai|anthropic|@anthropic-ai/sdk|langchain|llama-index|@google/generative-ai)"' package.json 2>/dev/null && _add llm.md
47
- fi
48
- ([ -f "requirements.txt" ] || [ -f "pyproject.toml" ] || [ -f "Pipfile" ]) && _add python.md
49
- ([ -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
50
- ([ -f "requirements.txt" ] && grep -q "neo4j" requirements.txt 2>/dev/null) && _add neo4j.md
51
- ([ -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
52
- ([ -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
53
- ([ -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
54
- [ -f "pubspec.yaml" ] && _add flutter.md
55
- [ -f "Dockerfile" ] && _add docker.md
56
- [ -d ".github/workflows" ] && _add github-actions.md
57
- ([ -f "playwright.config.ts" ] || [ -f "playwright.config.js" ]) && _add playwright.md
58
- [ -f "go.mod" ] && _add go.md
59
- [ -f "Cargo.toml" ] && _add rust.md
60
- fi
61
- ```
62
-
63
- If STACK_RULES is non-empty, append to the subagent prompt:
64
- ```
65
- ## Stack Rules (MANDATORY violations fail this task)
66
-
67
- {STACK_RULES}
68
-
69
- These standards have the same enforcement weight as contract compliance.
70
- Violations are task failures, not warnings.
71
- ```
72
-
73
- If STACK_RULES is empty (no templates/stacks/ dir or no matches), skip silently.
74
-
75
- Spawn a fresh subagent using the Task tool:
76
- ```
77
- subagent_type: general-purpose
78
- prompt: "You are running gsd-t-quick for this request: {$ARGUMENTS}
79
- Working directory: {current project root}
80
- Read CLAUDE.md and .gsd-t/progress.md for project context, then execute gsd-t-quick starting at Step 1.
81
- {STACK_RULES block if non-empty, append the ## Stack Rules section defined above; omit if empty}"
82
- ```
83
-
84
- After subagent returns run via Bash:
85
- `T_END=$(date +%s) && DT_END=$(date +"%Y-%m-%d %H:%M") && TOK_END=${CLAUDE_CONTEXT_TOKENS_USED:-0} && DURATION=$((T_END-T_START))`
86
- Compute tokens and compaction:
87
- - No compaction (TOK_END >= TOK_START): `TOKENS=$((TOK_END-TOK_START))`, COMPACTED=null
88
- - Compaction detected (TOK_END < TOK_START): `TOKENS=$(((TOK_MAX-TOK_START)+TOK_END))`, COMPACTED=$DT_END
89
- Append to `.gsd-t/token-log.md` (create with header `| Datetime-start | Datetime-end | Command | Step | Model | Duration(s) | Notes | Tokens | Compacted |` if missing):
90
- `| {DT_START} | {DT_END} | gsd-t-quick | Step 0 | sonnet | {DURATION}s | quick: {task summary} | {TOKENS} | {COMPACTED} |`
91
-
92
- Relay the subagent's summary to the user. **Do not execute Steps 1–5 yourself.**
93
-
94
- **If you are the spawned subagent** (your prompt says "starting at Step 1"):
95
- Continue to Step 1 below.
96
-
97
- ## Step 1: Load Context (Fast)
98
-
99
- Read:
100
- 1. `CLAUDE.md`
101
- 2. `.gsd-t/progress.md` (if exists)
102
- 3. `.gsd-t/contracts/` (if exists) — scan for relevant contracts
103
-
104
- ## Step 1.5: Graph-Enhanced Scope Check
105
-
106
- If `.gsd-t/graph/meta.json` exists (graph index is available):
107
- 1. Query `getDomainOwner` for the target function/file to verify it belongs to the expected domain
108
- 2. Query `getDomainBoundaryViolations` to check if the quick change would cross domain boundaries
109
- 3. If violations found, warn the user before proceeding — the change may need the full execute workflow
110
-
111
- If graph is not available, skip this step.
112
-
113
- ## Step 2: Scope Check
114
-
115
- Based on $ARGUMENTS, determine:
116
- - Which domain does this touch? (check `.gsd-t/domains/*/scope.md` if available)
117
- - Does it cross a domain boundary?
118
- - Does it affect any existing contract?
119
-
120
- ### If it crosses boundaries or affects contracts:
121
- Warn the user:
122
- "This change touches {domain-1} and {domain-2} and may affect {contract}.
123
- Should I proceed with quick mode or use the full execute workflow?"
124
-
125
- ### If it's within a single domain or pre-partition:
126
- Proceed.
127
-
128
- ## Step 3: Execute
129
-
130
- ### Deviation Rules
131
-
132
- When you encounter unexpected situations:
133
- 1. **Bug blocking progress** Fix it, up to 3 attempts. If still blocked, add to `.gsd-t/deferred-items.md` and skip.
134
- 2. **Missing dependency clearly needed** Add minimum required code to unblock. Note in commit.
135
- 3. **Blocker (missing file, wrong API)** → Fix blocker and continue. Log if non-trivial.
136
- 4. **Architectural change required** STOP. Apply Destructive Action Guard. Never self-approve.
137
-
138
- **3-attempt limit**: Stop looping after 3 failed fix attempts. Log and move on.
139
-
140
- 1. Identify exactly which files need to change
141
- 2. **Destructive Action Guard**: Check if this task involves destructive or structural changes (DROP TABLE, removing columns, deleting data, replacing architecture patterns, removing working modules, changing schema in ways that conflict with existing data). If YES → STOP and present the change to the user with what exists today, what will change, what will break, and a safe migration path. Wait for explicit approval.
142
- 3. If a contract exists for the relevant interface, implement to match it
143
- 4. Make the change — **adapt new code to existing structures**, not the other way around
144
- 5. Verify it works
145
- 6. Commit: `[quick] {description}`
146
-
147
- ## Step 3.5: Emit Task Metrics
148
-
149
- After committing, emit a task-metrics record for this quick task run via Bash:
150
- `node bin/metrics-collector.js --milestone {current-milestone-or-none} --domain {domain-or-quick} --task quick-{timestamp} --command quick --duration_s {elapsed} --tokens_used {estimated} --context_pct ${CTX_PCT:-0} --pass {true|false} --fix_cycles {0|N} --signal_type {pass-through|fix-cycle} --notes "[quick] {description}" 2>/dev/null || true`
151
-
152
- Signal type: `pass-through` if task completed on first attempt; `fix-cycle` if rework was needed.
153
-
154
- Emit task_complete eventrun via Bash:
155
- `node ~/.claude/scripts/gsd-t-event-writer.js --type task_complete --command gsd-t-quick --reasoning "signal_type={signal_type}, domain={domain}" --outcome {success|failure} || true`
156
-
157
- ## Step 4: Document Ripple (if GSD-T is active)
158
-
159
- If `.gsd-t/progress.md` exists, assess what documentation was affected and update ALL relevant files:
160
-
161
- ### Always update:
162
- 1. **`.gsd-t/progress.md`** — Log the quick task in the Decision Log with date and description
163
-
164
- ### Check if affected:
165
- 2. **`.gsd-t/contracts/`**Did you change an API endpoint, schema, or component interface? Update the contract
166
- 3. **Domain `scope.md`** Did you add new files? Update the owning domain's scope
167
- 4. **Domain `constraints.md`** — Did you establish a new pattern or discover a "must not"? Add it
168
- 5. **`docs/requirements.md`** Did this task add, change, or clarify a requirement? Update it
169
- 6. **`docs/architecture.md`** — Did this task change how components connect or data flows? Update it
170
- 7. **`docs/schema.md`** Did this task modify the database? Update it
171
- 8. **`.gsd-t/techdebt.md`** — Did this task resolve a debt item? Mark it done. Did it reveal new debt? Add it
172
- 9. **`CLAUDE.md`** — Did this task establish a convention future work should follow? Add it
173
-
174
- ### Scan Doc Micro-Update (if `.gsd-t/scan/` exists):
175
- Patch structural metadata in scan docs so they stay fresh between full scans. Near-zero cost — no LLM re-analysis.
176
-
177
- For each scan doc that exists, apply only the relevant patches:
178
- - **`.gsd-t/scan/architecture.md`** — Update file/directory counts, add new files/modules created
179
- - **`.gsd-t/scan/quality.md`** — Mark resolved TODOs/FIXMEs, update test counts, append new files to Consumer Surfaces if applicable
180
- - **`.gsd-t/scan/security.md`** — If a security finding was fixed, mark it `[RESOLVED]`
181
- - **`.gsd-t/scan/business-rules.md`** — Append any new validation/auth/workflow rules added
182
- - **`.gsd-t/scan/contract-drift.md`** — If contracts were updated, mark resolved drift items
183
-
184
- Skip scan docs not affected by this task. Skip analytical sections — those require a full scan.
185
-
186
- ### Skip what's not affected most quick tasks will only touch 1-2 of these.
187
-
188
- ## Step 5: Test & Verify (MANDATORY)
189
-
190
- Quick does not mean skip testing. Before committing:
191
-
192
- 1. **Write/update tests for every new or changed code path**:
193
- - Unit tests: happy path + common edge cases + error cases
194
- - Playwright E2E specs (if UI/routes/flows/modes changed): create new specs for new functionality, update existing specs for changed behavior
195
- - Cover all modes/flags affected by this change
196
- - "No feature code without test code" applies to quick tasks too
197
- - **Functional tests only**every E2E assertion must verify an action produced the correct outcome (state changed, data loaded, content updated). Tests that only check element existence (`isVisible`, `toBeEnabled`) are shallow/layout tests and are not acceptable. If a test would pass on an empty HTML page with the right IDs, rewrite it.
198
- 2. **Run ALL configured test suites** — not just affected tests, not just one suite:
199
- a. Detect all runners: check for vitest/jest config, playwright.config.*, cypress.config.*
200
- b. Run EVERY detected suite. Unit tests alone are NEVER sufficient when E2E exists.
201
- c. If `playwright.config.*` exists `npx playwright test` (full suite)
202
- d. Report ALL results: "Unit: X/Y pass | E2E: X/Y pass"
203
- - Fix any failures before proceeding (up to 2 attempts)
204
- 3. **Verify against requirements**:
205
- - Does the change satisfy its intended requirement?
206
- - Did the change break any existing functionality? (the full test run catches this)
207
- - If a contract exists for the interface touched, does the code still match?
208
- 4. **No test framework?**: Set one up, or at minimum manually verify and document how in the commit message
209
-
210
- ## Step 6: Doc-Ripple (Automated)
211
-
212
- After all work is committed but before reporting completion:
213
-
214
- 1. Run threshold check read `git diff --name-only HEAD~1` and evaluate against doc-ripple-contract.md trigger conditions
215
- 2. If SKIP: log "Doc-ripple: SKIP {reason}" and proceed to completion
216
- 3. If FIRE: spawn doc-ripple agent:
217
-
218
- [{model}] gsd-t-doc-ripple blast radius analysis + parallel updates
219
-
220
- Task subagent (general-purpose, model: sonnet):
221
- "Execute the doc-ripple workflow per commands/gsd-t-doc-ripple.md.
222
- Git diff context: {files changed list}
223
- Command that triggered: quick
224
- Produce manifest at .gsd-t/doc-ripple-manifest.md.
225
- Update all affected documents.
226
- Report: 'Doc-ripple: {N} checked, {N} updated, {N} skipped'"
227
-
228
- 4. After doc-ripple returns, verify manifest exists and report summary inline
229
-
230
- $ARGUMENTS
231
-
232
- ## Auto-Clear
233
-
234
- All work is committed to project files. Execute `/clear` to free the context window for the next command.
1
+ # GSD-T: Quick — Fast Task Execution with Contract Awareness
2
+
3
+ You are executing a small, focused task that doesn't need full phase planning. This is for bug fixes, config changes, small features, and ad-hoc work.
4
+
5
+ ## Step 0: Launch via Subagent
6
+
7
+ To give this task a fresh context window and prevent compaction during consecutive quick runs, always execute via a Task subagent.
8
+
9
+ **If you are the orchestrating agent** (you received the slash command directly):
10
+
11
+ **OBSERVABILITY LOGGING (MANDATORY):**
12
+ Before spawning — run via Bash:
13
+ `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}`
14
+
15
+ **Token Budget Check (before spawning subagent):**
16
+
17
+ Run via Bash:
18
+ `node -e "const tb = require('./bin/token-budget.js'); const s = tb.getSessionStatus('.'); process.stdout.write(s.threshold);" 2>/dev/null`
19
+
20
+ Apply the result:
21
+ - `normal` or file missing → proceed with default model (sonnet)
22
+ - `downgrade` → downgrade subagent model from sonnet to haiku for non-critical tasks; apply `getDegradationActions()` model overrides
23
+ - `conserve` → run quick task inline (skip subagent spawn overhead); skip Red Team and doc-ripple
24
+ - `stop` output: "Token budget exhausted quick task deferred. Resume after session reset." and halt
25
+
26
+ **Stack Rules Detection (before spawning subagent):**
27
+
28
+ Run via Bash to detect project stack and collect matching rules. Local overrides in `.gsd-t/stacks/` take precedence over global templates.
29
+
30
+ ```bash
31
+ GSD_T_DIR=$(npm root -g 2>/dev/null)/@tekyzinc/gsd-t
32
+ STACKS_DIR="$GSD_T_DIR/templates/stacks"
33
+ LOCAL_STACKS=".gsd-t/stacks"
34
+ STACK_RULES=""
35
+ _sf() { local n=$(basename "$1"); [ -f "$LOCAL_STACKS/$n" ] && cat "$LOCAL_STACKS/$n" || cat "$1"; }
36
+ _add() { [ -f "$STACKS_DIR/$1" ] && STACK_RULES="${STACK_RULES}$(_sf "$STACKS_DIR/$1")"$'\n\n'; }
37
+ if [ -d "$STACKS_DIR" ]; then
38
+ for f in "$STACKS_DIR"/_*.md; do [ -f "$f" ] && STACK_RULES="${STACK_RULES}$(_sf "$f")"$'\n\n'; done
39
+ if [ -f "package.json" ]; then
40
+ grep -q '"react-native"' package.json 2>/dev/null && _add react-native.md
41
+ grep -q '"react"' package.json 2>/dev/null && ! grep -q '"react-native"' package.json 2>/dev/null && _add react.md
42
+ grep -q '"next"' package.json 2>/dev/null && _add nextjs.md
43
+ grep -q '"vue"' package.json 2>/dev/null && _add vue.md
44
+ (grep -q '"typescript"' package.json 2>/dev/null || [ -f "tsconfig.json" ]) && _add typescript.md
45
+ grep -qE '"(express|fastify|hono|koa)"' package.json 2>/dev/null && _add node-api.md && _add rest-api.md
46
+ grep -q '"tailwindcss"' package.json 2>/dev/null && _add tailwind.md
47
+ grep -q '"vite"' package.json 2>/dev/null && _add vite.md
48
+ grep -q '"@supabase/supabase-js"' package.json 2>/dev/null && _add supabase.md
49
+ grep -q '"firebase"' package.json 2>/dev/null && _add firebase.md
50
+ grep -qE '"(graphql|@apollo/client|urql)"' package.json 2>/dev/null && _add graphql.md
51
+ grep -q '"zustand"' package.json 2>/dev/null && _add zustand.md
52
+ grep -q '"@reduxjs/toolkit"' package.json 2>/dev/null && _add redux.md
53
+ grep -q '"neo4j-driver"' package.json 2>/dev/null && _add neo4j.md
54
+ grep -qE '"(pg|prisma|drizzle-orm|knex)"' package.json 2>/dev/null && _add postgresql.md
55
+ grep -qE '"(prisma|@prisma/client)"' package.json 2>/dev/null && _add prisma.md
56
+ grep -qE '"(bullmq|bull|amqplib|@aws-sdk/client-sqs|bee-queue|agenda)"' package.json 2>/dev/null && _add queues.md
57
+ grep -qE '"(openai|anthropic|@anthropic-ai/sdk|langchain|llama-index|@google/generative-ai)"' package.json 2>/dev/null && _add llm.md
58
+ fi
59
+ ([ -f "requirements.txt" ] || [ -f "pyproject.toml" ] || [ -f "Pipfile" ]) && _add python.md
60
+ ([ -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
61
+ ([ -f "requirements.txt" ] && grep -q "neo4j" requirements.txt 2>/dev/null) && _add neo4j.md
62
+ ([ -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
63
+ ([ -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
64
+ ([ -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
65
+ [ -f "pubspec.yaml" ] && _add flutter.md
66
+ [ -f "Dockerfile" ] && _add docker.md
67
+ [ -d ".github/workflows" ] && _add github-actions.md
68
+ ([ -f "playwright.config.ts" ] || [ -f "playwright.config.js" ]) && _add playwright.md
69
+ [ -f "go.mod" ] && _add go.md
70
+ [ -f "Cargo.toml" ] && _add rust.md
71
+ fi
72
+ ```
73
+
74
+ If STACK_RULES is non-empty, append to the subagent prompt:
75
+ ```
76
+ ## Stack Rules (MANDATORY — violations fail this task)
77
+
78
+ {STACK_RULES}
79
+
80
+ These standards have the same enforcement weight as contract compliance.
81
+ Violations are task failures, not warnings.
82
+ ```
83
+
84
+ If STACK_RULES is empty (no templates/stacks/ dir or no matches), skip silently.
85
+
86
+ Spawn a fresh subagent using the Task tool:
87
+ ```
88
+ subagent_type: general-purpose
89
+ prompt: "You are running gsd-t-quick for this request: {$ARGUMENTS}
90
+ Working directory: {current project root}
91
+ Read CLAUDE.md and .gsd-t/progress.md for project context, then execute gsd-t-quick starting at Step 1.
92
+ {STACK_RULES block if non-empty, append the ## Stack Rules section defined above; omit if empty}"
93
+ ```
94
+
95
+ After subagent returns run via Bash:
96
+ `T_END=$(date +%s) && DT_END=$(date +"%Y-%m-%d %H:%M") && TOK_END=${CLAUDE_CONTEXT_TOKENS_USED:-0} && DURATION=$((T_END-T_START))`
97
+ Compute tokens and compaction:
98
+ - No compaction (TOK_END >= TOK_START): `TOKENS=$((TOK_END-TOK_START))`, COMPACTED=null
99
+ - Compaction detected (TOK_END < TOK_START): `TOKENS=$(((TOK_MAX-TOK_START)+TOK_END))`, COMPACTED=$DT_END
100
+ Append to `.gsd-t/token-log.md` (create with header `| Datetime-start | Datetime-end | Command | Step | Model | Duration(s) | Notes | Tokens | Compacted |` if missing):
101
+ `| {DT_START} | {DT_END} | gsd-t-quick | Step 0 | sonnet | {DURATION}s | quick: {task summary} | {TOKENS} | {COMPACTED} |`
102
+
103
+ Relay the subagent's summary to the user. **Do not execute Steps 1–5 yourself.**
104
+
105
+ **If you are the spawned subagent** (your prompt says "starting at Step 1"):
106
+ Continue to Step 1 below.
107
+
108
+ ## Step 1: Load Context (Fast)
109
+
110
+ Read:
111
+ 1. `CLAUDE.md`
112
+ 2. `.gsd-t/progress.md` (if exists)
113
+ 3. `.gsd-t/contracts/` (if exists) — scan for relevant contracts
114
+
115
+ ## Step 1.5: Graph-Enhanced Scope Check
116
+
117
+ If `.gsd-t/graph/meta.json` exists (graph index is available):
118
+ 1. Query `getDomainOwner` for the target function/file to verify it belongs to the expected domain
119
+ 2. Query `getDomainBoundaryViolations` to check if the quick change would cross domain boundaries
120
+ 3. If violations found, warn the user before proceeding — the change may need the full execute workflow
121
+
122
+ If graph is not available, skip this step.
123
+
124
+ ## Step 2: Scope Check
125
+
126
+ Based on $ARGUMENTS, determine:
127
+ - Which domain does this touch? (check `.gsd-t/domains/*/scope.md` if available)
128
+ - Does it cross a domain boundary?
129
+ - Does it affect any existing contract?
130
+
131
+ ### If it crosses boundaries or affects contracts:
132
+ Warn the user:
133
+ "This change touches {domain-1} and {domain-2} and may affect {contract}.
134
+ Should I proceed with quick mode or use the full execute workflow?"
135
+
136
+ ### If it's within a single domain or pre-partition:
137
+ Proceed.
138
+
139
+ ## Step 3: Execute
140
+
141
+ ### Deviation Rules
142
+
143
+ When you encounter unexpected situations:
144
+ 1. **Bug blocking progress** → Fix it, up to 3 attempts. If still blocked, add to `.gsd-t/deferred-items.md` and skip.
145
+ 2. **Missing dependency clearly needed** → Add minimum required code to unblock. Note in commit.
146
+ 3. **Blocker (missing file, wrong API)** → Fix blocker and continue. Log if non-trivial.
147
+ 4. **Architectural change required** → STOP. Apply Destructive Action Guard. Never self-approve.
148
+
149
+ **3-attempt limit**: Stop looping after 3 failed fix attempts. Log and move on.
150
+
151
+ 1. Identify exactly which files need to change
152
+ 2. **Destructive Action Guard**: Check if this task involves destructive or structural changes (DROP TABLE, removing columns, deleting data, replacing architecture patterns, removing working modules, changing schema in ways that conflict with existing data). If YES → STOP and present the change to the user with what exists today, what will change, what will break, and a safe migration path. Wait for explicit approval.
153
+ 3. If a contract exists for the relevant interface, implement to match it
154
+ 4. Make the change **adapt new code to existing structures**, not the other way around
155
+ 5. Verify it works
156
+ 6. Commit: `[quick] {description}`
157
+
158
+ ## Step 3.5: Emit Task Metrics
159
+
160
+ After committing, emit a task-metrics record for this quick task — run via Bash:
161
+ `node bin/metrics-collector.js --milestone {current-milestone-or-none} --domain {domain-or-quick} --task quick-{timestamp} --command quick --duration_s {elapsed} --tokens_used {estimated} --context_pct ${CTX_PCT:-0} --pass {true|false} --fix_cycles {0|N} --signal_type {pass-through|fix-cycle} --notes "[quick] {description}" 2>/dev/null || true`
162
+
163
+ Signal type: `pass-through` if task completed on first attempt; `fix-cycle` if rework was needed.
164
+
165
+ Emit task_complete event run via Bash:
166
+ `node ~/.claude/scripts/gsd-t-event-writer.js --type task_complete --command gsd-t-quick --reasoning "signal_type={signal_type}, domain={domain}" --outcome {success|failure} || true`
167
+
168
+ ## Step 4: Document Ripple (if GSD-T is active)
169
+
170
+ If `.gsd-t/progress.md` exists, assess what documentation was affected and update ALL relevant files:
171
+
172
+ ### Always update:
173
+ 1. **`.gsd-t/progress.md`** — Log the quick task in the Decision Log with date and description
174
+
175
+ ### Check if affected:
176
+ 2. **`.gsd-t/contracts/`** — Did you change an API endpoint, schema, or component interface? Update the contract
177
+ 3. **Domain `scope.md`** Did you add new files? Update the owning domain's scope
178
+ 4. **Domain `constraints.md`** — Did you establish a new pattern or discover a "must not"? Add it
179
+ 5. **`docs/requirements.md`** — Did this task add, change, or clarify a requirement? Update it
180
+ 6. **`docs/architecture.md`** — Did this task change how components connect or data flows? Update it
181
+ 7. **`docs/schema.md`** — Did this task modify the database? Update it
182
+ 8. **`.gsd-t/techdebt.md`** — Did this task resolve a debt item? Mark it done. Did it reveal new debt? Add it
183
+ 9. **`CLAUDE.md`** — Did this task establish a convention future work should follow? Add it
184
+
185
+ ### Scan Doc Micro-Update (if `.gsd-t/scan/` exists):
186
+ Patch structural metadata in scan docs so they stay fresh between full scans. Near-zero cost — no LLM re-analysis.
187
+
188
+ For each scan doc that exists, apply only the relevant patches:
189
+ - **`.gsd-t/scan/architecture.md`** — Update file/directory counts, add new files/modules created
190
+ - **`.gsd-t/scan/quality.md`** Mark resolved TODOs/FIXMEs, update test counts, append new files to Consumer Surfaces if applicable
191
+ - **`.gsd-t/scan/security.md`** — If a security finding was fixed, mark it `[RESOLVED]`
192
+ - **`.gsd-t/scan/business-rules.md`** Append any new validation/auth/workflow rules added
193
+ - **`.gsd-t/scan/contract-drift.md`** If contracts were updated, mark resolved drift items
194
+
195
+ Skip scan docs not affected by this task. Skip analytical sections — those require a full scan.
196
+
197
+ ### Skip what's not affected most quick tasks will only touch 1-2 of these.
198
+
199
+ ## Step 5: Test & Verify (MANDATORY)
200
+
201
+ **QA Calibration Injection** Before evaluating test results, check for known weak spots:
202
+
203
+ Run via Bash:
204
+ `node -e "const qc = require('./bin/qa-calibrator.js'); const inj = qc.generateQAInjection('.'); if(inj) process.stdout.write(inj);" 2>/dev/null`
205
+
206
+ If the command produces output, treat it as a preamble to your QA evaluation — pay extra attention to the flagged weak-spot categories when writing and reviewing tests. If the file doesn't exist or returns empty, skip silently.
207
+
208
+ Quick does not mean skip testing. Before committing:
209
+
210
+ 1. **Write/update tests for every new or changed code path**:
211
+ - Unit tests: happy path + common edge cases + error cases
212
+ - Playwright E2E specs (if UI/routes/flows/modes changed): create new specs for new functionality, update existing specs for changed behavior
213
+ - Cover all modes/flags affected by this change
214
+ - "No feature code without test code" applies to quick tasks too
215
+ - **Functional tests only** — every E2E assertion must verify an action produced the correct outcome (state changed, data loaded, content updated). Tests that only check element existence (`isVisible`, `toBeEnabled`) are shallow/layout tests and are not acceptable. If a test would pass on an empty HTML page with the right IDs, rewrite it.
216
+ 2. **Run ALL configured test suites** — not just affected tests, not just one suite:
217
+ a. Detect all runners: check for vitest/jest config, playwright.config.*, cypress.config.*
218
+ b. Run EVERY detected suite. Unit tests alone are NEVER sufficient when E2E exists.
219
+ c. If `playwright.config.*` exists → `npx playwright test` (full suite)
220
+ d. Report ALL results: "Unit: X/Y pass | E2E: X/Y pass"
221
+ - Fix any failures before proceeding (up to 2 attempts)
222
+ 3. **Verify against requirements**:
223
+ - Does the change satisfy its intended requirement?
224
+ - Did the change break any existing functionality? (the full test run catches this)
225
+ - If a contract exists for the interface touched, does the code still match?
226
+ 4. **No test framework?**: Set one up, or at minimum manually verify and document how in the commit message
227
+
228
+ ### Exploratory Testing (if Playwright MCP available)
229
+
230
+ After all scripted tests pass:
231
+ 1. Check if Playwright MCP is registered in Claude Code settings (look for "playwright" in mcpServers)
232
+ 2. If available: spend 3 minutes on interactive exploration using Playwright MCP
233
+ - Try variations of happy paths with unexpected inputs
234
+ - Probe for race conditions, double-submits, empty states
235
+ - Test accessibility (keyboard navigation, screen reader flow)
236
+ 3. Tag all findings [EXPLORATORY] in reports and append to .gsd-t/qa-issues.md
237
+ 4. If Playwright MCP is not available: skip this section silently
238
+ Note: Exploratory findings do NOT count against the scripted test pass/fail ratio.
239
+
240
+ ## Step 5.5: Red Team — Adversarial QA (MANDATORY)
241
+
242
+ After tests pass, spawn an adversarial Red Team agent. This agent's sole purpose is to BREAK the code that was just changed. Its success is measured by bugs found, not tests passed.
243
+
244
+ ⚙ [{model}] Red Team → adversarial validation of quick task
245
+
246
+ **OBSERVABILITY LOGGING (MANDATORY):**
247
+ Before spawning — run via Bash:
248
+ `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}`
249
+
250
+ ```
251
+ Task subagent (general-purpose, model: opus):
252
+ "You are a Red Team QA adversary. Your job is to BREAK the code that was just changed.
253
+
254
+ Your value is measured by REAL bugs found. More bugs = more value.
255
+ If you find zero bugs, you must prove you were thorough — list every
256
+ attack vector you tried and why it didn't break. A short list means
257
+ you didn't try hard enough.
258
+
259
+ Rules:
260
+ - False positives DESTROY your credibility. If you report something
261
+ as a bug and it's actually correct behavior, that's worse than
262
+ missing a real bug. Never report something you haven't reproduced.
263
+ - Style opinions are not bugs. Theoretical concerns are not bugs.
264
+ A bug is: 'I did X, expected Y, got Z.' With proof.
265
+ - You are done ONLY when you have exhausted every category below
266
+ and either found a bug or documented exactly what you tried.
267
+
268
+ ## Attack Categories (exhaust ALL of these)
269
+
270
+ 1. **Contract Violations**: Read .gsd-t/contracts/. Does the code EXACTLY
271
+ match every contract? Test each endpoint/interface/schema shape.
272
+ 2. **Boundary Inputs**: Empty strings, null, undefined, huge payloads,
273
+ special characters, SQL injection attempts, XSS payloads, path traversal.
274
+ 3. **State Transitions**: What happens when actions are performed out of
275
+ order? Double-submit? Concurrent access? Refresh mid-flow?
276
+ 4. **Error Paths**: Remove env vars. Kill the database. Send malformed
277
+ requests. Does the code handle failures gracefully or crash?
278
+ 5. **Missing Flows**: Read docs/requirements.md. Are there user flows that
279
+ exist in requirements but have NO test coverage? Write tests for them.
280
+ 6. **Regression**: Run the FULL test suite. Did any existing tests break?
281
+ 7. **E2E Functional Gaps**: Review ALL Playwright specs. Do they test actual
282
+ behavior (state changes, data loaded, navigation works) or just check
283
+ that elements exist? Flag and rewrite any shallow/layout tests.
284
+
285
+ ## Exploratory Testing (if Playwright MCP available)
286
+
287
+ After all scripted tests pass:
288
+ 1. Check if Playwright MCP is registered in Claude Code settings (look for "playwright" in mcpServers)
289
+ 2. If available: spend 5 minutes on adversarial interactive exploration using Playwright MCP
290
+ - Attempt race conditions, double-submits, concurrent access patterns
291
+ - Try unexpected input sequences, boundary values, rapid state transitions
292
+ - Probe error recovery: does the app recover after failures or get stuck?
293
+ 3. Tag all findings [EXPLORATORY] in your report
294
+ 4. If Playwright MCP is not available: skip this section silently
295
+ Note: Exploratory findings are additive — they do not replace scripted test results.
296
+
297
+ ## Report Format
298
+
299
+ For each bug found:
300
+ - **BUG-{N}**: {severity: CRITICAL/HIGH/MEDIUM/LOW}
301
+ - **Reproduction**: {exact steps to reproduce}
302
+ - **Expected**: {what should happen}
303
+ - **Actual**: {what actually happens}
304
+ - **Proof**: {test file or command that demonstrates the bug}
305
+
306
+ Summary:
307
+ - BUGS FOUND: {count} (with severity breakdown)
308
+ - COVERAGE GAPS: {untested flows from requirements}
309
+ - SHALLOW TESTS REWRITTEN: {count}
310
+ - CONTRACTS VERIFIED: {N}/{total}
311
+ - ATTACK VECTORS TRIED: {list every category attempted and results}
312
+ - VERDICT: FAIL ({N} bugs found) | GRUDGING PASS (exhaustive search, nothing found)
313
+
314
+ Write all findings to .gsd-t/red-team-report.md.
315
+ If bugs found, also append to .gsd-t/qa-issues.md."
316
+ ```
317
+
318
+ After subagent returns — run via Bash:
319
+ `T_END=$(date +%s) && DT_END=$(date +"%Y-%m-%d %H:%M") && TOK_END=${CLAUDE_CONTEXT_TOKENS_USED:-0} && DURATION=$((T_END-T_START))`
320
+ Compute tokens and compaction:
321
+ - No compaction (TOK_END >= TOK_START): `TOKENS=$((TOK_END-TOK_START))`, COMPACTED=null
322
+ - Compaction detected (TOK_END < TOK_START): `TOKENS=$(((TOK_MAX-TOK_START)+TOK_END))`, COMPACTED=$DT_END
323
+ Append to `.gsd-t/token-log.md`:
324
+ `| {DT_START} | {DT_END} | gsd-t-quick | Red Team | sonnet | {DURATION}s | {VERDICT} — {N} bugs found | {TOKENS} | {COMPACTED} | | | {CTX_PCT} |`
325
+
326
+ **If Red Team VERDICT is FAIL:**
327
+ 1. Fix all CRITICAL and HIGH bugs immediately (up to 2 fix attempts per bug)
328
+ 2. Re-run Red Team after fixes
329
+ 3. If bugs persist after 2 fix cycles, log to `.gsd-t/deferred-items.md` and present to user
330
+
331
+ **If Red Team VERDICT is GRUDGING PASS:** Proceed to doc-ripple.
332
+
333
+ ## Step 6: Doc-Ripple (Automated)
334
+
335
+ After all work is committed but before reporting completion:
336
+
337
+ 1. Run threshold check — read `git diff --name-only HEAD~1` and evaluate against doc-ripple-contract.md trigger conditions
338
+ 2. If SKIP: log "Doc-ripple: SKIP — {reason}" and proceed to completion
339
+ 3. If FIRE: spawn doc-ripple agent:
340
+
341
+ ⚙ [{model}] gsd-t-doc-ripple → blast radius analysis + parallel updates
342
+
343
+ Task subagent (general-purpose, model: sonnet):
344
+ "Execute the doc-ripple workflow per commands/gsd-t-doc-ripple.md.
345
+ Git diff context: {files changed list}
346
+ Command that triggered: quick
347
+ Produce manifest at .gsd-t/doc-ripple-manifest.md.
348
+ Update all affected documents.
349
+ Report: 'Doc-ripple: {N} checked, {N} updated, {N} skipped'"
350
+
351
+ 4. After doc-ripple returns, verify manifest exists and report summary inline
352
+
353
+ $ARGUMENTS
354
+
355
+ ## Auto-Clear
356
+
357
+ All work is committed to project files. Execute `/clear` to free the context window for the next command.