@mindfoldhq/trellis 0.4.0-beta.7 → 0.4.0-beta.9

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 (121) hide show
  1. package/README.md +10 -5
  2. package/dist/cli/index.js +2 -0
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/commands/init.d.ts +2 -0
  5. package/dist/commands/init.d.ts.map +1 -1
  6. package/dist/commands/init.js +34 -10
  7. package/dist/commands/init.js.map +1 -1
  8. package/dist/commands/update.d.ts.map +1 -1
  9. package/dist/commands/update.js +33 -2
  10. package/dist/commands/update.js.map +1 -1
  11. package/dist/configurators/codex.d.ts +7 -4
  12. package/dist/configurators/codex.d.ts.map +1 -1
  13. package/dist/configurators/codex.js +40 -10
  14. package/dist/configurators/codex.js.map +1 -1
  15. package/dist/configurators/copilot.d.ts +9 -0
  16. package/dist/configurators/copilot.d.ts.map +1 -0
  17. package/dist/configurators/copilot.js +34 -0
  18. package/dist/configurators/copilot.js.map +1 -0
  19. package/dist/configurators/index.d.ts +11 -1
  20. package/dist/configurators/index.d.ts.map +1 -1
  21. package/dist/configurators/index.js +59 -4
  22. package/dist/configurators/index.js.map +1 -1
  23. package/dist/configurators/windsurf.d.ts +8 -0
  24. package/dist/configurators/windsurf.d.ts.map +1 -0
  25. package/dist/configurators/windsurf.js +18 -0
  26. package/dist/configurators/windsurf.js.map +1 -0
  27. package/dist/migrations/manifests/0.4.0-beta.8.json +34 -0
  28. package/dist/migrations/manifests/0.4.0-beta.9.json +9 -0
  29. package/dist/templates/claude/commands/trellis/record-session.md +2 -1
  30. package/dist/templates/claude/hooks/inject-subagent-context.py +8 -1
  31. package/dist/templates/claude/hooks/ralph-loop.py +8 -1
  32. package/dist/templates/claude/hooks/session-start.py +31 -7
  33. package/dist/templates/claude/hooks/statusline.py +211 -0
  34. package/dist/templates/claude/settings.json +4 -0
  35. package/dist/templates/codex/agents/check.toml +23 -0
  36. package/dist/templates/codex/agents/implement.toml +19 -0
  37. package/dist/templates/codex/agents/research.toml +26 -0
  38. package/dist/templates/codex/codex-skills/parallel/SKILL.md +194 -0
  39. package/dist/templates/codex/config.toml +5 -0
  40. package/dist/templates/codex/hooks/session-start.py +228 -0
  41. package/dist/templates/codex/hooks.json +16 -0
  42. package/dist/templates/codex/index.d.ts +27 -5
  43. package/dist/templates/codex/index.d.ts.map +1 -1
  44. package/dist/templates/codex/index.js +60 -8
  45. package/dist/templates/codex/index.js.map +1 -1
  46. package/dist/templates/codex/skills/improve-ut/SKILL.md +69 -0
  47. package/dist/templates/codex/skills/record-session/SKILL.md +2 -1
  48. package/dist/templates/copilot/hooks/session-start.py +218 -0
  49. package/dist/templates/copilot/hooks.json +11 -0
  50. package/dist/templates/copilot/index.d.ts +23 -0
  51. package/dist/templates/copilot/index.d.ts.map +1 -0
  52. package/dist/templates/copilot/index.js +54 -0
  53. package/dist/templates/copilot/index.js.map +1 -0
  54. package/dist/templates/copilot/prompts/before-dev.prompt.md +33 -0
  55. package/dist/templates/copilot/prompts/brainstorm.prompt.md +491 -0
  56. package/dist/templates/copilot/prompts/break-loop.prompt.md +129 -0
  57. package/dist/templates/copilot/prompts/check-cross-layer.prompt.md +157 -0
  58. package/dist/templates/copilot/prompts/check.prompt.md +29 -0
  59. package/dist/templates/copilot/prompts/create-command.prompt.md +116 -0
  60. package/dist/templates/copilot/prompts/finish-work.prompt.md +157 -0
  61. package/dist/templates/copilot/prompts/integrate-skill.prompt.md +223 -0
  62. package/dist/templates/copilot/prompts/onboard.prompt.md +362 -0
  63. package/dist/templates/copilot/prompts/parallel.prompt.md +196 -0
  64. package/dist/templates/copilot/prompts/record-session.prompt.md +66 -0
  65. package/dist/templates/copilot/prompts/start.prompt.md +397 -0
  66. package/dist/templates/copilot/prompts/update-spec.prompt.md +358 -0
  67. package/dist/templates/cursor/commands/trellis-record-session.md +2 -1
  68. package/dist/templates/extract.d.ts +29 -0
  69. package/dist/templates/extract.d.ts.map +1 -1
  70. package/dist/templates/extract.js +51 -0
  71. package/dist/templates/extract.js.map +1 -1
  72. package/dist/templates/gemini/commands/trellis/record-session.toml +2 -1
  73. package/dist/templates/iflow/commands/trellis/record-session.md +2 -1
  74. package/dist/templates/iflow/hooks/inject-subagent-context.py +8 -1
  75. package/dist/templates/iflow/hooks/ralph-loop.py +8 -1
  76. package/dist/templates/iflow/hooks/session-start.py +31 -7
  77. package/dist/templates/kilo/workflows/record-session.md +2 -1
  78. package/dist/templates/kiro/skills/record-session/SKILL.md +2 -1
  79. package/dist/templates/markdown/agents.md +4 -0
  80. package/dist/templates/markdown/spec/backend/directory-structure.md +1 -1
  81. package/dist/templates/markdown/workspace-index.md +2 -0
  82. package/dist/templates/opencode/agents/dispatch.md +20 -19
  83. package/dist/templates/opencode/commands/trellis/record-session.md +2 -1
  84. package/dist/templates/opencode/lib/trellis-context.js +42 -2
  85. package/dist/templates/opencode/plugins/session-start.js +7 -27
  86. package/dist/templates/qoder/skills/record-session/SKILL.md +2 -1
  87. package/dist/templates/trellis/scripts/add_session.py +69 -16
  88. package/dist/templates/trellis/scripts/common/__init__.py +2 -0
  89. package/dist/templates/trellis/scripts/common/cli_adapter.py +108 -16
  90. package/dist/templates/trellis/scripts/common/developer.py +2 -2
  91. package/dist/templates/trellis/scripts/common/paths.py +57 -6
  92. package/dist/templates/trellis/scripts/common/task_store.py +6 -4
  93. package/dist/templates/trellis/scripts/common/task_utils.py +14 -8
  94. package/dist/templates/trellis/scripts/multi_agent/plan.py +7 -6
  95. package/dist/templates/trellis/scripts/multi_agent/start.py +16 -11
  96. package/dist/templates/trellis/scripts/task.py +1 -1
  97. package/dist/templates/windsurf/index.d.ts +21 -0
  98. package/dist/templates/windsurf/index.d.ts.map +1 -0
  99. package/dist/templates/windsurf/index.js +44 -0
  100. package/dist/templates/windsurf/index.js.map +1 -0
  101. package/dist/templates/windsurf/workflows/trellis-before-dev.md +31 -0
  102. package/dist/templates/windsurf/workflows/trellis-brainstorm.md +491 -0
  103. package/dist/templates/windsurf/workflows/trellis-break-loop.md +111 -0
  104. package/dist/templates/windsurf/workflows/trellis-check-cross-layer.md +157 -0
  105. package/dist/templates/windsurf/workflows/trellis-check.md +27 -0
  106. package/dist/templates/windsurf/workflows/trellis-create-command.md +154 -0
  107. package/dist/templates/windsurf/workflows/trellis-finish-work.md +147 -0
  108. package/dist/templates/windsurf/workflows/trellis-integrate-skill.md +220 -0
  109. package/dist/templates/windsurf/workflows/trellis-onboard.md +362 -0
  110. package/dist/templates/windsurf/workflows/trellis-record-session.md +66 -0
  111. package/dist/templates/windsurf/workflows/trellis-start.md +373 -0
  112. package/dist/templates/windsurf/workflows/trellis-update-spec.md +358 -0
  113. package/dist/types/ai-tools.d.ts +15 -3
  114. package/dist/types/ai-tools.d.ts.map +1 -1
  115. package/dist/types/ai-tools.js +34 -2
  116. package/dist/types/ai-tools.js.map +1 -1
  117. package/dist/utils/template-fetcher.d.ts +17 -4
  118. package/dist/utils/template-fetcher.d.ts.map +1 -1
  119. package/dist/utils/template-fetcher.js +94 -12
  120. package/dist/utils/template-fetcher.js.map +1 -1
  121. package/package.json +1 -1
@@ -0,0 +1,491 @@
1
+ ---
2
+ description: "Trellis Copilot prompt: Brainstorm - Requirements Discovery (AI Coding Enhanced)"
3
+ ---
4
+
5
+ # Brainstorm - Requirements Discovery (AI Coding Enhanced)
6
+
7
+ Guide AI through collaborative requirements discovery **before implementation**, optimized for AI coding workflows:
8
+
9
+ * **Task-first** (capture ideas immediately)
10
+ * **Action-before-asking** (reduce low-value questions)
11
+ * **Research-first** for technical choices (avoid asking users to invent options)
12
+ * **Diverge �?Converge** (expand thinking, then lock MVP)
13
+
14
+ ---
15
+
16
+ ## When to Use
17
+
18
+ Triggered from `/` when the user describes a development task, especially when:
19
+
20
+ * requirements are unclear or evolving
21
+ * there are multiple valid implementation paths
22
+ * trade-offs matter (UX, reliability, maintainability, cost, performance)
23
+ * the user might not know the best options up front
24
+
25
+ ---
26
+
27
+ ## Core Principles (Non-negotiable)
28
+
29
+ 1. **Task-first (capture early)**
30
+ Always ensure a task exists at the start so the user's ideas are recorded immediately.
31
+
32
+ 2. **Action before asking**
33
+ If you can derive the answer from repo code, docs, configs, conventions, or quick research �?do that first.
34
+
35
+ 3. **One question per message**
36
+ Never overwhelm the user with a list of questions. Ask one, update PRD, repeat.
37
+
38
+ 4. **Prefer concrete options**
39
+ For preference/decision questions, present 2�? feasible, specific approaches with trade-offs.
40
+
41
+ 5. **Research-first for technical choices**
42
+ If the decision depends on industry conventions / similar tools / established patterns, do research first, then propose options.
43
+
44
+ 6. **Diverge �?Converge**
45
+ After initial understanding, proactively consider future evolution, related scenarios, and failure/edge cases �?then converge to an MVP with explicit out-of-scope.
46
+
47
+ 7. **No meta questions**
48
+ Do not ask "should I search?" or "can you paste the code so I can continue?"
49
+ If you need information: search/inspect. If blocked: ask the minimal blocking question.
50
+
51
+ ---
52
+
53
+ ## Step 0: Ensure Task Exists (ALWAYS)
54
+
55
+ Before any Q&A, ensure a task exists. If none exists, create one immediately.
56
+
57
+ * Use a **temporary working title** derived from the user's message.
58
+ * It's OK if the title is imperfect �?refine later in PRD.
59
+
60
+ ```bash
61
+ TASK_DIR=$(python3 ./.trellis/scripts/task.py create "brainstorm: <short goal>" --slug <auto>)
62
+ ```
63
+
64
+ Create/seed `prd.md` immediately with what you know:
65
+
66
+ ```markdown
67
+ # brainstorm: <short goal>
68
+
69
+ ## Goal
70
+
71
+ <one paragraph: what + why>
72
+
73
+ ## What I already know
74
+
75
+ * <facts from user message>
76
+ * <facts discovered from repo/docs>
77
+
78
+ ## Assumptions (temporary)
79
+
80
+ * <assumptions to validate>
81
+
82
+ ## Open Questions
83
+
84
+ * <ONLY Blocking / Preference questions; keep list short>
85
+
86
+ ## Requirements (evolving)
87
+
88
+ * <start with what is known>
89
+
90
+ ## Acceptance Criteria (evolving)
91
+
92
+ * [ ] <testable criterion>
93
+
94
+ ## Definition of Done (team quality bar)
95
+
96
+ * Tests added/updated (unit/integration where appropriate)
97
+ * Lint / typecheck / CI green
98
+ * Docs/notes updated if behavior changes
99
+ * Rollout/rollback considered if risky
100
+
101
+ ## Out of Scope (explicit)
102
+
103
+ * <what we will not do in this task>
104
+
105
+ ## Technical Notes
106
+
107
+ * <files inspected, constraints, links, references>
108
+ * <research notes summary if applicable>
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Step 1: Auto-Context (DO THIS BEFORE ASKING QUESTIONS)
114
+
115
+ Before asking questions like "what does the code look like?", gather context yourself:
116
+
117
+ ### Repo inspection checklist
118
+
119
+ * Identify likely modules/files impacted
120
+ * Locate existing patterns (similar features, conventions, error handling style)
121
+ * Check configs, scripts, existing command definitions
122
+ * Note any constraints (runtime, dependency policy, build tooling)
123
+
124
+ ### Documentation checklist
125
+
126
+ * Look for existing PRDs/specs/templates
127
+ * Look for command usage examples, README, ADRs if any
128
+
129
+ Write findings into PRD:
130
+
131
+ * Add to `What I already know`
132
+ * Add constraints/links to `Technical Notes`
133
+
134
+ ---
135
+
136
+ ## Step 2: Classify Complexity (still useful, not gating task creation)
137
+
138
+ | Complexity | Criteria | Action |
139
+ | ------------ | ------------------------------------------------------ | ------------------------------------------- |
140
+ | **Trivial** | Single-line fix, typo, obvious change | Skip brainstorm, implement directly |
141
+ | **Simple** | Clear goal, 1�? files, scope well-defined | Ask 1 confirm question, then implement |
142
+ | **Moderate** | Multiple files, some ambiguity | Light brainstorm (2�? high-value questions) |
143
+ | **Complex** | Vague goal, architectural choices, multiple approaches | Full brainstorm |
144
+
145
+ > Note: Task already exists from Step 0. Classification only affects depth of brainstorming.
146
+
147
+ ---
148
+
149
+ ## Step 3: Question Gate (Ask ONLY high-value questions)
150
+
151
+ Before asking ANY question, run the following gate:
152
+
153
+ ### Gate A �?Can I derive this without the user?
154
+
155
+ If answer is available via:
156
+
157
+ * repo inspection (code/config)
158
+ * docs/specs/conventions
159
+ * quick market/OSS research
160
+
161
+ �?**Do not ask.** Fetch it, summarize, update PRD.
162
+
163
+ ### Gate B �?Is this a meta/lazy question?
164
+
165
+ Examples:
166
+
167
+ * "Should I search?"
168
+ * "Can you paste the code so I can proceed?"
169
+ * "What does the code look like?" (when repo is available)
170
+
171
+ �?**Do not ask.** Take action.
172
+
173
+ ### Gate C �?What type of question is it?
174
+
175
+ * **Blocking**: cannot proceed without user input
176
+ * **Preference**: multiple valid choices, depends on product/UX/risk preference
177
+ * **Derivable**: should be answered by inspection/research
178
+
179
+ �?Only ask **Blocking** or **Preference**.
180
+
181
+ ---
182
+
183
+ ## Step 4: Research-first Mode (Mandatory for technical choices)
184
+
185
+ ### Trigger conditions (any �?research-first)
186
+
187
+ * The task involves selecting an approach, library, protocol, framework, template system, plugin mechanism, or CLI UX convention
188
+ * The user asks for "best practice", "how others do it", "recommendation"
189
+ * The user can't reasonably enumerate options
190
+
191
+ ### Research steps
192
+
193
+ 1. Identify 2�? comparable tools/patterns
194
+ 2. Summarize common conventions and why they exist
195
+ 3. Map conventions onto our repo constraints
196
+ 4. Produce **2�? feasible approaches** for our project
197
+
198
+ ### Research output format (PRD)
199
+
200
+ Add a section in PRD (either within Technical Notes or as its own):
201
+
202
+ ```markdown
203
+ ## Research Notes
204
+
205
+ ### What similar tools do
206
+
207
+ * ...
208
+ * ...
209
+
210
+ ### Constraints from our repo/project
211
+
212
+ * ...
213
+
214
+ ### Feasible approaches here
215
+
216
+ **Approach A: <name>** (Recommended)
217
+
218
+ * How it works:
219
+ * Pros:
220
+ * Cons:
221
+
222
+ **Approach B: <name>**
223
+
224
+ * How it works:
225
+ * Pros:
226
+ * Cons:
227
+
228
+ **Approach C: <name>** (optional)
229
+
230
+ * ...
231
+ ```
232
+
233
+ Then ask **one** preference question:
234
+
235
+ * "Which approach do you prefer: A / B / C (or other)?"
236
+
237
+ ---
238
+
239
+ ## Step 5: Expansion Sweep (DIVERGE) �?Required after initial understanding
240
+
241
+ After you can summarize the goal, proactively broaden thinking before converging.
242
+
243
+ ### Expansion categories (keep to 1�? bullets each)
244
+
245
+ 1. **Future evolution**
246
+
247
+ * What might this feature become in 1�? months?
248
+ * What extension points are worth preserving now?
249
+
250
+ 2. **Related scenarios**
251
+
252
+ * What adjacent commands/flows should remain consistent with this?
253
+ * Are there parity expectations (create vs update, import vs export, etc.)?
254
+
255
+ 3. **Failure & edge cases**
256
+
257
+ * Conflicts, offline/network failure, retries, idempotency, compatibility, rollback
258
+ * Input validation, security boundaries, permission checks
259
+
260
+ ### Expansion message template (to user)
261
+
262
+ ```markdown
263
+ I understand you want to implement: <current goal>.
264
+
265
+ Before diving into design, let me quickly diverge to consider three categories (to avoid rework later):
266
+
267
+ 1. Future evolution: <1�? bullets>
268
+ 2. Related scenarios: <1�? bullets>
269
+ 3. Failure/edge cases: <1�? bullets>
270
+
271
+ For this MVP, which would you like to include (or none)?
272
+
273
+ 1. Current requirement only (minimal viable)
274
+ 2. Add <X> (reserve for future extension)
275
+ 3. Add <Y> (improve robustness/consistency)
276
+ 4. Other: describe your preference
277
+ ```
278
+
279
+ Then update PRD:
280
+
281
+ * What's in MVP �?`Requirements`
282
+ * What's excluded �?`Out of Scope`
283
+
284
+ ---
285
+
286
+ ## Step 6: Q&A Loop (CONVERGE)
287
+
288
+ ### Rules
289
+
290
+ * One question per message
291
+ * Prefer multiple-choice when possible
292
+ * After each user answer:
293
+
294
+ * Update PRD immediately
295
+ * Move answered items from `Open Questions` �?`Requirements`
296
+ * Update `Acceptance Criteria` with testable checkboxes
297
+ * Clarify `Out of Scope`
298
+
299
+ ### Question priority (recommended)
300
+
301
+ 1. **MVP scope boundary** (what is included/excluded)
302
+ 2. **Preference decisions** (after presenting concrete options)
303
+ 3. **Failure/edge behavior** (only for MVP-critical paths)
304
+ 4. **Success metrics & Acceptance Criteria** (what proves it works)
305
+
306
+ ### Preferred question format (multiple choice)
307
+
308
+ ```markdown
309
+ For <topic>, which approach do you prefer?
310
+
311
+ 1. **Option A** �?<what it means + trade-off>
312
+ 2. **Option B** �?<what it means + trade-off>
313
+ 3. **Option C** �?<what it means + trade-off>
314
+ 4. **Other** �?describe your preference
315
+ ```
316
+
317
+ ---
318
+
319
+ ## Step 7: Propose Approaches + Record Decisions (Complex tasks)
320
+
321
+ After requirements are clear enough, propose 2�? approaches (if not already done via research-first):
322
+
323
+ ```markdown
324
+ Based on current information, here are 2�? feasible approaches:
325
+
326
+ **Approach A: <name>** (Recommended)
327
+
328
+ * How:
329
+ * Pros:
330
+ * Cons:
331
+
332
+ **Approach B: <name>**
333
+
334
+ * How:
335
+ * Pros:
336
+ * Cons:
337
+
338
+ Which direction do you prefer?
339
+ ```
340
+
341
+ Record the outcome in PRD as an ADR-lite section:
342
+
343
+ ```markdown
344
+ ## Decision (ADR-lite)
345
+
346
+ **Context**: Why this decision was needed
347
+ **Decision**: Which approach was chosen
348
+ **Consequences**: Trade-offs, risks, potential future improvements
349
+ ```
350
+
351
+ ---
352
+
353
+ ## Step 8: Final Confirmation + Implementation Plan
354
+
355
+ When open questions are resolved, confirm complete requirements with a structured summary:
356
+
357
+ ### Final confirmation format
358
+
359
+ ```markdown
360
+ Here's my understanding of the complete requirements:
361
+
362
+ **Goal**: <one sentence>
363
+
364
+ **Requirements**:
365
+
366
+ * ...
367
+ * ...
368
+
369
+ **Acceptance Criteria**:
370
+
371
+ * [ ] ...
372
+ * [ ] ...
373
+
374
+ **Definition of Done**:
375
+
376
+ * ...
377
+
378
+ **Out of Scope**:
379
+
380
+ * ...
381
+
382
+ **Technical Approach**:
383
+ <brief summary + key decisions>
384
+
385
+ **Implementation Plan (small PRs)**:
386
+
387
+ * PR1: <scaffolding + tests + minimal plumbing>
388
+ * PR2: <core behavior>
389
+ * PR3: <edge cases + docs + cleanup>
390
+
391
+ Does this look correct? If yes, I'll proceed with implementation.
392
+ ```
393
+
394
+ ### Subtask Decomposition (Complex Tasks)
395
+
396
+ For complex tasks with multiple independent work items, create subtasks:
397
+
398
+ ```bash
399
+ # Create child tasks
400
+ CHILD1=$(python3 ./.trellis/scripts/task.py create "Child task 1" --slug child1 --parent "$TASK_DIR")
401
+ CHILD2=$(python3 ./.trellis/scripts/task.py create "Child task 2" --slug child2 --parent "$TASK_DIR")
402
+
403
+ # Or link existing tasks
404
+ python3 ./.trellis/scripts/task.py add-subtask "$TASK_DIR" "$CHILD_DIR"
405
+ ```
406
+
407
+ ---
408
+
409
+ ## PRD Target Structure (final)
410
+
411
+ `prd.md` should converge to:
412
+
413
+ ```markdown
414
+ # <Task Title>
415
+
416
+ ## Goal
417
+
418
+ <why + what>
419
+
420
+ ## Requirements
421
+
422
+ * ...
423
+
424
+ ## Acceptance Criteria
425
+
426
+ * [ ] ...
427
+
428
+ ## Definition of Done
429
+
430
+ * ...
431
+
432
+ ## Technical Approach
433
+
434
+ <key design + decisions>
435
+
436
+ ## Decision (ADR-lite)
437
+
438
+ Context / Decision / Consequences
439
+
440
+ ## Out of Scope
441
+
442
+ * ...
443
+
444
+ ## Technical Notes
445
+
446
+ <constraints, references, files, research notes>
447
+ ```
448
+
449
+ ---
450
+
451
+ ## Anti-Patterns (Hard Avoid)
452
+
453
+ * Asking user for code/context that can be derived from repo
454
+ * Asking user to choose an approach before presenting concrete options
455
+ * Meta questions about whether to research
456
+ * Staying narrowly on the initial request without considering evolution/edges
457
+ * Letting brainstorming drift without updating PRD
458
+
459
+ ---
460
+
461
+ ## Integration with Start Workflow
462
+
463
+ After brainstorm completes (Step 8 confirmation approved), the flow continues to the Task Workflow's **Phase 2: Prepare for Implementation**:
464
+
465
+ ```text
466
+ Brainstorm
467
+ Step 0: Create task directory + seed PRD
468
+ Step 1�?: Discover requirements, research, converge
469
+ Step 8: Final confirmation �?user approves
470
+ �?
471
+ Task Workflow Phase 2 (Prepare for Implementation)
472
+ Code-Spec Depth Check (if applicable)
473
+ �?Research codebase (based on confirmed PRD)
474
+ �?Configure code-spec context (jsonl files)
475
+ �?Activate task
476
+ �?
477
+ Task Workflow Phase 3 (Execute)
478
+ Implement �?Check �?Complete
479
+ ```
480
+
481
+ The task directory and PRD already exist from brainstorm, so Phase 1 of the Task Workflow is skipped entirely.
482
+
483
+ ---
484
+
485
+ ## Related Commands
486
+
487
+ | Command | When to Use |
488
+ |---------|-------------|
489
+ | `/` | Entry point that triggers brainstorm |
490
+ | `/` | After implementation is complete |
491
+ | `/` | If new patterns emerge during work |
@@ -0,0 +1,129 @@
1
+ ---
2
+ description: "Trellis Copilot prompt: Break the Loop - Deep Bug Analysis"
3
+ ---
4
+
5
+ # Break the Loop - Deep Bug Analysis
6
+
7
+ When debug is complete, use this command for deep analysis to break the "fix bug -> forget -> repeat" cycle.
8
+
9
+ ---
10
+
11
+ ## Analysis Framework
12
+
13
+ Analyze the bug you just fixed from these 5 dimensions:
14
+
15
+ ### 1. Root Cause Category
16
+
17
+ Which category does this bug belong to?
18
+
19
+ | Category | Characteristics | Example |
20
+ |----------|-----------------|---------|
21
+ | **A. Missing Spec** | No documentation on how to do it | New feature without checklist |
22
+ | **B. Cross-Layer Contract** | Interface between layers unclear | API returns different format than expected |
23
+ | **C. Change Propagation Failure** | Changed one place, missed others | Changed function signature, missed call sites |
24
+ | **D. Test Coverage Gap** | Unit test passes, integration fails | Works alone, breaks when combined |
25
+ | **E. Implicit Assumption** | Code relies on undocumented assumption | Timestamp seconds vs milliseconds |
26
+
27
+ ### 2. Why Fixes Failed (if applicable)
28
+
29
+ If you tried multiple fixes before succeeding, analyze each failure:
30
+
31
+ - **Surface Fix**: Fixed symptom, not root cause
32
+ - **Incomplete Scope**: Found root cause, didn't cover all cases
33
+ - **Tool Limitation**: grep missed it, type check wasn't strict
34
+ - **Mental Model**: Kept looking in same layer, didn't think cross-layer
35
+
36
+ ### 3. Prevention Mechanisms
37
+
38
+ What mechanisms would prevent this from happening again?
39
+
40
+ | Type | Description | Example |
41
+ |------|-------------|---------|
42
+ | **Documentation** | Write it down so people know | Update thinking guide |
43
+ | **Architecture** | Make the error impossible structurally | Type-safe wrappers |
44
+ | **Compile-time** | TypeScript strict, no any | Signature change causes compile error |
45
+ | **Runtime** | Monitoring, alerts, scans | Detect orphan entities |
46
+ | **Test Coverage** | E2E tests, integration tests | Verify full flow |
47
+ | **Code Review** | Checklist, PR template | "Did you check X?" |
48
+
49
+ ### 4. Systematic Expansion
50
+
51
+ What broader problems does this bug reveal?
52
+
53
+ - **Similar Issues**: Where else might this problem exist?
54
+ - **Design Flaw**: Is there a fundamental architecture issue?
55
+ - **Process Flaw**: Is there a development process improvement?
56
+ - **Knowledge Gap**: Is the team missing some understanding?
57
+
58
+ ### 5. Knowledge Capture
59
+
60
+ Solidify insights into the system:
61
+
62
+ - [ ] Update `.trellis/spec/guides/` thinking guides
63
+ - [ ] Update `.trellis/spec/backend/` or `frontend/` docs
64
+ - [ ] Create issue record (if applicable)
65
+ - [ ] Create feature ticket for root fix
66
+ - [ ] Update check commands if needed
67
+
68
+ ---
69
+
70
+ ## Output Format
71
+
72
+ Please output analysis in this format:
73
+
74
+ ```markdown
75
+ ## Bug Analysis: [Short Description]
76
+
77
+ ### 1. Root Cause Category
78
+ - **Category**: [A/B/C/D/E] - [Category Name]
79
+ - **Specific Cause**: [Detailed description]
80
+
81
+ ### 2. Why Fixes Failed (if applicable)
82
+ 1. [First attempt]: [Why it failed]
83
+ 2. [Second attempt]: [Why it failed]
84
+ ...
85
+
86
+ ### 3. Prevention Mechanisms
87
+ | Priority | Mechanism | Specific Action | Status |
88
+ |----------|-----------|-----------------|--------|
89
+ | P0 | ... | ... | TODO/DONE |
90
+
91
+ ### 4. Systematic Expansion
92
+ - **Similar Issues**: [List places with similar problems]
93
+ - **Design Improvement**: [Architecture-level suggestions]
94
+ - **Process Improvement**: [Development process suggestions]
95
+
96
+ ### 5. Knowledge Capture
97
+ - [ ] [Documents to update / tickets to create]
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Core Philosophy
103
+
104
+ > **The value of debugging is not in fixing the bug, but in making this class of bugs never happen again.**
105
+
106
+ Three levels of insight:
107
+ 1. **Tactical**: How to fix THIS bug
108
+ 2. **Strategic**: How to prevent THIS CLASS of bugs
109
+ 3. **Philosophical**: How to expand thinking patterns
110
+
111
+ 30 minutes of analysis saves 30 hours of future debugging.
112
+
113
+ ---
114
+
115
+ ## After Analysis: Immediate Actions
116
+
117
+ **IMPORTANT**: After completing the analysis above, you MUST immediately:
118
+
119
+ 1. **Update spec/guides** - Don't just list TODOs, actually update the relevant files:
120
+ - If it's a cross-platform issue �?update `cross-platform-thinking-guide.md`
121
+ - If it's a cross-layer issue �?update `cross-layer-thinking-guide.md`
122
+ - If it's a code reuse issue �?update `code-reuse-thinking-guide.md`
123
+ - If it's domain-specific �?update `backend/*.md` or `frontend/*.md`
124
+
125
+ 2. **Sync templates** - After updating `.trellis/spec/`, sync to `src/templates/markdown/spec/`
126
+
127
+ 3. **Commit the spec updates** - This is the primary output, not just the analysis text
128
+
129
+ > **The analysis is worthless if it stays in chat. The value is in the updated specs.**