@yan-geroge/omg 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 (59) hide show
  1. package/.claude/agents/trellis-check.md +109 -0
  2. package/.claude/agents/trellis-implement.md +109 -0
  3. package/.claude/agents/trellis-research.md +137 -0
  4. package/.claude/commands/trellis/continue.md +55 -0
  5. package/.claude/commands/trellis/finish-work.md +66 -0
  6. package/.claude/hooks/inject-subagent-context.py +749 -0
  7. package/.claude/hooks/inject-workflow-state.py +387 -0
  8. package/.claude/hooks/session-start.py +797 -0
  9. package/.claude/settings.json +73 -0
  10. package/.claude/skills/trellis-before-dev/SKILL.md +34 -0
  11. package/.claude/skills/trellis-brainstorm/SKILL.md +548 -0
  12. package/.claude/skills/trellis-break-loop/SKILL.md +130 -0
  13. package/.claude/skills/trellis-check/SKILL.md +92 -0
  14. package/.claude/skills/trellis-meta/SKILL.md +73 -0
  15. package/.claude/skills/trellis-meta/references/customize-local/add-project-local-conventions.md +83 -0
  16. package/.claude/skills/trellis-meta/references/customize-local/change-agents.md +54 -0
  17. package/.claude/skills/trellis-meta/references/customize-local/change-context-loading.md +81 -0
  18. package/.claude/skills/trellis-meta/references/customize-local/change-hooks.md +57 -0
  19. package/.claude/skills/trellis-meta/references/customize-local/change-skills-or-commands.md +78 -0
  20. package/.claude/skills/trellis-meta/references/customize-local/change-spec-structure.md +83 -0
  21. package/.claude/skills/trellis-meta/references/customize-local/change-task-lifecycle.md +90 -0
  22. package/.claude/skills/trellis-meta/references/customize-local/change-workflow.md +64 -0
  23. package/.claude/skills/trellis-meta/references/customize-local/overview.md +55 -0
  24. package/.claude/skills/trellis-meta/references/local-architecture/context-injection.md +68 -0
  25. package/.claude/skills/trellis-meta/references/local-architecture/generated-files.md +80 -0
  26. package/.claude/skills/trellis-meta/references/local-architecture/overview.md +51 -0
  27. package/.claude/skills/trellis-meta/references/local-architecture/spec-system.md +102 -0
  28. package/.claude/skills/trellis-meta/references/local-architecture/task-system.md +101 -0
  29. package/.claude/skills/trellis-meta/references/local-architecture/workflow.md +75 -0
  30. package/.claude/skills/trellis-meta/references/local-architecture/workspace-memory.md +71 -0
  31. package/.claude/skills/trellis-meta/references/platform-files/agents.md +79 -0
  32. package/.claude/skills/trellis-meta/references/platform-files/hooks-and-settings.md +69 -0
  33. package/.claude/skills/trellis-meta/references/platform-files/overview.md +59 -0
  34. package/.claude/skills/trellis-meta/references/platform-files/platform-map.md +74 -0
  35. package/.claude/skills/trellis-meta/references/platform-files/skills-and-commands.md +83 -0
  36. package/.claude/skills/trellis-spec-bootstarp/SKILL.md +41 -0
  37. package/.claude/skills/trellis-spec-bootstarp/references/mcp-setup.md +90 -0
  38. package/.claude/skills/trellis-spec-bootstarp/references/repository-analysis.md +59 -0
  39. package/.claude/skills/trellis-spec-bootstarp/references/spec-task-planning.md +61 -0
  40. package/.claude/skills/trellis-spec-bootstarp/references/spec-writing.md +70 -0
  41. package/.claude/skills/trellis-update-spec/SKILL.md +356 -0
  42. package/CLAUDE.md +88 -0
  43. package/agents/architect.md +80 -0
  44. package/agents/executor.md +79 -0
  45. package/agents/planner.md +76 -0
  46. package/agents/reviewer.md +81 -0
  47. package/agents/tdd-guide.md +95 -0
  48. package/agents/verifier.md +81 -0
  49. package/hooks/keyword-detector.mjs +115 -0
  50. package/hooks/lib/keyword-detector.js +89 -0
  51. package/hooks/session-start.mjs +104 -0
  52. package/marketplace.json +12 -0
  53. package/package.json +34 -0
  54. package/plugin.json +14 -0
  55. package/scripts/diagnose-marketplace.js +84 -0
  56. package/scripts/e2e-diagnose.mjs +118 -0
  57. package/scripts/validate-with-csc-schema.mjs +87 -0
  58. package/skills/costrict-autopilot/SKILL.md +53 -0
  59. package/skills/costrict-team/SKILL.md +65 -0
@@ -0,0 +1,90 @@
1
+ # MCP Setup
2
+
3
+ GitNexus and ABCoder are recommended when bootstrapping Trellis specs because they expose architecture and AST context to the agent. They are tool choices, not platform requirements. Configure them through whatever MCP mechanism your agent host provides.
4
+
5
+ ## GitNexus
6
+
7
+ GitNexus builds a code knowledge graph from the repository. Use it for module boundaries, execution flows, dependency relationships, blast radius, and graph queries.
8
+
9
+ ### Install and Index
10
+
11
+ ```bash
12
+ # Run from the repository root.
13
+ npx gitnexus analyze
14
+
15
+ # Check index status.
16
+ npx gitnexus status
17
+
18
+ # Re-index after code changes when the analysis is stale.
19
+ npx gitnexus analyze
20
+ ```
21
+
22
+ The index is written to `.gitnexus/`. Keep embeddings only if the project already uses them; otherwise a normal index is enough for spec bootstrapping.
23
+
24
+ ### MCP Server Command
25
+
26
+ Use this server command in the host's MCP configuration:
27
+
28
+ ```bash
29
+ npx -y gitnexus mcp
30
+ ```
31
+
32
+ ### Useful Tools
33
+
34
+ | Tool | Purpose |
35
+ |------|---------|
36
+ | `gitnexus_query` | Find execution flows and functional areas by concept |
37
+ | `gitnexus_context` | Inspect callers, callees, references, and process participation for a symbol |
38
+ | `gitnexus_impact` | Understand blast radius before changing a symbol |
39
+ | `gitnexus_detect_changes` | Check changed symbols and affected flows before finishing |
40
+ | `gitnexus_cypher` | Run direct graph queries |
41
+ | `gitnexus_list_repos` | List indexed repositories |
42
+
43
+ ## ABCoder
44
+
45
+ ABCoder parses code into UniAST and gives precise package, file, and node-level structure. Use it for signatures, type shapes, implementations, dependencies, and reverse references.
46
+
47
+ ### Install
48
+
49
+ ```bash
50
+ go install github.com/cloudwego/abcoder@latest
51
+ abcoder --help
52
+ ```
53
+
54
+ ### Parse Repositories
55
+
56
+ ```bash
57
+ abcoder parse /absolute/path/to/package \
58
+ --lang typescript \
59
+ --name package-name \
60
+ --output ~/abcoder-asts
61
+ ```
62
+
63
+ For monorepos, parse each package with a stable `--name` so task notes can reference the same repository names.
64
+
65
+ ### MCP Server Command
66
+
67
+ Use this server command in the host's MCP configuration:
68
+
69
+ ```bash
70
+ abcoder mcp ~/abcoder-asts
71
+ ```
72
+
73
+ ### Useful Tools
74
+
75
+ | Tool | Layer | Purpose |
76
+ |------|-------|---------|
77
+ | `list_repos` | 1 | List parsed repositories |
78
+ | `get_repo_structure` | 2 | Inspect packages and files |
79
+ | `get_package_structure` | 3 | Inspect nodes within a package |
80
+ | `get_file_structure` | 3 | Inspect functions, classes, types, and signatures in a file |
81
+ | `get_ast_node` | 4 | Retrieve code, dependencies, references, and implementations |
82
+
83
+ ## Verification
84
+
85
+ After configuration, verify from the agent host that both MCP servers are visible. Then run one simple query against each server before starting the spec writing pass.
86
+
87
+ ```bash
88
+ ls .gitnexus/meta.json
89
+ ls ~/abcoder-asts/*.json
90
+ ```
@@ -0,0 +1,59 @@
1
+ # Repository Analysis
2
+
3
+ The goal is to discover the project's real architecture before writing rules. Do not start from generic spec templates and fill blanks. Start from the code, then let the spec structure follow.
4
+
5
+ ## Analysis Order
6
+
7
+ 1. Read the existing `.trellis/spec/` tree and note which files are templates, outdated, or already project-specific.
8
+ 2. Inspect package manifests, build scripts, workspace config, and top-level documentation to identify packages and runtime layers.
9
+ 3. Use GitNexus for execution flows, module clusters, dependency hubs, and impact-sensitive areas.
10
+ 4. Use ABCoder or language-native tooling for exact signatures, types, class boundaries, and implementation examples.
11
+ 5. Read representative source and test files directly before turning any finding into a spec rule.
12
+
13
+ ## What To Capture
14
+
15
+ | Area | Questions |
16
+ |------|-----------|
17
+ | Package boundaries | What does each package own? What imports cross boundaries? |
18
+ | Runtime layers | Which code is CLI, backend, frontend, worker, shared library, test-only, or tooling? |
19
+ | Core abstractions | Which types, services, stores, commands, routes, or adapters define the system shape? |
20
+ | Data flow | Where does user input enter, how is it validated, and where does state persist? |
21
+ | Error handling | How are failures represented, logged, surfaced, and tested? |
22
+ | Configuration | Where do defaults, environment config, generated files, and templates live? |
23
+ | Tests | Which test styles are trusted examples for new work? |
24
+
25
+ ## GitNexus Usage
26
+
27
+ Start broad, then inspect specific symbols:
28
+
29
+ ```text
30
+ gitnexus_query({query: "CLI command execution flow"})
31
+ gitnexus_query({query: "template generation and migration"})
32
+ gitnexus_context({name: "SymbolName"})
33
+ gitnexus_cypher({query: "MATCH (n)-[r]->(m) RETURN n.name, type(r), m.name LIMIT 30"})
34
+ ```
35
+
36
+ Use GitNexus results to find important files and flows. Do not quote graph output as the final authority until you have checked the relevant source files.
37
+
38
+ ## ABCoder Usage
39
+
40
+ Use ABCoder when the spec needs exact code shapes:
41
+
42
+ ```text
43
+ list_repos()
44
+ get_repo_structure({repo_name: "package-name"})
45
+ get_file_structure({repo_name: "package-name", file_path: "src/example.ts"})
46
+ get_ast_node({repo_name: "package-name", node_ids: [{mod_path: "...", pkg_path: "...", name: "SymbolName"}]})
47
+ ```
48
+
49
+ ABCoder is most valuable for documenting constructor patterns, function signatures, type contracts, and reference chains.
50
+
51
+ ## Analysis Notes
52
+
53
+ Keep short notes while analyzing. The notes should include:
54
+
55
+ - Package or layer name.
56
+ - Files that define the local pattern.
57
+ - Rules the spec should teach.
58
+ - Anti-patterns found in old code, comments, tests, or migration paths.
59
+ - Spec files that should be created, deleted, renamed, or merged.
@@ -0,0 +1,61 @@
1
+ # Spec Task Planning
2
+
3
+ Use a single agent as the default execution model. The agent may create Trellis tasks for traceability, but the skill should not require a specific platform, CLI, or parallel worker model.
4
+
5
+ ## Decomposition
6
+
7
+ Create spec work units around real ownership boundaries:
8
+
9
+ - One package when a package has its own conventions.
10
+ - One layer when the same package has distinct frontend, backend, CLI, worker, or shared-library rules.
11
+ - One cross-cutting guide when a pattern spans packages and is not owned by one layer.
12
+
13
+ Avoid artificial decomposition. A small library usually needs one focused spec pass, not several tasks.
14
+
15
+ ## Task Shape
16
+
17
+ When a Trellis task is useful, write a concise PRD with these sections:
18
+
19
+ ```markdown
20
+ # Fill <package-or-layer> Trellis Specs
21
+
22
+ ## Goal
23
+ Write project-specific `.trellis/spec/` guidance for <scope>.
24
+
25
+ ## Scope
26
+ - Spec directory:
27
+ - Source directories to inspect:
28
+ - Tests to inspect:
29
+ - Out of scope:
30
+
31
+ ## Architecture Context
32
+ Summarize the concrete findings from repository analysis.
33
+
34
+ ## Files To Create Or Update
35
+ - `.trellis/spec/.../index.md`
36
+ - `.trellis/spec/.../<topic>.md`
37
+
38
+ ## Rules
39
+ - Adapt the spec file set to the real codebase.
40
+ - Use real source examples with file paths.
41
+ - Remove template-only sections that do not apply.
42
+ - Do not modify product source code unless the task explicitly asks for it.
43
+
44
+ ## Acceptance Criteria
45
+ - [ ] Specs contain concrete examples and anti-patterns from the repository.
46
+ - [ ] No placeholder text remains.
47
+ - [ ] Index files match the final spec files.
48
+ - [ ] Claims are backed by source files, tests, or project docs.
49
+ ```
50
+
51
+ ## Optional Helper Agents
52
+
53
+ If the host supports subagents, helpers can inspect independent packages or run verification. They are optional. The main agent still owns integration and final quality.
54
+
55
+ Helper tasks must have clear ownership:
56
+
57
+ - Read-only research tasks may inspect any source needed for the assigned scope.
58
+ - Write tasks should own disjoint spec directories.
59
+ - Verification tasks should check placeholder removal, broken links, and consistency.
60
+
61
+ Do not encode helper-agent names, vendor-specific commands, or platform-specific routing in the skill. Put only the required work and acceptance criteria in the task.
@@ -0,0 +1,70 @@
1
+ # Spec Writing
2
+
3
+ Trellis specs are coding guidance for future agents. They should explain how to work in this repository, not how a generic project might be organized.
4
+
5
+ ## Write From Evidence
6
+
7
+ Each important rule should be backed by one of these:
8
+
9
+ - A source file that demonstrates the preferred pattern.
10
+ - A test file that shows expected behavior.
11
+ - A project document that defines the convention.
12
+ - A repeated pattern across multiple files.
13
+
14
+ Use short snippets only when they make the rule clearer. Prefer linking to the file path and naming the symbol or behavior.
15
+
16
+ ## File Structure
17
+
18
+ Keep the spec tree aligned with the project:
19
+
20
+ - Keep `index.md` as the navigation file for the spec directory.
21
+ - Split topics when developers would look for them independently.
22
+ - Merge topics when separate files would repeat the same rule.
23
+ - Delete template files that do not apply.
24
+ - Add new files for important local patterns the template missed.
25
+
26
+ ## Content Standards
27
+
28
+ Good spec sections include:
29
+
30
+ - When the rule applies.
31
+ - The local pattern to follow.
32
+ - The source or test files that prove the pattern.
33
+ - Common mistakes or anti-patterns.
34
+ - Verification commands or checks when they are specific and reliable.
35
+
36
+ Avoid:
37
+
38
+ - Placeholder prose.
39
+ - Generic framework advice.
40
+ - Tool instructions that only work in one agent host.
41
+ - Long copied code blocks.
42
+ - Rules based on a single accidental implementation detail.
43
+
44
+ ## Example Shape
45
+
46
+ ```markdown
47
+ ## Command Handlers
48
+
49
+ Command handlers should keep argument parsing, validation, and side effects separate. The local pattern is:
50
+
51
+ - Parse CLI flags at the command boundary.
52
+ - Convert raw inputs into typed task options before invoking core logic.
53
+ - Keep filesystem writes in the command or service layer, not in template helpers.
54
+
55
+ Reference files:
56
+ - `packages/cli/src/commands/example.ts`
57
+ - `packages/cli/test/commands/example.test.ts`
58
+
59
+ Avoid passing raw `process.argv` or unvalidated config objects into shared helpers.
60
+ ```
61
+
62
+ ## Final Pass
63
+
64
+ Before finishing:
65
+
66
+ ```bash
67
+ grep -R "To be filled\\|TODO: fill\\|placeholder" .trellis/spec
68
+ ```
69
+
70
+ Also check links, index files, and whether any spec still describes a template rather than this repository.
@@ -0,0 +1,356 @@
1
+ ---
2
+ name: trellis-update-spec
3
+ description: "Captures executable contracts and coding conventions into .trellis/spec/ documents. Use when learning something valuable from debugging, implementing, or discussion that should be preserved for future sessions."
4
+ ---
5
+
6
+ # Update Code-Spec - Capture Executable Contracts
7
+
8
+ When you learn something valuable (from debugging, implementing, or discussion), use this to update the relevant code-spec documents.
9
+
10
+ **Timing**: After completing a task, fixing a bug, or discovering a new pattern
11
+
12
+ ---
13
+
14
+ ## Code-Spec First Rule (CRITICAL)
15
+
16
+ In this project, "spec" for implementation work means **code-spec**:
17
+ - Executable contracts (not principle-only text)
18
+ - Concrete signatures, payload fields, env keys, and boundary behavior
19
+ - Testable validation/error behavior
20
+
21
+ If the change touches infra or cross-layer contracts, code-spec depth is mandatory.
22
+
23
+ ### Mandatory Triggers
24
+
25
+ Apply code-spec depth when the change includes any of:
26
+ - New/changed command or API signature
27
+ - Cross-layer request/response contract change
28
+ - Database schema/migration change
29
+ - Infra integration (storage, queue, cache, secrets, env wiring)
30
+
31
+ ### Mandatory Output (7 Sections)
32
+
33
+ For triggered tasks, include all sections below:
34
+ 1. Scope / Trigger
35
+ 2. Signatures (command/API/DB)
36
+ 3. Contracts (request/response/env)
37
+ 4. Validation & Error Matrix
38
+ 5. Good/Base/Bad Cases
39
+ 6. Tests Required (with assertion points)
40
+ 7. Wrong vs Correct (at least one pair)
41
+
42
+ ---
43
+
44
+ ## When to Update Code-Specs
45
+
46
+ | Trigger | Example | Target Spec |
47
+ |---------|---------|-------------|
48
+ | **Implemented a feature** | Added a new integration or module | Relevant spec file |
49
+ | **Made a design decision** | Chose extensibility pattern over simplicity | Relevant spec + "Design Decisions" section |
50
+ | **Fixed a bug** | Found a subtle issue with error handling | Relevant spec (e.g., error-handling docs) |
51
+ | **Discovered a pattern** | Found a better way to structure code | Relevant spec file |
52
+ | **Hit a gotcha** | Learned that X must be done before Y | Relevant spec + "Common Mistakes" section |
53
+ | **Established a convention** | Team agreed on naming pattern | Quality guidelines |
54
+ | **New thinking trigger** | "Don't forget to check X before doing Y" | `guides/*.md` (as a checklist item) |
55
+
56
+ **Key Insight**: Code-spec updates are NOT just for problems. Every feature implementation contains design decisions and contracts that future AI/developers need to execute safely.
57
+
58
+ ---
59
+
60
+ ## Spec Structure Overview
61
+
62
+ ```
63
+ .trellis/spec/
64
+ ├── <layer>/ # Per-layer coding standards (e.g., backend/, frontend/, api/)
65
+ │ ├── index.md # Overview and links
66
+ │ └── *.md # Topic-specific guidelines
67
+ └── guides/ # Thinking checklists (NOT coding specs!)
68
+ ├── index.md # Guide index
69
+ └── *.md # Topic-specific guides
70
+ ```
71
+
72
+ ### CRITICAL: Code-Spec vs Guide - Know the Difference
73
+
74
+ | Type | Location | Purpose | Content Style |
75
+ |------|----------|---------|---------------|
76
+ | **Code-Spec** | `<layer>/*.md` | Tell AI "how to implement safely" | Signatures, contracts, matrices, cases, test points |
77
+ | **Guide** | `guides/*.md` | Help AI "what to think about" | Checklists, questions, pointers to specs |
78
+
79
+ **Decision Rule**: Ask yourself:
80
+
81
+ - "This is **how to write** the code" → Put in a spec layer directory
82
+ - "This is **what to consider** before writing" → Put in `guides/`
83
+
84
+ **Example**:
85
+
86
+ | Learning | Wrong Location | Correct Location |
87
+ |----------|----------------|------------------|
88
+ | "Use API X not API Y for this task" | ❌ `guides/` (too specific for a thinking guide) | ✅ Relevant spec file (concrete convention) |
89
+ | "Remember to check X when doing Y" | ❌ Spec file (too abstract for a spec) | ✅ `guides/` (thinking checklist) |
90
+
91
+ **Guides should be short checklists that point to specs**, not duplicate the detailed rules.
92
+
93
+ ---
94
+
95
+ ## Update Process
96
+
97
+ ### Step 1: Identify What You Learned
98
+
99
+ Answer these questions:
100
+
101
+ 1. **What did you learn?** (Be specific)
102
+ 2. **Why is it important?** (What problem does it prevent?)
103
+ 3. **Where does it belong?** (Which spec file?)
104
+
105
+ ### Step 2: Classify the Update Type
106
+
107
+ | Type | Description | Action |
108
+ |------|-------------|--------|
109
+ | **Design Decision** | Why we chose approach X over Y | Add to "Design Decisions" section |
110
+ | **Project Convention** | How we do X in this project | Add to relevant section with examples |
111
+ | **New Pattern** | A reusable approach discovered | Add to "Patterns" section |
112
+ | **Forbidden Pattern** | Something that causes problems | Add to "Anti-patterns" or "Don't" section |
113
+ | **Common Mistake** | Easy-to-make error | Add to "Common Mistakes" section |
114
+ | **Convention** | Agreed-upon standard | Add to relevant section |
115
+ | **Gotcha** | Non-obvious behavior | Add warning callout |
116
+
117
+ ### Step 3: Read the Target Code-Spec
118
+
119
+ Before editing, read the current code-spec to:
120
+ - Understand existing structure
121
+ - Avoid duplicating content
122
+ - Find the right section for your update
123
+
124
+ ```bash
125
+ cat .trellis/spec/<category>/<file>.md
126
+ ```
127
+
128
+ ### Step 4: Make the Update
129
+
130
+ Follow these principles:
131
+
132
+ 1. **Be Specific**: Include concrete examples, not just abstract rules
133
+ 2. **Explain Why**: State the problem this prevents
134
+ 3. **Show Contracts**: Add signatures, payload fields, and error behavior
135
+ 4. **Show Code**: Add code snippets for key patterns
136
+ 5. **Keep it Short**: One concept per section
137
+
138
+ ### Step 5: Update the Index (if needed)
139
+
140
+ If you added a new section or the code-spec status changed, update the category's `index.md`.
141
+
142
+ ---
143
+
144
+ ## Update Templates
145
+
146
+ ### Mandatory Template for Infra/Cross-Layer Work
147
+
148
+ ```markdown
149
+ ## Scenario: <name>
150
+
151
+ ### 1. Scope / Trigger
152
+ - Trigger: <why this requires code-spec depth>
153
+
154
+ ### 2. Signatures
155
+ - Backend command/API/DB signature(s)
156
+
157
+ ### 3. Contracts
158
+ - Request fields (name, type, constraints)
159
+ - Response fields (name, type, constraints)
160
+ - Environment keys (required/optional)
161
+
162
+ ### 4. Validation & Error Matrix
163
+ - <condition> -> <error>
164
+
165
+ ### 5. Good/Base/Bad Cases
166
+ - Good: ...
167
+ - Base: ...
168
+ - Bad: ...
169
+
170
+ ### 6. Tests Required
171
+ - Unit/Integration/E2E with assertion points
172
+
173
+ ### 7. Wrong vs Correct
174
+ #### Wrong
175
+ ...
176
+ #### Correct
177
+ ...
178
+ ```
179
+
180
+ ### Adding a Design Decision
181
+
182
+ ```markdown
183
+ ### Design Decision: [Decision Name]
184
+
185
+ **Context**: What problem were we solving?
186
+
187
+ **Options Considered**:
188
+ 1. Option A - brief description
189
+ 2. Option B - brief description
190
+
191
+ **Decision**: We chose Option X because...
192
+
193
+ **Example**:
194
+ \`\`\`typescript
195
+ // How it's implemented
196
+ code example
197
+ \`\`\`
198
+
199
+ **Extensibility**: How to extend this in the future...
200
+ ```
201
+
202
+ ### Adding a Project Convention
203
+
204
+ ```markdown
205
+ ### Convention: [Convention Name]
206
+
207
+ **What**: Brief description of the convention.
208
+
209
+ **Why**: Why we do it this way in this project.
210
+
211
+ **Example**:
212
+ \`\`\`typescript
213
+ // How to follow this convention
214
+ code example
215
+ \`\`\`
216
+
217
+ **Related**: Links to related conventions or specs.
218
+ ```
219
+
220
+ ### Adding a New Pattern
221
+
222
+ ```markdown
223
+ ### Pattern Name
224
+
225
+ **Problem**: What problem does this solve?
226
+
227
+ **Solution**: Brief description of the approach.
228
+
229
+ **Example**:
230
+ \`\`\`
231
+ // Good
232
+ code example
233
+
234
+ // Bad
235
+ code example
236
+ \`\`\`
237
+
238
+ **Why**: Explanation of why this works better.
239
+ ```
240
+
241
+ ### Adding a Forbidden Pattern
242
+
243
+ ```markdown
244
+ ### Don't: Pattern Name
245
+
246
+ **Problem**:
247
+ \`\`\`
248
+ // Don't do this
249
+ bad code example
250
+ \`\`\`
251
+
252
+ **Why it's bad**: Explanation of the issue.
253
+
254
+ **Instead**:
255
+ \`\`\`
256
+ // Do this instead
257
+ good code example
258
+ \`\`\`
259
+ ```
260
+
261
+ ### Adding a Common Mistake
262
+
263
+ ```markdown
264
+ ### Common Mistake: Description
265
+
266
+ **Symptom**: What goes wrong
267
+
268
+ **Cause**: Why this happens
269
+
270
+ **Fix**: How to correct it
271
+
272
+ **Prevention**: How to avoid it in the future
273
+ ```
274
+
275
+ ### Adding a Gotcha
276
+
277
+ ```markdown
278
+ > **Warning**: Brief description of the non-obvious behavior.
279
+ >
280
+ > Details about when this happens and how to handle it.
281
+ ```
282
+
283
+ ---
284
+
285
+ ## Interactive Mode
286
+
287
+ If you're unsure what to update, answer these prompts:
288
+
289
+ 1. **What did you just finish?**
290
+ - [ ] Fixed a bug
291
+ - [ ] Implemented a feature
292
+ - [ ] Refactored code
293
+ - [ ] Had a discussion about approach
294
+
295
+ 2. **What did you learn or decide?**
296
+ - Design decision (why X over Y)
297
+ - Project convention (how we do X)
298
+ - Non-obvious behavior (gotcha)
299
+ - Better approach (pattern)
300
+
301
+ 3. **Would future AI/developers need to know this?**
302
+ - To understand how the code works → Yes, update spec
303
+ - To maintain or extend the feature → Yes, update spec
304
+ - To avoid repeating mistakes → Yes, update spec
305
+ - Purely one-off implementation detail → Maybe skip
306
+
307
+ 4. **Which area does it relate to?**
308
+ - [ ] Backend code
309
+ - [ ] Frontend code
310
+ - [ ] Cross-layer data flow
311
+ - [ ] Code organization/reuse
312
+ - [ ] Quality/testing
313
+
314
+ ---
315
+
316
+ ## Quality Checklist
317
+
318
+ Before finishing your code-spec update:
319
+
320
+ - [ ] Is the content specific and actionable?
321
+ - [ ] Did you include a code example?
322
+ - [ ] Did you explain WHY, not just WHAT?
323
+ - [ ] Did you include executable signatures/contracts?
324
+ - [ ] Did you include validation and error matrix?
325
+ - [ ] Did you include Good/Base/Bad cases?
326
+ - [ ] Did you include required tests with assertion points?
327
+ - [ ] Is it in the right code-spec file?
328
+ - [ ] Does it duplicate existing content?
329
+ - [ ] Would a new team member understand it?
330
+
331
+ ---
332
+
333
+ ## Relationship to Other Commands
334
+
335
+ ```
336
+ Development Flow:
337
+ Learn something → /trellis:update-spec → Knowledge captured
338
+ ↑ ↓
339
+ /trellis:break-loop ←──────────────────── Future sessions benefit
340
+ (deep bug analysis)
341
+ ```
342
+
343
+ - `/trellis:break-loop` - Analyzes bugs deeply, often reveals spec updates needed
344
+ - `/trellis:update-spec` - Actually makes the updates
345
+ - `/trellis:finish-work` - Reminds you to check if specs need updates
346
+
347
+ ---
348
+
349
+ ## Core Philosophy
350
+
351
+ > **Code-specs are living documents. Every debugging session, every "aha moment" is an opportunity to make the implementation contract clearer.**
352
+
353
+ The goal is **institutional memory**:
354
+ - What one person learns, everyone benefits from
355
+ - What AI learns in one session, persists to future sessions
356
+ - Mistakes become documented guardrails