scip-query 0.10.0 → 0.10.1
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 +115 -58
- package/dist/augment-vue-worker.js +1 -1
- package/dist/chunk-23FVN4Y5.js +2 -0
- package/dist/chunk-24PFLKFK.js +2 -0
- package/dist/{chunk-A2VTV2QB.js → chunk-27KPKLRJ.js} +2 -2
- package/dist/chunk-2NLK4INB.js +2 -0
- package/dist/{chunk-6K2JQ2VI.js → chunk-2XKAMW6B.js} +2 -2
- package/dist/{chunk-4DAPXOWD.js → chunk-332L7SRO.js} +2 -2
- package/dist/chunk-44JOJLMO.js +38 -0
- package/dist/{chunk-MCW36F2D.js → chunk-4EAANIWC.js} +2 -2
- package/dist/{chunk-FVIKFWUL.js → chunk-4N7LFYSD.js} +2 -2
- package/dist/{chunk-4MHT7LKP.js → chunk-5ALI77D7.js} +2 -2
- package/dist/{chunk-V76FCF5F.js → chunk-5BZOSICN.js} +2 -2
- package/dist/{chunk-IVAIPXNO.js → chunk-5D3BT4B4.js} +2 -2
- package/dist/{chunk-ADRYSISR.js → chunk-5HDYAOSF.js} +2 -2
- package/dist/{chunk-IC3RC3KJ.js → chunk-5IDEQEM4.js} +2 -2
- package/dist/{chunk-NC4IUW25.js → chunk-5VB3WU7K.js} +2 -2
- package/dist/chunk-623UQCVG.js +2 -0
- package/dist/chunk-62NMBOA5.js +2 -0
- package/dist/chunk-64LH2QUP.js +62 -0
- package/dist/{chunk-PG3ZI5IH.js → chunk-65UWNXEH.js} +1 -1
- package/dist/{chunk-OLCKSG3Y.js → chunk-6TWFT4Y5.js} +2 -2
- package/dist/chunk-6U4EODW3.js +2 -0
- package/dist/{chunk-MN75T4UB.js → chunk-6YKJSETN.js} +2 -2
- package/dist/chunk-A2GVUCZR.js +8 -0
- package/dist/{chunk-WEJYUS5O.js → chunk-ADKQX2OY.js} +2 -2
- package/dist/{chunk-YWZBKYLS.js → chunk-ADTG377O.js} +2 -2
- package/dist/chunk-ATGRITZP.js +20 -0
- package/dist/chunk-B3HMRQDA.js +2 -0
- package/dist/chunk-B75HZHUP.js +2 -0
- package/dist/chunk-BGBBVSH4.js +2 -0
- package/dist/chunk-BJ7OHKB5.js +2 -0
- package/dist/{chunk-VZRILF2Z.js → chunk-CCB45WDY.js} +2 -2
- package/dist/chunk-CFLYMEUS.js +2 -0
- package/dist/{chunk-ISCKLDSS.js → chunk-CMGOXDVP.js} +3 -3
- package/dist/chunk-DBIG4QAJ.js +2 -0
- package/dist/{chunk-4JQFTUKD.js → chunk-DMLPJ75B.js} +2 -2
- package/dist/chunk-DRU74YUM.js +71 -0
- package/dist/chunk-DTERBKUE.js +7 -0
- package/dist/{chunk-4HTJZC6G.js → chunk-E55WCTLH.js} +2 -2
- package/dist/{chunk-CMXFASVD.js → chunk-F4PKYBQB.js} +2 -2
- package/dist/{chunk-L2KFPRMA.js → chunk-FVX4GEAC.js} +2 -2
- package/dist/{chunk-AP5GTKSG.js → chunk-GTNPPGZJ.js} +2 -2
- package/dist/{chunk-ZZ2W5P3D.js → chunk-GZXXBDJA.js} +2 -2
- package/dist/chunk-HCQ7J2N5.js +3 -0
- package/dist/chunk-HQHFMPLJ.js +2 -0
- package/dist/{chunk-SCEMECW7.js → chunk-I6PTB2CM.js} +2 -2
- package/dist/{chunk-772YYL6I.js → chunk-IJYWCB57.js} +2 -2
- package/dist/chunk-JTRY2YRJ.js +2 -0
- package/dist/chunk-L77GXANO.js +6 -0
- package/dist/{chunk-R6XDPWJA.js → chunk-LT6GJ27X.js} +2 -2
- package/dist/chunk-LUBKUISI.js +2 -0
- package/dist/{chunk-ZGIK464P.js → chunk-LVYXX7ZW.js} +2 -2
- package/dist/{chunk-2WEH5QHC.js → chunk-LWPEZ4FP.js} +2 -2
- package/dist/chunk-LWWZBABT.js +2 -0
- package/dist/chunk-LXM7AHQG.js +4 -0
- package/dist/chunk-LY6NRJPJ.js +2 -0
- package/dist/chunk-LYS4SMAQ.js +2 -0
- package/dist/{chunk-BNW3Q24R.js → chunk-MESUJJVQ.js} +2 -2
- package/dist/{chunk-Y5H7TBVE.js → chunk-MHAQXOZY.js} +2 -2
- package/dist/chunk-N2T2GPYQ.js +2 -0
- package/dist/chunk-OB6PEVI3.js +2 -0
- package/dist/chunk-PNN3D4BE.js +2 -0
- package/dist/{chunk-QJWN6LA5.js → chunk-PV4CEDIL.js} +2 -2
- package/dist/chunk-QH5GTVVB.js +3 -0
- package/dist/{chunk-ZOT3WUZW.js → chunk-QOFKVNFE.js} +2 -2
- package/dist/chunk-QUKZ77A6.js +4 -0
- package/dist/chunk-R42LZMLX.js +2 -0
- package/dist/{chunk-2BMFRBV6.js → chunk-R7S3UCDR.js} +2 -2
- package/dist/chunk-RGDUIMNE.js +3 -0
- package/dist/{chunk-BGRPMGTD.js → chunk-RNLUCQJB.js} +2 -2
- package/dist/chunk-RYBMW2EN.js +2 -0
- package/dist/{chunk-VGBSY6N7.js → chunk-SA6B3EGD.js} +2 -2
- package/dist/chunk-T67R7V5I.js +2 -0
- package/dist/chunk-TMS4JPWY.js +3 -0
- package/dist/chunk-TTGWDUJ4.js +5 -0
- package/dist/chunk-TUAPDKBI.js +2 -0
- package/dist/chunk-UVK3SL4Z.js +2 -0
- package/dist/chunk-W3PQRAI4.js +2 -0
- package/dist/{chunk-PRVDXGSK.js → chunk-WWFBDM5Y.js} +2 -2
- package/dist/{chunk-AQYBOORI.js → chunk-WZVTADY7.js} +1 -1
- package/dist/chunk-XGGTESMN.js +2 -0
- package/dist/{chunk-NGI4V4AB.js → chunk-Y33GRQK6.js} +2 -2
- package/dist/{chunk-QKO474FG.js → chunk-YIE5FZAF.js} +2 -2
- package/dist/chunk-YISMWW66.js +7 -0
- package/dist/chunk-YVQUQIBM.js +5 -0
- package/dist/{chunk-6DEX3XP6.js → chunk-YYCQQBMG.js} +2 -2
- package/dist/cli.js +221 -233
- package/dist/{config-types-CGIeLEpY.d.ts → config-types-Bok4jrO3.d.ts} +29 -1
- package/dist/{db-DdTPetj5.d.ts → db-BkFlkzI3.d.ts} +1 -1
- package/dist/{health-C6r2VgpA.d.ts → health-CbGMdRPg.d.ts} +42 -3
- package/dist/index.d.ts +7 -6
- package/dist/index.js +1 -1
- package/dist/postinstall.js +2 -2
- package/dist/queries/affected.d.ts +2 -2
- package/dist/queries/affected.js +1 -1
- package/dist/queries/bottlenecks.d.ts +2 -2
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.d.ts +2 -2
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +2 -2
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.d.ts +2 -2
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.d.ts +2 -2
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.d.ts +5 -4
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.d.ts +2 -2
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.d.ts +2 -2
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +2 -2
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/convergence.d.ts +2 -2
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.d.ts +2 -2
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.d.ts +2 -2
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.d.ts +2 -2
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.d.ts +2 -2
- package/dist/queries/dead.js +1 -1
- package/dist/queries/deep-chains.d.ts +2 -2
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/deps.d.ts +2 -2
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-gate.d.ts +21 -3
- package/dist/queries/diff-gate.js +1 -1
- package/dist/queries/diff-impact.d.ts +20 -4
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.d.ts +2 -2
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.d.ts +2 -2
- package/dist/queries/drift.js +1 -1
- package/dist/queries/extract-candidates.d.ts +2 -2
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.d.ts +2 -2
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.d.ts +2 -2
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.d.ts +3 -3
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +2 -2
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.d.ts +2 -2
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +2 -2
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.d.ts +4 -2
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +10 -4
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.d.ts +2 -2
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/members.d.ts +2 -2
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.d.ts +2 -2
- package/dist/queries/methods.js +1 -1
- package/dist/queries/outline.d.ts +2 -2
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.d.ts +2 -2
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.d.ts +2 -2
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.d.ts +31 -0
- package/dist/queries/react-component-duplicates.js +2 -0
- package/dist/queries/react-hook-candidates.d.ts +34 -0
- package/dist/queries/react-hook-candidates.js +2 -0
- package/dist/queries/react-large-component-pressure.d.ts +28 -0
- package/dist/queries/react-large-component-pressure.js +2 -0
- package/dist/queries/recent-duplicates.d.ts +10 -3
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +2 -2
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.d.ts +2 -2
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.d.ts +2 -2
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.d.ts +2 -2
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.d.ts +2 -2
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.d.ts +2 -2
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +8 -3
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.d.ts +2 -2
- package/dist/queries/slice.js +1 -1
- package/dist/queries/stale-abstractions.d.ts +2 -2
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/stats.d.ts +2 -2
- package/dist/queries/stats.js +1 -1
- package/dist/queries/surface.d.ts +2 -2
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.d.ts +2 -2
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system.d.ts +2 -2
- package/dist/queries/system.js +1 -1
- package/dist/queries/trace.d.ts +2 -2
- package/dist/queries/trace.js +1 -1
- package/dist/queries/unused-params.d.ts +2 -2
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/vue-component-duplicates.d.ts +35 -0
- package/dist/queries/vue-component-duplicates.js +2 -0
- package/dist/queries/vue-composable-candidates.d.ts +34 -0
- package/dist/queries/vue-composable-candidates.js +2 -0
- package/dist/queries/vue-large-view-pressure.d.ts +31 -0
- package/dist/queries/vue-large-view-pressure.js +2 -0
- package/dist/queries/wrapper-candidates.d.ts +2 -2
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +10 -10
- package/dist/reindex.d.ts +1 -1
- package/dist/reindex.js +22 -22
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +2 -2
- package/docs/AGENT_GUIDE.md +353 -0
- package/docs/AI_FAILURE_MODES.md +278 -0
- package/docs/API.md +40 -0
- package/docs/COMMAND_REFERENCE.md +130 -0
- package/docs/DETECTOR_GUIDE.md +119 -0
- package/docs/accuracy-hardening-goal.md +54 -0
- package/docs/assets/scip-query-logo-dark.svg +21 -0
- package/docs/assets/scip-query-logo.svg +24 -0
- package/package.json +31 -3
- package/skills/scip-maintainability/SKILL.md +24 -3
- package/skills/scip-query/SKILL.md +2 -1
- package/skills/scip-react-maintainability/SKILL.md +114 -0
- package/skills/scip-vue-maintainability/SKILL.md +130 -0
- package/dist/chunk-5OHZEO3U.js +0 -3
- package/dist/chunk-5QJIEYFB.js +0 -34
- package/dist/chunk-6IGXZZQ4.js +0 -4
- package/dist/chunk-6QVCPUK6.js +0 -2
- package/dist/chunk-6VL4AIEO.js +0 -8
- package/dist/chunk-AI2ECT7L.js +0 -2
- package/dist/chunk-BUAC4Q4G.js +0 -2
- package/dist/chunk-BZ6LCGE6.js +0 -2
- package/dist/chunk-CO3AL7NZ.js +0 -2
- package/dist/chunk-FVVT7GV6.js +0 -4
- package/dist/chunk-HXXRN77A.js +0 -2
- package/dist/chunk-ITHQJZTG.js +0 -2
- package/dist/chunk-IW7ASGVF.js +0 -2
- package/dist/chunk-JODYQDE4.js +0 -2
- package/dist/chunk-MX6F756F.js +0 -2
- package/dist/chunk-O6KCZPJQ.js +0 -62
- package/dist/chunk-OAI5GEIN.js +0 -6
- package/dist/chunk-OH5HIAID.js +0 -4
- package/dist/chunk-OXKEUWMJ.js +0 -2
- package/dist/chunk-PBGTMPJ7.js +0 -2
- package/dist/chunk-QYKKTYBN.js +0 -6
- package/dist/chunk-R3G6ERW7.js +0 -7
- package/dist/chunk-SJR4SB7B.js +0 -2
- package/dist/chunk-SYKCO25G.js +0 -16
- package/dist/chunk-T22X7WT6.js +0 -2
- package/dist/chunk-TH4JVC34.js +0 -71
- package/dist/chunk-VDY4HYNK.js +0 -2
- package/dist/chunk-VDZIEDJB.js +0 -2
- package/dist/chunk-VDZL45XI.js +0 -2
- package/dist/chunk-WJIS6BNI.js +0 -3
- package/dist/chunk-WN5Z3UVT.js +0 -7
- package/dist/chunk-XCW7DYHM.js +0 -2
- package/dist/chunk-ZF6P2NAT.js +0 -63
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
# scip-query Agent Guide
|
|
2
|
+
|
|
3
|
+
Goal-oriented workflows for AI agents and developers. Each section starts with a goal and walks through the exact commands to run, what to expect back, and how to use the results.
|
|
4
|
+
|
|
5
|
+
For command syntax and options reference, see [Command Reference](COMMAND_REFERENCE.md).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Workflow 1: Understand a system before making changes
|
|
10
|
+
|
|
11
|
+
**Goal:** Build a complete mental model of a module or feature area so you can write a precise implementation plan with no ambiguity about what code exists, what it does, and what depends on it.
|
|
12
|
+
|
|
13
|
+
### Steps
|
|
14
|
+
|
|
15
|
+
1. **Map the module**
|
|
16
|
+
```bash
|
|
17
|
+
scip-query system <module-path>
|
|
18
|
+
```
|
|
19
|
+
Returns: all files in the module, all exported symbols with line ranges, all inbound and outbound dependencies. This is your starting map.
|
|
20
|
+
|
|
21
|
+
2. **Understand the public contract**
|
|
22
|
+
```bash
|
|
23
|
+
scip-query surface <module-path>
|
|
24
|
+
```
|
|
25
|
+
Returns: which symbols external consumers actually reference. This is the true public API — not what's exported, but what's used. Any change to these symbols is a breaking change.
|
|
26
|
+
|
|
27
|
+
3. **Trace specific symbols**
|
|
28
|
+
```bash
|
|
29
|
+
scip-query trace <symbol-name>
|
|
30
|
+
```
|
|
31
|
+
Returns: where the symbol is defined (file + line range + signature) and every file that references it. Use this for any symbol you need to understand deeply.
|
|
32
|
+
|
|
33
|
+
4. **Map the call graph**
|
|
34
|
+
```bash
|
|
35
|
+
scip-query call-graph <function-name>
|
|
36
|
+
```
|
|
37
|
+
Returns: what calls this function (incoming) and what this function calls (outgoing). Gives you the function's role in the execution flow.
|
|
38
|
+
|
|
39
|
+
5. **Check blast radius**
|
|
40
|
+
```bash
|
|
41
|
+
scip-query affected <symbol-name>
|
|
42
|
+
```
|
|
43
|
+
Returns: the full transitive closure of symbols that could break if this symbol changes. Depth 1 = direct consumers. Depth 2 = consumers of consumers. Shows the complete ripple effect.
|
|
44
|
+
|
|
45
|
+
6. **Pre-change briefing**
|
|
46
|
+
```bash
|
|
47
|
+
scip-query change-surface <file>
|
|
48
|
+
```
|
|
49
|
+
Returns: every symbol in the file, how many external consumers each has, and a risk level (high/medium/low). Run this before modifying any file.
|
|
50
|
+
|
|
51
|
+
### What you should know after this workflow
|
|
52
|
+
|
|
53
|
+
- Every file in the module and what it contains
|
|
54
|
+
- The true public API (what consumers actually use)
|
|
55
|
+
- The full dependency graph (what the module depends on and what depends on it)
|
|
56
|
+
- The blast radius of any specific symbol change
|
|
57
|
+
- Which symbols are high-risk (many consumers, wide blast radius)
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Workflow 2: Write a concrete implementation plan
|
|
62
|
+
|
|
63
|
+
**Goal:** Produce an implementation plan where every file to create/modify is named, every symbol to change is identified with line numbers, every dependency is mapped, and every risk is called out.
|
|
64
|
+
|
|
65
|
+
### Steps
|
|
66
|
+
|
|
67
|
+
1. **Map the target area**
|
|
68
|
+
```bash
|
|
69
|
+
scip-query system <module-path>
|
|
70
|
+
scip-query outline <each-file-you-will-modify>
|
|
71
|
+
```
|
|
72
|
+
Get the structural outline with line ranges for every file in scope. Add `--signatures` only when type details are useful.
|
|
73
|
+
|
|
74
|
+
2. **Identify the public contract you must preserve**
|
|
75
|
+
```bash
|
|
76
|
+
scip-query surface <module-path>
|
|
77
|
+
```
|
|
78
|
+
Any symbol that appears here must maintain backward compatibility or all consumers must be updated.
|
|
79
|
+
|
|
80
|
+
3. **Map every symbol you plan to change**
|
|
81
|
+
```bash
|
|
82
|
+
scip-query refs <symbol> # who uses it
|
|
83
|
+
scip-query affected <symbol> # transitive blast radius
|
|
84
|
+
scip-query fan-in <symbol> # quantified consumer count
|
|
85
|
+
```
|
|
86
|
+
For each symbol you'll modify: know exactly who consumes it and how many layers deep the impact goes.
|
|
87
|
+
|
|
88
|
+
4. **Check blast radius before editing**
|
|
89
|
+
```bash
|
|
90
|
+
scip-query change-surface <file>
|
|
91
|
+
scip-query diff-impact
|
|
92
|
+
```
|
|
93
|
+
Identify which symbols in your change set have many external consumers and which downstream files will be affected.
|
|
94
|
+
|
|
95
|
+
5. **Find reusable code**
|
|
96
|
+
```bash
|
|
97
|
+
scip-query similar <symbol-you-plan-to-write>
|
|
98
|
+
scip-query deps <file>
|
|
99
|
+
```
|
|
100
|
+
Before writing new code, check if something similar already exists. `similar` finds functions with overlapping callee patterns. `deps` shows what the file already imports that you can reuse.
|
|
101
|
+
|
|
102
|
+
6. **After making changes, verify impact**
|
|
103
|
+
```bash
|
|
104
|
+
scip-query diff-impact
|
|
105
|
+
scip-query drift
|
|
106
|
+
```
|
|
107
|
+
Shows every symbol affected by your git diff, every consumer file impacted, and whether the change introduced new structural drift.
|
|
108
|
+
|
|
109
|
+
### Plan template
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
## Change: [description]
|
|
113
|
+
|
|
114
|
+
### Files to modify
|
|
115
|
+
- `path/to/file.ts` — [what changes, which symbols]
|
|
116
|
+
- `symbolName` (lines X-Y) — [change description]
|
|
117
|
+
- Fan-in: N, External consumers: N, Risk: low/medium/high
|
|
118
|
+
|
|
119
|
+
### Files to create
|
|
120
|
+
- `path/to/new-file.ts` — [purpose]
|
|
121
|
+
- Similar to: `existing-file.ts` (N% callee overlap via `similar`)
|
|
122
|
+
|
|
123
|
+
### Public contract impact
|
|
124
|
+
- `surface` shows N symbols consumed externally
|
|
125
|
+
- [List any breaking changes]
|
|
126
|
+
|
|
127
|
+
### Blast radius
|
|
128
|
+
- `affected` shows N symbols across M files at depth 1-2
|
|
129
|
+
- [List high-risk symbols]
|
|
130
|
+
|
|
131
|
+
### Impact checks
|
|
132
|
+
- `change-surface` shows N externally consumed symbols
|
|
133
|
+
- `diff-impact` shows N downstream consumer files
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Workflow 3: Clean up and de-bloat a codebase
|
|
139
|
+
|
|
140
|
+
**Goal:** Systematically reduce unnecessary code, eliminate duplication, and improve structural health.
|
|
141
|
+
|
|
142
|
+
### Steps
|
|
143
|
+
|
|
144
|
+
1. **Get the full health report**
|
|
145
|
+
```bash
|
|
146
|
+
scip-query health
|
|
147
|
+
```
|
|
148
|
+
This runs every analysis and produces a prioritized action list. Start here. The actions are sorted by impact/effort ratio — do the top ones first.
|
|
149
|
+
|
|
150
|
+
2. **Delete dead code (safest, highest impact)**
|
|
151
|
+
```bash
|
|
152
|
+
scip-query dead --min-loc 10 --skip-barrels
|
|
153
|
+
```
|
|
154
|
+
These symbols have zero cross-file references. They can be safely deleted. `--skip-barrels` ignores references from inactive barrel files, which helps surface exports kept alive only by unused re-export layers without hiding live package entry surfaces.
|
|
155
|
+
|
|
156
|
+
3. **Delete isolated symbols**
|
|
157
|
+
```bash
|
|
158
|
+
scip-query isolated --min-loc 5
|
|
159
|
+
```
|
|
160
|
+
Stricter than `dead` — these symbols have zero references anywhere, including in their own file. Completely disconnected from the codebase.
|
|
161
|
+
|
|
162
|
+
4. **Break circular dependencies**
|
|
163
|
+
```bash
|
|
164
|
+
scip-query cycles
|
|
165
|
+
```
|
|
166
|
+
If any exist, they need structural fixes: dependency inversion, module splitting, or interface extraction.
|
|
167
|
+
|
|
168
|
+
5. **Consolidate similar functions**
|
|
169
|
+
```bash
|
|
170
|
+
scip-query similar --min-similarity 0.5
|
|
171
|
+
```
|
|
172
|
+
Pairs of functions with overlapping callee sets. For each pair:
|
|
173
|
+
```bash
|
|
174
|
+
scip-query convergence <symbol1> <symbol2>
|
|
175
|
+
```
|
|
176
|
+
Shows what the consolidated version would look like: shared callees = common body, unique callees = parameterization points.
|
|
177
|
+
|
|
178
|
+
6. **Extract large functions**
|
|
179
|
+
```bash
|
|
180
|
+
scip-query extract-candidates --min-loc 20
|
|
181
|
+
```
|
|
182
|
+
Functions with isolated callee clusters — natural "Extract Method" seams.
|
|
183
|
+
|
|
184
|
+
7. **Remove unnecessary indirection**
|
|
185
|
+
```bash
|
|
186
|
+
scip-query wrapper-candidates
|
|
187
|
+
scip-query passthrough-candidates
|
|
188
|
+
```
|
|
189
|
+
Wrappers: single-consumer symbols that can be inlined. Passthroughs: functions that just forward to one callee.
|
|
190
|
+
|
|
191
|
+
8. **Prune premature abstractions**
|
|
192
|
+
```bash
|
|
193
|
+
scip-query stale-abstractions
|
|
194
|
+
```
|
|
195
|
+
Types and interfaces with 0-1 consumers. An interface with one implementation isn't an abstraction.
|
|
196
|
+
|
|
197
|
+
9. **Fix pattern drift**
|
|
198
|
+
```bash
|
|
199
|
+
scip-query drift
|
|
200
|
+
```
|
|
201
|
+
Files that deviate from their directory's typical dependency pattern. Bring them into line with their neighbors.
|
|
202
|
+
|
|
203
|
+
10. **Remove redundant re-exports**
|
|
204
|
+
```bash
|
|
205
|
+
scip-query redundant-reexports
|
|
206
|
+
```
|
|
207
|
+
Barrel file entries that nobody imports through. Clean up the barrel.
|
|
208
|
+
|
|
209
|
+
11. **Find same-shape functions**
|
|
210
|
+
```bash
|
|
211
|
+
scip-query similar-signatures --min-loc 5
|
|
212
|
+
```
|
|
213
|
+
Functions with identical parameter/return types. Different signal from callee similarity — catches "same interface, different implementation."
|
|
214
|
+
|
|
215
|
+
### Priority order
|
|
216
|
+
|
|
217
|
+
| Priority | What | Why |
|
|
218
|
+
|---|---|---|
|
|
219
|
+
| 1 | Dead code | Zero risk, immediate LOC reduction |
|
|
220
|
+
| 2 | Isolated symbols | Zero risk, zero consumers |
|
|
221
|
+
| 3 | Circular deps | Structural fix, prevents future problems |
|
|
222
|
+
| 4 | Similar functions | Reduces duplication, use `convergence` for prescription |
|
|
223
|
+
| 5 | Extraction candidates | Reduces function complexity |
|
|
224
|
+
| 6 | Wrappers / passthroughs | Removes unnecessary indirection |
|
|
225
|
+
| 7 | Stale abstractions | Removes premature over-engineering |
|
|
226
|
+
| 8 | Pattern drift | Consistency improvement |
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Workflow 4: Assess code quality and risk
|
|
231
|
+
|
|
232
|
+
**Goal:** Produce a quality assessment of a codebase or module with quantified metrics.
|
|
233
|
+
|
|
234
|
+
### Steps
|
|
235
|
+
|
|
236
|
+
1. **Overall health**
|
|
237
|
+
```bash
|
|
238
|
+
scip-query health
|
|
239
|
+
scip-query health --json # for programmatic use
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
2. **Complexity risks**
|
|
243
|
+
```bash
|
|
244
|
+
scip-query complexity-hotspots -n 20
|
|
245
|
+
```
|
|
246
|
+
Symbols with the highest composite score (LOC x fan-in x fan-out). These are the most likely to contain bugs and the hardest to modify.
|
|
247
|
+
|
|
248
|
+
3. **Coupling risks**
|
|
249
|
+
```bash
|
|
250
|
+
scip-query bottlenecks -n 20
|
|
251
|
+
```
|
|
252
|
+
Symbols with both high fan-in (many consumers) AND high fan-out (many dependencies). Changes to these are risky in both directions.
|
|
253
|
+
|
|
254
|
+
4. **Architecture depth**
|
|
255
|
+
```bash
|
|
256
|
+
scip-query deep-chains --min-depth 5
|
|
257
|
+
```
|
|
258
|
+
Long transitive dependency chains. If chains are deeper than 6-7, the architecture may need flattening.
|
|
259
|
+
|
|
260
|
+
5. **Structural drift**
|
|
261
|
+
```bash
|
|
262
|
+
scip-query drift
|
|
263
|
+
```
|
|
264
|
+
Files with unused imports, layer violations, or dependency profiles that deviate from their neighbors.
|
|
265
|
+
|
|
266
|
+
### Quality report template
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
## Quality Assessment: [project/module]
|
|
270
|
+
|
|
271
|
+
### Overview
|
|
272
|
+
- Files: N | Symbols: N | Index size: N
|
|
273
|
+
- Health score: N/100
|
|
274
|
+
|
|
275
|
+
### Risk Areas
|
|
276
|
+
- Complexity hotspots: [top 5 from complexity-hotspots]
|
|
277
|
+
- Coupling bottlenecks: [top 5 from bottlenecks]
|
|
278
|
+
- Deepest dependency chain: N layers
|
|
279
|
+
- Circular dependencies: N
|
|
280
|
+
|
|
281
|
+
### Structural quality
|
|
282
|
+
- Pattern drift: N files
|
|
283
|
+
|
|
284
|
+
### Cleanup Opportunities
|
|
285
|
+
- Dead code: N symbols (N LOC recoverable)
|
|
286
|
+
- Similar function pairs: N
|
|
287
|
+
- Stale abstractions: N
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## Workflow 5: Understand impact after making changes
|
|
293
|
+
|
|
294
|
+
**Goal:** After modifying code, verify what was affected and identify gaps.
|
|
295
|
+
|
|
296
|
+
### Steps
|
|
297
|
+
|
|
298
|
+
1. **Compute diff impact**
|
|
299
|
+
```bash
|
|
300
|
+
scip-query diff-impact
|
|
301
|
+
```
|
|
302
|
+
Shows: changed files, changed symbols with fan-in counts, and affected consumer files.
|
|
303
|
+
|
|
304
|
+
2. **Check transitive impact for critical symbols**
|
|
305
|
+
```bash
|
|
306
|
+
scip-query affected <changed-symbol>
|
|
307
|
+
```
|
|
308
|
+
For any high fan-in symbol that changed, check the full transitive blast wave.
|
|
309
|
+
|
|
310
|
+
3. **Re-check structural drift around the changed area**
|
|
311
|
+
```bash
|
|
312
|
+
scip-query drift
|
|
313
|
+
scip-query change-surface <changed-file>
|
|
314
|
+
```
|
|
315
|
+
Verify the change did not introduce new dependency-pattern outliers and understand the remaining blast radius.
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## Quick Reference
|
|
320
|
+
|
|
321
|
+
| I want to... | Run |
|
|
322
|
+
|---|---|
|
|
323
|
+
| Understand a module | `system <module>` |
|
|
324
|
+
| See what consumers actually use | `surface <module>` |
|
|
325
|
+
| Find all references to a symbol | `refs <symbol>` or `trace <symbol>` |
|
|
326
|
+
| See what a function calls and who calls it | `call-graph <symbol>` |
|
|
327
|
+
| Check blast radius of a change | `affected <symbol>` |
|
|
328
|
+
| Get a pre-change briefing | `change-surface <file>` |
|
|
329
|
+
| See impact of my git changes | `diff-impact` |
|
|
330
|
+
| Find dead code to delete | `dead --min-loc 10 --skip-barrels` |
|
|
331
|
+
| Find duplicate functions | `similar --min-similarity 0.5` |
|
|
332
|
+
| Find same-shape functions | `similar-signatures --min-loc 5` |
|
|
333
|
+
| Get a refactoring prescription | `convergence <sym1> <sym2>` |
|
|
334
|
+
| Find redundant barrel re-exports | `redundant-reexports` |
|
|
335
|
+
| Find extraction opportunities | `extract-candidates --min-loc 20` |
|
|
336
|
+
| Find unnecessary wrappers | `wrapper-candidates` |
|
|
337
|
+
| Find single-implementation types | `stale-abstractions` |
|
|
338
|
+
| Find pattern outliers | `drift` |
|
|
339
|
+
| Get overall codebase health | `health` |
|
|
340
|
+
| Find riskiest symbols | `complexity-hotspots` |
|
|
341
|
+
| Find coupling pressure points | `bottlenecks` |
|
|
342
|
+
| Find circular dependencies | `cycles` |
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
## Tips for AI Agents
|
|
346
|
+
|
|
347
|
+
- **Always reindex before analysis** if the codebase has changed significantly: `scip-query reindex`
|
|
348
|
+
- **Use `--json` on `health`** for programmatic consumption — parse the JSON to make decisions
|
|
349
|
+
- **Run `change-surface` before every file modification** — it takes <1 second and prevents surprises
|
|
350
|
+
- **Run `diff-impact` before committing** — catches unexpected blast radius across downstream consumers
|
|
351
|
+
- **Use `convergence` after `similar`** — `similar` finds the problem, `convergence` gives the solution
|
|
352
|
+
- **Start cleanup with `health`** — it prioritizes for you so you don't have to decide what to fix first
|
|
353
|
+
- **Scope commands with `-s`** — most commands accept `--scope <path>` to limit analysis to a specific module. Use this on large codebases to keep results focused.
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# The Ways AI Coding Rots a Codebase — and the Detector Built for Each
|
|
2
|
+
|
|
3
|
+
AI-assisted development fails in *specific, repeatable* ways. None of them are
|
|
4
|
+
visible in a single file, which is why linters and code review miss them: every
|
|
5
|
+
one lives in the relationships between files — the reference graph, the git
|
|
6
|
+
change graph, or the gap between docs and code. Each failure mode below names
|
|
7
|
+
the behavior, the detector built for it, exactly how to run it, and how to wire
|
|
8
|
+
it in so it gets caught automatically.
|
|
9
|
+
|
|
10
|
+
Every detector is evidence-ranked and honest about confidence: graph facts vs
|
|
11
|
+
heuristic candidates are labeled, and heuristic output always says so.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 1. Re-implementing code that already exists
|
|
16
|
+
|
|
17
|
+
**What the agent does:** it can't see the whole repo, so it writes a helper,
|
|
18
|
+
hook, composable, or frontend component that already exists - a date formatter,
|
|
19
|
+
a retry wrapper, a validation guard, a table toolbar. Now there are two implementations that drift independently until they
|
|
20
|
+
contradict each other.
|
|
21
|
+
|
|
22
|
+
**The detector:** `recent-duplicates` makes similarity *directional* using git
|
|
23
|
+
file ages - which side is the established original, which is the freshly-added
|
|
24
|
+
echo:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
91% ECHO react-component src/components/ProjectCardVisual.tsx ProjectCardVisual (added 62 commits ago)
|
|
28
|
+
duplicates established src/pages/HomePage.tsx RecentProjectRow()
|
|
29
|
+
basis: jsx-structure
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Use it:**
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
scip-query recent-duplicates # after any AI session
|
|
36
|
+
scip-query similar <closest-existing-fn> # BEFORE writing a new helper
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Caught automatically by:** the `echo` check in `diff-gate` — flags any
|
|
40
|
+
changed symbol that is ≥80% similar to established code elsewhere.
|
|
41
|
+
|
|
42
|
+
## 2. Duplicating itself within one session
|
|
43
|
+
|
|
44
|
+
**What the agent does:** generates the same function in two places during one
|
|
45
|
+
session — neither copy is "established," both are new, and they diverge from
|
|
46
|
+
day one.
|
|
47
|
+
|
|
48
|
+
**The detector:** `recent-duplicates` reports these as **TWIN** (both sides
|
|
49
|
+
inside the recency window) and tells you to pick one before they drift:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
100% TWIN src/workflows/a.ts ensureAccessible() / src/workflows/b.ts ensureAccessible()
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Use it:** `scip-query recent-duplicates` at the end of every agent session.
|
|
56
|
+
|
|
57
|
+
## 3. Extracting a helper but only migrating some call sites
|
|
58
|
+
|
|
59
|
+
**What the agent does:** creates an abstraction, rewires one or two call
|
|
60
|
+
sites into it, and abandons the rest — the extracted logic survives inline at
|
|
61
|
+
every site it missed. The codebase ends up with the worst of both worlds: an
|
|
62
|
+
abstraction *and* the duplication it was meant to remove.
|
|
63
|
+
|
|
64
|
+
**The detector:** `incomplete-migration` finds symbols that are new at the
|
|
65
|
+
base ref, confirms they were wired into at least one site, then reports
|
|
66
|
+
established untouched functions whose callee sets *contain* the helper's
|
|
67
|
+
(containment scoring, because a missed site holds the helper's logic plus its
|
|
68
|
+
own — symmetric similarity under-scores exactly these):
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
src:demo:summarize:recordScore() (src/demo/summarize.ts)
|
|
72
|
+
wired into: src/demo/report-a.ts
|
|
73
|
+
un-migrated: 100% buildReportB() (src/demo/report-b.ts)
|
|
74
|
+
un-migrated: 100% buildReportC() (src/demo/report-c.ts)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Use it:**
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
scip-query incomplete-migration # after any extraction
|
|
81
|
+
scip-query incomplete-migration --base origin/main # gate a whole branch
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Caught automatically by:** the `incomplete-migration` check in `diff-gate`.
|
|
85
|
+
|
|
86
|
+
## 4. Writing code that never gets wired up
|
|
87
|
+
|
|
88
|
+
**What the agent does:** builds the function, the type, the handler — and
|
|
89
|
+
never connects it. Or it *was* connected, then a later session rewired the
|
|
90
|
+
flow and left the original dangling. Dead code that looks intentional.
|
|
91
|
+
|
|
92
|
+
**The detectors:** `dead` (evidence-ranked, entrypoint-aware), and the
|
|
93
|
+
`new-dead` check in `diff-gate` that catches it *at the moment of creation*:
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
[new-dead] resolveTheme (src/theme.ts) was changed but has zero indexed consumers
|
|
97
|
+
-> Wire it up, or remove it before it becomes permanent dead code.
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Use it:**
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
scip-query dead --min-loc 10 --skip-barrels
|
|
104
|
+
scip-query isolated # whole files nothing imports
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## 5. Speculative generality — options and parameters "for later"
|
|
108
|
+
|
|
109
|
+
**What the agent does:** adds trailing parameters, option bags, and config
|
|
110
|
+
flags for futures that never arrive. Every one is permanent API surface that
|
|
111
|
+
every future reader has to understand.
|
|
112
|
+
|
|
113
|
+
**The detectors:** `unused-params` (trailing parameters no body uses, scoped
|
|
114
|
+
to removals that are type-safe by construction), plus the abstraction-level
|
|
115
|
+
versions: `wrapper-candidates` (functions that only forward),
|
|
116
|
+
`passthrough-candidates` (layers that add nothing), and `stale-abstractions`
|
|
117
|
+
(interfaces/bases with a single implementation).
|
|
118
|
+
|
|
119
|
+
**Use it:**
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
scip-query unused-params
|
|
123
|
+
scip-query wrapper-candidates
|
|
124
|
+
scip-query stale-abstractions
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Caught automatically by:** the `unused-params` check in `diff-gate`.
|
|
128
|
+
|
|
129
|
+
## 6. Letting the standards docs lie
|
|
130
|
+
|
|
131
|
+
**What the agent does:** nothing — that's the problem. You write in-repo
|
|
132
|
+
standards *for* agents; the code moves on; the doc doesn't. The next agent
|
|
133
|
+
reads the doc and faithfully implements against a dead spec. A stale standard
|
|
134
|
+
is worse than none.
|
|
135
|
+
|
|
136
|
+
**The detector:** `doc-drift` reads every doc's file citations *and* its
|
|
137
|
+
co-change history, and flags docs whose referenced code kept changing after
|
|
138
|
+
the doc stopped — including broken references to files that no longer exist:
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
staleness 94 product/domain-model.md
|
|
142
|
+
BROKEN REFERENCE: cites src/api/servicePlans.ts — that file no longer exists
|
|
143
|
+
22 change(s) since doc update src/workflows/serviceTasks.ts
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Use it:** `scip-query doc-drift`, then run the `scip-doc-reconcile` skill to
|
|
147
|
+
drive staleness to zero (it updates descriptive claims and *escalates*
|
|
148
|
+
normative violations instead of silently blessing them).
|
|
149
|
+
|
|
150
|
+
**Caught automatically by:** the `doc-reference` check in `diff-gate` — a doc
|
|
151
|
+
cites a file you changed and wasn't updated in the same diff.
|
|
152
|
+
|
|
153
|
+
## 7. Editing one side of an invisible contract
|
|
154
|
+
|
|
155
|
+
**What the agent does:** changes the schema but not the generated inventory;
|
|
156
|
+
the `.env.example` but not its parser; the API contract but not the frontend
|
|
157
|
+
store. The reference graph can't see these pairs — no import connects them —
|
|
158
|
+
but git history can: they've changed together in 12 of the last 14 commits.
|
|
159
|
+
|
|
160
|
+
**The detector:** `co-change` finds file pairs that repeatedly change in the
|
|
161
|
+
same commits with *no* dependency edge.
|
|
162
|
+
|
|
163
|
+
**Use it:**
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
scip-query co-change # repo-wide hidden coupling
|
|
167
|
+
scip-query co-change src/db/schema.prisma # partners of one file
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Caught automatically by:** the `co-change-partner` check in `diff-gate`:
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
[co-change-partner] schema.prisma changed, but scripts/scope-inventory.mjs did not — they change together 12x (86%)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## 8. Deleting things that are still used — or refusing to delete at all
|
|
177
|
+
|
|
178
|
+
**What the agent does:** both. It deletes a "dead" function that a dynamic
|
|
179
|
+
path still references, or it hoards code because it can't prove anything is
|
|
180
|
+
safe to remove.
|
|
181
|
+
|
|
182
|
+
**The detector:** `cleanup-plan` runs dead-code analysis to a *fixpoint* —
|
|
183
|
+
deleting batch 0 makes batch 1 dead, and the plan shows the cascade. Then
|
|
184
|
+
`--verify` applies each batch in a throwaway git worktree and runs **your own
|
|
185
|
+
compiler** (tsc, cargo, go, python oracles — differentially, so pre-existing
|
|
186
|
+
errors don't drown the signal):
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
── Batch 0: deletable now (graph-fact, 67 LOC) ──
|
|
190
|
+
Batch 0: COMPILER-VERIFIED
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
When verification fails, the errors name the exact references the static
|
|
194
|
+
evidence missed. Delete with a proof in hand, not vibes.
|
|
195
|
+
|
|
196
|
+
**Use it:**
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
scip-query cleanup-plan --verify
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## 9. Making every change blind to its blast radius
|
|
203
|
+
|
|
204
|
+
**What the agent does:** edits a symbol without knowing who consumes it, what
|
|
205
|
+
breaks transitively, or which files historically move together with it — then
|
|
206
|
+
"finishes" with three consumers silently broken.
|
|
207
|
+
|
|
208
|
+
**The detectors:** `plan-context` (one command bundling definitions,
|
|
209
|
+
references, call graph, blast radius, churn, and co-change partners — the
|
|
210
|
+
pre-edit briefing), `change-surface`, `affected`, `diff-impact`.
|
|
211
|
+
|
|
212
|
+
**Use it:**
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
scip-query plan-context <symbol-or-file> # before the edit
|
|
216
|
+
scip-query diff-impact # after the edit
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
The `concrete-plan` skill enforces this end-to-end: every step in a plan must
|
|
220
|
+
cite the scip-query command that verified it.
|
|
221
|
+
|
|
222
|
+
## 10. Slow quality decay nobody notices
|
|
223
|
+
|
|
224
|
+
**What the agent does:** each session adds a little rot. No single diff is
|
|
225
|
+
alarming; six weeks later the repo is unrecognizable.
|
|
226
|
+
|
|
227
|
+
**The detector:** the ratchet. `health --write-baseline` snapshots finding
|
|
228
|
+
identities into a committable file; `health --baseline` exits 1 on any *new*
|
|
229
|
+
finding. "Don't get worse" becomes an objective gate no score arithmetic can
|
|
230
|
+
game.
|
|
231
|
+
|
|
232
|
+
**Use it:**
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
scip-query health --write-baseline # once, committed
|
|
236
|
+
scip-query health --baseline # in CI
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Caught automatically by:** the `baseline` check in `diff-gate`.
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Wiring it all up so nobody has to remember any of this
|
|
244
|
+
|
|
245
|
+
The detectors only help if they run. Three layers, in increasing strength:
|
|
246
|
+
|
|
247
|
+
**1. Skills (routing).** Installing scip-query symlinks nine skills into
|
|
248
|
+
`~/.agents/skills/`, `~/.claude/skills/`, and `~/.codex/skills/` — they update
|
|
249
|
+
automatically with the package. The `scip-query` router skill triggers on any
|
|
250
|
+
codebase work and dispatches to the right specialist (explore → plan →
|
|
251
|
+
implement → verify → clean up), carrying the non-negotiables: similarity check
|
|
252
|
+
before new helpers, `incomplete-migration` after extractions, `diff-gate`
|
|
253
|
+
before done.
|
|
254
|
+
|
|
255
|
+
**2. Project guidance (instructions).** Run once per project:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
scip-query setup-agent
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Seeds a managed block in `AGENTS.md` (the cross-tool standard Codex, Cursor,
|
|
262
|
+
Gemini, and others read) pointing at the router skill and the gate — plus an
|
|
263
|
+
`@AGENTS.md` import shim in `CLAUDE.md`, because Claude Code doesn't read
|
|
264
|
+
AGENTS.md natively. Only the marked block is ever managed; your content is
|
|
265
|
+
never touched, and an existing `@AGENTS.md` bridge is left alone.
|
|
266
|
+
|
|
267
|
+
**3. The gate (enforcement).**
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
scip-query diff-gate # one command, every check above, scoped to the diff, exit 1 on findings
|
|
271
|
+
scip-query setup-agent --git-hook # pre-commit backstop: fires whoever wrote the diff
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Every finding ships with a remediation an agent can act on without human
|
|
275
|
+
triage. For in-session enforcement, `diff-gate --hook` speaks the turn-end
|
|
276
|
+
hook contract shared by Claude Code, Codex, and Gemini CLI (blocks the agent's
|
|
277
|
+
"done" and feeds the findings back as its next prompt) — wire it into your
|
|
278
|
+
tool's hook config if you want the gate to be unskippable.
|
package/docs/API.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Programmatic API
|
|
2
|
+
|
|
3
|
+
Every CLI command is also available as a TypeScript function. The `queries` namespace exports cover the public commands, including the `top*` variants of `fan-in`, `fan-out`, and `coupling`, plus `similarAll` for the cross-codebase mode of `similar`.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
import { ScipDatabase, createGitignoreFilter } from 'scip-query';
|
|
7
|
+
import {
|
|
8
|
+
health,
|
|
9
|
+
affected,
|
|
10
|
+
changeSurface,
|
|
11
|
+
diffImpact,
|
|
12
|
+
hotspots,
|
|
13
|
+
similar,
|
|
14
|
+
dead,
|
|
15
|
+
convergence,
|
|
16
|
+
} from 'scip-query/queries';
|
|
17
|
+
|
|
18
|
+
const filter = createGitignoreFilter('/path/to/project');
|
|
19
|
+
const db = new ScipDatabase(
|
|
20
|
+
{
|
|
21
|
+
dbPath: '/path/to/index.db',
|
|
22
|
+
indexPath: '/path/to/index.scip',
|
|
23
|
+
projectRoot: '/path/to/project',
|
|
24
|
+
},
|
|
25
|
+
filter,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const report = health(db);
|
|
29
|
+
console.log(`Score: ${report.score}/100`);
|
|
30
|
+
console.log(`Actions: ${report.actions.length}`);
|
|
31
|
+
|
|
32
|
+
const blast = affected(db, 'login', { maxDepth: 3 });
|
|
33
|
+
const brief = changeSurface(db, 'auth.service.ts');
|
|
34
|
+
const impact = diffImpact(db, { base: 'main' });
|
|
35
|
+
|
|
36
|
+
const pairs = similar(db, 'myFunction', { minSimilarity: 0.5 });
|
|
37
|
+
const recipe = convergence(db, 'funcA', 'funcB');
|
|
38
|
+
|
|
39
|
+
db.close();
|
|
40
|
+
```
|