scip-query 0.7.1 → 0.8.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 (178) hide show
  1. package/README.md +171 -1132
  2. package/dist/augment-vue-worker.js +1 -1
  3. package/dist/{chunk-NSTZMBAB.js → chunk-2EC4JTHC.js} +2 -2
  4. package/dist/{chunk-ZXFTC5ET.js → chunk-46ILZVMX.js} +2 -2
  5. package/dist/chunk-4A4JFNWG.js +2 -0
  6. package/dist/{chunk-GAQGJ52J.js → chunk-4B7YLRXX.js} +2 -2
  7. package/dist/chunk-64UY7VTR.js +63 -0
  8. package/dist/chunk-66ORT3LS.js +2 -0
  9. package/dist/{chunk-QPRIYXH4.js → chunk-6G76D2YM.js} +2 -2
  10. package/dist/{chunk-VUBQBW7H.js → chunk-6P5W4U6G.js} +2 -2
  11. package/dist/chunk-6ZFKI5EP.js +40 -0
  12. package/dist/{chunk-ZNUPGRPR.js → chunk-7I6KNKE3.js} +2 -2
  13. package/dist/{chunk-23YIGCYF.js → chunk-7TYJD45F.js} +5 -5
  14. package/dist/chunk-7UZWNW4E.js +2 -0
  15. package/dist/{chunk-4STLJYHI.js → chunk-AGW2MVIO.js} +2 -2
  16. package/dist/chunk-APLCSDXL.js +4 -0
  17. package/dist/chunk-BCFED24F.js +2 -0
  18. package/dist/chunk-CVRXOP6M.js +3 -0
  19. package/dist/chunk-D43L5PQF.js +2 -0
  20. package/dist/chunk-DJTJ3DLZ.js +7 -0
  21. package/dist/chunk-EAU4RDFG.js +2 -0
  22. package/dist/{chunk-BI4F6GXI.js → chunk-EKP7XJ6L.js} +2 -2
  23. package/dist/{chunk-33SSUPCB.js → chunk-EM2PPDN7.js} +2 -2
  24. package/dist/{chunk-ROOHENEP.js → chunk-FIPE5AQT.js} +2 -2
  25. package/dist/chunk-FTBT4RP2.js +7 -0
  26. package/dist/{chunk-WPLKHAH7.js → chunk-GD7XRHSV.js} +2 -2
  27. package/dist/{chunk-WJQY2LGT.js → chunk-GMEBYEMU.js} +2 -2
  28. package/dist/chunk-GTZAU7OL.js +2 -0
  29. package/dist/chunk-HVGNOUYP.js +2 -0
  30. package/dist/chunk-HVXIXDLV.js +2 -0
  31. package/dist/{chunk-KJ3ZJIE5.js → chunk-I7OTKWNY.js} +2 -2
  32. package/dist/{chunk-2JEFS2YJ.js → chunk-JAMU6FLN.js} +2 -2
  33. package/dist/chunk-JTCEWV7Q.js +2 -0
  34. package/dist/chunk-K4Z3FCUJ.js +6 -0
  35. package/dist/{chunk-FD37DBTD.js → chunk-K6YIGVL7.js} +2 -2
  36. package/dist/chunk-MKE7SEEX.js +2 -0
  37. package/dist/chunk-N5D5ZCBW.js +7 -0
  38. package/dist/{chunk-ROZNBWIF.js → chunk-NGLRXEWN.js} +2 -2
  39. package/dist/{chunk-J6Z5YKGQ.js → chunk-NK7TQQG4.js} +2 -2
  40. package/dist/chunk-NOVKLH2F.js +2 -0
  41. package/dist/chunk-OIMM7KMI.js +2 -0
  42. package/dist/chunk-OQSV6OS2.js +2 -0
  43. package/dist/chunk-PBGTMPJ7.js +2 -0
  44. package/dist/{chunk-ARBZM2NF.js → chunk-PCMVXWDC.js} +4 -4
  45. package/dist/{chunk-U75WH4XG.js → chunk-PE4EJOLN.js} +2 -2
  46. package/dist/chunk-PLFYFZX3.js +2 -0
  47. package/dist/{chunk-A2AVLALL.js → chunk-QYQXPPDI.js} +2 -2
  48. package/dist/{chunk-3OUC276S.js → chunk-RCRK4E7E.js} +2 -2
  49. package/dist/chunk-RIXOMSOR.js +20 -0
  50. package/dist/chunk-SB6I6O3P.js +2 -0
  51. package/dist/{chunk-KNA6Z7JB.js → chunk-SDGCKEB7.js} +2 -2
  52. package/dist/chunk-SLOIQKY7.js +2 -0
  53. package/dist/chunk-SOGLYIJ4.js +62 -0
  54. package/dist/chunk-SSINY7HL.js +4 -0
  55. package/dist/{chunk-563HLCDW.js → chunk-TFO4OMJZ.js} +2 -2
  56. package/dist/chunk-TH4JVC34.js +71 -0
  57. package/dist/chunk-TQTVM27C.js +6 -0
  58. package/dist/{chunk-LDV2B7ET.js → chunk-TR5AU6A5.js} +2 -2
  59. package/dist/{chunk-WODJHE6Z.js → chunk-UQE3DSXY.js} +2 -2
  60. package/dist/{chunk-72JOIFXL.js → chunk-UUDYI3FF.js} +2 -2
  61. package/dist/chunk-VDZL45XI.js +2 -0
  62. package/dist/{chunk-QWJBIBE6.js → chunk-VN6B6HFB.js} +2 -2
  63. package/dist/{chunk-DFK54IRN.js → chunk-WC43FMAB.js} +2 -2
  64. package/dist/chunk-WEJYUS5O.js +2 -0
  65. package/dist/chunk-WQFOZIID.js +4 -0
  66. package/dist/chunk-XBFLIGWU.js +3 -0
  67. package/dist/chunk-XSZ5NC4O.js +2 -0
  68. package/dist/{chunk-2IYEIFPP.js → chunk-Z2AJQ7VA.js} +2 -2
  69. package/dist/chunk-ZIIQ55VK.js +2 -0
  70. package/dist/chunk-ZJ737ZMD.js +2 -0
  71. package/dist/cli.js +171 -174
  72. package/dist/health-C6r2VgpA.d.ts +234 -0
  73. package/dist/index.d.ts +16 -30
  74. package/dist/index.js +1 -1
  75. package/dist/postinstall.js +4 -4
  76. package/dist/queries/affected.js +1 -1
  77. package/dist/queries/bottlenecks.js +1 -1
  78. package/dist/queries/by-kind.js +1 -1
  79. package/dist/queries/call-graph.js +1 -1
  80. package/dist/queries/change-surface.js +1 -1
  81. package/dist/queries/cleanup-plan.d.ts +66 -0
  82. package/dist/queries/cleanup-plan.js +2 -0
  83. package/dist/queries/co-change.d.ts +42 -0
  84. package/dist/queries/co-change.js +2 -0
  85. package/dist/queries/code.js +1 -1
  86. package/dist/queries/complexity-hotspots.d.ts +1 -1
  87. package/dist/queries/complexity-hotspots.js +1 -1
  88. package/dist/queries/complexity.js +1 -1
  89. package/dist/queries/convergence.js +1 -1
  90. package/dist/queries/coupling.js +1 -1
  91. package/dist/queries/cycles.js +1 -1
  92. package/dist/queries/dataflow.js +1 -1
  93. package/dist/queries/dead.js +1 -1
  94. package/dist/queries/deep-chains.js +1 -1
  95. package/dist/queries/deps.js +1 -1
  96. package/dist/queries/diff-gate.d.ts +52 -0
  97. package/dist/queries/diff-gate.js +2 -0
  98. package/dist/queries/diff-impact.js +1 -1
  99. package/dist/queries/doc-drift.d.ts +69 -0
  100. package/dist/queries/doc-drift.js +2 -0
  101. package/dist/queries/drift.js +1 -1
  102. package/dist/queries/extract-candidates.js +1 -1
  103. package/dist/queries/fan.js +1 -1
  104. package/dist/queries/health.d.ts +1 -1
  105. package/dist/queries/health.js +1 -1
  106. package/dist/queries/hierarchy.js +1 -1
  107. package/dist/queries/hotspots.js +1 -1
  108. package/dist/queries/imports.js +1 -1
  109. package/dist/queries/index.d.ts +38 -2
  110. package/dist/queries/index.js +1 -1
  111. package/dist/queries/isolated.js +1 -1
  112. package/dist/queries/members.js +1 -1
  113. package/dist/queries/methods.js +1 -1
  114. package/dist/queries/outline.d.ts +1 -0
  115. package/dist/queries/outline.js +1 -1
  116. package/dist/queries/passthrough-candidates.js +1 -1
  117. package/dist/queries/plan-context.d.ts +65 -0
  118. package/dist/queries/plan-context.js +2 -0
  119. package/dist/queries/recent-duplicates.d.ts +48 -0
  120. package/dist/queries/recent-duplicates.js +2 -0
  121. package/dist/queries/redundant-reexports.js +1 -1
  122. package/dist/queries/refs.js +1 -1
  123. package/dist/queries/self-audit.d.ts +58 -0
  124. package/dist/queries/self-audit.js +2 -0
  125. package/dist/queries/similar-chains.js +1 -1
  126. package/dist/queries/similar-files.d.ts +6 -0
  127. package/dist/queries/similar-files.js +1 -1
  128. package/dist/queries/similar-signatures.js +1 -1
  129. package/dist/queries/similar.js +1 -1
  130. package/dist/queries/slice.js +1 -1
  131. package/dist/queries/stale-abstractions.js +1 -1
  132. package/dist/queries/surface.js +1 -1
  133. package/dist/queries/symbols.js +1 -1
  134. package/dist/queries/system.js +1 -1
  135. package/dist/queries/trace.js +1 -1
  136. package/dist/queries/unused-params.d.ts +38 -0
  137. package/dist/queries/unused-params.js +2 -0
  138. package/dist/queries/wrapper-candidates.js +1 -1
  139. package/dist/reindex-worker.js +1 -1
  140. package/dist/reindex.js +16 -16
  141. package/dist/runtime.d.ts +3 -2
  142. package/dist/runtime.js +2 -2
  143. package/package.json +34 -1
  144. package/skills/concrete-plan/SKILL.md +37 -7
  145. package/skills/scip-ai-cleanup/SKILL.md +145 -0
  146. package/skills/scip-debloat/SKILL.md +37 -7
  147. package/skills/scip-explore/SKILL.md +22 -9
  148. package/skills/scip-language-playbook/SKILL.md +4 -4
  149. package/skills/scip-maintainability/SKILL.md +264 -0
  150. package/skills/scip-verify/SKILL.md +2 -2
  151. package/dist/chunk-3GNFUVFA.js +0 -2
  152. package/dist/chunk-5TT47UMX.js +0 -44
  153. package/dist/chunk-6H2XIIPY.js +0 -71
  154. package/dist/chunk-7H4RJ4MC.js +0 -2
  155. package/dist/chunk-7O4MJYIW.js +0 -63
  156. package/dist/chunk-7OX2O53H.js +0 -62
  157. package/dist/chunk-BOVNTAKQ.js +0 -3
  158. package/dist/chunk-CKIO6SVS.js +0 -2
  159. package/dist/chunk-D6Z67MZL.js +0 -2
  160. package/dist/chunk-FOQQDXE7.js +0 -2
  161. package/dist/chunk-IODTPF5H.js +0 -20
  162. package/dist/chunk-JB4PUN5S.js +0 -40
  163. package/dist/chunk-JTXKS5GK.js +0 -3
  164. package/dist/chunk-KJ6CW6EK.js +0 -2
  165. package/dist/chunk-MDAYGS6T.js +0 -2
  166. package/dist/chunk-NHDPYW7O.js +0 -2
  167. package/dist/chunk-NKJKI6SE.js +0 -2
  168. package/dist/chunk-NYEMZHUC.js +0 -6
  169. package/dist/chunk-OHEIZWIA.js +0 -4
  170. package/dist/chunk-QAEDNTY7.js +0 -2
  171. package/dist/chunk-QE6MGGUY.js +0 -2
  172. package/dist/chunk-RCJEFQOK.js +0 -4
  173. package/dist/chunk-TGK5DFBJ.js +0 -2
  174. package/dist/chunk-TRNAQABL.js +0 -7
  175. package/dist/chunk-V53J46BX.js +0 -2
  176. package/dist/chunk-XO6R3X5J.js +0 -2
  177. package/dist/chunk-YSZNAG4G.js +0 -2
  178. package/dist/health-x7B4Xu_6.d.ts +0 -119
@@ -23,9 +23,39 @@ You are writing a production implementation plan as a markdown checklist. Every
23
23
 
24
24
  ---
25
25
 
26
+ ## Gather Context Fast
27
+
28
+ Start every plan with the bundled context command — it replaces a half-dozen
29
+ separate queries and adds evidence no single query has:
30
+
31
+ ```bash
32
+ scip-query plan-context <symbol-or-file>
33
+ ```
34
+
35
+ Use its sections directly in the plan:
36
+
37
+ - **DEFINITIONS / REFERENCES / CALL GRAPH / DOWNSTREAM IMPACT** — the Source
38
+ citations for your steps.
39
+ - **HISTORY** — files that usually change together with the target. If the
40
+ plan edits the target, the plan MUST either cover its co-change partners or
41
+ state why they're untouched this time. This is how plans stop causing drift.
42
+ - **CHANGE RISK** — high-risk consumers get their own verification steps.
43
+
44
+ Two pre-plan checks that prevent planning mistakes:
45
+
46
+ ```bash
47
+ scip-query doc-drift <standard.md> # is the standard this plan follows stale?
48
+ scip-query recent-duplicates # does the helper you're about to plan already exist?
49
+ ```
50
+
51
+ If `doc-drift` shows the standard's referenced code moved on without it,
52
+ updating that standard becomes step 0 of the plan. If the plan creates a new
53
+ helper, cite the `similar` / `recent-duplicates` evidence that nothing
54
+ established already does the job.
55
+
26
56
  ## Symbol Lookup Tips
27
57
 
28
- scip-query accepts partial symbol names — you don't need the full SCIP symbol path. These all work:
58
+ `scip-query` accepts partial symbol names — you don't need the full SCIP symbol path. These all work:
29
59
 
30
60
  ```bash
31
61
  scip-query code processVegaMention # just the function name
@@ -52,7 +82,7 @@ scip-query code 'src/modules/chat/chat.service.ts:100-200'
52
82
 
53
83
  **If "Symbol not found":**
54
84
  1. Try a shorter/simpler name — `login` instead of `AuthService:login`
55
- 2. Try `scip-query symbols <file>` to see what symbols exist in the file
85
+ 2. Try `scip-query outline <file>` to see what symbols exist in the file
56
86
  3. Try `scip-query trace <name>` which uses a different lookup path
57
87
  4. Use the `file:line-line` syntax for `code` if you know the location
58
88
 
@@ -67,13 +97,13 @@ This skill deliberately excludes `Grep` and `Read` from its allowed tools. This
67
97
  - Using `Read` via a subagent to browse files for discovery. Subagents must also use scip-query.
68
98
  - Spawning Explore agents that fall back to grep and file reads. If a subagent's output does not cite scip-query commands, reject its findings and re-run.
69
99
 
70
- **Instead, use scip-query (full reference at `/Users/aydansalois/Documents/GitHub/scip-query/README.md`):**
100
+ **Instead, use scip-query (full reference at `/Users/aydansalois/Documents/GitHub/scip-query/docs/COMMAND_REFERENCE.md`):**
71
101
 
72
102
  | You want to... | Use this |
73
103
  |---|---|
74
104
  | **Read source code** | `scip-query code <symbol>` (reads file, bounded to definition range) |
75
105
  | **Read source with context** | `scip-query code <symbol> -C 5` (5 extra lines above/below) |
76
- | Find a symbol / list file contents | `scip-query symbols <file>` (all symbols with line ranges + signatures) |
106
+ | Find a symbol / list file contents | `scip-query outline <file>` (all symbols with line ranges + signatures) |
77
107
  | Find files by name | `scip-query files <pattern>` |
78
108
  | See callers + callees | `scip-query call-graph <symbol>` |
79
109
  | Full module map | `scip-query system <module>` |
@@ -107,7 +137,7 @@ If none of these can answer your question, say so explicitly in the plan rather
107
137
 
108
138
  ### Full Documentation
109
139
 
110
- - **Every command with options and examples:** `/Users/aydansalois/Documents/GitHub/scip-query/README.md`
140
+ - **Every command with options and examples:** `/Users/aydansalois/Documents/GitHub/scip-query/docs/COMMAND_REFERENCE.md`
111
141
  - **Goal-oriented agent workflows:** `/Users/aydansalois/Documents/GitHub/scip-query/docs/AGENT_GUIDE.md`
112
142
 
113
143
  ---
@@ -284,7 +314,7 @@ You have the `scip-query` CLI for compiler-resolved code intelligence. Use it fo
284
314
  Navigation:
285
315
  - `scip-query code <symbol>` — read source code (bounded to definition range)
286
316
  - `scip-query code <symbol> -C 5` — read source with 5 extra context lines
287
- - `scip-query symbols <file>` — all symbols in a file with line ranges + signatures
317
+ - `scip-query outline <file>` — all symbols in a file with line ranges + signatures
288
318
  - `scip-query files <pattern>` — find files by name
289
319
  - `scip-query refs <symbol>` — every file referencing a symbol
290
320
  - `scip-query trace <symbol>` — definition + signature + all references
@@ -314,7 +344,7 @@ Quality:
314
344
  - `scip-query complexity-hotspots` — riskiest symbols
315
345
  - `scip-query cycles` — circular dependencies
316
346
 
317
- Full command reference: /Users/aydansalois/Documents/GitHub/scip-query/README.md
347
+ Full command reference: /Users/aydansalois/Documents/GitHub/scip-query/docs/COMMAND_REFERENCE.md
318
348
  Agent workflows guide: /Users/aydansalois/Documents/GitHub/scip-query/docs/AGENT_GUIDE.md
319
349
 
320
350
  ### Rules
@@ -0,0 +1,145 @@
1
+ ---
2
+ name: scip-ai-cleanup
3
+ description: Clean up AI-generated code rot using scip-query's change-graph and verification tooling. Finds recent re-implementations of established code, drifting standards docs, speculative parameters, hidden coupling, and produces compiler-verified deletion plans. Sets up the CI ratchet so findings never regress.
4
+ allowed-tools: [Bash, Write, Edit, Glob, Agent, TaskCreate, TaskUpdate, TaskGet, TaskList]
5
+ keywords: [ai-slop, ai-generated, cleanup, duplicates, echo, doc-drift, standards, stale-docs, cleanup-plan, verify, co-change, ratchet, baseline, unused-params]
6
+ ---
7
+
8
+ # AI-Generated Code Cleanup with scip-query
9
+
10
+ AI-assisted development rots a codebase in specific, detectable ways: agents
11
+ re-implement helpers they didn't know existed, leave half-wired parallel
12
+ implementations behind, add parameters "for later" that never come, and the
13
+ standards docs written FOR agents drift away from the code — so the next agent
14
+ implements against a dead spec. None of this is visible in a single file;
15
+ all of it is visible in the reference graph + the git change graph.
16
+
17
+ This skill runs the full sweep and ends with a compiler-verified deletion
18
+ plan and a CI ratchet.
19
+
20
+ ## When to Use This Skill
21
+
22
+ - "Clean up the AI slop in this repo"
23
+ - "Did the agents duplicate code?"
24
+ - "Are our standards docs stale?"
25
+ - "What can we safely delete?"
26
+ - "Set up a quality gate for agent-written code"
27
+
28
+ ## Hard Rules
29
+
30
+ 1. **Evidence first.** Run `scip-query status` and `scip-query reindex` before
31
+ trusting graph facts. All detectors print whether they're heuristic.
32
+ 2. **Verify before deleting.** Findings are candidates; only
33
+ `cleanup-plan --verify` output stamped COMPILER-VERIFIED is proof.
34
+ A FAILED verification is signal too — its errors name the references the
35
+ static evidence missed. Never delete on a failed batch.
36
+ 3. **Echoes consolidate INTO the established side.** When recent code
37
+ duplicates older code, extend the original and delete the echo — not the
38
+ reverse. The established side has the consumers and the bug-fix history.
39
+ 4. **Fix the doc or delete the doc — never leave it lying.** A stale standards
40
+ doc actively misleads every agent that reads it.
41
+
42
+ ## The Sweep
43
+
44
+ ### Step 1: Recent re-implementations (echoes)
45
+
46
+ ```bash
47
+ scip-query recent-duplicates --window 100
48
+ ```
49
+
50
+ - `ECHO` — recent code duplicating established code. Read both sides, then
51
+ migrate the echo's callers to the established symbol and delete the echo.
52
+ - `TWIN` — both sides landed recently (often one agent session duplicating
53
+ itself). Pick the better-placed one, consolidate before they diverge.
54
+ - Widen `--window` on slow-moving repos; narrow it right after a big agent
55
+ session.
56
+
57
+ ### Step 2: Drifting and lying docs
58
+
59
+ ```bash
60
+ scip-query doc-drift
61
+ scip-query doc-drift AGENTS.md # detail mode for one doc
62
+ ```
63
+
64
+ - `BROKEN REFERENCE` lines are the worst class: the doc cites files that no
65
+ longer exist. Fix those citations first.
66
+ - `referenced by doc` subjects changed after the doc's last update — re-read
67
+ the subject files and update the doc's claims (or delete the doc).
68
+ - Re-run after updating: staleness should drop to 0 for the docs you touched.
69
+
70
+ ### Step 3: Speculative generality
71
+
72
+ ```bash
73
+ scip-query unused-params
74
+ ```
75
+
76
+ Trailing parameters no body uses — already scoped to removals that are
77
+ type-safe by construction (TS/JS, trailing-only, no parameter properties).
78
+ Drop the parameters and any arguments at call sites.
79
+
80
+ ### Step 4: Hidden coupling
81
+
82
+ ```bash
83
+ scip-query co-change
84
+ ```
85
+
86
+ File pairs that repeatedly change in the same commits with NO dependency
87
+ edge: hand-synchronized artifacts (schema ↔ inventory doc ↔ generator
88
+ script, backend schema ↔ frontend store, .env.example ↔ env parser).
89
+ For each pair, either name the shared concept in code (one source of truth)
90
+ or add a contract test that fails when one side changes without the other.
91
+
92
+ ### Step 5: Compiler-verified deletion
93
+
94
+ ```bash
95
+ scip-query cleanup-plan --verify
96
+ ```
97
+
98
+ - Batches are ordered: batch 0 is graph-fact dead now; batch n is dead once
99
+ batch n-1 lands (the cascade). Apply ONE batch at a time.
100
+ - `COMPILER-VERIFIED` means the deletion was applied in a throwaway worktree
101
+ and your own checker (tsc / cargo check) passed differentially.
102
+ - `FAILED` errors name real references — usually barrel export lines or
103
+ imports that must be removed together with the symbol, occasionally a
104
+ detector false positive. Investigate before deleting anything.
105
+ - The `blocked` list explains why candidates can't cascade (e.g. a spec file
106
+ still references them).
107
+
108
+ ### Step 6: Ratchet it
109
+
110
+ ```bash
111
+ scip-query health --write-baseline # commit .scipquery-baseline.json
112
+ scip-query health --baseline # exit 1 on any NEW finding — wire into CI
113
+ scip-query diff-gate # per-diff gate: echoes, missing partners, uncited docs
114
+ ```
115
+
116
+ `diff-gate` is the leading indicator: run it on every agent commit / PR
117
+ (`--base origin/main` in CI). Each finding carries a remediation the agent
118
+ can apply directly.
119
+
120
+ After each cleanup round, re-run `--write-baseline` to ratchet the count
121
+ down. The gate is "don't get worse" — objective and ungameable.
122
+
123
+ ## Before Writing New Code (prevention)
124
+
125
+ Tell implementing agents to run these BEFORE writing a helper or reading a
126
+ standard:
127
+
128
+ ```bash
129
+ scip-query plan-context <symbol-or-file> # structure + HISTORY (churn, co-change partners)
130
+ scip-query similar <new-function-name> # does this already exist?
131
+ scip-query doc-drift <standard.md> # is the standard I'm about to follow stale?
132
+ ```
133
+
134
+ The HISTORY section of plan-context lists the files that usually change with
135
+ the target — the edit checklist that prevents the drift this skill cleans up.
136
+
137
+ ## Reporting
138
+
139
+ End with a prioritized summary:
140
+
141
+ 1. Echoes/twins consolidated (LOC removed, callers migrated)
142
+ 2. Docs fixed vs deleted (staleness before → after)
143
+ 3. Compiler-verified deletions applied (LOC, batches)
144
+ 4. Hidden couplings resolved (named mechanism or contract test added)
145
+ 5. Baseline ratcheted: N findings → M
@@ -9,6 +9,8 @@ keywords: [debloat, clean, cleanup, refactor, dead-code, duplication, dry, conso
9
9
 
10
10
  You are performing a comprehensive codebase audit to find every opportunity to reduce bloat, eliminate duplication, consolidate similar code, remove unnecessary abstractions, and improve structural health. You are thorough — you check from every angle, not just the obvious ones. Every finding must come from `scip-query`.
11
11
 
12
+ This is not a score-maxing workflow. Health scores, finding counts, and LOC totals are diagnostic signals. The objective is to make the codebase easier to understand and safer to change by removing unnecessary structure, naming hidden policies, and preserving real behavior.
13
+
12
14
  ---
13
15
 
14
16
  ## When to Use This Skill
@@ -28,19 +30,47 @@ You are performing a comprehensive codebase audit to find every opportunity to r
28
30
 
29
31
  1. **Run `scip-query health` first.** It aggregates all analyses and gives you the prioritized starting point. Don't skip it.
30
32
 
31
- 2. **Check from every angle.** Dead code is the easy win. Go deeper similar functions, stale abstractions, wrapper indirection, pattern drift, convergence opportunities, passthrough functions. Each catches a different class of bloat.
33
+ 2. **Do not chase the score.** Do not recommend work merely because it raises `health`, reduces a detector count, or deletes LOC. A finding is actionable only when the change removes a real maintenance burden while preserving required behavior.
34
+
35
+ 3. **Check from every angle.** Dead code is the easy win. Go deeper — similar functions, stale abstractions, wrapper indirection, pattern drift, convergence opportunities, passthrough functions. Each catches a different class of bloat.
32
36
 
33
- 3. **Verify before recommending deletion.** Before saying "delete X," confirm it's truly unused: check `scip-query refs`, `scip-query affected`, and whether it's an entry point (CLI, worker, test file). Entry points appear dead because nothing imports them.
37
+ 4. **Verify before recommending deletion.** Before saying "delete X," confirm it's truly unused: check `scip-query refs`, `scip-query affected`, and whether it's an entry point (CLI, worker, test file). Entry points appear dead because nothing imports them.
34
38
 
35
- 4. **Produce concrete actions.** Don't say "there's some duplication." Say "functions A and B have 80% callee overlap consolidate into a shared helper with the 2 divergent callees as parameters (per `scip-query convergence A B`)."
39
+ 5. **Distinguish accidental variation from essential variation.** Accidental variation is difference in code shape that does not reflect a real behavior, domain, runtime, or compatibility difference. Essential variation is difference that must remain because the real units differ. Consolidate the first; preserve the second.
36
40
 
37
- 5. **The report goes in `reports/debloat/YYYY-MM-DD-<scope>.md`.** If no reports directory exists, use the project root.
41
+ 6. **Produce concrete actions.** Don't say "there's some duplication." Say "functions A and B have 80% callee overlap — consolidate into a shared helper with the 2 divergent callees as parameters (per `scip-query convergence A B`)."
42
+
43
+ 7. **The report goes in `reports/debloat/YYYY-MM-DD-<scope>.md`.** If no reports directory exists, use the project root.
38
44
 
39
45
  ---
40
46
 
47
+ ## Start Here: The Verified Pipeline
48
+
49
+ Before working the angles below one by one, run the high-leverage trio:
50
+
51
+ ```bash
52
+ scip-query cleanup-plan --verify # cascade dead-code plan, COMPILER-VERIFIED per batch
53
+ scip-query recent-duplicates # recent code that re-implements established code
54
+ scip-query doc-drift # docs whose referenced code moved on without them
55
+ ```
56
+
57
+ `cleanup-plan --verify` subsumes the manual dead-code workflow: it runs dead
58
+ code to a fixpoint (deleting batch 0 makes batch 1 dead), applies each batch
59
+ in a throwaway worktree, and runs the project's own checker (tsc / cargo
60
+ check) differentially. Only act on batches stamped COMPILER-VERIFIED; FAILED
61
+ output names the references the static evidence missed. For AI-generated
62
+ codebases specifically, prefer the dedicated scip-ai-cleanup skill.
63
+
64
+ After cleanup, ratchet the result so it never regresses:
65
+
66
+ ```bash
67
+ scip-query health --write-baseline # commit .scipquery-baseline.json
68
+ scip-query health --baseline # CI gate: exit 1 on any NEW finding
69
+ ```
70
+
41
71
  ## Symbol Lookup Tips
42
72
 
43
- scip-query accepts partial symbol names — you don't need the full SCIP symbol path. These all work:
73
+ `scip-query` accepts partial symbol names — you don't need the full SCIP symbol path. These all work:
44
74
 
45
75
  ```bash
46
76
  scip-query code processVegaMention # just the function name
@@ -67,7 +97,7 @@ scip-query code 'src/modules/chat/chat.service.ts:100-200'
67
97
 
68
98
  **If "Symbol not found":**
69
99
  1. Try a shorter/simpler name — `login` instead of `AuthService:login`
70
- 2. Try `scip-query symbols <file>` to see what symbols exist in the file
100
+ 2. Try `scip-query outline <file>` to see what symbols exist in the file
71
101
  3. Try `scip-query trace <name>` which uses a different lookup path
72
102
  4. Use the `file:line-line` syntax for `code` if you know the location
73
103
 
@@ -276,7 +306,7 @@ scip-query reindex # Ensure index is fresh
276
306
  scip-query health # Get the full report
277
307
  ```
278
308
 
279
- Read the health score, the findings breakdown, and the prioritized action list. This is your roadmap.
309
+ Read the health score, the findings breakdown, and the prioritized action list as evidence. They are not the goal. Use them to find places where unnecessary structure, hidden policy, accidental variation, or disconnected code creates maintenance cost.
280
310
 
281
311
  ### Phase 2: Deep Scan (10-15 minutes)
282
312
 
@@ -24,19 +24,21 @@ You are exploring a codebase to build a deep, accurate understanding of how a sy
24
24
 
25
25
  ## Hard Rules
26
26
 
27
- 1. **Every claim must come from scip-query.** If you say "function X calls function Y," you must have run `scip-query call-graph X` or `scip-query code X` to verify it. No memory. No assumptions.
27
+ 1. **Use a current index.** Before exploration, run `scip-query status` when available and check whether the index is missing, stale, or built for a different project root. If the codebase has changed, the status is uncertain, or the user asks for current facts, run `scip-query reindex` before trusting results. If reindexing fails, report that the index may be stale and mark affected claims as unverified.
28
28
 
29
- 2. **Read the code.** Don't describe what a function "probably does" run `scip-query code <symbol>` and describe what it actually does.
29
+ 2. **Every claim must come from scip-query.** If you say "function X calls function Y," you must have run `scip-query call-graph X` or `scip-query code X` to verify it. No memory. No assumptions.
30
30
 
31
- 3. **Follow the graph, not the folder structure.** File organization can be misleading. Use `scip-query deps`, `scip-query rdeps`, `scip-query call-graph`, and `scip-query dataflow` to trace actual execution paths.
31
+ 3. **Read the code.** Don't describe what a function "probably does" run `scip-query code <symbol>` and describe what it actually does.
32
32
 
33
- 4. **Start wide, then narrow.** Begin with `scip-query system` for the module map, then drill into specific symbols with `scip-query call-graph`, `scip-query code`, and `scip-query dataflow`.
33
+ 4. **Follow the graph, not the folder structure.** File organization can be misleading. Use `scip-query deps`, `scip-query rdeps`, `scip-query call-graph`, and `scip-query dataflow` to trace actual execution paths.
34
+
35
+ 5. **Start wide, then narrow.** Begin with `scip-query system` for the module map, then drill into specific symbols with `scip-query call-graph`, `scip-query code`, and `scip-query dataflow`.
34
36
 
35
37
  ---
36
38
 
37
39
  ## Symbol Lookup Tips
38
40
 
39
- scip-query accepts partial symbol names — you don't need the full SCIP symbol path. These all work:
41
+ `scip-query` accepts partial symbol names — you don't need the full SCIP symbol path. These all work:
40
42
 
41
43
  ```bash
42
44
  scip-query code processVegaMention # just the function name
@@ -63,7 +65,7 @@ scip-query code 'src/modules/chat/chat.service.ts:100-200'
63
65
 
64
66
  **If "Symbol not found":**
65
67
  1. Try a shorter/simpler name — `login` instead of `AuthService:login`
66
- 2. Try `scip-query symbols <file>` to see what symbols exist in the file
68
+ 2. Try `scip-query outline <file>` to see what symbols exist in the file
67
69
  3. Try `scip-query trace <name>` which uses a different lookup path
68
70
  4. Use the `file:line-line` syntax for `code` if you know the location
69
71
 
@@ -71,6 +73,17 @@ scip-query code 'src/modules/chat/chat.service.ts:100-200'
71
73
 
72
74
  ## Exploration Workflow
73
75
 
76
+ ### Step 0: Verify the index
77
+
78
+ Start by making sure the SCIP facts are current enough to trust:
79
+
80
+ ```bash
81
+ scip-query status # Check index location, freshness, and project root
82
+ scip-query reindex # Run when missing, stale, uncertain, or after code changes
83
+ ```
84
+
85
+ If `status` is unavailable or inconclusive, run `scip-query stats` and `scip-query reindex` when the repository has changed. Do not explore from an index you know is stale.
86
+
74
87
  ### Step 1: Orient — What are we looking at?
75
88
 
76
89
  Start with the high-level map. Run these first:
@@ -78,7 +91,7 @@ Start with the high-level map. Run these first:
78
91
  ```bash
79
92
  scip-query stats # How big is this codebase?
80
93
  scip-query system <module> # Full module map: files, symbols, deps
81
- scip-query symbols <entry-file> # What's in the entry point?
94
+ scip-query outline <entry-file> # What's in the entry point?
82
95
  ```
83
96
 
84
97
  **Output:** List all files in the module, the key symbols, what it depends on, and what depends on it. This is your map.
@@ -152,7 +165,7 @@ scip-query complexity X # How complex is it
152
165
 
153
166
  ### "What happens when a user does Y?"
154
167
 
155
- 1. Find the entry point: `scip-query files <handler-pattern>` or `scip-query symbols <route-file>`
168
+ 1. Find the entry point: `scip-query files <handler-pattern>` or `scip-query outline <route-file>`
156
169
  2. Read the handler: `scip-query code <handler>`
157
170
  3. Follow each call: `scip-query call-graph <callee>` → `scip-query code <callee>` → repeat
158
171
  4. Trace the data: `scip-query dataflow <key-variable>` at each step
@@ -207,7 +220,7 @@ Every file path, line number, and behavioral claim includes the scip-query comma
207
220
  | Purpose | Command |
208
221
  |---|---|
209
222
  | Read source code | `scip-query code <symbol> [-C N]` |
210
- | All symbols in a file | `scip-query symbols <file>` |
223
+ | All symbols in a file | `scip-query outline <file>` |
211
224
  | Find files | `scip-query files <pattern>` |
212
225
  | Full module map | `scip-query system <module>` |
213
226
  | True public API | `scip-query surface <module>` |
@@ -27,7 +27,7 @@ Run these in almost every codebase, regardless of language:
27
27
  ```bash
28
28
  scip-query stats
29
29
  scip-query files <feature-or-module-name>
30
- scip-query symbols <file>
30
+ scip-query outline <file>
31
31
  scip-query trace <symbol>
32
32
  scip-query code <symbol>
33
33
  ```
@@ -68,7 +68,7 @@ Vue note: `.vue` single-file components are handled by the same path. scip-query
68
68
 
69
69
  Use first:
70
70
  ```bash
71
- scip-query symbols <file>
71
+ scip-query outline <file>
72
72
  scip-query outline <file>
73
73
  scip-query system <module-or-file>
74
74
  scip-query imports <file>
@@ -209,7 +209,7 @@ Use first:
209
209
  scip-query trace <symbol>
210
210
  scip-query call-graph <symbol>
211
211
  scip-query refs <symbol>
212
- scip-query symbols <file>
212
+ scip-query outline <file>
213
213
  scip-query outline <file>
214
214
  ```
215
215
 
@@ -347,7 +347,7 @@ scip-query extract-candidates
347
347
 
348
348
  ```bash
349
349
  scip-query files <feature>
350
- scip-query symbols <file>
350
+ scip-query outline <file>
351
351
  scip-query trace <entry-symbol>
352
352
  scip-query call-graph <entry-symbol>
353
353
  scip-query code <entry-symbol>