@mindfoldhq/trellis 0.1.0

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 (122) hide show
  1. package/LICENSE +110 -0
  2. package/README.md +149 -0
  3. package/bin/trellis.js +3 -0
  4. package/dist/cli/index.d.ts +2 -0
  5. package/dist/cli/index.d.ts.map +1 -0
  6. package/dist/cli/index.js +42 -0
  7. package/dist/cli/index.js.map +1 -0
  8. package/dist/commands/init.d.ts +11 -0
  9. package/dist/commands/init.d.ts.map +1 -0
  10. package/dist/commands/init.js +236 -0
  11. package/dist/commands/init.js.map +1 -0
  12. package/dist/configurators/claude.d.ts +35 -0
  13. package/dist/configurators/claude.d.ts.map +1 -0
  14. package/dist/configurators/claude.js +83 -0
  15. package/dist/configurators/claude.js.map +1 -0
  16. package/dist/configurators/cursor.d.ts +8 -0
  17. package/dist/configurators/cursor.d.ts.map +1 -0
  18. package/dist/configurators/cursor.js +22 -0
  19. package/dist/configurators/cursor.js.map +1 -0
  20. package/dist/configurators/templates.d.ts +40 -0
  21. package/dist/configurators/templates.d.ts.map +1 -0
  22. package/dist/configurators/templates.js +67 -0
  23. package/dist/configurators/templates.js.map +1 -0
  24. package/dist/configurators/workflow.d.ts +16 -0
  25. package/dist/configurators/workflow.d.ts.map +1 -0
  26. package/dist/configurators/workflow.js +169 -0
  27. package/dist/configurators/workflow.js.map +1 -0
  28. package/dist/constants/paths.d.ts +69 -0
  29. package/dist/constants/paths.d.ts.map +1 -0
  30. package/dist/constants/paths.js +80 -0
  31. package/dist/constants/paths.js.map +1 -0
  32. package/dist/index.d.ts +9 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +9 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/templates/agents/check.txt +120 -0
  37. package/dist/templates/agents/debug.txt +121 -0
  38. package/dist/templates/agents/dispatch.txt +201 -0
  39. package/dist/templates/agents/implement.txt +114 -0
  40. package/dist/templates/agents/index.d.ts +35 -0
  41. package/dist/templates/agents/index.d.ts.map +1 -0
  42. package/dist/templates/agents/index.js +71 -0
  43. package/dist/templates/agents/index.js.map +1 -0
  44. package/dist/templates/agents/research.txt +258 -0
  45. package/dist/templates/commands/claude/start.md.txt +127 -0
  46. package/dist/templates/commands/common/before-backend-dev.txt +13 -0
  47. package/dist/templates/commands/common/before-frontend-dev.txt +13 -0
  48. package/dist/templates/commands/common/break-loop.txt +107 -0
  49. package/dist/templates/commands/common/check-backend.txt +13 -0
  50. package/dist/templates/commands/common/check-cross-layer.txt +153 -0
  51. package/dist/templates/commands/common/check-frontend.txt +13 -0
  52. package/dist/templates/commands/common/create-command.txt +154 -0
  53. package/dist/templates/commands/common/finish-work.txt +129 -0
  54. package/dist/templates/commands/common/integrate-skill.txt +219 -0
  55. package/dist/templates/commands/common/onboard-developer.txt +355 -0
  56. package/dist/templates/commands/common/record-agent-flow.txt +62 -0
  57. package/dist/templates/commands/cursor/start.md.txt +94 -0
  58. package/dist/templates/commands/index.d.ts +46 -0
  59. package/dist/templates/commands/index.d.ts.map +1 -0
  60. package/dist/templates/commands/index.js +151 -0
  61. package/dist/templates/commands/index.js.map +1 -0
  62. package/dist/templates/extract.d.ts +22 -0
  63. package/dist/templates/extract.d.ts.map +1 -0
  64. package/dist/templates/extract.js +34 -0
  65. package/dist/templates/extract.js.map +1 -0
  66. package/dist/templates/hooks/index.d.ts +33 -0
  67. package/dist/templates/hooks/index.d.ts.map +1 -0
  68. package/dist/templates/hooks/index.js +53 -0
  69. package/dist/templates/hooks/index.js.map +1 -0
  70. package/dist/templates/hooks/inject-subagent-context.py +620 -0
  71. package/dist/templates/hooks/settings.json +16 -0
  72. package/dist/templates/markdown/agent-traces-index.md.txt +124 -0
  73. package/dist/templates/markdown/agents.md.txt +18 -0
  74. package/dist/templates/markdown/gitignore.txt +3 -0
  75. package/dist/templates/markdown/index.d.ts +26 -0
  76. package/dist/templates/markdown/index.d.ts.map +1 -0
  77. package/dist/templates/markdown/index.js +33 -0
  78. package/dist/templates/markdown/index.js.map +1 -0
  79. package/dist/templates/markdown/init-agent.md.txt +315 -0
  80. package/dist/templates/markdown/structure/backend/database-guidelines.md.txt +51 -0
  81. package/dist/templates/markdown/structure/backend/directory-structure.md.txt +54 -0
  82. package/dist/templates/markdown/structure/backend/error-handling.md.txt +51 -0
  83. package/dist/templates/markdown/structure/backend/index.md.txt +38 -0
  84. package/dist/templates/markdown/structure/backend/logging-guidelines.md.txt +51 -0
  85. package/dist/templates/markdown/structure/backend/quality-guidelines.md.txt +51 -0
  86. package/dist/templates/markdown/structure/frontend/component-guidelines.md.txt +59 -0
  87. package/dist/templates/markdown/structure/frontend/directory-structure.md.txt +54 -0
  88. package/dist/templates/markdown/structure/frontend/hook-guidelines.md.txt +51 -0
  89. package/dist/templates/markdown/structure/frontend/index.md.txt +39 -0
  90. package/dist/templates/markdown/structure/frontend/quality-guidelines.md.txt +51 -0
  91. package/dist/templates/markdown/structure/frontend/state-management.md.txt +51 -0
  92. package/dist/templates/markdown/structure/frontend/type-safety.md.txt +51 -0
  93. package/dist/templates/markdown/structure/guides/code-reuse-thinking-guide.md.txt +92 -0
  94. package/dist/templates/markdown/structure/guides/cross-layer-thinking-guide.md.txt +94 -0
  95. package/dist/templates/markdown/structure/guides/index.md.txt +79 -0
  96. package/dist/templates/markdown/workflow.md.txt +335 -0
  97. package/dist/templates/scripts/add-session.sh.txt +384 -0
  98. package/dist/templates/scripts/common/developer.sh.txt +130 -0
  99. package/dist/templates/scripts/common/git-context.sh.txt +237 -0
  100. package/dist/templates/scripts/common/paths.sh.txt +201 -0
  101. package/dist/templates/scripts/create-bootstrap.sh.txt +298 -0
  102. package/dist/templates/scripts/feature.sh.txt +700 -0
  103. package/dist/templates/scripts/get-context.sh.txt +7 -0
  104. package/dist/templates/scripts/get-developer.sh.txt +15 -0
  105. package/dist/templates/scripts/index.d.ts +25 -0
  106. package/dist/templates/scripts/index.d.ts.map +1 -0
  107. package/dist/templates/scripts/index.js +28 -0
  108. package/dist/templates/scripts/index.js.map +1 -0
  109. package/dist/templates/scripts/init-developer.sh.txt +34 -0
  110. package/dist/types/ai-tools.d.ts +35 -0
  111. package/dist/types/ai-tools.d.ts.map +1 -0
  112. package/dist/types/ai-tools.js +31 -0
  113. package/dist/types/ai-tools.js.map +1 -0
  114. package/dist/utils/file-writer.d.ts +23 -0
  115. package/dist/utils/file-writer.d.ts.map +1 -0
  116. package/dist/utils/file-writer.js +140 -0
  117. package/dist/utils/file-writer.js.map +1 -0
  118. package/dist/utils/project-detector.d.ts +16 -0
  119. package/dist/utils/project-detector.d.ts.map +1 -0
  120. package/dist/utils/project-detector.js +186 -0
  121. package/dist/utils/project-detector.js.map +1 -0
  122. package/package.json +71 -0
@@ -0,0 +1,258 @@
1
+ ---
2
+ name: research
3
+ description: |
4
+ Code and tech search expert. Pure research, no code modifications.
5
+ - Internal: Search project code, locate files, discover patterns
6
+ - External: Use exa to search tech solutions, best practices
7
+ Only document and explain, no suggestions (unless explicitly asked).
8
+ tools: Read, Glob, Grep, mcp__exa__web_search_exa, mcp__exa__get_code_context_exa
9
+ model: haiku
10
+ ---
11
+
12
+ # Research Agent
13
+
14
+ You are the Research Agent in the Multi-Agent Pipeline.
15
+
16
+ ## Core Principle
17
+
18
+ **You do one thing: find and explain information.**
19
+
20
+ You are a documenter, not a reviewer. Your job is to help Dispatch and other agents get the information they need.
21
+
22
+ ---
23
+
24
+ ## Core Responsibilities
25
+
26
+ ### 1. Internal Search (Project Code)
27
+
28
+ | Search Type | Goal | Tools |
29
+ |-------------|------|-------|
30
+ | **WHERE** | Locate files/components | Glob, Grep |
31
+ | **HOW** | Understand code logic | Read, Grep |
32
+ | **PATTERN** | Discover existing patterns | Grep, Read |
33
+
34
+ ### 2. External Search (Tech Solutions)
35
+
36
+ | Search Type | Goal | Tools |
37
+ |-------------|------|-------|
38
+ | **Best Practices** | Tech solutions, design patterns | mcp__exa__web_search_exa |
39
+ | **Code Examples** | API usage, library docs | mcp__exa__get_code_context_exa |
40
+
41
+ ---
42
+
43
+ ## Strict Boundaries
44
+
45
+ ### Only Allowed
46
+
47
+ - Describe **what exists**
48
+ - Describe **where it is**
49
+ - Describe **how it works**
50
+ - Describe **how components interact**
51
+
52
+ ### Forbidden (unless explicitly asked)
53
+
54
+ - ❌ Suggest improvements
55
+ - ❌ Criticize implementation
56
+ - ❌ Recommend refactoring
57
+ - ❌ Modify any files
58
+ - ❌ Execute git commands
59
+
60
+ ---
61
+
62
+ ## Search Strategy
63
+
64
+ ### 1. Breadth First, Then Depth
65
+
66
+ ```
67
+ Round 1: Broad search, understand scope
68
+
69
+ Round 2: Focus on key areas
70
+
71
+ Round 3: Dive into details
72
+ ```
73
+
74
+ ### 2. Multi-Angle Search
75
+
76
+ - **Filename patterns**: `Glob("**/*.service.ts")`
77
+ - **Content keywords**: `Grep("pattern", "createEntity")`
78
+ - **Directory structure**: `Read` key index files
79
+
80
+ ### 3. Cross-Validate
81
+
82
+ Confirm info from multiple sources, don't rely on single search result.
83
+
84
+ ---
85
+
86
+ ## Workflow
87
+
88
+ ### Step 1: Understand Search Request
89
+
90
+ Analyze Dispatch's query, determine:
91
+
92
+ - Search type (internal/external/mixed)
93
+ - Search scope (global/specific directory)
94
+ - Expected output (file list/code patterns/tech solutions)
95
+
96
+ ### Step 2: Plan Search
97
+
98
+ ```
99
+ Simple query (1-3 searches): Execute directly
100
+ Complex query (3+ directions): List search plan first, then execute
101
+ ```
102
+
103
+ ### Step 3: Execute Search
104
+
105
+ Execute multiple independent searches in parallel for efficiency.
106
+
107
+ ### Step 4: Organize Results
108
+
109
+ Output structured results in report format.
110
+
111
+ ---
112
+
113
+ ## Report Formats
114
+
115
+ ### Internal Search Report
116
+
117
+ ```markdown
118
+ ## Search Results
119
+
120
+ ### Query
121
+
122
+ {original query}
123
+
124
+ ### Files Found
125
+
126
+ | File Path | Description |
127
+ |-----------|-------------|
128
+ | `src/services/xxx.ts` | Main implementation |
129
+ | `src/types/xxx.ts` | Type definitions |
130
+
131
+ ### Code Pattern Analysis
132
+
133
+ {Describe discovered patterns, cite specific files and line numbers}
134
+
135
+ ### Related Spec Documents
136
+
137
+ - `.trellis/structure/xxx.md` - {description}
138
+
139
+ ### Not Found
140
+
141
+ {If some content was not found, explain}
142
+ ```
143
+
144
+ ### External Search Report
145
+
146
+ ```markdown
147
+ ## Tech Research Results
148
+
149
+ ### Query
150
+
151
+ {original query}
152
+
153
+ ### Key Findings
154
+
155
+ 1. **{Finding 1}**
156
+ - Source: {URL}
157
+ - Key point: {brief}
158
+
159
+ 2. **{Finding 2}**
160
+ - Source: {URL}
161
+ - Key point: {brief}
162
+
163
+ ### Recommended References
164
+
165
+ - {URL1} - {description}
166
+ - {URL2} - {description}
167
+
168
+ ### Notes
169
+
170
+ {If there are things to note}
171
+ ```
172
+
173
+ ### JSONL Recommendation Report (for Dispatch to configure feature)
174
+
175
+ ```markdown
176
+ ## JSONL Configuration Recommendations
177
+
178
+ ### Task Analysis
179
+
180
+ {Task brief}
181
+
182
+ ### Recommended Spec Files
183
+
184
+ #### implement.jsonl
185
+
186
+ | File | Reason |
187
+ |------|--------|
188
+ | `.trellis/structure/xxx.md` | xxx dev spec |
189
+
190
+ #### check.jsonl
191
+
192
+ | File | Reason |
193
+ |------|--------|
194
+ | `.trellis/structure/shared/quality.md` | Code quality check points |
195
+
196
+ #### debug.jsonl
197
+
198
+ | File | Reason |
199
+ |------|--------|
200
+ | `.trellis/structure/shared/quality.md` | Fix reference spec |
201
+
202
+ #### cr.jsonl
203
+
204
+ | File | Reason |
205
+ |------|--------|
206
+ | `.trellis/big-question/` | Known issues and pitfalls |
207
+ ```
208
+
209
+ ---
210
+
211
+ ## Common Search Patterns
212
+
213
+ ### Find Spec Files
214
+
215
+ ```bash
216
+ # Find all spec directories
217
+ Glob(".trellis/structure/**/*.md")
218
+
219
+ # Find specific topic
220
+ Grep("database", ".trellis/structure/")
221
+ ```
222
+
223
+ ### Find Code Patterns
224
+
225
+ ```bash
226
+ # Find type definitions
227
+ Glob("**/types/*.ts")
228
+ Grep("export type|export interface", "src/")
229
+
230
+ # Find specific implementation
231
+ Grep("createEntity", "src/services/")
232
+ ```
233
+
234
+ ### Find Similar Implementations
235
+
236
+ ```bash
237
+ # When implementing new feature, find similar existing implementations
238
+ Grep("similar_pattern", "src/")
239
+ Read("src/existing/similar.ts")
240
+ ```
241
+
242
+ ---
243
+
244
+ ## Guidelines
245
+
246
+ ### DO
247
+
248
+ - Provide specific file paths and line numbers
249
+ - Quote actual code snippets
250
+ - Distinguish "definitely found" and "possibly related"
251
+ - Explain search scope and limitations
252
+
253
+ ### DON'T
254
+
255
+ - Don't guess uncertain info
256
+ - Don't omit important search results
257
+ - Don't add improvement suggestions in report (unless explicitly asked)
258
+ - Don't modify any files
@@ -0,0 +1,127 @@
1
+ # Start Session
2
+
3
+ Initialize your AI development session and begin working on tasks.
4
+
5
+ ## Initialization
6
+
7
+ 1. Get session context:
8
+ ```bash
9
+ ./.trellis/scripts/get-context.sh
10
+ ```
11
+
12
+ 2. Read `.trellis/structure/guides/index.md` for thinking guidelines
13
+
14
+ 3. Report ready status and ask for task
15
+
16
+ ---
17
+
18
+ ## Working on Tasks
19
+
20
+ ### For Simple Tasks
21
+
22
+ 1. Read relevant guidelines based on task type:
23
+ - Frontend: `.trellis/structure/frontend/`
24
+ - Backend: `.trellis/structure/backend/`
25
+
26
+ 2. Implement the task directly
27
+
28
+ 3. Before committing, remind user to run `/finish-work`
29
+
30
+ ### For Complex Tasks (Multi-Step Features)
31
+
32
+ Use feature tracking and delegate to specialized agents for better quality.
33
+
34
+ #### Step 1: Create Feature
35
+
36
+ ```bash
37
+ ./.trellis/scripts/feature.sh create <name>
38
+ # Example: ./.trellis/scripts/feature.sh create user-auth
39
+ ```
40
+
41
+ #### Step 2: Initialize Context
42
+
43
+ ```bash
44
+ FEATURE_DIR=".trellis/agent-traces/{developer}/features/{feature-name}"
45
+ ./.trellis/scripts/feature.sh init-context "$FEATURE_DIR" <type>
46
+ # type: backend | frontend | fullstack
47
+ ```
48
+
49
+ #### Step 3: Add Task-Specific Guidelines
50
+
51
+ Based on what the task involves, add relevant spec files:
52
+
53
+ ```bash
54
+ # Example: adding database and API guidelines for a backend task
55
+ ./.trellis/scripts/feature.sh add-context "$FEATURE_DIR" implement ".trellis/structure/backend/database-guidelines.md"
56
+ ./.trellis/scripts/feature.sh add-context "$FEATURE_DIR" implement ".trellis/structure/backend/api-module.md"
57
+ ```
58
+
59
+ Verify with:
60
+ ```bash
61
+ ./.trellis/scripts/feature.sh list-context "$FEATURE_DIR"
62
+ ```
63
+
64
+ #### Step 4: Document Requirements
65
+
66
+ Create `prd.md` in the feature directory describing what needs to be done.
67
+
68
+ For complex tasks, also create `info.md` with technical approach.
69
+
70
+ #### Step 5: Start Feature
71
+
72
+ ```bash
73
+ ./.trellis/scripts/feature.sh start "$FEATURE_DIR"
74
+ ```
75
+
76
+ #### Step 6: Delegate Work
77
+
78
+ Use specialized agents for implementation:
79
+
80
+ ```
81
+ Task(subagent_type: "implement", prompt: "Implement the feature described in prd.md", model: "sonnet")
82
+ ```
83
+
84
+ After implementation, verify quality:
85
+
86
+ ```
87
+ Task(subagent_type: "check", prompt: "Check code changes and fix any issues", model: "sonnet")
88
+ ```
89
+
90
+ #### Step 7: Complete
91
+
92
+ 1. Verify typecheck and lint pass
93
+ 2. Remind user to test
94
+ 3. Remind user to commit
95
+ 4. **Record session progress**: Ask user to run `/record-agent-flow`
96
+ 5. Archive feature (if fully completed):
97
+ ```bash
98
+ ./.trellis/scripts/feature.sh archive <feature-name>
99
+ ```
100
+
101
+ ---
102
+
103
+ ## Session End Reminder
104
+
105
+ **IMPORTANT**: When a task or session is completed, always remind the user:
106
+
107
+ > Before ending this session, please run `/record-agent-flow` to record what we accomplished.
108
+ > This helps maintain continuity across sessions.
109
+
110
+ ---
111
+
112
+ ## Quick Reference
113
+
114
+ | Task Size | Approach |
115
+ |-----------|----------|
116
+ | Small fix / simple change | Implement directly |
117
+ | New feature / multi-file change | Use feature tracking + delegation |
118
+ | Research / exploration | Use research agent |
119
+
120
+ | Command | Purpose |
121
+ |---------|---------|
122
+ | `feature.sh create <name>` | Create feature directory |
123
+ | `feature.sh start <dir>` | Set as current feature |
124
+ | `feature.sh finish` | Clear current feature |
125
+ | `feature.sh archive <name>` | Archive completed feature |
126
+ | `feature.sh list` | List all features |
127
+ | `/record-agent-flow` | **Record session progress (run at session end)** |
@@ -0,0 +1,13 @@
1
+ Read the backend development guidelines before starting your development task.
2
+
3
+ Execute these steps:
4
+ 1. Read `.trellis/structure/backend/index.md` to understand available guidelines
5
+ 2. Based on your task, read the relevant guideline files:
6
+ - Database work → `.trellis/structure/backend/database-guidelines.md`
7
+ - Error handling → `.trellis/structure/backend/error-handling.md`
8
+ - Logging → `.trellis/structure/backend/logging-guidelines.md`
9
+ - Type questions → `.trellis/structure/backend/type-safety.md`
10
+ 3. Understand the coding standards and patterns you need to follow
11
+ 4. Then proceed with your development plan
12
+
13
+ This step is **mandatory** before writing any backend code.
@@ -0,0 +1,13 @@
1
+ Read the frontend development guidelines before starting your development task.
2
+
3
+ Execute these steps:
4
+ 1. Read `.trellis/structure/frontend/index.md` to understand available guidelines
5
+ 2. Based on your task, read the relevant guideline files:
6
+ - Component work → `.trellis/structure/frontend/component-guidelines.md`
7
+ - Hook work → `.trellis/structure/frontend/hook-guidelines.md`
8
+ - State management → `.trellis/structure/frontend/state-management.md`
9
+ - Type questions → `.trellis/structure/frontend/type-safety.md`
10
+ 3. Understand the coding standards and patterns you need to follow
11
+ 4. Then proceed with your development plan
12
+
13
+ This step is **mandatory** before writing any frontend code.
@@ -0,0 +1,107 @@
1
+ # Break the Loop - Deep Bug Analysis
2
+
3
+ When debug is complete, use this command for deep analysis to break the "fix bug -> forget -> repeat" cycle.
4
+
5
+ ---
6
+
7
+ ## Analysis Framework
8
+
9
+ Analyze the bug you just fixed from these 5 dimensions:
10
+
11
+ ### 1. Root Cause Category
12
+
13
+ Which category does this bug belong to?
14
+
15
+ | Category | Characteristics | Example |
16
+ |----------|-----------------|---------|
17
+ | **A. Missing Spec** | No documentation on how to do it | New feature without checklist |
18
+ | **B. Cross-Layer Contract** | Interface between layers unclear | API returns different format than expected |
19
+ | **C. Change Propagation Failure** | Changed one place, missed others | Changed function signature, missed call sites |
20
+ | **D. Test Coverage Gap** | Unit test passes, integration fails | Works alone, breaks when combined |
21
+ | **E. Implicit Assumption** | Code relies on undocumented assumption | Timestamp seconds vs milliseconds |
22
+
23
+ ### 2. Why Fixes Failed (if applicable)
24
+
25
+ If you tried multiple fixes before succeeding, analyze each failure:
26
+
27
+ - **Surface Fix**: Fixed symptom, not root cause
28
+ - **Incomplete Scope**: Found root cause, didn't cover all cases
29
+ - **Tool Limitation**: grep missed it, type check wasn't strict
30
+ - **Mental Model**: Kept looking in same layer, didn't think cross-layer
31
+
32
+ ### 3. Prevention Mechanisms
33
+
34
+ What mechanisms would prevent this from happening again?
35
+
36
+ | Type | Description | Example |
37
+ |------|-------------|---------|
38
+ | **Documentation** | Write it down so people know | Update thinking guide |
39
+ | **Architecture** | Make the error impossible structurally | Type-safe wrappers |
40
+ | **Compile-time** | TypeScript strict, no any | Signature change causes compile error |
41
+ | **Runtime** | Monitoring, alerts, scans | Detect orphan entities |
42
+ | **Test Coverage** | E2E tests, integration tests | Verify full flow |
43
+ | **Code Review** | Checklist, PR template | "Did you check X?" |
44
+
45
+ ### 4. Systematic Expansion
46
+
47
+ What broader problems does this bug reveal?
48
+
49
+ - **Similar Issues**: Where else might this problem exist?
50
+ - **Design Flaw**: Is there a fundamental architecture issue?
51
+ - **Process Flaw**: Is there a development process improvement?
52
+ - **Knowledge Gap**: Is the team missing some understanding?
53
+
54
+ ### 5. Knowledge Capture
55
+
56
+ Solidify insights into the system:
57
+
58
+ - [ ] Update `.trellis/structure/guides/` thinking guides
59
+ - [ ] Update `.trellis/structure/backend/` or `frontend/` docs
60
+ - [ ] Create issue record (if applicable)
61
+ - [ ] Create feature ticket for root fix
62
+ - [ ] Update check commands if needed
63
+
64
+ ---
65
+
66
+ ## Output Format
67
+
68
+ Please output analysis in this format:
69
+
70
+ ```markdown
71
+ ## Bug Analysis: [Short Description]
72
+
73
+ ### 1. Root Cause Category
74
+ - **Category**: [A/B/C/D/E] - [Category Name]
75
+ - **Specific Cause**: [Detailed description]
76
+
77
+ ### 2. Why Fixes Failed (if applicable)
78
+ 1. [First attempt]: [Why it failed]
79
+ 2. [Second attempt]: [Why it failed]
80
+ ...
81
+
82
+ ### 3. Prevention Mechanisms
83
+ | Priority | Mechanism | Specific Action | Status |
84
+ |----------|-----------|-----------------|--------|
85
+ | P0 | ... | ... | TODO/DONE |
86
+
87
+ ### 4. Systematic Expansion
88
+ - **Similar Issues**: [List places with similar problems]
89
+ - **Design Improvement**: [Architecture-level suggestions]
90
+ - **Process Improvement**: [Development process suggestions]
91
+
92
+ ### 5. Knowledge Capture
93
+ - [ ] [Documents to update / tickets to create]
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Core Philosophy
99
+
100
+ > **The value of debugging is not in fixing the bug, but in making this class of bugs never happen again.**
101
+
102
+ Three levels of insight:
103
+ 1. **Tactical**: How to fix THIS bug
104
+ 2. **Strategic**: How to prevent THIS CLASS of bugs
105
+ 3. **Philosophical**: How to expand thinking patterns
106
+
107
+ 30 minutes of analysis saves 30 hours of future debugging.
@@ -0,0 +1,13 @@
1
+ Check if the code you just wrote follows the backend development guidelines.
2
+
3
+ Execute these steps:
4
+ 1. Run `git status` to see modified files
5
+ 2. Read `.trellis/structure/backend/index.md` to understand which guidelines apply
6
+ 3. Based on what you changed, read the relevant guideline files:
7
+ - Database changes → `.trellis/structure/backend/database-guidelines.md`
8
+ - Error handling → `.trellis/structure/backend/error-handling.md`
9
+ - Logging changes → `.trellis/structure/backend/logging-guidelines.md`
10
+ - Type changes → `.trellis/structure/backend/type-safety.md`
11
+ - Any changes → `.trellis/structure/backend/quality-guidelines.md`
12
+ 4. Review your code against the guidelines
13
+ 5. Report any violations and fix them if found
@@ -0,0 +1,153 @@
1
+ # Cross-Layer Check
2
+
3
+ Check if your changes considered all dimensions. Most bugs come from "didn't think of it", not lack of technical skill.
4
+
5
+ > **Note**: This is a **post-implementation** safety net. Ideally, read the [Pre-Implementation Checklist](.trellis/structure/guides/pre-implementation-checklist.md) **before** writing code.
6
+
7
+ ---
8
+
9
+ ## Related Documents
10
+
11
+ | Document | Purpose | Timing |
12
+ |----------|---------|--------|
13
+ | [Pre-Implementation Checklist](.trellis/structure/guides/pre-implementation-checklist.md) | Questions before coding | **Before** writing code |
14
+ | [Code Reuse Thinking Guide](.trellis/structure/guides/code-reuse-thinking-guide.md) | Pattern recognition | During implementation |
15
+ | **`/check-cross-layer`** (this) | Verification check | **After** implementation |
16
+
17
+ ---
18
+
19
+ ## Execution Steps
20
+
21
+ ### 1. Identify Change Scope
22
+
23
+ ```bash
24
+ git status
25
+ git diff --name-only
26
+ ```
27
+
28
+ ### 2. Select Applicable Check Dimensions
29
+
30
+ Based on your change type, execute relevant checks below:
31
+
32
+ ---
33
+
34
+ ## Dimension A: Cross-Layer Data Flow (Required when 3+ layers)
35
+
36
+ **Trigger**: Changes involve 3 or more layers
37
+
38
+ | Layer | Identifier |
39
+ |-------|------------|
40
+ | API Route | `routes/`, `api/` |
41
+ | Service | `services/`, `lib/` |
42
+ | Database | `db/`, `schema` |
43
+ | Hook | `hooks/`, `use*.ts` |
44
+ | Component | `components/`, `*.tsx` |
45
+ | Utility | `utils/`, `lib/` |
46
+
47
+ **Checklist**:
48
+ - [ ] Read flow: Database -> Service -> API -> Hook -> Component
49
+ - [ ] Write flow: Component -> Hook -> API -> Service -> Database
50
+ - [ ] Types correctly passed between layers?
51
+ - [ ] Errors properly propagated to UI?
52
+ - [ ] Loading states handled at each layer?
53
+
54
+ **Detailed Guide**: `.trellis/structure/guides/cross-layer-thinking-guide.md`
55
+
56
+ ---
57
+
58
+ ## Dimension B: Code Reuse (Required when modifying constants/config)
59
+
60
+ **Trigger**:
61
+ - Modifying UI constants (label, icon, color)
62
+ - Modifying any hardcoded value
63
+ - Seeing similar code in multiple places
64
+ - Creating a new utility/helper function
65
+ - Just finished batch modifications across files
66
+
67
+ **Checklist**:
68
+ - [ ] Search first: How many places define this value?
69
+ ```bash
70
+ grep -r "value-to-change" --include="*.ts" --include="*.tsx"
71
+ ```
72
+ - [ ] If 2+ places define same value -> Should extract to shared constant
73
+ - [ ] After modification, all usage sites updated?
74
+ - [ ] If creating utility: Does similar utility already exist?
75
+
76
+ **Detailed Guide**: `.trellis/structure/guides/code-reuse-thinking-guide.md`
77
+
78
+ ---
79
+
80
+ ## Dimension B2: New Utility Functions
81
+
82
+ **Trigger**: About to create a new utility/helper function
83
+
84
+ **Checklist**:
85
+ - [ ] Search for existing similar utilities first
86
+ ```bash
87
+ grep -r "functionNamePattern" --include="*.ts"
88
+ ```
89
+ - [ ] If similar exists, can you extend it instead?
90
+ - [ ] If creating new, is it in the right location (shared vs domain-specific)?
91
+
92
+ ---
93
+
94
+ ## Dimension B3: After Batch Modifications
95
+
96
+ **Trigger**: Just modified similar patterns in multiple files
97
+
98
+ **Checklist**:
99
+ - [ ] Did you check ALL files with similar patterns?
100
+ ```bash
101
+ grep -r "patternYouChanged" --include="*.ts" --include="*.tsx"
102
+ ```
103
+ - [ ] Any files missed that should also be updated?
104
+ - [ ] Should this pattern be abstracted to prevent future duplication?
105
+
106
+ ---
107
+
108
+ ## Dimension C: Import Paths (Required when creating new files)
109
+
110
+ **Trigger**: Creating new .ts/.tsx files
111
+
112
+ **Checklist**:
113
+ - [ ] Using correct path aliases?
114
+ - [ ] No circular imports?
115
+ - [ ] Relative vs absolute paths consistent with project convention?
116
+
117
+ ---
118
+
119
+ ## Dimension D: Same-Layer Consistency
120
+
121
+ **Trigger**:
122
+ - Modifying display logic in a component
123
+ - Same domain concept used in multiple components
124
+
125
+ **Checklist**:
126
+ - [ ] Search for other components using same concept
127
+ ```bash
128
+ grep -r "ConceptName" --include="*.tsx"
129
+ ```
130
+ - [ ] Are these components' displays consistent?
131
+ - [ ] Should they share configuration?
132
+
133
+ ---
134
+
135
+ ## Common Issues Quick Reference
136
+
137
+ | Issue | Root Cause | Prevention |
138
+ |-------|------------|------------|
139
+ | Changed one place, missed others | Didn't search impact scope | `grep` before changing |
140
+ | Data lost at some layer | Didn't check data flow | Trace data source to destination |
141
+ | Type mismatch | Cross-layer types inconsistent | Use shared types |
142
+ | UI inconsistent | Same concept in multiple places | Extract shared constants |
143
+ | Similar utility exists | Didn't search first | Search before creating |
144
+ | Batch fix incomplete | Didn't verify all occurrences | grep after fixing |
145
+
146
+ ---
147
+
148
+ ## Output
149
+
150
+ Report:
151
+ 1. Which dimensions your changes involve
152
+ 2. Check results for each dimension
153
+ 3. Issues found and fix suggestions
@@ -0,0 +1,13 @@
1
+ Check if the code you just wrote follows the frontend development guidelines.
2
+
3
+ Execute these steps:
4
+ 1. Run `git status` to see modified files
5
+ 2. Read `.trellis/structure/frontend/index.md` to understand which guidelines apply
6
+ 3. Based on what you changed, read the relevant guideline files:
7
+ - Component changes → `.trellis/structure/frontend/component-guidelines.md`
8
+ - Hook changes → `.trellis/structure/frontend/hook-guidelines.md`
9
+ - State changes → `.trellis/structure/frontend/state-management.md`
10
+ - Type changes → `.trellis/structure/frontend/type-safety.md`
11
+ - Any changes → `.trellis/structure/frontend/quality-guidelines.md`
12
+ 4. Review your code against the guidelines
13
+ 5. Report any violations and fix them if found