octocode-cli 1.2.9 → 1.2.10
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/README.md +10 -10
- package/out/octocode-cli.js +74 -33
- package/package.json +7 -8
- package/skills/octocode-engineer/SKILL.md +404 -490
|
@@ -1,499 +1,413 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: octocode-engineer
|
|
3
|
-
description: "
|
|
3
|
+
description: "System-aware engineering skill for code understanding, safe implementation, refactoring, architecture review, and quality analysis. Use this before planning and for general task support when an agent must start with local Octocode tools, use AST search/tree-search to prove structure, and combine those checks with LSP and scanner results to understand structure, flows, blast radius, contracts, documentation gaps, and architectural risk instead of looking only at one file. Aims to improve any system, and is especially effective for Node-based applications."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Octocode
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
-
|
|
146
|
-
-
|
|
147
|
-
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
|
197
|
-
|
|
198
|
-
|
|
|
199
|
-
|
|
|
200
|
-
|
|
|
201
|
-
|
|
|
202
|
-
|
|
|
203
|
-
|
|
|
204
|
-
|
|
|
205
|
-
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
-
|
|
224
|
-
-
|
|
225
|
-
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
1.
|
|
272
|
-
2.
|
|
273
|
-
3.
|
|
274
|
-
4. Check
|
|
275
|
-
5.
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
|
295
|
-
|
|
296
|
-
|
|
|
297
|
-
|
|
|
298
|
-
| Who uses
|
|
299
|
-
|
|
|
300
|
-
|
|
|
301
|
-
|
|
|
302
|
-
|
|
|
303
|
-
|
|
|
304
|
-
|
|
|
305
|
-
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
|
351
|
-
|
|
352
|
-
|
|
|
353
|
-
|
|
|
354
|
-
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
### External tools — ask user before running
|
|
361
|
-
|
|
362
|
-
`npx` only. Scanner already covers duplicates, unused deps, dead exports — no external tool needed for those.
|
|
363
|
-
|
|
364
|
-
| Tool | When | Command |
|
|
365
|
-
|------|------|---------|
|
|
366
|
-
| eslint | Lint & auto-fix | `npx eslint --fix <path>` |
|
|
367
|
-
| tsc | Type check | `npx tsc --noEmit` |
|
|
368
|
-
| stylelint | CSS/SCSS | `npx stylelint "**/*.css"` |
|
|
369
|
-
| knip | Framework-aware dead code | `npx knip --exports` |
|
|
370
|
-
| type-coverage | Type safety % | `npx type-coverage --strict --detail` |
|
|
371
|
-
| dep-cruiser | Custom arch rules | `npx depcruise --no-config -T err <path>` |
|
|
372
|
-
|
|
373
|
-
Details: [external tools](./references/externals.md).
|
|
374
|
-
|
|
375
|
-
### Architecture interpretation signals
|
|
376
|
-
|
|
377
|
-
When raw architecture findings are noisy, use these structural signals to prioritize:
|
|
378
|
-
|
|
379
|
-
| Signal | What it means | Action |
|
|
380
|
-
|--------|--------------|--------|
|
|
381
|
-
| **SCC cluster** | Overlapping dependency cycles forming a strongly connected component | Treat entire cluster as one refactor unit — breaking one edge may not help |
|
|
382
|
-
| **Broker/chokepoint** | High fan-in + high fan-out — dependency pressure node | Decompose by splitting read vs write consumers, or extract interface |
|
|
383
|
-
| **Bridge module** | Articulation-style file connecting two subsystems | Fragile — breaking it disconnects the graph. Stabilize or duplicate at boundary |
|
|
384
|
-
| **Package chatter** | Excessive cross-package imports | Boundary erosion — consolidate shared types or redraw package lines |
|
|
385
|
-
|
|
386
|
-
Prioritize fixes where **hotspots and critical paths overlap** — those are the highest-leverage changes.
|
|
387
|
-
|
|
388
|
-
### Metrics reference
|
|
389
|
-
|
|
390
|
-
| Metric | Formula / Scale | What it means | Threshold signal |
|
|
391
|
-
|--------|----------------|---------------|------------------|
|
|
392
|
-
| Instability | `I = Ce / (Ca + Ce)` | How change-prone vs depended-on (0 = stable, 1 = unstable) | Stable module depending on unstable one = SDP violation |
|
|
393
|
-
| Cognitive complexity | Incremental per branch/nesting | Mental load to understand a function | >15 = decomposition candidate |
|
|
394
|
-
| Maintainability index | 0-100 composite (volume, complexity, LOC) | Overall maintainability score | <20 = high-risk |
|
|
395
|
-
| Halstead effort | Operators × operands formula | Estimated comprehension effort | Very high = split or refactor |
|
|
396
|
-
| Fan-in | Count of incoming dependencies | How many modules depend on this | >20 = god module risk |
|
|
397
|
-
| Fan-out | Count of outgoing dependencies | How many modules this depends on | >15 = coupling risk |
|
|
398
|
-
|
|
399
|
-
Use thresholds as heuristics, not absolute truth. Context matters — a config module with fan-in=45 may be fine if it's read-only.
|
|
400
|
-
|
|
401
|
-
### Working with scanner output
|
|
402
|
-
|
|
403
|
-
Read scan results in this order:
|
|
404
|
-
1. `summary.md` → health scores, severity breakdown, top recommendations
|
|
405
|
-
2. `summary.json` → `featureScores[]`, `investigationPrompts[]`, `recommendedValidation`
|
|
406
|
-
3. `findings.json` → per-finding detail with `evidence.location`, `correlatedSignals[]`, `lspHints[]`
|
|
407
|
-
4. Pillar files as needed
|
|
408
|
-
|
|
409
|
-
Per finding, use:
|
|
410
|
-
- `recommendedValidation.tools[]` → which tools to run for confirmation
|
|
411
|
-
- `evidence.location` → exact `file:line` to inspect
|
|
412
|
-
- `correlatedSignals[]` → related findings to check together
|
|
413
|
-
- `suggestedFix.strategy` + `suggestedFix.steps` → actionable fix path
|
|
414
|
-
|
|
415
|
-
Follow `investigationPrompts[]` from `summary.json` — ready-made next steps.
|
|
416
|
-
|
|
417
|
-
**Scoring model** — the scanner produces two complementary scores:
|
|
418
|
-
|
|
419
|
-
*Feature scores* (`featureScores[]`): per-category scores using severity weights (`critical=25, high=10, medium=3, low=1`). Formula: `100 / (1 + (weightedFindingsPerFile / 10))`. Guardrails: critical findings cap at 95, high at 98. Hotspot overlap applies context penalties.
|
|
420
|
-
|
|
421
|
-
*Quality rating* (`qualityRating`): hybrid AI + structural rating across 6 weighted aspects:
|
|
422
|
-
- Architecture & Structure (30%) — dependency health, modularity, coupling
|
|
423
|
-
- Folder Topology (15%) — directory depth, naming coherence, layout clarity
|
|
424
|
-
- Naming Quality (15%) — consistent conventions, descriptive identifiers
|
|
425
|
-
- Common/Shared Layer Health (15%) — utility modules, shared abstractions
|
|
426
|
-
- Maintainability & Evolvability (15%) — change readiness, encapsulation
|
|
427
|
-
- Codebase Consistency (10%) — uniform patterns across modules
|
|
428
|
-
|
|
429
|
-
Use `featureScores[]` to rank worst categories. Use `qualityRating.aspects[]` for soft-signal scoring.
|
|
430
|
-
|
|
431
|
-
**Finding correlation patterns** — findings that appear together often signal deeper issues:
|
|
432
|
-
|
|
433
|
-
| Combination | Likely root cause |
|
|
434
|
-
|-------------|-------------------|
|
|
435
|
-
| `feature-envy` + `low-cohesion` | Boundary error — logic in the wrong module |
|
|
436
|
-
| `layer-violation` + `feature-envy` | Dependency leak across architecture layers |
|
|
437
|
-
| `import-side-effect-risk` + hotspot tags | Startup risk — initialization on import |
|
|
438
|
-
| `dependency-critical-path` + complexity tags | Change chokepoint — high-risk modification path |
|
|
439
|
-
|
|
440
|
-
**File inventory deep fields** (`file-inventory.json`) — per-file AST lens for targeted investigation:
|
|
441
|
-
- `functions[]` — shape, complexity, span per function
|
|
442
|
-
- `flows[]` — repeated control-flow structures
|
|
443
|
-
- `dependencyProfile` — exports, imports, re-exports, internal/external deps
|
|
444
|
-
- `topLevelEffects[]` — hidden initialization / import-time side effects
|
|
445
|
-
- `effectProfile` — summarized import-time risk
|
|
446
|
-
- `symbolUsageSummary` — compact import/export shape for boundary follow-up
|
|
447
|
-
- `boundaryRoleHints[]` — lightweight role inference (entrypoint, utility, config, etc.)
|
|
448
|
-
- `cfgFlags` — flow clues for validation, cleanup, exit behavior, async boundaries (with `--flow`)
|
|
449
|
-
|
|
450
|
-
If `architecture.json` names a hotspot, use `file-inventory.json` to explain *why* it's structurally hard to change.
|
|
451
|
-
|
|
452
|
-
## Task Sizing & Planning
|
|
453
|
-
|
|
454
|
-
| Size | Scope | Approach |
|
|
455
|
-
|------|-------|----------|
|
|
456
|
-
| S | Single-file, low-risk | Investigate → implement → verify (lint + tests) |
|
|
457
|
-
| M | Multi-file with consumers | Multi-angle investigation → present plan → implement → verify (lint + tests + build) |
|
|
458
|
-
| L | Cross-cutting / architectural | Full investigation → present improvement plan → implement → verify (lint + tests + build + re-scan) |
|
|
459
|
-
|
|
460
|
-
Upgrade to L if: fan-in >20, cycle/hotspot involvement, or unclear contract risk.
|
|
461
|
-
|
|
462
|
-
**M/L improvement plan** — per item:
|
|
463
|
-
- **Target**: file:symbol
|
|
464
|
-
- **Issue**: what's wrong + evidence (tool + file:line)
|
|
465
|
-
- **Impact**: consumer count, severity
|
|
466
|
-
- **Fix**: strategy + steps
|
|
467
|
-
- **Test**: what to add/update
|
|
468
|
-
- **Risk**: low/medium/high + mitigation
|
|
469
|
-
- **Order**: dependency-aware (foundations first)
|
|
470
|
-
|
|
471
|
-
Present plan to user. Ask before proceeding.
|
|
6
|
+
# Octocode Engineer
|
|
7
|
+
|
|
8
|
+
This skill helps an agent investigate, change, and verify a codebase with system awareness.
|
|
9
|
+
|
|
10
|
+
Use this skill before writing a plan. First build system understanding, then switch to plan mode once structure, flows, blast radius, and architectural risks are clear.
|
|
11
|
+
Use it as an organizer for agents: pick the right lens, choose the right tools, understand the system, then move into planning or implementation.
|
|
12
|
+
Use it with a senior-architect review posture: check whether the system is clear, modular, extensible, efficient, documented, and safe to evolve.
|
|
13
|
+
Start with local Octocode tools whenever they are available. Use AST to check and prove structural claims instead of trusting text search alone.
|
|
14
|
+
|
|
15
|
+
Most agents naturally zoom into the file in front of them. This skill pushes the opposite direction first:
|
|
16
|
+
- start with local Octocode discovery before deep reading
|
|
17
|
+
- use AST to check structural patterns and confirm smells
|
|
18
|
+
- understand the structure before editing the line
|
|
19
|
+
- trace flows before changing behavior
|
|
20
|
+
- check architecture before trusting a local fix
|
|
21
|
+
- validate important claims from more than one angle
|
|
22
|
+
|
|
23
|
+
## What This Skill Does
|
|
24
|
+
|
|
25
|
+
Use this skill to:
|
|
26
|
+
- help with almost any engineering task, especially before planning, by organizing investigation and decision-making
|
|
27
|
+
- understand how a feature, bug, or module really works
|
|
28
|
+
- trace definitions, callers, callees, imports, and shared contracts
|
|
29
|
+
- find architectural issues such as cycles, chokepoints, coupling, hotspots, and layer violations
|
|
30
|
+
- validate structural code smells with AST tools instead of weak text guesses
|
|
31
|
+
- push toward clean code, clean modular architecture, strong contracts, and low duplication
|
|
32
|
+
- check efficiency problems such as avoidable `O(n^2)` work, repeated scans, repeated queries, and wasteful flows
|
|
33
|
+
- flag rigid, naive, brittle, or clearly unnecessary code paths before they spread
|
|
34
|
+
- prevent patchy fixes that work locally but make the system harder to extend later
|
|
35
|
+
- improve both delivery velocity and long-term quality through smarter flows and better structure
|
|
36
|
+
- plan safer refactors with blast-radius awareness
|
|
37
|
+
- check that important critical aspects are documented when behavior, contracts, architecture, or operations depend on them
|
|
38
|
+
- verify that a change did not create new code-quality, architecture, or test-quality problems
|
|
39
|
+
|
|
40
|
+
This is not only a code-editing skill.
|
|
41
|
+
It is a structure, architecture, and flow-analysis skill that also supports coding.
|
|
42
|
+
It aims to make systems easier to extend, safer to evolve, and smarter to work in over time.
|
|
43
|
+
It applies to any system, but is especially effective for Node and TypeScript applications where module boundaries, async flows, contracts, package dependencies, and runtime edges must stay clean.
|
|
44
|
+
|
|
45
|
+
## When To Use It
|
|
46
|
+
|
|
47
|
+
Use this skill when the user asks to:
|
|
48
|
+
- help with almost any code or architecture task that benefits from better system understanding first
|
|
49
|
+
- understand code before changing it
|
|
50
|
+
- fix a bug in shared or unclear code
|
|
51
|
+
- refactor a module, package, or cross-file flow
|
|
52
|
+
- review code quality, architecture, or technical debt
|
|
53
|
+
- improve maintainability, modularity, contracts, or extensibility
|
|
54
|
+
- validate docs, plans, or RFCs against the real implementation
|
|
55
|
+
- check dead code, test gaps, security risks, or design problems
|
|
56
|
+
- implement a change safely in a non-trivial area
|
|
57
|
+
- prepare for planning by understanding the real system before switching to plan mode
|
|
58
|
+
|
|
59
|
+
## Core Mindset
|
|
60
|
+
|
|
61
|
+
1. System first, file second.
|
|
62
|
+
2. Root causes often live in boundaries, flows, ownership, coupling, or missing tests, not just in the visible line of code.
|
|
63
|
+
3. Important findings should be validated with at least 2 approaches when possible.
|
|
64
|
+
4. Prefer local Octocode tools first for discovery, scope, and evidence.
|
|
65
|
+
5. Use AST to check structural claims whenever text search may be misleading.
|
|
66
|
+
6. Report confidence clearly: `confirmed`, `likely`, or `uncertain`.
|
|
67
|
+
7. Prefer clean, modular, contract-driven solutions over local patches.
|
|
68
|
+
8. For medium or large changes, understand blast radius and architecture before editing.
|
|
69
|
+
9. Track meaningful work with tasks or todos when the runtime supports it.
|
|
70
|
+
10. Ask the user at the right checkpoint when scope, risk, or tradeoffs are genuinely unclear.
|
|
71
|
+
|
|
72
|
+
## The Main Problem This Skill Solves
|
|
73
|
+
|
|
74
|
+
A local code read is often not enough.
|
|
75
|
+
A function may look wrong, but the real issue may be:
|
|
76
|
+
- too many callers
|
|
77
|
+
- circular dependencies
|
|
78
|
+
- a shared module doing too much
|
|
79
|
+
- a weak boundary between layers
|
|
80
|
+
- weak or implicit contracts between modules, APIs, or types
|
|
81
|
+
- inefficient loops, repeated work, or avoidable `O(n^2)` logic
|
|
82
|
+
- rigid or brittle code that is hard to extend without patching around it
|
|
83
|
+
- duplicate logic spread across packages
|
|
84
|
+
- a hidden flow through re-exports, side effects, or orchestration code
|
|
85
|
+
- poor tests around a high-risk path
|
|
86
|
+
- a quick patch that solves today but blocks safe extension tomorrow
|
|
87
|
+
|
|
88
|
+
Because of that, always look at:
|
|
89
|
+
- structure: where code lives and how modules are grouped
|
|
90
|
+
- architecture: dependencies, boundaries, cycles, hotspots, and ownership
|
|
91
|
+
- contracts: TypeScript types, interfaces, DTOs, schemas, and public module boundaries
|
|
92
|
+
- flows: entry points, call chains, data movement, and side effects
|
|
93
|
+
- quality: clean code, low duplication, CSS hygiene, and maintainable module responsibilities
|
|
94
|
+
- efficiency: algorithmic complexity, repeated work, repeated queries, N+1 patterns, and unnecessary orchestration
|
|
95
|
+
- rigidity: brittle logic, over-coupled decisions, and code that is harder than necessary to extend
|
|
96
|
+
- docs: whether critical setup, contracts, flows, constraints, migrations, and caveats are documented
|
|
97
|
+
- code: the actual implementation details
|
|
98
|
+
|
|
99
|
+
The target is not just "working code".
|
|
100
|
+
The target is a system that stays extendable, understandable, and fast to change.
|
|
101
|
+
|
|
102
|
+
## Investigation Lenses
|
|
103
|
+
|
|
104
|
+
| Lens | Main question | Best tools |
|
|
105
|
+
|------|---------------|------------|
|
|
106
|
+
| Layout | Where does this behavior live? | `localViewStructure`, `localFindFiles`, `localSearchCode` |
|
|
107
|
+
| Semantics | What symbol is this and who uses it? | `localSearchCode` -> LSP tools |
|
|
108
|
+
| Persistence | How is state stored and mutated? | schema files, SQL/Prisma/Mongoose definitions, migration files, repository/storage modules |
|
|
109
|
+
| Efficiency | Is the implementation doing avoidable work or unnecessary complexity? | scanner complexity findings, code read, query/storage access paths, tests/benchmarks when available |
|
|
110
|
+
| Docs | Are critical behaviors, contracts, flows, and operational constraints documented? | docs/readmes, API docs, config docs, migration notes, code comments near boundaries |
|
|
111
|
+
| Structure | Does this pattern really exist? | `scripts/ast/search.js`, `scripts/ast/tree-search.js` |
|
|
112
|
+
| Architecture | Is this area hard or risky to change? | `scripts/run.js`, graph and flow modes |
|
|
113
|
+
| Behavior | What does the code actually do? | `localGetFileContent`, tests |
|
|
114
|
+
|
|
115
|
+
## Tool Families And Their Jobs
|
|
116
|
+
|
|
117
|
+
### 1. Local Octocode tools
|
|
118
|
+
|
|
119
|
+
Use local tools first to map the workspace.
|
|
120
|
+
These are the default first tools for this skill, not a fallback.
|
|
121
|
+
|
|
122
|
+
| Tool | Use it for |
|
|
123
|
+
|------|------------|
|
|
124
|
+
| `localViewStructure` | Package/module layout, folder depth, source spread |
|
|
125
|
+
| `localFindFiles` | Large files, recent churn, suspicious filenames, likely hotspots |
|
|
126
|
+
| `localSearchCode` | Fast discovery, symbol search, text patterns, and `lineHint` for LSP |
|
|
127
|
+
| `localGetFileContent` | Final code reading after you know what you are looking at |
|
|
128
|
+
|
|
129
|
+
Rule: do not start with a random full-file read if discovery tools can narrow the target first.
|
|
130
|
+
|
|
131
|
+
### 2. LSP tools
|
|
132
|
+
|
|
133
|
+
Use LSP tools to understand real semantic relationships.
|
|
134
|
+
|
|
135
|
+
Critical rule: every LSP tool needs `lineHint` from `localSearchCode`.
|
|
136
|
+
Never guess it.
|
|
137
|
+
|
|
138
|
+
| Tool | Use it for |
|
|
139
|
+
|------|------------|
|
|
140
|
+
| `lspGotoDefinition` | What symbol is this really? |
|
|
141
|
+
| `lspFindReferences` | Blast radius, all usages, dead-code checks |
|
|
142
|
+
| `lspCallHierarchy` | Function call flow only: incoming callers and outgoing callees |
|
|
143
|
+
|
|
144
|
+
LSP is the main way to answer:
|
|
145
|
+
- who depends on this?
|
|
146
|
+
- what will break if we change it?
|
|
147
|
+
- what path does execution follow?
|
|
148
|
+
|
|
149
|
+
### 3. AST tools
|
|
150
|
+
|
|
151
|
+
Use AST tools when text search is too weak and you need structural proof.
|
|
152
|
+
AST is a primary checking tool in this skill, especially for validating smells, redundancy, and code-shape claims.
|
|
153
|
+
|
|
154
|
+
| Tool | Use it for |
|
|
155
|
+
|------|------------|
|
|
156
|
+
| `scripts/ast/search.js` | Live source analysis and structural pattern matching |
|
|
157
|
+
| `scripts/ast/tree-search.js` | Fast triage over cached AST trees from a previous scan |
|
|
158
|
+
|
|
159
|
+
Use AST tools for things like:
|
|
160
|
+
- empty catch blocks
|
|
161
|
+
- `any` usage
|
|
162
|
+
- nested ternaries
|
|
163
|
+
- broad exports
|
|
164
|
+
- repeated structural patterns
|
|
165
|
+
- verifying whether a smell is real or just a text coincidence
|
|
166
|
+
|
|
167
|
+
Rule: `tree-search.js` is for fast narrowing. `search.js` is the authoritative proof on live code.
|
|
168
|
+
Rule: if a structural claim matters, check it with AST before presenting it as fact.
|
|
169
|
+
|
|
170
|
+
### 4. Scanner
|
|
171
|
+
|
|
172
|
+
Use `scripts/run.js` when the question is bigger than one symbol or one file.
|
|
173
|
+
|
|
174
|
+
The scanner is especially important for this skill because it surfaces the issues agents often miss when they focus too narrowly on code:
|
|
175
|
+
- dependency cycles
|
|
176
|
+
- chokepoints and broker modules
|
|
177
|
+
- coupling and fan-in/fan-out pressure
|
|
178
|
+
- layer violations
|
|
179
|
+
- dead code clusters
|
|
180
|
+
- security sinks and risky flows
|
|
181
|
+
- test-quality gaps
|
|
182
|
+
- hotspots and critical paths
|
|
183
|
+
|
|
184
|
+
Use scanner output to reason about:
|
|
185
|
+
- where change risk is concentrated
|
|
186
|
+
- whether a module is structurally unhealthy
|
|
187
|
+
- whether a local fix ignores a broader architectural problem
|
|
188
|
+
- which area should be refactored first
|
|
189
|
+
- where duplication, weak contracts, or poor boundaries are slowing future velocity
|
|
190
|
+
- where complexity, repeated work, or inefficient flows are wasting performance or developer time
|
|
191
|
+
|
|
192
|
+
### 5. Quality and hygiene checks
|
|
193
|
+
|
|
194
|
+
Use supporting quality checks when the task touches the relevant surface area.
|
|
195
|
+
|
|
196
|
+
| Check | Use it for |
|
|
197
|
+
|------|------------|
|
|
198
|
+
| clean code review | naming, cohesion, responsibility split, readability |
|
|
199
|
+
| contract review | TypeScript types, interfaces, DTOs, schemas, return shapes |
|
|
200
|
+
| duplication review | repeated logic, near-clones, copy-pasted flows, repeated CSS patterns, general redundancy |
|
|
201
|
+
| efficiency review | avoidable `O(n^2)` work, repeated scans, N+1 calls, wasteful transforms, unnecessary recomputation |
|
|
202
|
+
| rigidity review | brittle condition trees, hard-coded branching, patchy glue code, over-coupled modules, naive solutions |
|
|
203
|
+
| docs review | whether critical assumptions, contracts, flows, setup, migrations, and risks are documented where they should be |
|
|
204
|
+
| clean CSS review | selector scope, token reuse, naming clarity, dead styles, layout consistency |
|
|
205
|
+
| `knip` | unused exports, unused files, unused dependencies, dead integration edges |
|
|
206
|
+
|
|
207
|
+
These checks matter because quality and velocity support each other.
|
|
208
|
+
Messy structure slows teams down. Clear structure speeds them up.
|
|
209
|
+
|
|
210
|
+
### 6. Task and user checkpoints
|
|
211
|
+
|
|
212
|
+
Use task or todo tracking when the work has multiple steps, risks, or follow-ups.
|
|
213
|
+
Track at least:
|
|
214
|
+
- investigation
|
|
215
|
+
- decision or plan
|
|
216
|
+
- implementation
|
|
217
|
+
- verification
|
|
218
|
+
- docs follow-up when needed
|
|
219
|
+
|
|
220
|
+
Ask the user when needed at a real checkpoint, especially if:
|
|
221
|
+
- requirements are ambiguous
|
|
222
|
+
- multiple reasonable architectures exist
|
|
223
|
+
- a public contract or persistence model may change
|
|
224
|
+
- the safest fix conflicts with the smallest fix
|
|
225
|
+
- the work may have migration, rollout, or compatibility impact
|
|
226
|
+
|
|
227
|
+
When asking, be concise and specific. Ask only what is needed to move forward safely.
|
|
228
|
+
|
|
229
|
+
## Default Working Order
|
|
230
|
+
|
|
231
|
+
For any non-trivial task, follow this order:
|
|
232
|
+
|
|
233
|
+
1. Clarify the behavior or question.
|
|
234
|
+
2. Create or update tasks/todos if the work is multi-step.
|
|
235
|
+
3. Map the package/module area with local tools.
|
|
236
|
+
4. Trace important symbols with LSP.
|
|
237
|
+
5. Validate and check structural claims with AST tools.
|
|
238
|
+
6. Check architecture, docs, and flow risk with the scanner and relevant docs.
|
|
239
|
+
7. Read the actual code with context.
|
|
240
|
+
8. Pause and ask the user if a real decision checkpoint appears.
|
|
241
|
+
9. Only then decide whether to explain, plan, or edit.
|
|
242
|
+
|
|
243
|
+
Short form:
|
|
244
|
+
`clarify -> track -> layout -> symbols -> structure -> architecture/docs -> code -> checkpoint -> action`
|
|
245
|
+
|
|
246
|
+
## How To Use This Skill
|
|
247
|
+
|
|
248
|
+
### For code understanding
|
|
249
|
+
|
|
250
|
+
1. Start with `localViewStructure` or `localFindFiles` to see the area.
|
|
251
|
+
2. Use `localSearchCode` to find the symbol or flow.
|
|
252
|
+
3. Use LSP to trace definitions, references, callers, and callees.
|
|
253
|
+
4. Read the relevant code only after the surrounding context is clear.
|
|
254
|
+
5. Check whether important contracts or critical flows are documented.
|
|
255
|
+
6. If the area is shared, central, or suspicious, run a scoped scanner pass.
|
|
256
|
+
|
|
257
|
+
### For bug fixing
|
|
258
|
+
|
|
259
|
+
1. Identify the failing behavior and likely entry point.
|
|
260
|
+
2. Trace incoming callers and outgoing callees.
|
|
261
|
+
3. Check adjacent risk areas: error handling, retries, side effects, tests, shared consumers, and contract mismatches.
|
|
262
|
+
4. Use AST tools if the bug may involve a structural smell.
|
|
263
|
+
5. Use the scanner if the bug points to a hotspot, cycle, or orchestration problem.
|
|
264
|
+
6. Fix the smallest layer that solves the root cause, not just the symptom.
|
|
265
|
+
7. Prefer a clean boundary or contract fix over a narrow patch if the issue is systemic.
|
|
266
|
+
8. Check whether the bug is caused by redundant work, inefficient flow, or rigid branching.
|
|
267
|
+
9. Check whether the risky behavior and fix assumptions should be documented.
|
|
268
|
+
|
|
269
|
+
### For refactors
|
|
270
|
+
|
|
271
|
+
1. Measure blast radius with `lspFindReferences` and `lspCallHierarchy`.
|
|
272
|
+
2. Check architecture health in the target area with `scripts/run.js --scope=...`.
|
|
273
|
+
3. Look for similar patterns nearby with AST or local search.
|
|
274
|
+
4. Check whether duplication, weak contracts, or bad boundaries are the real refactor driver.
|
|
275
|
+
5. Plan the change if multiple files, packages, or shared symbols are involved.
|
|
276
|
+
6. Prefer extracting modules, clarifying contracts, simplifying flows, and removing redundant work over cosmetic reshuffling.
|
|
277
|
+
7. Implement incrementally.
|
|
278
|
+
8. Re-run verification after each batch.
|
|
279
|
+
9. Update or propose docs when the refactor changes important usage, contracts, or constraints.
|
|
280
|
+
|
|
281
|
+
### For architecture review
|
|
282
|
+
|
|
283
|
+
1. Start broad with the scanner, especially graph and flow output.
|
|
284
|
+
2. Identify hotspots, cycles, chokepoints, and suspicious shared modules.
|
|
285
|
+
3. Use local tools to understand the folder and package layout.
|
|
286
|
+
4. Use LSP to verify the real dependency pressure around candidate modules.
|
|
287
|
+
5. Read representative files to explain why the structure is problematic.
|
|
288
|
+
6. Check whether contracts, duplication, and module boundaries support extensibility.
|
|
289
|
+
7. Check whether critical architectural constraints are documented.
|
|
290
|
+
8. Report both local code issues and system-level causes.
|
|
291
|
+
|
|
292
|
+
## Recommended Tool Combos
|
|
293
|
+
|
|
294
|
+
| Question | Recommended approach |
|
|
295
|
+
|----------|----------------------|
|
|
296
|
+
| Where should I start? | `localViewStructure` + `localFindFiles` |
|
|
297
|
+
| What is this symbol? | `localSearchCode` -> `lspGotoDefinition` |
|
|
298
|
+
| Who uses this shared function/type/export? | `localSearchCode` -> `lspFindReferences` |
|
|
299
|
+
| What is the runtime path? | `localSearchCode` -> `lspCallHierarchy` |
|
|
300
|
+
| Is this smell real? | AST search + targeted code read |
|
|
301
|
+
| Can I prove this structural claim? | AST search/tree-search + targeted code read |
|
|
302
|
+
| Are contracts weak or inconsistent? | LSP on public symbols + code read + scanner/AST signals |
|
|
303
|
+
| Is this implementation inefficient? | scanner complexity signals + code read + persistence/query path review |
|
|
304
|
+
| Is this dead code? | `lspFindReferences` + AST import/export check + scanner dead-code signals |
|
|
305
|
+
| Is this module risky to change? | scanner scope + LSP references/call flow + code read |
|
|
306
|
+
| Is the problem architectural? | scanner graph/flow + local structure + LSP on chokepoints |
|
|
307
|
+
| Are important critical aspects documented? | docs/readmes + code boundaries + config/schema/migration docs |
|
|
308
|
+
| Is the codebase losing velocity? | scanner hotspots + duplication/redundancy checks + boundary/contract review |
|
|
309
|
+
| Did the fix actually improve things? | tests + lint/build + scoped scanner + targeted LSP re-check |
|
|
310
|
+
|
|
311
|
+
## Before / During / After A Change
|
|
312
|
+
|
|
313
|
+
### Before
|
|
314
|
+
- understand current behavior and invariants
|
|
315
|
+
- find consumers and callers
|
|
316
|
+
- inspect tests around the changed path
|
|
317
|
+
- check whether the area is a hotspot, cycle member, or shared boundary
|
|
318
|
+
- check contracts: types, inputs, outputs, schemas, and public APIs
|
|
319
|
+
- check whether critical behavior and constraints are documented
|
|
320
|
+
- check for duplication before adding another branch or helper
|
|
321
|
+
- check for unnecessary complexity or repeated work before accepting the current shape
|
|
322
|
+
- look for an existing local pattern before inventing a new one
|
|
323
|
+
|
|
324
|
+
### During
|
|
325
|
+
- keep edits focused
|
|
326
|
+
- preserve boundaries unless the plan intentionally changes them
|
|
327
|
+
- prefer the smallest change that fixes the real issue
|
|
328
|
+
- prefer the cleanest modular fix that keeps the system extendable
|
|
329
|
+
- maintain clear contracts, especially in TypeScript-heavy code
|
|
330
|
+
- reduce redundancy and avoid layering new logic on top of rigid or naive code when a cleaner simplification is possible
|
|
331
|
+
- improve inefficient flows when they are part of the real problem
|
|
332
|
+
- keep CSS clean and scoped if the task touches frontend styling
|
|
333
|
+
- update or flag docs when critical behavior, contracts, setup, migration, or architecture understanding changed
|
|
334
|
+
- if the root cause is structural, say so instead of hiding it behind a cosmetic patch
|
|
335
|
+
|
|
336
|
+
### After
|
|
337
|
+
- run the relevant tests
|
|
338
|
+
- run lint and build or type-check as appropriate
|
|
339
|
+
- run CSS checks when styles changed
|
|
340
|
+
- run `knip` when refactors may have left dead exports, files, or deps behind
|
|
341
|
+
- re-check changed symbols with LSP after renames or moves
|
|
342
|
+
- run a scoped scanner pass for non-trivial changes
|
|
343
|
+
- verify important critical aspects are documented if the task changed them
|
|
344
|
+
- mention any remaining architectural risk even if the code now works
|
|
345
|
+
|
|
346
|
+
## Confidence Rules
|
|
347
|
+
|
|
348
|
+
Use these confidence levels in your reasoning and user-facing output:
|
|
349
|
+
|
|
350
|
+
| Level | Meaning |
|
|
351
|
+
|-------|---------|
|
|
352
|
+
| `confirmed` | 2 or more approaches agree, or one source is clearly authoritative |
|
|
353
|
+
| `likely` | good evidence exists, but one important angle is still missing |
|
|
354
|
+
| `uncertain` | signals conflict, context is incomplete, or only one weak source exists |
|
|
355
|
+
|
|
356
|
+
Examples:
|
|
357
|
+
- `confirmed`: AST proves an empty catch, and LSP shows the function is widely used
|
|
358
|
+
- `likely`: scanner reports a hotspot and code shape agrees, but blast radius is still unverified
|
|
359
|
+
- `uncertain`: text search suggests dead code, but LSP is unavailable
|
|
472
360
|
|
|
473
361
|
## Hard Rules
|
|
474
362
|
|
|
475
|
-
- Never present
|
|
476
|
-
- Never guess `lineHint
|
|
477
|
-
- Never use `lspCallHierarchy` on non-function symbols
|
|
478
|
-
- Never
|
|
479
|
-
- Never
|
|
480
|
-
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
363
|
+
- Never present raw detector output as unquestioned fact.
|
|
364
|
+
- Never guess `lineHint`; get it from `localSearchCode`.
|
|
365
|
+
- Never use `lspCallHierarchy` on non-function symbols.
|
|
366
|
+
- Never judge a shared module by one file read alone.
|
|
367
|
+
- Never skip local Octocode discovery when those tools are available.
|
|
368
|
+
- Never present an important structural claim without checking it with AST when AST can prove it.
|
|
369
|
+
- Never stop at code style if the deeper issue is structure or flow.
|
|
370
|
+
- Never prefer a quick patch when the real issue is contracts, boundaries, duplication, or architecture.
|
|
371
|
+
- Never ignore obvious inefficiency, redundancy, or rigid code if it materially hurts extensibility or clarity.
|
|
372
|
+
- Never add new duplication if an existing abstraction or module should be improved instead.
|
|
373
|
+
- Never leave critical contract, flow, setup, or migration changes undocumented when documentation is needed.
|
|
374
|
+
- Always check blast radius before changing shared symbols.
|
|
375
|
+
- Always mention architecture, flow, or boundary impact when it matters.
|
|
376
|
+
- Always consider whether the change improves or hurts extensibility and team velocity.
|
|
377
|
+
- Always use task tracking for meaningful multi-step work when the runtime supports it.
|
|
378
|
+
- Always ask the user when a real decision or ambiguity checkpoint blocks safe progress.
|
|
379
|
+
- For medium or large changes, present a plan before making the edit.
|
|
380
|
+
|
|
381
|
+
## Fallback Mode
|
|
382
|
+
|
|
383
|
+
If local Octocode tools or LSP are unavailable:
|
|
384
|
+
- continue with AST tools and the scanner
|
|
385
|
+
- rely more on local search and direct code reading
|
|
386
|
+
- reduce confidence on semantic claims
|
|
387
|
+
- say clearly which parts were proven and which parts were inferred
|
|
388
|
+
|
|
389
|
+
## Outcome Standard
|
|
390
|
+
|
|
391
|
+
A good result from this skill should answer all of these:
|
|
392
|
+
- What is happening?
|
|
393
|
+
- Where is the real ownership or boundary?
|
|
394
|
+
- What is the blast radius?
|
|
395
|
+
- Are the contracts clear and safe?
|
|
396
|
+
- Is the problem local, structural, or architectural?
|
|
397
|
+
- Is the implementation efficient enough, or is avoidable complexity hurting it?
|
|
398
|
+
- Is the system becoming cleaner, more modular, and easier to extend?
|
|
399
|
+
- Are important critical aspects documented?
|
|
400
|
+
- What is the safest next move?
|
|
401
|
+
|
|
402
|
+
If the answer only explains one file, it is usually incomplete.
|
|
491
403
|
|
|
492
404
|
## References
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
- [
|
|
496
|
-
- [
|
|
497
|
-
- [
|
|
498
|
-
- [
|
|
499
|
-
- [
|
|
405
|
+
|
|
406
|
+
Use these only when needed:
|
|
407
|
+
- [Tool workflows](./references/tool-workflows.md)
|
|
408
|
+
- [CLI reference](./references/cli-reference.md)
|
|
409
|
+
- [Output files](./references/output-files.md)
|
|
410
|
+
- [AST reference](./references/ast-reference.md)
|
|
411
|
+
- [Validation playbooks](./references/validation-playbooks.md)
|
|
412
|
+
- [Quality indicators](./references/quality-indicators.md)
|
|
413
|
+
- [External tools](./references/externals.md)
|