opencodekit 0.21.10 → 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.
- package/dist/index.js +1 -1
- package/dist/template/.opencode/AGENTS.md +116 -487
- package/dist/template/.opencode/README.md +1 -1
- package/dist/template/.opencode/agent/build.md +56 -396
- package/dist/template/.opencode/agent/explore.md +0 -1
- package/dist/template/.opencode/agent/review.md +0 -1
- package/dist/template/.opencode/agent/scout.md +0 -1
- package/dist/template/.opencode/agent/vision.md +0 -1
- package/dist/template/.opencode/command/clarify.md +48 -0
- package/dist/template/.opencode/command/commit.md +53 -0
- package/dist/template/.opencode/command/fix.md +56 -0
- package/dist/template/.opencode/command/improve-architecture.md +55 -0
- package/dist/template/.opencode/command/init.md +88 -68
- package/dist/template/.opencode/command/refactor.md +66 -0
- package/dist/template/.opencode/command/test.md +66 -0
- package/dist/template/.opencode/dcp.jsonc +13 -2
- package/dist/template/.opencode/memory/README.md +3 -5
- package/dist/template/.opencode/memory/_templates/adr.md +45 -0
- package/dist/template/.opencode/memory/project/gotchas.md +1 -1
- package/dist/template/.opencode/memory/session-context.md +1 -1
- package/dist/template/.opencode/plugin/README.md +1 -1
- package/dist/template/.opencode/plugin/guard.ts +62 -0
- package/dist/template/.opencode/plugin/{lib/memory-admin-tools.ts → memory/admin.ts} +4 -4
- package/dist/template/.opencode/plugin/{lib → memory}/capture.ts +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/compile.ts +2 -2
- package/dist/template/.opencode/plugin/{lib → memory}/context.ts +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/curator.ts +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/db/observations.ts +102 -3
- package/dist/template/.opencode/plugin/{lib → memory}/db/schema.ts +43 -1
- package/dist/template/.opencode/plugin/{lib → memory}/db/types.ts +22 -0
- package/dist/template/.opencode/plugin/{lib/memory-db.ts → memory/db.ts} +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/distill.ts +1 -1
- package/dist/template/.opencode/plugin/{lib/memory-helpers.ts → memory/helpers.ts} +5 -1
- package/dist/template/.opencode/plugin/{lib/memory-hooks.ts → memory/hooks.ts} +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/index-generator.ts +2 -2
- package/dist/template/.opencode/plugin/{lib → memory}/inject.ts +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/lint.ts +2 -2
- package/dist/template/.opencode/plugin/memory/tools.ts +322 -0
- package/dist/template/.opencode/plugin/{lib → memory}/validate.ts +2 -2
- package/dist/template/.opencode/plugin/memory.ts +7 -17
- package/dist/template/.opencode/plugin/srcwalk.ts +721 -0
- package/dist/template/.opencode/skill/agent-code-quality-gate/SKILL.md +98 -0
- package/dist/template/.opencode/skill/behavioral-kernel/SKILL.md +52 -0
- package/dist/template/.opencode/skill/browser-testing-with-devtools/SKILL.md +85 -0
- package/dist/template/.opencode/skill/code-cleanup/SKILL.md +114 -0
- package/dist/template/.opencode/skill/code-navigation/SKILL.md +142 -0
- package/dist/template/.opencode/skill/code-review-and-quality/SKILL.md +131 -0
- package/dist/template/.opencode/skill/debugging-and-error-recovery/SKILL.md +109 -0
- package/dist/template/.opencode/skill/deep-module-design/SKILL.md +207 -0
- package/dist/template/.opencode/skill/git-workflow-and-versioning/SKILL.md +77 -0
- package/dist/template/.opencode/skill/grill-me/SKILL.md +140 -0
- package/dist/template/.opencode/skill/memory-system/SKILL.md +9 -10
- package/dist/template/.opencode/skill/planning-and-task-breakdown/SKILL.md +116 -0
- package/dist/template/.opencode/skill/shipping-and-launch/SKILL.md +95 -0
- package/dist/template/.opencode/skill/source-driven-development/SKILL.md +103 -0
- package/dist/template/.opencode/skill/spec-driven-development/SKILL.md +121 -0
- package/dist/template/.opencode/skill/srcwalk/SKILL.md +161 -0
- package/dist/template/.opencode/skill/ubiquitous-language/SKILL.md +184 -0
- package/package.json +1 -1
- package/dist/template/.opencode/AGENT_ALIGNMENT.md +0 -564
- package/dist/template/.opencode/agent/painter.md +0 -83
- package/dist/template/.opencode/command/compound.md +0 -240
- package/dist/template/.opencode/command/curate.md +0 -299
- package/dist/template/.opencode/command/handoff.md +0 -149
- package/dist/template/.opencode/command/health.md +0 -356
- package/dist/template/.opencode/command/init-context.md +0 -297
- package/dist/template/.opencode/command/init-user.md +0 -125
- package/dist/template/.opencode/command/iterate.md +0 -200
- package/dist/template/.opencode/command/lfg.md +0 -173
- package/dist/template/.opencode/command/resume.md +0 -78
- package/dist/template/.opencode/command/status.md +0 -126
- package/dist/template/.opencode/command/ui-slop-check.md +0 -169
- package/dist/template/.opencode/plugin/lib/memory-tools.ts +0 -535
- package/dist/template/.opencode/skill/agent-evals/SKILL.md +0 -208
- package/dist/template/.opencode/skill/anti-ai-slop/SKILL.md +0 -76
- package/dist/template/.opencode/skill/augment-context-engine/SKILL.md +0 -122
- package/dist/template/.opencode/skill/augment-context-engine/mcp.json +0 -6
- package/dist/template/.opencode/skill/brand-asset-protocol/SKILL.md +0 -222
- package/dist/template/.opencode/skill/code-search-patterns/SKILL.md +0 -224
- package/dist/template/.opencode/skill/code-simplification/SKILL.md +0 -211
- package/dist/template/.opencode/skill/context-condensation/SKILL.md +0 -149
- package/dist/template/.opencode/skill/context-initialization/SKILL.md +0 -69
- package/dist/template/.opencode/skill/context-management/SKILL.md +0 -390
- package/dist/template/.opencode/skill/deep-research/SKILL.md +0 -384
- package/dist/template/.opencode/skill/design-direction-advisor/SKILL.md +0 -139
- package/dist/template/.opencode/skill/dispatching-parallel-agents/SKILL.md +0 -191
- package/dist/template/.opencode/skill/executing-plans/SKILL.md +0 -247
- package/dist/template/.opencode/skill/figma-go/SKILL.md +0 -65
- package/dist/template/.opencode/skill/finishing-a-development-branch/SKILL.md +0 -357
- package/dist/template/.opencode/skill/full-output-enforcement/SKILL.md +0 -62
- package/dist/template/.opencode/skill/gh-address-comments/SKILL.md +0 -29
- package/dist/template/.opencode/skill/gh-address-comments/scripts/fetch_comments.py +0 -237
- package/dist/template/.opencode/skill/gh-fix-ci/SKILL.md +0 -38
- package/dist/template/.opencode/skill/gh-fix-ci/scripts/inspect_pr_checks.py +0 -509
- package/dist/template/.opencode/skill/hi-fi-prototype-html/SKILL.md +0 -253
- package/dist/template/.opencode/skill/html-deck-export/SKILL.md +0 -189
- package/dist/template/.opencode/skill/index-knowledge/SKILL.md +0 -413
- package/dist/template/.opencode/skill/memory-grounding/SKILL.md +0 -68
- package/dist/template/.opencode/skill/playwriter/SKILL.md +0 -158
- package/dist/template/.opencode/skill/portless/SKILL.md +0 -109
- package/dist/template/.opencode/skill/prd/SKILL.md +0 -146
- package/dist/template/.opencode/skill/prd-task/SKILL.md +0 -182
- package/dist/template/.opencode/skill/prd-task/references/prd-schema.json +0 -124
- package/dist/template/.opencode/skill/prompt-leverage/SKILL.md +0 -90
- package/dist/template/.opencode/skill/prompt-leverage/references/framework.md +0 -91
- package/dist/template/.opencode/skill/prompt-leverage/scripts/augment_prompt.py +0 -157
- package/dist/template/.opencode/skill/receiving-code-review/SKILL.md +0 -263
- package/dist/template/.opencode/skill/reconcile/SKILL.md +0 -183
- package/dist/template/.opencode/skill/reflection-checkpoints/SKILL.md +0 -183
- package/dist/template/.opencode/skill/requesting-code-review/SKILL.md +0 -443
- package/dist/template/.opencode/skill/requesting-code-review/references/specialist-profiles.md +0 -108
- package/dist/template/.opencode/skill/requesting-code-review/review.md +0 -160
- package/dist/template/.opencode/skill/rtk-command-compression/SKILL.md +0 -134
- package/dist/template/.opencode/skill/screenshot/SKILL.md +0 -48
- package/dist/template/.opencode/skill/screenshot/scripts/ensure_macos_permissions.sh +0 -54
- package/dist/template/.opencode/skill/screenshot/scripts/macos_display_info.swift +0 -22
- package/dist/template/.opencode/skill/screenshot/scripts/macos_permissions.swift +0 -40
- package/dist/template/.opencode/skill/screenshot/scripts/macos_window_info.swift +0 -126
- package/dist/template/.opencode/skill/screenshot/scripts/take_screenshot.ps1 +0 -163
- package/dist/template/.opencode/skill/screenshot/scripts/take_screenshot.py +0 -585
- package/dist/template/.opencode/skill/security-threat-model/SKILL.md +0 -36
- package/dist/template/.opencode/skill/security-threat-model/references/prompt-template.md +0 -255
- package/dist/template/.opencode/skill/security-threat-model/references/security-controls-and-assets.md +0 -32
- package/dist/template/.opencode/skill/sharing-skills/SKILL.md +0 -214
- package/dist/template/.opencode/skill/skill-creator/SKILL.md +0 -181
- package/dist/template/.opencode/skill/skill-installer/SKILL.md +0 -58
- package/dist/template/.opencode/skill/skill-installer/scripts/github_utils.py +0 -21
- package/dist/template/.opencode/skill/skill-installer/scripts/install-skill-from-github.py +0 -313
- package/dist/template/.opencode/skill/skill-installer/scripts/list-skills.py +0 -106
- package/dist/template/.opencode/skill/swarm-coordination/SKILL.md +0 -244
- package/dist/template/.opencode/skill/swarm-coordination/references/architecture.md +0 -39
- package/dist/template/.opencode/skill/swarm-coordination/references/delegation-worker-protocol.md +0 -145
- package/dist/template/.opencode/skill/swarm-coordination/references/dependency-graph.md +0 -50
- package/dist/template/.opencode/skill/swarm-coordination/references/drift-check.md +0 -90
- package/dist/template/.opencode/skill/swarm-coordination/references/integration-beads.md +0 -20
- package/dist/template/.opencode/skill/swarm-coordination/references/launch-flow.md +0 -186
- package/dist/template/.opencode/skill/swarm-coordination/references/reconciler.md +0 -172
- package/dist/template/.opencode/skill/swarm-coordination/references/tier-enforcement.md +0 -78
- package/dist/template/.opencode/skill/swarm-coordination/references/tmux-integration.md +0 -134
- package/dist/template/.opencode/skill/systematic-debugging/SKILL.md +0 -402
- package/dist/template/.opencode/skill/terse-output-mode/SKILL.md +0 -95
- package/dist/template/.opencode/skill/think-in-code/SKILL.md +0 -136
- package/dist/template/.opencode/skill/ux-quality-gates/SKILL.md +0 -137
- package/dist/template/.opencode/skill/v1-run/SKILL.md +0 -175
- package/dist/template/.opencode/skill/v1-run/mcp.json +0 -6
- package/dist/template/.opencode/skill/verification-gates/SKILL.md +0 -63
- package/dist/template/.opencode/skill/visual-analysis/SKILL.md +0 -154
- package/dist/template/.opencode/skill/web-design-guidelines/SKILL.md +0 -46
- package/dist/template/.opencode/skill/workspace-setup/SKILL.md +0 -76
- package/dist/template/.opencode/skill/writing-plans/SKILL.md +0 -320
- /package/dist/template/.opencode/plugin/{lib → memory}/compact.ts +0 -0
- /package/dist/template/.opencode/plugin/{lib → memory}/db/graph.ts +0 -0
- /package/dist/template/.opencode/plugin/{lib → memory}/db/maintenance.ts +0 -0
- /package/dist/template/.opencode/plugin/{lib → memory}/db/pipeline.ts +0 -0
- /package/dist/template/.opencode/plugin/{lib → memory}/notify.ts +0 -0
- /package/dist/template/.opencode/plugin/{lib → memory}/operation-log.ts +0 -0
|
@@ -1,224 +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 srcwalk CLI
|
|
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:
|
|
12
|
-
|
|
13
|
-
- **Main agent**: built-in tools + LSP + srcwalk CLI
|
|
14
|
-
- **Subagents**: Bash + `srcwalk` 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 srcwalk 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
|
-
- srcwalk: `srcwalk impact <symbol>` or `srcwalk callers <symbol>`
|
|
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
|
-
- srcwalk: pass `--scope <dir>` to restrict the scan area
|
|
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
|
-
- srcwalk 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
|
-
## srcwalk CLI
|
|
95
|
-
|
|
96
|
-
`srcwalk` is available to all agents (main agent and subagents) via Bash. It combines grep + tree-sitter AST into one CLI tool.
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
srcwalk guide # Print agent routing policy (run once per session)
|
|
100
|
-
srcwalk find <symbol> # Symbol search (definitions + usages)
|
|
101
|
-
srcwalk <file> # Smart file read (outline for large files)
|
|
102
|
-
srcwalk map # Codebase structural overview
|
|
103
|
-
srcwalk files '<glob>' # Find files by pattern
|
|
104
|
-
srcwalk callers <sym> # Reverse call graph
|
|
105
|
-
srcwalk impact <sym> # Blast-radius heuristic
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### Auto-detection
|
|
109
|
-
|
|
110
|
-
| Query shape | Auto-detected action |
|
|
111
|
-
| --------------------------------- | ------------------------------------ |
|
|
112
|
-
| Existing file path (`src/foo.ts`) | Read file (smart outline/full) |
|
|
113
|
-
| Identifier (`initCommand`) | Symbol search (definitions + usages) |
|
|
114
|
-
| `find <symbol>` | Explicit symbol search |
|
|
115
|
-
| `files <glob>` | File discovery |
|
|
116
|
-
|
|
117
|
-
### Core operations
|
|
118
|
-
|
|
119
|
-
#### 1) Read file
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
srcwalk src/index.ts
|
|
123
|
-
srcwalk src/index.ts --full
|
|
124
|
-
srcwalk src/index.ts --section 45-89
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
#### 2) Search symbols
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
srcwalk find initCommand --scope src/
|
|
131
|
-
srcwalk find "initCommand,detectMode" --scope src/
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
#### 3) Search text/regex
|
|
135
|
-
|
|
136
|
-
```bash
|
|
137
|
-
srcwalk find "TODO" --scope src/
|
|
138
|
-
srcwalk find "/TODO.*fix/" --scope src/
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
#### 4) Find callers
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
srcwalk callers initCommand --scope src/
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
#### 5) List files
|
|
148
|
-
|
|
149
|
-
```bash
|
|
150
|
-
srcwalk files "*.test.ts" --scope src/
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
#### 6) Blast radius
|
|
154
|
-
|
|
155
|
-
```bash
|
|
156
|
-
srcwalk impact initCommand --scope src/
|
|
157
|
-
srcwalk callers initCommand --scope src/
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
#### 7) Codebase map
|
|
161
|
-
|
|
162
|
-
```bash
|
|
163
|
-
srcwalk map --scope src/
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### Useful flags
|
|
167
|
-
|
|
168
|
-
| Flag | Purpose | Example |
|
|
169
|
-
| ----------------------- | --------------------------------------------- | ----------------------------------- |
|
|
170
|
-
| `--scope <dir>` | Restrict scan area | `--scope src/commands/` |
|
|
171
|
-
| `--section <range\|sym>` | Targeted file slice (line range or symbol) | `--section 120-180`, `--section fn` |
|
|
172
|
-
| `--full` | Force full file output (no outline) | `--full` |
|
|
173
|
-
| `--budget <n>` | Limit output token size | `--budget 2000` |
|
|
174
|
-
| `--json` | Machine-readable output | `--json` |
|
|
175
|
-
| `--filter <qualifiers>` | Filter find results by field:value | `--filter kind:fn` |
|
|
176
|
-
| `--glob <pattern>` | File pattern filter within find | `--glob "*.ts"` |
|
|
177
|
-
| `--expand[=<n>]` | Inline source for top N matches | `--expand 3` |
|
|
178
|
-
| `--depth <n>` | Depth for callers/callees traversal | `--depth 2` |
|
|
179
|
-
|
|
180
|
-
### Example subagent dispatch
|
|
181
|
-
|
|
182
|
-
```ts
|
|
183
|
-
task({
|
|
184
|
-
subagent_type: "general",
|
|
185
|
-
prompt: `Use srcwalk via Bash for navigation.
|
|
186
|
-
|
|
187
|
-
1) Locate symbol and usages:
|
|
188
|
-
srcwalk find initCommand --scope src/
|
|
189
|
-
|
|
190
|
-
2) Find callers:
|
|
191
|
-
srcwalk callers initCommand --scope src/
|
|
192
|
-
|
|
193
|
-
3) Check blast radius before edits:
|
|
194
|
-
srcwalk impact initCommand --scope src/
|
|
195
|
-
|
|
196
|
-
4) Read only the relevant section:
|
|
197
|
-
srcwalk src/commands/init.ts --section 500-620
|
|
198
|
-
|
|
199
|
-
Then implement the requested change with minimal file edits.`,
|
|
200
|
-
});
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
## Cost Awareness
|
|
204
|
-
|
|
205
|
-
Navigation cost compounds quickly. Optimize for fewer, richer calls.
|
|
206
|
-
|
|
207
|
-
- Prefer one structural search over multiple blind reads
|
|
208
|
-
- Reuse search output; avoid duplicate reads of the same symbol body
|
|
209
|
-
- Scope aggressively (`path`, `scope`) to cut noise
|
|
210
|
-
- Use section reads for large files instead of full-file pulls
|
|
211
|
-
|
|
212
|
-
Target heuristic: understand a symbol and its direct impact in **≤3 calls** whenever possible.
|
|
213
|
-
|
|
214
|
-
## Common Mistakes
|
|
215
|
-
|
|
216
|
-
| Mistake | Better pattern |
|
|
217
|
-
| ------------------------------------------------ | ------------------------------------------------------------------- |
|
|
218
|
-
| Reading big files before locating symbol | Search first, then section read |
|
|
219
|
-
| Re-reading code already shown in search output | Work from returned snippet; re-read only if needed for edit anchors |
|
|
220
|
-
| Serially tracing one function at a time | Multi-symbol search + callers/deps |
|
|
221
|
-
| Ignoring blast radius before API/signature edits | Run references/incoming/deps first |
|
|
222
|
-
| Unscoped repository-wide search | Use `path`/`--scope` to localize |
|
|
223
|
-
| Using CLI defaults when mode is ambiguous | Use explicit subcommand (`find`, `files`, `callers`) or `--filter kind:<label>` |
|
|
224
|
-
| 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
|
-
```bash
|
|
25
|
-
srcwalk files "*.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
|
-
```bash
|
|
66
|
-
srcwalk files "*.md" --scope .opencode/memory/project
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Report created files with their injection status (auto-injected vs on-demand).
|