trinity-method-sdk 2.1.0 → 2.2.1

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 (101) hide show
  1. package/CHANGELOG.md +728 -467
  2. package/README.md +550 -539
  3. package/dist/cli/commands/deploy/ci-cd.d.ts +4 -3
  4. package/dist/cli/commands/deploy/ci-cd.js +10 -9
  5. package/dist/cli/commands/deploy/configuration.js +10 -11
  6. package/dist/cli/commands/deploy/directories.js +13 -14
  7. package/dist/cli/commands/deploy/gitignore.js +3 -4
  8. package/dist/cli/commands/deploy/index.d.ts +1 -1
  9. package/dist/cli/commands/deploy/index.js +6 -2
  10. package/dist/cli/commands/deploy/knowledge-base.js +2 -2
  11. package/dist/cli/commands/deploy/pre-flight.js +1 -1
  12. package/dist/cli/commands/deploy/root-files.js +2 -17
  13. package/dist/cli/commands/deploy/summary.js +3 -3
  14. package/dist/cli/commands/deploy/templates.js +5 -5
  15. package/dist/cli/commands/update/backup.js +6 -12
  16. package/dist/cli/commands/update/index.js +15 -1
  17. package/dist/cli/commands/update/knowledge-base.js +1 -1
  18. package/dist/cli/commands/update/migration.d.ts +31 -0
  19. package/dist/cli/commands/update/migration.js +130 -0
  20. package/dist/cli/commands/update/pre-flight.d.ts +7 -2
  21. package/dist/cli/commands/update/pre-flight.js +21 -20
  22. package/dist/cli/commands/update/summary.js +11 -5
  23. package/dist/cli/commands/update/templates.js +1 -1
  24. package/dist/cli/commands/update/types.d.ts +2 -0
  25. package/dist/cli/commands/update/verification.js +5 -5
  26. package/dist/cli/commands/update/version.js +6 -4
  27. package/dist/cli/utils/deploy-ci.d.ts +3 -2
  28. package/dist/cli/utils/deploy-ci.js +24 -24
  29. package/dist/cli/utils/deploy-linting.js +100 -5
  30. package/dist/cli/utils/error-classes.d.ts +2 -2
  31. package/dist/cli/utils/linting-tools.js +14 -6
  32. package/dist/cli/utils/template-processor.js +1 -3
  33. package/dist/templates/.claude/EMPLOYEE-DIRECTORY.md.template +16 -22
  34. package/dist/templates/.claude/agents/aj-team/apo-documentation-specialist.md.template +7 -7
  35. package/dist/templates/.claude/agents/aj-team/bas-quality-gate.md.template +8 -8
  36. package/dist/templates/.claude/agents/aj-team/dra-code-reviewer.md.template +3 -3
  37. package/dist/templates/.claude/agents/aj-team/kil-task-executor.md.template +6 -6
  38. package/dist/templates/.claude/agents/audit/juno-auditor.md.template +39 -40
  39. package/dist/templates/.claude/agents/deployment/ein-cicd.md.template +56 -159
  40. package/dist/templates/.claude/agents/deployment/ino-context.md.template +21 -21
  41. package/dist/templates/.claude/agents/deployment/tan-structure.md.template +28 -29
  42. package/dist/templates/.claude/agents/deployment/zen-knowledge.md.template +22 -23
  43. package/dist/templates/.claude/agents/leadership/aj-maestro.md.template +6 -6
  44. package/dist/templates/.claude/agents/leadership/aly-cto.md.template +17 -18
  45. package/dist/templates/.claude/agents/planning/eus-decomposer.md.template +4 -4
  46. package/dist/templates/.claude/agents/planning/mon-requirements.md.template +4 -4
  47. package/dist/templates/.claude/agents/planning/ror-design.md.template +4 -4
  48. package/dist/templates/.claude/agents/planning/tra-planner.md.template +4 -4
  49. package/dist/templates/.claude/commands/execution/trinity-audit.md.template +9 -9
  50. package/dist/templates/.claude/commands/execution/trinity-breakdown.md.template +535 -0
  51. package/dist/templates/.claude/commands/execution/trinity-orchestrate.md.template +43 -43
  52. package/dist/templates/.claude/commands/infrastructure/trinity-init.md.template +20 -43
  53. package/dist/templates/.claude/commands/investigation/trinity-create-investigation.md.template +5 -5
  54. package/dist/templates/.claude/commands/investigation/trinity-investigate-templates.md.template +10 -10
  55. package/dist/templates/.claude/commands/investigation/trinity-plan-investigation.md.template +1 -1
  56. package/dist/templates/.claude/commands/maintenance/trinity-changelog.md.template +4 -4
  57. package/dist/templates/.claude/commands/maintenance/trinity-docs-update.md.template +10 -10
  58. package/dist/templates/.claude/commands/maintenance/trinity-docs.md.template +62 -62
  59. package/dist/templates/.claude/commands/maintenance/trinity-readme.md.template +16 -16
  60. package/dist/templates/.claude/commands/session/trinity-continue.md.template +22 -22
  61. package/dist/templates/.claude/commands/session/trinity-end.md.template +22 -22
  62. package/dist/templates/.claude/commands/session/trinity-start.md.template +1 -2
  63. package/dist/templates/.claude/commands/utility/trinity-agents.md.template +3 -6
  64. package/dist/templates/.claude/commands/utility/trinity-verify.md.template +48 -54
  65. package/dist/templates/.claude/commands/utility/trinity-workorder.md.template +5 -5
  66. package/dist/templates/ci/ci.yml.template +2 -2
  67. package/dist/templates/root/CLAUDE.md.template +9 -9
  68. package/dist/templates/root/linting/nodejs/.husky-pre-commit.template +5 -0
  69. package/dist/templates/source/base-CLAUDE.md.template +310 -310
  70. package/dist/templates/source/flutter-CLAUDE.md.template +593 -593
  71. package/dist/templates/source/nodejs-CLAUDE.md.template +531 -531
  72. package/dist/templates/source/python-CLAUDE.md.template +510 -510
  73. package/dist/templates/source/react-CLAUDE.md.template +513 -513
  74. package/dist/templates/source/rust-CLAUDE.md.template +653 -653
  75. package/dist/templates/trinity/CLAUDE.md.template +14 -14
  76. package/dist/templates/trinity/knowledge-base/ARCHITECTURE.md.template +4 -4
  77. package/dist/templates/trinity/knowledge-base/ISSUES.md.template +8 -8
  78. package/dist/templates/trinity/knowledge-base/Technical-Debt.md.template +1 -3
  79. package/dist/templates/trinity/knowledge-base/To-do.md.template +1 -1
  80. package/dist/templates/trinity/knowledge-base/Trinity.md.template +5 -5
  81. package/dist/templates/trinity/templates/documentation/configuration/env-example-generator.md.template +1 -1
  82. package/dist/templates/trinity/templates/documentation/processes/error-handling-protocol.md.template +2 -2
  83. package/dist/templates/trinity/templates/documentation/reports/apo-docs-update-checklist.md.template +7 -7
  84. package/dist/templates/trinity/templates/documentation/reports/juno-docs-update-checklist.md.template +4 -4
  85. package/dist/templates/trinity/templates/documentation/reports/juno-internal-report.md.template +10 -10
  86. package/dist/templates/trinity/templates/investigations/bug.md.template +14 -14
  87. package/dist/templates/trinity/templates/investigations/feature.md.template +14 -14
  88. package/dist/templates/trinity/templates/investigations/performance.md.template +14 -14
  89. package/dist/templates/trinity/templates/investigations/security.md.template +14 -14
  90. package/dist/templates/trinity/templates/investigations/technical.md.template +14 -14
  91. package/dist/templates/trinity/templates/work-orders/ANALYSIS-TEMPLATE.md.template +10 -10
  92. package/dist/templates/trinity/templates/work-orders/AUDIT-TEMPLATE.md.template +10 -10
  93. package/dist/templates/trinity/templates/work-orders/IMPLEMENTATION-TEMPLATE.md.template +10 -10
  94. package/dist/templates/trinity/templates/work-orders/INVESTIGATION-TEMPLATE.md.template +10 -10
  95. package/dist/templates/trinity/templates/work-orders/PATTERN-TEMPLATE.md.template +10 -10
  96. package/dist/templates/trinity/templates/work-orders/VERIFICATION-TEMPLATE.md.template +10 -10
  97. package/package.json +99 -94
  98. package/dist/templates/.claude/agents/leadership/aj-cc.md.template +0 -467
  99. package/dist/templates/ci/cd.yml.template +0 -175
  100. package/dist/templates/ci/github-actions.yml +0 -86
  101. package/dist/templates/root/TRINITY.md.template +0 -52
@@ -28,8 +28,8 @@
28
28
  - ✅ **Tool-based:** Uses actual linters/scanners, not just file reading
29
29
 
30
30
  **Deliverable:**
31
- - `trinity/reports/CODEBASE-AUDIT-{date}.md` (human-readable report)
32
- - `trinity/reports/AUDIT-BASELINE-{date}.json` (machine-readable baseline for future comparisons)
31
+ - `.claude/trinity/reports/CODEBASE-AUDIT-{date}.md` (human-readable report)
32
+ - `.claude/trinity/reports/AUDIT-BASELINE-{date}.json` (machine-readable baseline for future comparisons)
33
33
 
34
34
  ---
35
35
 
@@ -56,7 +56,7 @@
56
56
 
57
57
  ### ⚠️ Second Audit Behavior:
58
58
 
59
- When a baseline exists (`trinity/reports/AUDIT-BASELINE-*.json`):
59
+ When a baseline exists (`.claude/trinity/reports/AUDIT-BASELINE-*.json`):
60
60
  - **FIXED issues:** ✅ Marked as resolved (celebrate!)
61
61
  - **NEW issues:** ⚠️ Flagged as introduced since last audit
62
62
  - **PERSISTENT issues:** 🔴 Still present from previous audit
@@ -75,7 +75,7 @@ JUNO follows a **strict, repeatable process** to ensure consistent results:
75
75
 
76
76
  ```bash
77
77
  # Check for existing baseline
78
- IF trinity/reports/AUDIT-BASELINE-*.json exists:
78
+ IF .claude/trinity/reports/AUDIT-BASELINE-*.json exists:
79
79
  - Load previous findings
80
80
  - Track what's been fixed ✅
81
81
  - Track what's new ⚠️
@@ -425,7 +425,7 @@ IF baseline exists:
425
425
 
426
426
  **Two files created:**
427
427
 
428
- #### 1. Human-Readable Report: `trinity/reports/CODEBASE-AUDIT-{date}.md`
428
+ #### 1. Human-Readable Report: `.claude/trinity/reports/CODEBASE-AUDIT-{date}.md`
429
429
 
430
430
  ```markdown
431
431
  # Codebase Audit Report
@@ -503,10 +503,10 @@ Expected result: "0 new issues, 0 persistent issues, X fixed issues"
503
503
 
504
504
  **Audit Complete:** {timestamp}
505
505
  **Confidence:** {HIGH|MEDIUM|LOW}
506
- **Baseline Saved:** trinity/reports/AUDIT-BASELINE-{date}.json
506
+ **Baseline Saved:** .claude/trinity/reports/AUDIT-BASELINE-{date}.json
507
507
  ```
508
508
 
509
- #### 2. Machine-Readable Baseline: `trinity/reports/AUDIT-BASELINE-{date}.json`
509
+ #### 2. Machine-Readable Baseline: `.claude/trinity/reports/AUDIT-BASELINE-{date}.json`
510
510
 
511
511
  ```json
512
512
  {
@@ -599,8 +599,8 @@ JUNO: Loading previous audit baseline...
599
599
 
600
600
  **Recommendation:** You're done! The codebase is in excellent shape.
601
601
 
602
- **Audit saved:** trinity/reports/CODEBASE-AUDIT-2025-12-21.md
603
- **Baseline updated:** trinity/reports/AUDIT-BASELINE-2025-12-21.json
602
+ **Audit saved:** .claude/trinity/reports/CODEBASE-AUDIT-2025-12-21.md
603
+ **Baseline updated:** .claude/trinity/reports/AUDIT-BASELINE-2025-12-21.json
604
604
  ```
605
605
 
606
606
  **This is how the cycle ends.**
@@ -0,0 +1,535 @@
1
+ # Trinity Breakdown
2
+
3
+ **Command:** `/execution:trinity-breakdown`
4
+ **Purpose:** Guided step-by-step implementation where the user makes all edits, instructed by AJ MAESTRO
5
+ **Architecture:** ALY (CTO) → AJ MAESTRO analysis → Step-by-step user guidance → User verification
6
+ **Trinity Version:** 2.1.0
7
+ **Last Updated:** 2026-02-23
8
+
9
+ **Use throughout your session:** This command guides you through implementations step by step.
10
+
11
+ ---
12
+
13
+ ## Overview
14
+
15
+ `/trinity-breakdown` is the **guided implementation command** in Trinity Method development. Unlike `/trinity-orchestrate` where CC executes changes directly, this command has CC act as an **implementation instructor** — explaining what to change, where to change it, and why — so **you make the edits yourself**.
16
+
17
+ **Key Difference from Orchestrate:**
18
+
19
+ | Aspect | `/trinity-orchestrate` | `/trinity-breakdown` |
20
+ |--------|----------------------|---------------------|
21
+ | Who edits code | CC / KIL agents | **You** (the user) |
22
+ | CC's role | Execute changes | Explain what to change |
23
+ | Output | Commits and reports | Step-by-step instructions |
24
+ | Quality gates | BAS runs automatically | You run quality checks with guidance |
25
+ | Learning | Minimal | **Maximum** — you understand every change |
26
+
27
+ **When to use Breakdown vs Orchestrate:**
28
+ - **Breakdown:** You want to learn, understand the codebase, or make changes yourself
29
+ - **Orchestrate:** You want CC to handle implementation autonomously
30
+
31
+ **Development Session Flow:**
32
+ ```
33
+ /trinity-start or /trinity-continue
34
+ |
35
+ /trinity-breakdown (GUIDED LOOP - user makes edits)
36
+ |
37
+ /trinity-end
38
+ ```
39
+
40
+ ---
41
+
42
+ ## Usage Patterns
43
+
44
+ ### 1. Break Down Work Orders (Formal Tasks)
45
+
46
+ ```bash
47
+ /trinity-breakdown @WO-XXX-{task-name}.md
48
+ ```
49
+
50
+ **When to use:**
51
+ - Complex tasks where you want to understand every change
52
+ - Learning a new codebase through guided implementation
53
+ - Tasks requiring careful manual review at each step
54
+ - Work that benefits from human judgment at each edit
55
+
56
+ **Workflow:**
57
+ 1. Create work order: `/trinity-workorder`
58
+ 2. Work order saved to: `trinity/work-orders/WO-XXX-{task-name}.md`
59
+ 3. Guide: `/trinity-breakdown @WO-042-jwt-refresh.md`
60
+ 4. **AJ MAESTRO** analyzes the task and creates step-by-step instructions
61
+ 5. **You implement each step** following CC's guidance
62
+ 6. **You verify each step** (run tests, lint, build as instructed)
63
+ 7. **After completion:** Move work order from `trinity/work-orders/` to `trinity/sessions/`
64
+
65
+ **Example:**
66
+ ```bash
67
+ /trinity-breakdown @WO-042-jwt-refresh-implementation.md
68
+ ```
69
+
70
+ ---
71
+
72
+ ### 2. Break Down Investigations (READ-ONLY Analysis)
73
+
74
+ ```bash
75
+ /trinity-breakdown @INV-XXX-{title}.md
76
+ ```
77
+
78
+ **When to use:**
79
+ - Guided investigation where you want to explore the codebase yourself
80
+ - Learning how systems work through structured exploration
81
+ - When you want to understand root causes firsthand
82
+
83
+ **Workflow:**
84
+ 1. Create investigation: `/trinity-create-investigation`
85
+ 2. Investigation saved to: `trinity/investigations/INV-XXX-{title}.md`
86
+ 3. Guide: `/trinity-breakdown @INV-015-performance-analysis.md`
87
+ 4. **AJ MAESTRO** provides exploration steps
88
+ 5. **You explore** following CC's guidance (READ-ONLY — no code changes)
89
+ 6. **Findings documented** based on your discoveries
90
+ 7. **After completion:** Move investigation from `trinity/investigations/` to `trinity/sessions/`
91
+
92
+ **Example:**
93
+ ```bash
94
+ /trinity-breakdown @INV-015-database-performance-analysis.md
95
+ ```
96
+
97
+ ---
98
+
99
+ ### 3. Break Down General Tasks (Quick Tasks)
100
+
101
+ ```bash
102
+ /trinity-breakdown "Task description"
103
+ ```
104
+
105
+ **When to use:**
106
+ - Quick changes where you want step-by-step guidance
107
+ - Learning how to implement a specific pattern
108
+ - Simple fixes with instructional walkthrough
109
+
110
+ **How it works:**
111
+ - AJ MAESTRO assesses task complexity
112
+ - Breaks it into individual steps with instructions
113
+ - Guides you through each step
114
+ - Helps you verify the result
115
+
116
+ **Example:**
117
+ ```bash
118
+ /trinity-breakdown "Fix date validation bug in UserForm component"
119
+ ```
120
+
121
+ ---
122
+
123
+ ## AJ MAESTRO's Breakdown Process
124
+
125
+ When you invoke `/trinity-breakdown`, here's what happens:
126
+
127
+ ### Step 1: Task Analysis
128
+
129
+ **AJ MAESTRO reads and analyzes:**
130
+ - Work order file (if @WO-XXX provided)
131
+ - Investigation file (if @INV-XXX provided)
132
+ - Task description (if general task)
133
+
134
+ **Determines:**
135
+ - Task complexity and scope
136
+ - Required expertise areas
137
+ - Optimal step-by-step breakdown
138
+ - Verification checks for each step
139
+
140
+ ---
141
+
142
+ ### Step 2: Agent Persona Selection
143
+
144
+ **AJ MAESTRO selects the best agent persona(s) for guidance:**
145
+
146
+ CC adopts the relevant agent's expertise to provide specialized instructions:
147
+
148
+ - **MON persona** — Requirements guidance
149
+ - **ROR persona** — Design and architecture guidance
150
+ - **KIL persona** — Implementation instructions (TDD guidance)
151
+ - **BAS persona** — Quality gate verification instructions
152
+ - **DRA persona** — Code review guidance
153
+ - **APO persona** — Documentation instructions
154
+
155
+ **Selection Criteria:**
156
+ - Small tasks (1-2 files): Direct KIL-style implementation guidance
157
+ - Medium tasks (3-5 files): Design overview, then step-by-step implementation
158
+ - Large tasks (6+ files): Full planning overview, then phased step-by-step guidance
159
+
160
+ ---
161
+
162
+ ### Step 3: Walk-Through Execution
163
+
164
+ **AJ MAESTRO presents each change as a structured instruction:**
165
+
166
+ For each step, CC provides:
167
+
168
+ 1. **What file to open** — Exact file path
169
+ 2. **Where to make the change** — Line numbers or code context
170
+ 3. **What to change** — The specific edit (old code → new code)
171
+ 4. **Why this change is needed** — Reasoning and context
172
+ 5. **How to verify** — What to check after making the change
173
+
174
+ **Instruction Format:**
175
+
176
+ ```
177
+ STEP X of Y: [Brief description]
178
+
179
+ FILE: path/to/file.ext
180
+ LOCATION: Line XX (after/before [context])
181
+
182
+ WHAT TO DO:
183
+ [Clear instruction — add, modify, or remove code]
184
+
185
+ CODE:
186
+ [Exact code to write or the change to make]
187
+
188
+ WHY:
189
+ [Brief explanation of why this change is needed]
190
+
191
+ VERIFY:
192
+ [How to check this step worked — e.g., "Save and run: npm test"]
193
+ ```
194
+
195
+ **Important Rules for Instructions:**
196
+ - One change per step (atomic instructions)
197
+ - Always provide the exact file path
198
+ - Always explain WHY, not just WHAT
199
+ - Include verification after each meaningful change
200
+ - Never skip ahead — wait for user confirmation before next step
201
+
202
+ ---
203
+
204
+ ### Step 4: User Verification
205
+
206
+ **After each significant phase, CC guides you to verify:**
207
+
208
+ ```
209
+ VERIFICATION CHECKPOINT
210
+
211
+ Run these commands to verify your changes:
212
+
213
+ 1. Build: npm run build
214
+ 2. Lint: npm run lint
215
+ 3. Test: npm test
216
+
217
+ Expected Results:
218
+ - Build: Should compile without errors
219
+ - Lint: No new warnings or errors
220
+ - Test: All tests should pass
221
+
222
+ If any check fails, let me know and I'll help you fix it.
223
+ ```
224
+
225
+ ---
226
+
227
+ ### Step 5: Completion Summary
228
+
229
+ **After all steps are complete, CC provides:**
230
+ - Summary of all changes made
231
+ - Files modified
232
+ - Tests affected
233
+ - Next steps or follow-up recommendations
234
+ - Work order completion workflow (move to sessions/)
235
+
236
+ ---
237
+
238
+ ## After Task Completion Workflow
239
+
240
+ ### When You've Completed All Steps
241
+
242
+ **Step 1: Verify All Changes**
243
+ - [ ] All instructed changes have been made
244
+ - [ ] Build passes: `npm run build` (or equivalent)
245
+ - [ ] Lint passes: `npm run lint` (or equivalent)
246
+ - [ ] Tests pass: `npm test` (or equivalent)
247
+
248
+ **Step 2: Move Completed File to Sessions**
249
+
250
+ ```bash
251
+ # Work Order
252
+ mv trinity/work-orders/WO-XXX-*.md trinity/sessions/
253
+
254
+ # Investigation
255
+ mv trinity/investigations/INV-XXX-*.md trinity/sessions/
256
+ ```
257
+
258
+ **Step 3: Verify File Locations**
259
+ - [ ] Completed file NOW EXISTS in: `trinity/sessions/`
260
+ - [ ] Completed file NO LONGER EXISTS in: `trinity/work-orders/` or `trinity/investigations/`
261
+
262
+ **Step 4: Continue or End Session**
263
+ - Continue with next task, or
264
+ - Run `/trinity-end` to archive session
265
+
266
+ ---
267
+
268
+ ## Real-World Examples
269
+
270
+ ### Example 1: Work Order Breakdown
271
+
272
+ ```
273
+ User: /trinity-breakdown @WO-042-jwt-refresh-implementation.md
274
+
275
+ AJ MAESTRO: Reading work order WO-042...
276
+
277
+ I'll walk you through implementing JWT token refresh step by step.
278
+ You'll make all the edits — I'll tell you exactly what to change and why.
279
+
280
+ OVERVIEW:
281
+ - 4 files to create/modify
282
+ - 8 steps total
283
+ - Estimated time: 45-60 minutes
284
+ - You'll need: Your code editor and a terminal
285
+
286
+ Let's begin.
287
+
288
+ ---
289
+
290
+ STEP 1 of 8: Create the token refresh service file
291
+
292
+ FILE: src/services/token-refresh.service.ts
293
+ LOCATION: New file
294
+
295
+ WHAT TO DO:
296
+ Create a new file with the following content:
297
+
298
+ CODE:
299
+ import { sign, verify } from 'jsonwebtoken';
300
+
301
+ export interface TokenPair {
302
+ accessToken: string;
303
+ refreshToken: string;
304
+ }
305
+
306
+ export class TokenRefreshService {
307
+ async refreshToken(userId: string): Promise<TokenPair> {
308
+ const accessToken = sign({ userId }, process.env.JWT_SECRET!, {
309
+ expiresIn: '15m',
310
+ });
311
+ const refreshToken = sign({ userId }, process.env.REFRESH_SECRET!, {
312
+ expiresIn: '7d',
313
+ });
314
+ return { accessToken, refreshToken };
315
+ }
316
+ }
317
+
318
+ WHY:
319
+ This service encapsulates token generation logic. We separate access tokens
320
+ (short-lived, 15 min) from refresh tokens (long-lived, 7 days) following
321
+ the OAuth 2.0 refresh token pattern. This prevents users from needing to
322
+ re-authenticate frequently while maintaining security.
323
+
324
+ VERIFY:
325
+ Save the file and run: npm run build
326
+ Expected: Should compile without errors (no tests yet — that's next)
327
+
328
+ Ready for Step 2? (Say "next" to continue)
329
+ ```
330
+
331
+ ---
332
+
333
+ ### Example 2: Investigation Breakdown
334
+
335
+ ```
336
+ User: /trinity-breakdown @INV-015-database-performance-analysis.md
337
+
338
+ AJ MAESTRO: Reading investigation INV-015...
339
+
340
+ I'll guide you through investigating the database performance issue.
341
+ You'll explore the codebase yourself — I'll point you where to look.
342
+
343
+ This is a READ-ONLY investigation. No code changes.
344
+
345
+ OVERVIEW:
346
+ - 5 exploration steps
347
+ - Estimated time: 30 minutes
348
+ - Goal: Identify root cause of 300% query time increase
349
+
350
+ Let's begin.
351
+
352
+ ---
353
+
354
+ STEP 1 of 5: Check the slow query patterns
355
+
356
+ WHAT TO DO:
357
+ Open this file and look for the getUserOrders function:
358
+
359
+ FILE: src/services/order.service.ts
360
+ LOCATION: Search for "getUserOrders"
361
+
362
+ WHAT TO LOOK FOR:
363
+ - Is it loading related data (users, products) inside a loop?
364
+ - Does it use eager loading (include/join) or lazy loading (separate queries)?
365
+ - Count how many database calls happen per invocation
366
+
367
+ WHY:
368
+ N+1 query patterns are the most common cause of sudden performance
369
+ degradation. If orders are loaded first, then each order's user is
370
+ loaded individually, that's N+1 queries.
371
+
372
+ REPORT BACK:
373
+ Tell me what you find — specifically:
374
+ 1. How many queries does this function make?
375
+ 2. Is there a loop that makes individual DB calls?
376
+ 3. Are there any JOIN or include statements?
377
+ ```
378
+
379
+ ---
380
+
381
+ ### Example 3: Quick Task Breakdown
382
+
383
+ ```
384
+ User: /trinity-breakdown "Fix date validation bug in UserForm component"
385
+
386
+ AJ MAESTRO: Analyzing task...
387
+
388
+ I'll walk you through fixing the date validation bug.
389
+ 2 steps — should take about 10 minutes.
390
+
391
+ ---
392
+
393
+ STEP 1 of 2: Add the validation function
394
+
395
+ FILE: src/components/UserForm.tsx
396
+ LOCATION: Find the validateDate function (around line 45)
397
+
398
+ WHAT TO DO:
399
+ Replace the current validation:
400
+
401
+ BEFORE:
402
+ const isValid = date !== '';
403
+
404
+ AFTER:
405
+ const isValid = (() => {
406
+ if (!date) return false;
407
+ const parsed = new Date(date);
408
+ return parsed instanceof Date && !isNaN(parsed.getTime());
409
+ })();
410
+
411
+ WHY:
412
+ The current validation only checks if the string is non-empty.
413
+ It doesn't validate the actual date format, so "13/32/2025" passes.
414
+ The new validation parses the date and checks if it's a real date.
415
+
416
+ VERIFY:
417
+ Save and run: npm test -- --testPathPattern="UserForm"
418
+ Expected: Tests should pass (existing tests still work)
419
+
420
+ ---
421
+
422
+ STEP 2 of 2: Add test for the edge case
423
+
424
+ FILE: src/components/UserForm.test.tsx
425
+ LOCATION: After the last test in the "date validation" describe block
426
+
427
+ WHAT TO DO:
428
+ Add this test:
429
+
430
+ CODE:
431
+ it('should reject invalid date formats', () => {
432
+ render(<UserForm />);
433
+ const dateInput = screen.getByLabelText('Date');
434
+ fireEvent.change(dateInput, { target: { value: '13/32/2025' } });
435
+ expect(screen.getByText('Invalid date')).toBeInTheDocument();
436
+ });
437
+
438
+ WHY:
439
+ This test ensures the bug doesn't regress. It specifically tests the
440
+ invalid date format that was previously accepted.
441
+
442
+ VERIFY:
443
+ Run: npm test -- --testPathPattern="UserForm"
444
+ Expected: All tests pass, including the new one
445
+
446
+ ---
447
+
448
+ VERIFICATION CHECKPOINT
449
+
450
+ All changes complete! Run final checks:
451
+
452
+ 1. npm run build (should compile)
453
+ 2. npm run lint (no new warnings)
454
+ 3. npm test (all tests pass)
455
+
456
+ Summary:
457
+ - Fixed: Date validation now rejects invalid formats
458
+ - Added: 1 regression test
459
+ - Files changed: 2 (UserForm.tsx, UserForm.test.tsx)
460
+
461
+ Task complete!
462
+ ```
463
+
464
+ ---
465
+
466
+ ## When NOT to Use /trinity-breakdown
467
+
468
+ **Don't use for:**
469
+
470
+ - **Starting a session** → Use `/trinity-start` or `/trinity-continue`
471
+ - **Creating work orders** → Use `/trinity-workorder` to create, then break it down
472
+ - **Creating investigations** → Use `/trinity-create-investigation` to create, then break it down
473
+ - **Ending your session** → Use `/trinity-end` to archive work
474
+ - **When you want AI to do the work** → Use `/trinity-orchestrate` instead
475
+
476
+ **Use /trinity-breakdown for:**
477
+
478
+ - Learning how to implement a feature
479
+ - Understanding the codebase through guided changes
480
+ - Making changes yourself with expert guidance
481
+ - Training or onboarding through hands-on implementation
482
+
483
+ ---
484
+
485
+ ## Related Commands
486
+
487
+ ### Session Management
488
+ - `/trinity-start` - Begin new development session
489
+ - `/trinity-continue` - Resume interrupted session
490
+ - `/trinity-end` - End session and archive work
491
+
492
+ ### Task Creation
493
+ - `/trinity-workorder` - Create formal work order for complex tasks
494
+ - `/trinity-create-investigation` - Create investigation for analysis
495
+
496
+ ### Execution Alternatives
497
+ - `/trinity-orchestrate` - AI-executed implementation (CC makes the changes)
498
+ - `/trinity-audit` - Comprehensive Trinity deployment audit
499
+
500
+ ### Planning
501
+ - `/trinity-requirements` - Deep requirements analysis with MON
502
+ - `/trinity-design` - Technical design creation with ROR
503
+ - `/trinity-plan` - Implementation planning with TRA
504
+ - `/trinity-decompose` - Atomic task decomposition with EUS
505
+
506
+ ---
507
+
508
+ ## Summary
509
+
510
+ **Guided Implementation Command:** `/trinity-breakdown` walks you through changes step by step.
511
+
512
+ **Key Points:**
513
+ 1. **You make all edits** — CC instructs, you implement
514
+ 2. **Step-by-step instructions** — File path, line numbers, what to change, why
515
+ 3. **Verification at each step** — Run tests, lint, build as guided
516
+ 4. **Same usage patterns** — @WO-XXX (work orders), @INV-XXX (investigations), "description" (quick tasks)
517
+ 5. **Maximum learning** — Understand every change you make
518
+
519
+ **When to choose Breakdown:**
520
+ - You want to learn and understand the changes
521
+ - You prefer hands-on implementation with expert guidance
522
+ - You want to review each change before it's applied
523
+
524
+ **When to choose Orchestrate instead:**
525
+ - You want CC to handle implementation autonomously
526
+ - Speed is more important than learning
527
+ - You trust the AI to make the right changes
528
+
529
+ **Typical Session Flow:**
530
+ ```bash
531
+ /trinity-start # Begin session
532
+ /trinity-breakdown @WO-042-jwt-refresh.md # Guided implementation
533
+ /trinity-breakdown "Fix validation bug" # Quick guided fix
534
+ /trinity-end # End session
535
+ ```