opencodekit 0.21.9 → 0.22.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 (165) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/template/.opencode/AGENTS.md +116 -499
  3. package/dist/template/.opencode/README.md +1 -1
  4. package/dist/template/.opencode/agent/build.md +56 -396
  5. package/dist/template/.opencode/agent/explore.md +15 -16
  6. package/dist/template/.opencode/agent/general.md +2 -2
  7. package/dist/template/.opencode/agent/plan.md +3 -3
  8. package/dist/template/.opencode/agent/review.md +2 -3
  9. package/dist/template/.opencode/agent/scout.md +34 -16
  10. package/dist/template/.opencode/agent/vision.md +0 -1
  11. package/dist/template/.opencode/command/clarify.md +48 -0
  12. package/dist/template/.opencode/command/commit.md +53 -0
  13. package/dist/template/.opencode/command/design.md +4 -4
  14. package/dist/template/.opencode/command/fix.md +56 -0
  15. package/dist/template/.opencode/command/improve-architecture.md +55 -0
  16. package/dist/template/.opencode/command/init.md +88 -68
  17. package/dist/template/.opencode/command/refactor.md +66 -0
  18. package/dist/template/.opencode/command/review-codebase.md +1 -1
  19. package/dist/template/.opencode/command/ship.md +1 -1
  20. package/dist/template/.opencode/command/test.md +66 -0
  21. package/dist/template/.opencode/dcp.jsonc +29 -46
  22. package/dist/template/.opencode/memory/README.md +3 -5
  23. package/dist/template/.opencode/memory/_templates/adr.md +45 -0
  24. package/dist/template/.opencode/memory/project/gotchas.md +1 -1
  25. package/dist/template/.opencode/memory/project/user.md +1 -2
  26. package/dist/template/.opencode/memory/session-context.md +1 -1
  27. package/dist/template/.opencode/opencode.json +10 -332
  28. package/dist/template/.opencode/plugin/README.md +1 -1
  29. package/dist/template/.opencode/plugin/guard.ts +62 -0
  30. package/dist/template/.opencode/plugin/{lib/memory-admin-tools.ts → memory/admin.ts} +4 -4
  31. package/dist/template/.opencode/plugin/{lib → memory}/capture.ts +1 -1
  32. package/dist/template/.opencode/plugin/{lib → memory}/compile.ts +2 -2
  33. package/dist/template/.opencode/plugin/{lib → memory}/context.ts +1 -1
  34. package/dist/template/.opencode/plugin/{lib → memory}/curator.ts +1 -1
  35. package/dist/template/.opencode/plugin/{lib → memory}/db/observations.ts +102 -3
  36. package/dist/template/.opencode/plugin/{lib → memory}/db/schema.ts +43 -1
  37. package/dist/template/.opencode/plugin/{lib → memory}/db/types.ts +22 -0
  38. package/dist/template/.opencode/plugin/{lib/memory-db.ts → memory/db.ts} +1 -1
  39. package/dist/template/.opencode/plugin/{lib → memory}/distill.ts +1 -1
  40. package/dist/template/.opencode/plugin/{lib/memory-helpers.ts → memory/helpers.ts} +5 -1
  41. package/dist/template/.opencode/plugin/{lib/memory-hooks.ts → memory/hooks.ts} +1 -1
  42. package/dist/template/.opencode/plugin/{lib → memory}/index-generator.ts +2 -2
  43. package/dist/template/.opencode/plugin/{lib → memory}/inject.ts +1 -1
  44. package/dist/template/.opencode/plugin/{lib → memory}/lint.ts +2 -2
  45. package/dist/template/.opencode/plugin/memory/tools.ts +322 -0
  46. package/dist/template/.opencode/plugin/{lib → memory}/validate.ts +2 -2
  47. package/dist/template/.opencode/plugin/memory.ts +7 -17
  48. package/dist/template/.opencode/plugin/srcwalk.ts +721 -0
  49. package/dist/template/.opencode/skill/agent-code-quality-gate/SKILL.md +98 -0
  50. package/dist/template/.opencode/skill/behavioral-kernel/SKILL.md +52 -0
  51. package/dist/template/.opencode/skill/browser-testing-with-devtools/SKILL.md +85 -0
  52. package/dist/template/.opencode/skill/code-cleanup/SKILL.md +114 -0
  53. package/dist/template/.opencode/skill/code-navigation/SKILL.md +142 -0
  54. package/dist/template/.opencode/skill/code-review-and-quality/SKILL.md +131 -0
  55. package/dist/template/.opencode/skill/debugging-and-error-recovery/SKILL.md +109 -0
  56. package/dist/template/.opencode/skill/deep-module-design/SKILL.md +207 -0
  57. package/dist/template/.opencode/skill/git-workflow-and-versioning/SKILL.md +77 -0
  58. package/dist/template/.opencode/skill/grill-me/SKILL.md +140 -0
  59. package/dist/template/.opencode/skill/memory-system/SKILL.md +9 -10
  60. package/dist/template/.opencode/skill/planning-and-task-breakdown/SKILL.md +116 -0
  61. package/dist/template/.opencode/skill/shipping-and-launch/SKILL.md +95 -0
  62. package/dist/template/.opencode/skill/source-driven-development/SKILL.md +103 -0
  63. package/dist/template/.opencode/skill/spec-driven-development/SKILL.md +121 -0
  64. package/dist/template/.opencode/skill/srcwalk/SKILL.md +161 -0
  65. package/dist/template/.opencode/skill/ubiquitous-language/SKILL.md +184 -0
  66. package/dist/template/.opencode/tool/context7.ts +1 -1
  67. package/dist/template/.opencode/tool/grepsearch.ts +1 -1
  68. package/package.json +1 -1
  69. package/dist/template/.opencode/AGENT_ALIGNMENT.md +0 -564
  70. package/dist/template/.opencode/agent/painter.md +0 -83
  71. package/dist/template/.opencode/command/compound.md +0 -240
  72. package/dist/template/.opencode/command/curate.md +0 -299
  73. package/dist/template/.opencode/command/handoff.md +0 -149
  74. package/dist/template/.opencode/command/health.md +0 -356
  75. package/dist/template/.opencode/command/init-context.md +0 -297
  76. package/dist/template/.opencode/command/init-user.md +0 -125
  77. package/dist/template/.opencode/command/iterate.md +0 -200
  78. package/dist/template/.opencode/command/lfg.md +0 -173
  79. package/dist/template/.opencode/command/resume.md +0 -78
  80. package/dist/template/.opencode/command/status.md +0 -126
  81. package/dist/template/.opencode/command/ui-slop-check.md +0 -169
  82. package/dist/template/.opencode/plugin/lib/memory-tools.ts +0 -535
  83. package/dist/template/.opencode/skill/agent-evals/SKILL.md +0 -208
  84. package/dist/template/.opencode/skill/anti-ai-slop/SKILL.md +0 -76
  85. package/dist/template/.opencode/skill/augment-context-engine/SKILL.md +0 -122
  86. package/dist/template/.opencode/skill/augment-context-engine/mcp.json +0 -6
  87. package/dist/template/.opencode/skill/brand-asset-protocol/SKILL.md +0 -222
  88. package/dist/template/.opencode/skill/code-search-patterns/SKILL.md +0 -253
  89. package/dist/template/.opencode/skill/code-simplification/SKILL.md +0 -211
  90. package/dist/template/.opencode/skill/context-condensation/SKILL.md +0 -149
  91. package/dist/template/.opencode/skill/context-initialization/SKILL.md +0 -69
  92. package/dist/template/.opencode/skill/context-management/SKILL.md +0 -390
  93. package/dist/template/.opencode/skill/deep-research/SKILL.md +0 -384
  94. package/dist/template/.opencode/skill/design-direction-advisor/SKILL.md +0 -139
  95. package/dist/template/.opencode/skill/dispatching-parallel-agents/SKILL.md +0 -191
  96. package/dist/template/.opencode/skill/executing-plans/SKILL.md +0 -247
  97. package/dist/template/.opencode/skill/figma-go/SKILL.md +0 -65
  98. package/dist/template/.opencode/skill/finishing-a-development-branch/SKILL.md +0 -357
  99. package/dist/template/.opencode/skill/full-output-enforcement/SKILL.md +0 -62
  100. package/dist/template/.opencode/skill/gh-address-comments/SKILL.md +0 -29
  101. package/dist/template/.opencode/skill/gh-address-comments/scripts/fetch_comments.py +0 -237
  102. package/dist/template/.opencode/skill/gh-fix-ci/SKILL.md +0 -38
  103. package/dist/template/.opencode/skill/gh-fix-ci/scripts/inspect_pr_checks.py +0 -509
  104. package/dist/template/.opencode/skill/hi-fi-prototype-html/SKILL.md +0 -253
  105. package/dist/template/.opencode/skill/html-deck-export/SKILL.md +0 -189
  106. package/dist/template/.opencode/skill/index-knowledge/SKILL.md +0 -413
  107. package/dist/template/.opencode/skill/memory-grounding/SKILL.md +0 -68
  108. package/dist/template/.opencode/skill/playwriter/SKILL.md +0 -158
  109. package/dist/template/.opencode/skill/portless/SKILL.md +0 -109
  110. package/dist/template/.opencode/skill/prd/SKILL.md +0 -146
  111. package/dist/template/.opencode/skill/prd-task/SKILL.md +0 -182
  112. package/dist/template/.opencode/skill/prd-task/references/prd-schema.json +0 -124
  113. package/dist/template/.opencode/skill/prompt-leverage/SKILL.md +0 -90
  114. package/dist/template/.opencode/skill/prompt-leverage/references/framework.md +0 -91
  115. package/dist/template/.opencode/skill/prompt-leverage/scripts/augment_prompt.py +0 -157
  116. package/dist/template/.opencode/skill/receiving-code-review/SKILL.md +0 -263
  117. package/dist/template/.opencode/skill/reconcile/SKILL.md +0 -183
  118. package/dist/template/.opencode/skill/reflection-checkpoints/SKILL.md +0 -183
  119. package/dist/template/.opencode/skill/requesting-code-review/SKILL.md +0 -443
  120. package/dist/template/.opencode/skill/requesting-code-review/references/specialist-profiles.md +0 -108
  121. package/dist/template/.opencode/skill/requesting-code-review/review.md +0 -160
  122. package/dist/template/.opencode/skill/rtk-command-compression/SKILL.md +0 -134
  123. package/dist/template/.opencode/skill/screenshot/SKILL.md +0 -48
  124. package/dist/template/.opencode/skill/screenshot/scripts/ensure_macos_permissions.sh +0 -54
  125. package/dist/template/.opencode/skill/screenshot/scripts/macos_display_info.swift +0 -22
  126. package/dist/template/.opencode/skill/screenshot/scripts/macos_permissions.swift +0 -40
  127. package/dist/template/.opencode/skill/screenshot/scripts/macos_window_info.swift +0 -126
  128. package/dist/template/.opencode/skill/screenshot/scripts/take_screenshot.ps1 +0 -163
  129. package/dist/template/.opencode/skill/screenshot/scripts/take_screenshot.py +0 -585
  130. package/dist/template/.opencode/skill/security-threat-model/SKILL.md +0 -36
  131. package/dist/template/.opencode/skill/security-threat-model/references/prompt-template.md +0 -255
  132. package/dist/template/.opencode/skill/security-threat-model/references/security-controls-and-assets.md +0 -32
  133. package/dist/template/.opencode/skill/sharing-skills/SKILL.md +0 -214
  134. package/dist/template/.opencode/skill/skill-creator/SKILL.md +0 -181
  135. package/dist/template/.opencode/skill/skill-installer/SKILL.md +0 -58
  136. package/dist/template/.opencode/skill/skill-installer/scripts/github_utils.py +0 -21
  137. package/dist/template/.opencode/skill/skill-installer/scripts/install-skill-from-github.py +0 -313
  138. package/dist/template/.opencode/skill/skill-installer/scripts/list-skills.py +0 -106
  139. package/dist/template/.opencode/skill/swarm-coordination/SKILL.md +0 -244
  140. package/dist/template/.opencode/skill/swarm-coordination/references/architecture.md +0 -39
  141. package/dist/template/.opencode/skill/swarm-coordination/references/delegation-worker-protocol.md +0 -145
  142. package/dist/template/.opencode/skill/swarm-coordination/references/dependency-graph.md +0 -50
  143. package/dist/template/.opencode/skill/swarm-coordination/references/drift-check.md +0 -90
  144. package/dist/template/.opencode/skill/swarm-coordination/references/integration-beads.md +0 -20
  145. package/dist/template/.opencode/skill/swarm-coordination/references/launch-flow.md +0 -186
  146. package/dist/template/.opencode/skill/swarm-coordination/references/reconciler.md +0 -172
  147. package/dist/template/.opencode/skill/swarm-coordination/references/tier-enforcement.md +0 -78
  148. package/dist/template/.opencode/skill/swarm-coordination/references/tmux-integration.md +0 -134
  149. package/dist/template/.opencode/skill/systematic-debugging/SKILL.md +0 -402
  150. package/dist/template/.opencode/skill/terse-output-mode/SKILL.md +0 -95
  151. package/dist/template/.opencode/skill/think-in-code/SKILL.md +0 -136
  152. package/dist/template/.opencode/skill/ux-quality-gates/SKILL.md +0 -137
  153. package/dist/template/.opencode/skill/v1-run/SKILL.md +0 -175
  154. package/dist/template/.opencode/skill/v1-run/mcp.json +0 -6
  155. package/dist/template/.opencode/skill/verification-gates/SKILL.md +0 -63
  156. package/dist/template/.opencode/skill/visual-analysis/SKILL.md +0 -154
  157. package/dist/template/.opencode/skill/web-design-guidelines/SKILL.md +0 -46
  158. package/dist/template/.opencode/skill/workspace-setup/SKILL.md +0 -76
  159. package/dist/template/.opencode/skill/writing-plans/SKILL.md +0 -320
  160. /package/dist/template/.opencode/plugin/{lib → memory}/compact.ts +0 -0
  161. /package/dist/template/.opencode/plugin/{lib → memory}/db/graph.ts +0 -0
  162. /package/dist/template/.opencode/plugin/{lib → memory}/db/maintenance.ts +0 -0
  163. /package/dist/template/.opencode/plugin/{lib → memory}/db/pipeline.ts +0 -0
  164. /package/dist/template/.opencode/plugin/{lib → memory}/notify.ts +0 -0
  165. /package/dist/template/.opencode/plugin/{lib → memory}/operation-log.ts +0 -0
@@ -1,253 +0,0 @@
1
- ---
2
- name: code-search-patterns
3
- description: Use when navigating unfamiliar code with search-first patterns, combining built-in/LSP navigation with tilth MCP (main agent) and tilth CLI (subagents)
4
- version: 1.0.0
5
- tags: [workflow, code-quality, context, subagent]
6
- dependencies: []
7
- ---
8
-
9
- # Code Search Patterns
10
-
11
- Unified navigation skill for fast, low-waste code understanding across both execution modes:
12
-
13
- - **Main agent**: built-in tools + LSP + tilth MCP
14
- - **Subagents**: Bash + `npx -y tilth` CLI
15
-
16
- This skill merges practical navigation heuristics with concrete tool usage so you can locate behavior, trace impact, and edit safely with fewer calls.
17
-
18
- ## When to Use
19
-
20
- - Exploring unfamiliar modules before editing
21
- - Tracing call chains across files and directories
22
- - Checking blast radius before signature/export changes
23
- - Dispatching subagents that need structural code navigation
24
- - Reducing token/tool-call waste during implementation
25
-
26
- ## When NOT to Use
27
-
28
- - Trivial single-file edits where symbol location is already known
29
- - Pure docs/config reads with no dependency tracing
30
- - Tasks focused on external web research (use web research tools instead)
31
-
32
- ## Core Principle
33
-
34
- > Collapse multiple tool calls into fewer, smarter ones. Every unnecessary read or search wastes tokens and turns.
35
-
36
- ## Navigation Patterns
37
-
38
- ### 1) Search First, Read Second
39
-
40
- Start with symbol/content search to find exact locations, then read only the needed slice.
41
-
42
- - **Good**: `search -> targeted read`
43
- - **Avoid**: `read many files -> search later`
44
-
45
- Use LSP (`findReferences`, `outgoingCalls`) or tilth search first; read deep only after narrowing scope.
46
-
47
- ### 2) Multi-Symbol Search
48
-
49
- When flow spans multiple functions, query them together (`A,B,C`) instead of serial one-by-one lookups.
50
-
51
- - Faster call-chain reconstruction
52
- - Fewer repeated scans of the same files
53
-
54
- ### 3) Don’t Re-Read What Search Already Returned
55
-
56
- If search output already includes definition body/context, proceed from it.
57
- Re-read only when you need:
58
-
59
- - exact edit anchors,
60
- - additional surrounding lines,
61
- - or untruncated content.
62
-
63
- ### 4) Blast Radius Check (Before Breaking Changes)
64
-
65
- Before renaming/removing/changing signatures, inspect downstream impact first.
66
-
67
- - LSP: `findReferences`, `incomingCalls`
68
- - tilth: `tilth_tilth_deps` or `--deps`
69
-
70
- Then apply edits from dependents inward.
71
-
72
- ### 5) Context Locality
73
-
74
- Prefer nearby package/module scope first.
75
-
76
- - built-in search: constrain `path`
77
- - tilth: pass `scope` / `context`
78
-
79
- Locality reduces irrelevant matches and token churn.
80
-
81
- ### 6) Outline Before Deep Read
82
-
83
- For large files, inspect structure first (symbols/outline), then read only target sections.
84
-
85
- - LSP: `documentSymbol`
86
- - tilth read: smart outline by default, then section drill-in
87
-
88
- ### 7) Follow Call Chain, Not File Tree
89
-
90
- Start at entry behavior and walk calls (`definition -> outgoing -> next definition`) instead of reading folders linearly.
91
-
92
- This exposes real execution flow with fewer reads.
93
-
94
- ## tilth MCP (Main Agent)
95
-
96
- Use MCP variants when available in the main agent session:
97
-
98
- - `tilth_tilth_search`
99
- - `tilth_tilth_read`
100
- - `tilth_tilth_files`
101
- - `tilth_tilth_deps`
102
-
103
- ### Built-in/LSP vs tilth MCP (when to choose which)
104
-
105
- | Need | Built-in / LSP | Prefer tilth MCP when | Why tilth helps |
106
- | ----------------------- | -------------------------------------- | ----------------------------------------------------------- | ----------------------------------- |
107
- | Find symbols/usages | `grep` / `lsp.findReferences` | You want definitions + usages + expanded source in one call | Reduces search+read round trips |
108
- | Read file content | `read` | File is large or you only need structure first | Smart outline + section targeting |
109
- | List candidate files | `glob` | You want quick glob results with token-aware relevance | Faster triage for large directories |
110
- | Pre-change impact check | `lsp.incomingCalls` + manual follow-up | You need import + dependent view before breaking change | Single blast-radius view via deps |
111
-
112
- Guideline: if tilth MCP is active, use it as default for navigation; fall back to built-in/LSP when you need language-server-specific semantics or exact editor-position operations.
113
-
114
- ## tilth CLI (Subagents)
115
-
116
- ### Why this exists
117
-
118
- Subagents typically cannot call MCP tools directly. They can still use tilth through Bash:
119
-
120
- ```bash
121
- npx -y tilth <query> [flags]
122
- ```
123
-
124
- ### Auto-detection
125
-
126
- | Query shape | Auto-detected action |
127
- | --------------------------------- | ------------------------------------ |
128
- | Existing file path (`src/foo.ts`) | Read file (smart outline/full) |
129
- | Identifier (`initCommand`) | Symbol search (definitions + usages) |
130
- | Glob (`*.test.ts`) | List files |
131
- | Plain text / phrase | Content search |
132
-
133
- Use `--kind` to force a specific mode when needed.
134
-
135
- ### Core operations
136
-
137
- #### 1) Read file
138
-
139
- ```bash
140
- npx -y tilth src/index.ts
141
- npx -y tilth src/index.ts --full
142
- npx -y tilth src/index.ts --section 45-89
143
- ```
144
-
145
- #### 2) Search symbols
146
-
147
- ```bash
148
- npx -y tilth initCommand --scope src/
149
- npx -y tilth "initCommand,detectMode" --scope src/
150
- ```
151
-
152
- #### 3) Search text/regex
153
-
154
- ```bash
155
- npx -y tilth --kind content "TODO" --scope src/
156
- npx -y tilth --kind regex "/TODO.*fix/" --scope src/
157
- ```
158
-
159
- #### 4) Find callers
160
-
161
- ```bash
162
- npx -y tilth --kind callers initCommand --scope src/
163
- ```
164
-
165
- #### 5) List files
166
-
167
- ```bash
168
- npx -y tilth "*.test.ts" --scope src/
169
- ```
170
-
171
- #### 6) Blast radius / deps
172
-
173
- ```bash
174
- npx -y tilth --deps src/commands/init.ts --scope src/
175
- ```
176
-
177
- #### 7) Codebase map
178
-
179
- ```bash
180
- npx -y tilth --map --scope src/
181
- ```
182
-
183
- ### Useful flags
184
-
185
- | Flag | Purpose | Example |
186
- | ----------------- | ------------------------------ | ---------------------------- | ------------------- | ----------------- | ---------------- |
187
- | `--scope <dir>` | Restrict scan area | `--scope src/commands/` |
188
- | `--section <range | heading>` | Targeted file slice | `--section 120-180` |
189
- | `--full` | Force full file output | `--full` |
190
- | `--budget <n>` | Limit output size | `--budget 2000` |
191
- | `--json` | Machine-readable output | `--json` |
192
- | `--map` | Structural project skeleton | `--map --scope src/` |
193
- | `--kind <symbol | content | regex | callers>` | Force search mode | `--kind callers` |
194
- | `--deps <file>` | Import/dependent blast radius | `--deps src/utils/errors.ts` |
195
- | `--expand <n>` | Expand top matches with source | `--expand 3` |
196
-
197
- ### MCP vs CLI
198
-
199
- | Capability | MCP (main agent) | CLI (subagents) |
200
- | ---------------------------- | -------------------------------------------------- | ------------------------------------------ |
201
- | Access mode | Tool call | Bash command |
202
- | Session dedup/context carry | Yes | No |
203
- | Hash-anchored edit flow | Yes (via MCP edit tools) | No |
204
- | Symbol/content/regex/callers | Yes | Yes |
205
- | Deps/blast-radius | Yes | Yes |
206
- | Codebase map | Limited by toolset | Yes (`--map`) |
207
- | Best for | Interactive main-agent navigation + edit workflows | Subagent discovery/exploration without MCP |
208
-
209
- ### Example subagent dispatch
210
-
211
- ```ts
212
- task({
213
- subagent_type: "general",
214
- prompt: `Use tilth CLI via Bash for navigation.
215
-
216
- 1) Locate symbol and usages:
217
- npx -y tilth initCommand --scope src/
218
-
219
- 2) Find callers:
220
- npx -y tilth --kind callers initCommand --scope src/
221
-
222
- 3) Check blast radius before edits:
223
- npx -y tilth --deps src/commands/init.ts --scope src/
224
-
225
- 4) Read only the relevant section:
226
- npx -y tilth src/commands/init.ts --section 500-620
227
-
228
- Then implement the requested change with minimal file edits.`,
229
- });
230
- ```
231
-
232
- ## Cost Awareness
233
-
234
- Navigation cost compounds quickly. Optimize for fewer, richer calls.
235
-
236
- - Prefer one structural search over multiple blind reads
237
- - Reuse search output; avoid duplicate reads of the same symbol body
238
- - Scope aggressively (`path`, `scope`) to cut noise
239
- - Use section reads for large files instead of full-file pulls
240
-
241
- Target heuristic: understand a symbol and its direct impact in **≤3 calls** whenever possible.
242
-
243
- ## Common Mistakes
244
-
245
- | Mistake | Better pattern |
246
- | ------------------------------------------------ | ------------------------------------------------------------------- |
247
- | Reading big files before locating symbol | Search first, then section read |
248
- | Re-reading code already shown in search output | Work from returned snippet; re-read only if needed for edit anchors |
249
- | Serially tracing one function at a time | Multi-symbol search + callers/deps |
250
- | Ignoring blast radius before API/signature edits | Run references/incoming/deps first |
251
- | Unscoped repository-wide search | Use `path`/`--scope` to localize |
252
- | Using CLI defaults when mode is ambiguous | Force with `--kind` |
253
- | Overusing `--full` on large files | Outline first, then `--section` |
@@ -1,211 +0,0 @@
1
- ---
2
- name: code-simplification
3
- description: Use when reducing code complexity, eliminating dead code, or refactoring for clarity — enforces measure-before-cutting discipline to prevent breaking changes disguised as cleanup
4
- version: 1.0.0
5
- tags: [code-quality, refactoring]
6
- dependencies: [verification-before-completion]
7
- ---
8
-
9
- # Code Simplification
10
-
11
- > **Replaces** ad-hoc "cleanup" refactors that introduce bugs — enforces systematic simplification with verification at every step
12
-
13
- ## When to Use
14
-
15
- - Code is harder to understand than it needs to be
16
- - Functions are too long (>50 lines), files are too large (>500 lines)
17
- - Dead code, unused imports, or unnecessary abstractions exist
18
- - You're asked to "clean up" or "simplify" a module
19
- - Complexity is making bugs harder to fix
20
-
21
- ## When NOT to Use
22
-
23
- - The code works, is readable, and isn't blocking anything — leave it alone
24
- - You're implementing a new feature (use incremental-implementation instead)
25
- - The "simplification" is actually a rewrite with different behavior
26
-
27
- ## Common Rationalizations
28
-
29
- | Rationalization | Rebuttal |
30
- | -------------------------------------- | ---------------------------------------------------------------------------------------- |
31
- | "This code is ugly, let me rewrite it" | Ugly but working > beautiful but broken. Simplify incrementally, not wholesale |
32
- | "Nobody uses this, I'll delete it" | Verify with grep/find-references FIRST. "Nobody uses this" is the #1 cause of breakage |
33
- | "I'll simplify it while I'm in here" | Mixing feature work with refactoring makes both harder to review and revert |
34
- | "This abstraction isn't needed" | Check if it serves a testing, extension, or boundary purpose before removing |
35
- | "I can make this more elegant" | Elegant for whom? Optimize for the next reader, not for cleverness |
36
- | "The tests will catch any issues" | Tests cover known behavior. Simplification can change behavior in ways tests don't cover |
37
-
38
- ## Overview
39
-
40
- Code simplification is the discipline of making code easier to understand and maintain WITHOUT changing its behavior. The key word is discipline — undisciplined simplification introduces bugs.
41
-
42
- **Core principle:** Measure complexity, simplify the worst offender, verify nothing broke, repeat.
43
-
44
- ## The Process
45
-
46
- ```
47
- 1. MEASURE — Identify what's actually complex (not just what feels complex)
48
- 2. ISOLATE — Pick ONE simplification target
49
- 3. VERIFY — Ensure tests exist for current behavior
50
- 4. SIMPLIFY — Apply the smallest change that reduces complexity
51
- 5. CONFIRM — Run full verification to prove behavior is unchanged
52
- 6. REPEAT — Pick the next target
53
- ```
54
-
55
- ## Complexity Signals
56
-
57
- | Signal | Threshold | Action |
58
- | --------------------- | ---------------- | ------------------------------------------- |
59
- | Function length | >50 lines | Extract helper functions |
60
- | File length | >500 lines | Split into modules |
61
- | Nesting depth | >3 levels | Flatten with early returns or extract |
62
- | Parameter count | >4 params | Use an options object |
63
- | Cyclomatic complexity | >10 per function | Break into smaller functions |
64
- | Dead code | Any | Remove after verifying with find-references |
65
- | Unused imports | Any | Remove (linter usually catches these) |
66
- | Duplicate code | 3+ copies | Extract shared function |
67
-
68
- ## Simplification Patterns
69
-
70
- ### Extract Function
71
-
72
- ```typescript
73
- // BEFORE: Long function with embedded logic
74
- function processOrder(order: Order) {
75
- // 20 lines of validation
76
- // 15 lines of pricing
77
- // 10 lines of notification
78
- }
79
-
80
- // AFTER: Named steps
81
- function processOrder(order: Order) {
82
- validateOrder(order);
83
- const total = calculateTotal(order);
84
- notifyCustomer(order, total);
85
- }
86
- ```
87
-
88
- ### Early Return (Flatten Nesting)
89
-
90
- ```typescript
91
- // BEFORE: Deep nesting
92
- function getUser(id: string) {
93
- if (id) {
94
- const user = db.find(id);
95
- if (user) {
96
- if (user.active) {
97
- return user;
98
- }
99
- }
100
- }
101
- return null;
102
- }
103
-
104
- // AFTER: Guard clauses
105
- function getUser(id: string) {
106
- if (!id) return null;
107
- const user = db.find(id);
108
- if (!user) return null;
109
- if (!user.active) return null;
110
- return user;
111
- }
112
- ```
113
-
114
- ### Remove Dead Code
115
-
116
- ```
117
- 1. Search: grep/find-references for the symbol
118
- 2. Verify: No callers exist (check tests too)
119
- 3. Remove: Delete the code
120
- 4. Confirm: All tests still pass
121
- ```
122
-
123
- **NEVER assume code is dead without searching.** Check:
124
-
125
- - Direct calls
126
- - Dynamic references (string-based lookups, reflection)
127
- - Test-only usage
128
- - Configuration references
129
-
130
- ### Inline Unnecessary Abstraction
131
-
132
- ```typescript
133
- // BEFORE: Wrapper that adds nothing
134
- function getUserName(user: User): string {
135
- return user.name;
136
- }
137
-
138
- // AFTER: Just use the property directly
139
- user.name;
140
- ```
141
-
142
- Only inline if the abstraction doesn't serve a testing, boundary, or extension purpose.
143
-
144
- ### Replace Conditional with Early Exit
145
-
146
- ```typescript
147
- // BEFORE
148
- function handle(input: string) {
149
- let result = "";
150
- if (isValid(input)) {
151
- result = transform(input);
152
- } else {
153
- throw new Error("Invalid");
154
- }
155
- return result;
156
- }
157
-
158
- // AFTER
159
- function handle(input: string) {
160
- if (!isValid(input)) throw new Error("Invalid");
161
- return transform(input);
162
- }
163
- ```
164
-
165
- ## What NOT to Simplify
166
-
167
- - **Working error handling** — even if verbose, it's there for a reason
168
- - **Compatibility shims** — they exist because something needs them
169
- - **Performance-critical paths** — "simpler" may mean "slower"
170
- - **Code with extensive test coverage pointing at specific behavior** — the tests document WHY it's complex
171
- - **Other people's current work** — don't simplify files with active PRs
172
-
173
- ## Red Flags — STOP
174
-
175
- If you catch yourself:
176
-
177
- - Changing behavior while "simplifying"
178
- - Removing code without checking references first
179
- - Simplifying more than one thing per commit
180
- - "Cleaning up" files you weren't asked to touch
181
- - Making the code "more elegant" without a clear readability improvement
182
-
183
- **STOP.** Revert the current change and pick a smaller target.
184
-
185
- ## Verification
186
-
187
- Before each simplification:
188
-
189
- ```bash
190
- # Ensure tests exist for current behavior
191
- npm test -- --related [file]
192
- ```
193
-
194
- After each simplification:
195
-
196
- ```bash
197
- npm run typecheck
198
- npm run lint
199
- npm test
200
- ```
201
-
202
- **If ANY test fails, the simplification changed behavior.** Either:
203
-
204
- 1. The simplification is wrong — revert it
205
- 2. The test is testing implementation details — fix the test, but document WHY
206
-
207
- ## See Also
208
-
209
- - **incremental-implementation** — Build new features in slices; simplify afterward
210
- - **systematic-debugging** — When simplification reveals hidden bugs
211
- - **defense-in-depth** — When simplifying validation, ensure all layers still hold
@@ -1,149 +0,0 @@
1
- ---
2
- name: context-condensation
3
- description: Use when context is approaching budget limits and you need to compress, OR when handing off to another session. Provides the explicit keep/drop rubric for what survives compression — preserve goals, progress, critical files, failing tests; drop exploration noise and resolved threads. Pairs with `/dcp compress` and `/handoff`. Adapted from OpenHands context-condensation, Manus context engineering, HumanLayer backpressure.
4
- ---
5
-
6
- # Context Condensation
7
-
8
- > Compression is not deletion — it is **selection of what survives**. The wrong selection makes the agent restart from zero. This skill defines what to keep.
9
-
10
- ## When to Use
11
-
12
- - Context >100k tokens and growing
13
- - Phase boundary reached (research done, ready to implement)
14
- - Handing off to a new session via `/handoff`
15
- - A subagent returns large output you need to integrate
16
- - After `/dcp compress` ran but you still feel context drift
17
-
18
- ## Core Principle: 4 Tiers of Survival
19
-
20
- Every conversation chunk falls into one of four tiers. Compress accordingly.
21
-
22
- | Tier | Content | Action |
23
- | ---- | -------------------------------------------------------- | ----------------------- |
24
- | 1 | Goal, constraints, user-stated requirements | **Preserve verbatim** |
25
- | 2 | Critical state — failing tests, current bug, open files | **Preserve as summary** |
26
- | 3 | Decisions made, alternatives rejected, why | **Preserve as 1-liner** |
27
- | 4 | Exploration noise — failed greps, dead ends, raw outputs | **Drop entirely** |
28
-
29
- ## Keep List (Always)
30
-
31
- Compress around these — never drop:
32
-
33
- - **The user's literal request.** Direct quote when short. Paraphrase only when long, and label as paraphrase.
34
- - **Active failures.** Current error message, failing test name + reason, open bug. Tells the next agent what's broken.
35
- - **Decisions + rationale.** "Chose JWT over sessions because [reason]." One line each. Future agents inherit the why.
36
- - **File paths currently being edited.** Exact paths, not "the auth file".
37
- - **Verification status.** Last typecheck/lint/test result with timestamp.
38
- - **Open questions for the user.** Questions awaiting human input.
39
- - **Constraints discovered mid-task.** "User can't add new deps", "DB is read-only in this env".
40
-
41
- ## Drop List (Aggressive)
42
-
43
- Compress these to a single line or remove entirely:
44
-
45
- - **Resolved exploration.** Found the file? Drop the 5 greps that led there.
46
- - **Tool output noise.** Full directory listings, `ls` outputs, package install logs. Keep only the relevant filename.
47
- - **Verbose reasoning.** Your own multi-paragraph thinking that ended in one decision. Keep the decision.
48
- - **Acknowledgments.** "Got it", "I'll do that next" — pure social filler.
49
- - **Failed attempts that taught nothing.** If a wrong approach added no information, drop it. Keep failures that revealed a constraint.
50
- - **Sub-agent self-reports.** Keep the result + verification, drop the agent's narrative summary (Worker Distrust Protocol — don't trust the prose).
51
- - **Old plans you've since revised.** Keep only the current plan.
52
-
53
- ## Failure Preservation Rule
54
-
55
- > **Useful failures stay. Useless failures go.**
56
-
57
- A failure is **useful** if it:
58
-
59
- - Revealed a constraint ("can't use `mv` on this filesystem")
60
- - Eliminated a hypothesis ("the bug is not in the parser")
61
- - Showed a trap that another agent would re-fall into
62
-
63
- A failure is **useless** if it:
64
-
65
- - Was a typo / fat-finger fixed immediately
66
- - Was a tool-call format error with no semantic content
67
- - Was an obvious dead end no agent would repeat
68
-
69
- **Manus rule** (from "Context Engineering for AI Agents: Lessons from Building Manus"): keep useful failures **in-context** as warnings. Don't compress to "encountered errors then succeeded" — that loses the warning.
70
-
71
- ## Condensation Triggers (Beyond Token Count)
72
-
73
- Token count is one trigger. These are the others:
74
-
75
- | Trigger | Action |
76
- | ------------------------------------- | ----------------------------------------------- |
77
- | Phase boundary (research → implement) | Compress all of research phase to summary |
78
- | Subagent returns >2k tokens | Compress immediately, keep result + evidence |
79
- | Same question asked twice in session | Indicates context drift — compress aggressively |
80
- | Plan revised | Drop old plan completely |
81
- | Conversation feels "lost" | Compress; restart from goal + current state |
82
-
83
- ## The Handoff Variant
84
-
85
- When compressing for `/handoff` (different session, different agent will pick up), be **even more selective**:
86
-
87
- - Preserve everything in Keep List
88
- - Add a **`## Next Step`** with the literal next action
89
- - Add a **`## Don't Re-Discover`** with traps already mapped
90
- - Drop everything else
91
-
92
- Handoff format:
93
-
94
- ```markdown
95
- ## Goal
96
-
97
- [user's literal request]
98
-
99
- ## Status
100
-
101
- - Done: [list of completed items with file:line]
102
- - In progress: [current task]
103
- - Blocked: [what's blocking, what was tried]
104
-
105
- ## Critical State
106
-
107
- - Open files: [paths]
108
- - Last verification: [command + result + timestamp]
109
- - Active failures: [error / failing test]
110
-
111
- ## Decisions Made
112
-
113
- - [one-liner] → [one-line rationale]
114
-
115
- ## Don't Re-Discover
116
-
117
- - [trap 1]: [why]
118
- - [trap 2]: [why]
119
-
120
- ## Next Step
121
-
122
- [literal next action — copy-pastable command or description]
123
- ```
124
-
125
- ## Anti-Patterns
126
-
127
- - **"Let me summarize what we did so far..."** in every response — you're re-summarizing instead of compressing once at boundaries
128
- - **Dropping the goal during compression** — the worst failure mode; the next agent has no anchor
129
- - **Keeping all failures** — context fills with noise, real signals get buried
130
- - **Lossy paraphrase of user request** — when in doubt, quote verbatim
131
- - **Compressing during active edits** — wait for atomic step to finish
132
-
133
- ## Integration
134
-
135
- - **Before `/dcp compress`:** Use this rubric to decide what your `summary` field should contain
136
- - **In `/handoff`:** This skill defines the handoff format
137
- - **After subagent return:** Apply Drop List to the agent's narrative, keep result + verification only
138
- - **In long sessions:** Re-read your own context every ~30 messages and apply the rubric
139
-
140
- ## Output
141
-
142
- When you condense, briefly state what survived and what dropped:
143
-
144
- ```
145
- Compressed messages 12-34. Kept: goal, 3 decisions, current failure (auth.ts:42 null deref).
146
- Dropped: 5 file searches, 2 abandoned approaches, dir listings.
147
- ```
148
-
149
- This makes the compression auditable. The user (or next agent) can challenge what got cut.
@@ -1,69 +0,0 @@
1
- ---
2
- name: context-initialization
3
- description: Initialize project context files from templates. Creates on-demand planning files (roadmap.md, state.md) and updates auto-injected project.md.
4
- version: 2.0.0
5
- tags: [context, workflow]
6
- dependencies: []
7
- ---
8
-
9
- # Context Initialization
10
-
11
- ## When to Use
12
-
13
- - When initializing project context files (project.md, roadmap.md, state.md) from templates.
14
- - project.md is auto-injected into every prompt; roadmap.md and state.md are on-demand.
15
-
16
- ## When NOT to Use
17
-
18
- - When context files already exist and only need minor manual edits.
19
-
20
- ## Process
21
-
22
- ### 1. Verify Templates
23
-
24
- ```typescript
25
- tilth_tilth_files({ pattern: "*.md", scope: ".opencode/memory/_templates" });
26
- // Required templates: project.md, roadmap.md, state.md
27
- ```
28
-
29
- Stop if missing.
30
-
31
- ### 2. Gather Input
32
-
33
- Ask 5 questions:
34
-
35
- 1. Project vision
36
- 2. Success criteria
37
- 3. Target users
38
- 4. Phases
39
- 5. Current phase
40
-
41
- Skip if `--skip-questions` flag set.
42
-
43
- ### 3. Create Files
44
-
45
- **project.md** (auto-injected — keep concise)
46
-
47
- - Read template via `Read({ filePath: ".opencode/memory/_templates/project.md" })`
48
- - Fill with answers
49
- - Write via `memory-update({ file: "project/project", content: ..., mode: "replace" })`
50
-
51
- **roadmap.md** (on-demand — access via `memory-read({ file: "project/roadmap" })`)
52
-
53
- - Read template
54
- - Parse phases into table
55
- - Write via `memory-update({ file: "project/roadmap", content: ..., mode: "replace" })`
56
-
57
- **state.md** (on-demand — access via `memory-read({ file: "project/state" })`)
58
-
59
- - Read template
60
- - Set initial state
61
- - Write via `memory-update({ file: "project/state", content: ..., mode: "replace" })`
62
-
63
- ### 4. Verify
64
-
65
- ```typescript
66
- tilth_tilth_files({ pattern: "*.md", scope: ".opencode/memory/project" });
67
- ```
68
-
69
- Report created files with their injection status (auto-injected vs on-demand).