@codragraph/cli 1.6.4 → 2.1.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 (105) hide show
  1. package/README.md +34 -0
  2. package/dist/_shared/cgdb/schema-constants.d.ts +16 -0
  3. package/dist/_shared/cgdb/schema-constants.d.ts.map +1 -0
  4. package/dist/_shared/cgdb/schema-constants.js +67 -0
  5. package/dist/_shared/cgdb/schema-constants.js.map +1 -0
  6. package/dist/_shared/index.d.ts +2 -2
  7. package/dist/_shared/index.js +1 -1
  8. package/dist/cli/analyze.d.ts +22 -0
  9. package/dist/cli/analyze.js +109 -6
  10. package/dist/cli/compress-stats.d.ts +29 -0
  11. package/dist/cli/compress-stats.js +97 -0
  12. package/dist/cli/graphstore.d.ts +6 -2
  13. package/dist/cli/graphstore.js +45 -23
  14. package/dist/cli/index-repo.js +3 -3
  15. package/dist/cli/index.js +16 -2
  16. package/dist/cli/profile-heap.d.ts +35 -0
  17. package/dist/cli/profile-heap.js +126 -0
  18. package/dist/cli/setup.d.ts +13 -0
  19. package/dist/cli/setup.js +22 -11
  20. package/dist/cli/skill-gen.d.ts +14 -2
  21. package/dist/cli/skill-gen.js +52 -19
  22. package/dist/cli/tool.js +4 -0
  23. package/dist/cli/wiki.js +3 -3
  24. package/dist/core/augmentation/engine.js +7 -7
  25. package/dist/core/cgdb/cgdb-adapter.d.ts +176 -0
  26. package/dist/core/cgdb/cgdb-adapter.js +1320 -0
  27. package/dist/core/cgdb/content-read.d.ts +46 -0
  28. package/dist/core/cgdb/content-read.js +64 -0
  29. package/dist/core/cgdb/csv-generator.d.ts +29 -0
  30. package/dist/core/cgdb/csv-generator.js +492 -0
  31. package/dist/core/cgdb/pool-adapter.d.ts +93 -0
  32. package/dist/core/cgdb/pool-adapter.js +550 -0
  33. package/dist/core/cgdb/schema.d.ts +62 -0
  34. package/dist/core/cgdb/schema.js +502 -0
  35. package/dist/core/embeddings/embedding-pipeline.js +27 -10
  36. package/dist/core/graphstore/cgdb-row-source.d.ts +19 -0
  37. package/dist/core/graphstore/cgdb-row-source.js +141 -0
  38. package/dist/core/graphstore/index.d.ts +1 -1
  39. package/dist/core/graphstore/index.js +3 -3
  40. package/dist/core/group/bridge-db.d.ts +2 -2
  41. package/dist/core/group/bridge-db.js +123 -36
  42. package/dist/core/group/bridge-schema.d.ts +4 -4
  43. package/dist/core/group/bridge-schema.js +4 -4
  44. package/dist/core/group/cross-impact.js +3 -3
  45. package/dist/core/group/sync.js +4 -4
  46. package/dist/core/lbug/content-read.d.ts +46 -0
  47. package/dist/core/lbug/content-read.js +64 -0
  48. package/dist/core/lbug/csv-generator.d.ts +2 -6
  49. package/dist/core/lbug/csv-generator.js +45 -12
  50. package/dist/core/lbug/lbug-adapter.d.ts +4 -1
  51. package/dist/core/lbug/lbug-adapter.js +153 -21
  52. package/dist/core/lbug/schema.d.ts +7 -7
  53. package/dist/core/lbug/schema.js +18 -0
  54. package/dist/core/run-analyze.d.ts +13 -0
  55. package/dist/core/run-analyze.js +114 -27
  56. package/dist/core/search/bm25-index.d.ts +3 -3
  57. package/dist/core/search/bm25-index.js +75 -23
  58. package/dist/core/search/hybrid-search.js +2 -2
  59. package/dist/core/wiki/generator.d.ts +2 -2
  60. package/dist/core/wiki/generator.js +4 -4
  61. package/dist/core/wiki/graph-queries.d.ts +2 -2
  62. package/dist/core/wiki/graph-queries.js +5 -5
  63. package/dist/mcp/core/cgdb-adapter.d.ts +5 -0
  64. package/dist/mcp/core/cgdb-adapter.js +5 -0
  65. package/dist/mcp/core/embedder.js +1 -1
  66. package/dist/mcp/local/local-backend.d.ts +2 -2
  67. package/dist/mcp/local/local-backend.js +36 -19
  68. package/dist/mcp/server.js +3 -3
  69. package/dist/mcp/tools.js +1 -1
  70. package/dist/server/analyze-worker.js +2 -2
  71. package/dist/server/api.js +34 -33
  72. package/dist/storage/repo-manager.d.ts +42 -3
  73. package/dist/storage/repo-manager.js +23 -4
  74. package/hooks/claude/codragraph-hook.cjs +98 -5
  75. package/package.json +4 -4
  76. package/scripts/build-tree-sitter-proto.cjs +15 -3
  77. package/scripts/build.js +8 -9
  78. package/scripts/patch-tree-sitter-swift.cjs +17 -4
  79. package/skills/codragraph-api-surface.md +110 -0
  80. package/skills/codragraph-config-audit.md +146 -0
  81. package/skills/codragraph-cross-repo-impact.md +135 -0
  82. package/skills/codragraph-data-lineage.md +137 -0
  83. package/skills/codragraph-dead-code.md +119 -0
  84. package/skills/codragraph-gh-actions-debug.md +162 -0
  85. package/skills/codragraph-gh-issue-workflow.md +178 -0
  86. package/skills/codragraph-gh-pr-workflow.md +176 -0
  87. package/skills/codragraph-gh-release-workflow.md +187 -0
  88. package/skills/codragraph-git-bisect.md +176 -0
  89. package/skills/codragraph-git-force-push.md +147 -0
  90. package/skills/codragraph-git-history-rewrite.md +174 -0
  91. package/skills/codragraph-git-rebase-vs-merge.md +138 -0
  92. package/skills/codragraph-git-recovery.md +181 -0
  93. package/skills/codragraph-git-worktree.md +145 -0
  94. package/skills/codragraph-migration-tracking.md +130 -0
  95. package/skills/codragraph-notebook-context.md +136 -0
  96. package/skills/codragraph-observability-coverage.md +125 -0
  97. package/skills/codragraph-onboarding.md +129 -0
  98. package/skills/codragraph-perf-hotspots.md +132 -0
  99. package/skills/codragraph-project-switcher.md +116 -0
  100. package/skills/codragraph-security-audit.md +144 -0
  101. package/skills/codragraph-sql-tracing.md +122 -0
  102. package/skills/codragraph-supply-chain-audit.md +153 -0
  103. package/skills/codragraph-test-coverage.md +97 -0
  104. package/vendor/tree-sitter-proto/bindings/node/index.js +3 -3
  105. package/vendor/tree-sitter-proto/src/node-types.json +1 -1
@@ -0,0 +1,130 @@
1
+ ---
2
+ name: codragraph-migration-tracking
3
+ description: "Use when tracking the progress of a phased refactor or migration (renaming an API, swapping a library, moving from class- to functional-components, deprecating a flag). Examples: \"how far is the migration\", \"what's left to migrate\", \"track this refactor\", \"are we done with the move from X to Y\", \"is the migration done\""
4
+ ---
5
+
6
+ # Migration Progress Tracking with CodraGraph
7
+
8
+ ## When to Use
9
+
10
+ - "How far along is the migration from `<old>` to `<new>`?"
11
+ - "What's left to migrate / refactor / deprecate?"
12
+ - "Are we done with `<old API>`?"
13
+ - Coordinating a phased refactor across many PRs
14
+ - Reporting migration status to stakeholders
15
+
16
+ ## Why CodraGraph helps here
17
+
18
+ Migrations span dozens of PRs and weeks. Without a structural index, the
19
+ question "are we done?" reduces to grep-and-eyeball. CodraGraph's versioned
20
+ graphstore lets you snapshot the codebase at the start of the migration,
21
+ then diff against today to see exactly what's converted and what isn't.
22
+ Pair with `cypher` to count remaining instances of the old pattern.
23
+
24
+ ## Workflow
25
+
26
+ ```
27
+ 1. Establish baseline (once, at migration start):
28
+ codragraph commit -m "migration baseline: pre-X-removal"
29
+ codragraph branch create migration-baseline
30
+ → captures the structural state for later comparison
31
+
32
+ 2. Count remaining old-API call sites today:
33
+ codragraph_cypher({query: `
34
+ MATCH (n)-[:CALLS]->(target)
35
+ WHERE target.name = '<oldFunction>'
36
+ RETURN n.filePath, count(n) AS callers
37
+ ORDER BY callers DESC
38
+ `})
39
+ → "27 callers in 14 files still using <oldFunction>"
40
+
41
+ 3. Diff against the baseline to see structural progress:
42
+ codragraph diff migration-baseline HEAD --semantic --json
43
+ → look at removedAPIs (old surface gone), addedAPIs (new surface added),
44
+ classifiedModifications (signatures swapped)
45
+
46
+ 4. Assess flows still touching the old API:
47
+ codragraph_impact({target: "<oldFunction>", direction: "upstream"})
48
+ → list of remaining callers grouped by depth
49
+
50
+ 5. Suggest the next batch of files to migrate (highest caller-count first)
51
+ ```
52
+
53
+ > If `migration-baseline` doesn't exist, you skipped step 1 — fall back to
54
+ > the earliest commit in `codragraph log` as a baseline (less precise but
55
+ > usable).
56
+
57
+ ## Checklist
58
+
59
+ ```
60
+ - [ ] Establish a baseline (branch / tagged commit) at migration start
61
+ - [ ] Cypher count of remaining old-API references
62
+ - [ ] codragraph diff baseline HEAD --semantic for structural progress
63
+ - [ ] impact upstream on the old API → list of remaining callers
64
+ - [ ] Group remaining work by file → suggest next batch
65
+ - [ ] Report: "<N>%% of <total> call sites converted. <K> files remaining."
66
+ ```
67
+
68
+ ## Migration Patterns This Catches
69
+
70
+ | Pattern | Cypher hint |
71
+ | --- | --- |
72
+ | API rename (foo → bar) | `MATCH ()-[:CALLS]->(n) WHERE n.name = 'foo' RETURN n.filePath, count(*)` |
73
+ | Library swap (lodash → native) | Filter on `filePath` for files still importing the old library |
74
+ | Class → functional component | Match by `n.label = 'Class'` in the relevant directory |
75
+ | Feature flag removal | Cypher for string literals matching the flag name |
76
+ | Type-system migration (any → typed) | `MATCH (n) WHERE n.returnType = 'any' OR n.returnType IS NULL` |
77
+
78
+ ## Example: "Track our migration from `validatePaymentV1` to `validatePaymentV2`"
79
+
80
+ ```
81
+ 1. (Baseline established 3 months ago: codragraph branch migration-v2-start)
82
+
83
+ 2. codragraph_cypher({query: `
84
+ MATCH (caller)-[:CALLS]->(target)
85
+ WHERE target.name STARTS WITH 'validatePayment'
86
+ RETURN target.name, count(caller) AS callers
87
+ `})
88
+ → validatePaymentV1: 8 callers
89
+ → validatePaymentV2: 31 callers
90
+
91
+ 3. codragraph diff migration-v2-start HEAD --semantic
92
+ → addedAPIs: validatePaymentV2 (and 4 helpers)
93
+ → classifiedModifications: 23 functions migrated from V1 to V2
94
+ → removedAPIs: 0 (V1 still exported)
95
+
96
+ 4. codragraph_impact({target: "validatePaymentV1", direction: "upstream"})
97
+ → d=1 callers (still on V1):
98
+ - legacyCheckout (src/legacy/checkout.ts)
99
+ - webhookV1 (src/webhooks/v1.ts)
100
+ - … 6 more
101
+
102
+ Report: 79%% migrated (31 / 39 callers). 8 callers in 3 files remaining.
103
+ Next batch: src/legacy/checkout.ts (5 callers in one file).
104
+ ```
105
+
106
+ ## Output Format
107
+
108
+ ```markdown
109
+ ## Migration Progress: <name>
110
+
111
+ ### Baseline
112
+ `migration-baseline` (3 months ago, before refactor started)
113
+
114
+ ### Current state
115
+ - **Converted:** 31 / 39 call sites (79%%)
116
+ - **Remaining:** 8 callers in 3 files
117
+ - **Old API surface:** still exported (cannot remove yet)
118
+ - **New API surface:** stable (4 helpers added)
119
+
120
+ ### Remaining work
121
+ | File | Old-API callers | Notes |
122
+ | --- | --- | --- |
123
+ | `src/legacy/checkout.ts` | 5 | one batch |
124
+ | `src/webhooks/v1.ts` | 2 | tied to legacy webhook contract |
125
+ | ... | ... | ... |
126
+
127
+ ### Done criteria
128
+ - 0 remaining callers
129
+ - removedAPIs in `codragraph diff` includes `validatePaymentV1`
130
+ ```
@@ -0,0 +1,136 @@
1
+ ---
2
+ name: codragraph-notebook-context
3
+ description: "Use when working with notebook-heavy projects (Jupyter, Databricks, Colab, Marimo) where each notebook contains long pipelines of cells, and the user needs to navigate, summarize, or refactor across them. Examples: \"what do these notebooks do\", \"summarize this analysis pipeline\", \"refactor cells from this notebook into modules\", \"data analysis project tour\""
4
+ ---
5
+
6
+ # Notebook-Heavy Project Navigation with CodraGraph
7
+
8
+ ## When to Use
9
+
10
+ - "What's in these notebooks?"
11
+ - "Summarize the analysis pipeline across `<notebook>.ipynb`"
12
+ - "Help me refactor a notebook into a proper module"
13
+ - "What functions defined in notebooks does the production code call?"
14
+ - "Audit the data analyses in this project"
15
+
16
+ ## Why CodraGraph helps here
17
+
18
+ Data-science / analytics projects often have 80%% of the logic inside
19
+ `.ipynb` files: top-level imports, helper functions, ad-hoc transforms.
20
+ CodraGraph indexes Python (the most common notebook language) and treats
21
+ notebook-derived code as first-class graph content. That means `query`,
22
+ `context`, and `impact` work on notebook-defined symbols just like
23
+ production-code symbols, so you can navigate a 30-cell notebook the same
24
+ way you'd navigate a typical module.
25
+
26
+ ## Workflow
27
+
28
+ ```
29
+ 1. List notebook-derived symbols:
30
+ codragraph_cypher({query: `
31
+ MATCH (n)
32
+ WHERE n.filePath ENDS WITH '.ipynb'
33
+ RETURN n.filePath, n.name, labels(n)[0] AS label
34
+ ORDER BY n.filePath, n.startLine
35
+ `})
36
+ → every function/class defined inside any notebook
37
+
38
+ 2. For each notebook of interest:
39
+ codragraph_query({query: "<notebook concept, e.g. 'monthly retention'>"})
40
+ → top-ranked symbols across notebooks (process-grouped)
41
+
42
+ 3. codragraph_context({name: "<notebook function>"})
43
+ → callers (other notebooks? production?) and callees (libraries used)
44
+
45
+ 4. Cross-notebook reuse check:
46
+ codragraph_impact({target: "<helper>", direction: "upstream"})
47
+ → if multiple notebooks call the same helper, that's a refactor candidate
48
+ (extract into a shared module)
49
+
50
+ 5. Production / notebook bridge:
51
+ codragraph_cypher({query: `
52
+ MATCH (caller)-[:CALLS]->(target)
53
+ WHERE NOT caller.filePath ENDS WITH '.ipynb'
54
+ AND target.filePath ENDS WITH '.ipynb'
55
+ RETURN caller.filePath, target.filePath, target.name
56
+ `})
57
+ → production code calling into notebooks (usually a bug — flag it)
58
+ ```
59
+
60
+ > Notebooks export when wrapped in nbconvert / papermill / databricks-cli.
61
+ > CodraGraph parses the `.ipynb` JSON and treats each code cell as part of
62
+ > the file's symbol space.
63
+
64
+ ## Checklist
65
+
66
+ ```
67
+ - [ ] Cypher query for all symbols with .ipynb file paths
68
+ - [ ] Group by notebook → see total symbol count per notebook
69
+ - [ ] query for the analysis topic to find top-ranked symbols
70
+ - [ ] context on key notebook helpers
71
+ - [ ] impact upstream on cross-notebook helpers → refactor candidates
72
+ - [ ] Cypher for production-code → notebook calls (bridge audit)
73
+ ```
74
+
75
+ ## Refactor Signals
76
+
77
+ | Signal | What to do |
78
+ | --- | --- |
79
+ | Same helper defined in 3+ notebooks | Extract into a shared `.py` module |
80
+ | Notebook function called from production code | Move to production module; notebook should re-import |
81
+ | Notebook with > 30 distinct symbols | Likely needs to be split (or graduated to a module) |
82
+ | Notebook calling another notebook | Strong refactor signal — extract the shared part |
83
+
84
+ ## Example: "Summarize the customer-churn analyses in notebooks/"
85
+
86
+ ```
87
+ 1. codragraph_cypher({
88
+ query: `MATCH (n) WHERE n.filePath STARTS WITH 'notebooks/'
89
+ AND n.filePath ENDS WITH '.ipynb'
90
+ RETURN n.filePath, count(n) AS symbols
91
+ ORDER BY symbols DESC`
92
+ })
93
+ → 4 notebooks: churn_baseline.ipynb (28 symbols),
94
+ churn_features.ipynb (35 symbols),
95
+ churn_model.ipynb (22 symbols),
96
+ churn_eval.ipynb (12 symbols)
97
+
98
+ 2. codragraph_query({query: "customer churn cohort"})
99
+ → top symbols across the 4 notebooks, grouped by detected processes
100
+
101
+ 3. codragraph_context({name: "compute_cohort_retention"})
102
+ → defined in: churn_features.ipynb
103
+ → called by: churn_model.ipynb, churn_eval.ipynb (TWO notebooks)
104
+ → REFACTOR CANDIDATE — extract into src/churn/cohort.py
105
+
106
+ 4. codragraph_cypher for production → notebook calls
107
+ → 1 hit: scripts/daily_churn_report.py imports from churn_eval.ipynb ⚠
108
+ → Production should not depend on a notebook. Extract.
109
+
110
+ Findings:
111
+ - 97 total symbols across 4 notebooks
112
+ - 1 multi-notebook helper (compute_cohort_retention) → extract to module
113
+ - 1 production → notebook bridge (daily_churn_report) → flag as tech debt
114
+ ```
115
+
116
+ ## Output Format
117
+
118
+ ```markdown
119
+ ## Notebook Tour: `notebooks/`
120
+
121
+ ### Notebooks
122
+ | Notebook | Symbols | Purpose (top-3 symbols) |
123
+ | --- | --- | --- |
124
+ | churn_baseline.ipynb | 28 | baseline_churn_rate, … |
125
+ | churn_features.ipynb | 35 | compute_cohort_retention, … |
126
+ | churn_model.ipynb | 22 | train_churn_classifier, … |
127
+ | churn_eval.ipynb | 12 | evaluate_churn_model, … |
128
+
129
+ ### Refactor candidates
130
+ 1. `compute_cohort_retention` — used in 2 notebooks → extract to `src/churn/cohort.py`
131
+ 2. ...
132
+
133
+ ### Bridge audits
134
+ - ⚠ `scripts/daily_churn_report.py` imports from `churn_eval.ipynb` —
135
+ production should not depend on a notebook.
136
+ ```
@@ -0,0 +1,125 @@
1
+ ---
2
+ name: codragraph-observability-coverage
3
+ description: "Use to audit observability coverage — which functions / processes have logs, metrics, or distributed-trace spans, and which don't. Find the dark corners where you're flying blind. Examples: \"observability coverage\", \"unlogged code\", \"missing traces\", \"telemetry audit\", \"where are we flying blind\""
4
+ ---
5
+
6
+ # Observability Coverage Audit with CodraGraph
7
+
8
+ ## When to Use
9
+
10
+ - "Which functions have NO logs / metrics / traces?"
11
+ - "Audit telemetry coverage on the request path."
12
+ - "Find dark spots in my observability."
13
+ - "Are all my critical processes instrumented?"
14
+ - Post-incident review: "did we have visibility into X?"
15
+
16
+ ## Why CodraGraph helps here
17
+
18
+ Telemetry calls are just function calls — `logger.info(...)`,
19
+ `tracer.startSpan(...)`, `metrics.histogram(...)`. CodraGraph's call
20
+ graph shows you exactly which symbols invoke them. Subtract those from
21
+ your full symbol set: the difference is your dark zone.
22
+
23
+ ## Workflow
24
+
25
+ ```
26
+ 1. Identify your telemetry surface area:
27
+ codragraph_query({query: "logger trace span metric histogram counter"})
28
+ → list of telemetry-emitting helpers (logger.info, span.end, metrics.timing, ...)
29
+
30
+ 2. For each telemetry helper, find its callers:
31
+ codragraph_cypher({query: `
32
+ MATCH (caller)-[:CALLS]->(t {name: '<telemetry-fn>'})
33
+ RETURN DISTINCT caller.id, caller.name
34
+ `})
35
+ → "instrumented" set: every function that emits telemetry
36
+
37
+ 3. Map your critical surface (processes / entry points):
38
+ READ codragraph://repo/{name}/processes
39
+ → request-path / job-path flows
40
+
41
+ 4. Subtract: which symbols in critical processes are NOT in the
42
+ instrumented set?
43
+ codragraph_cypher({query: `
44
+ MATCH (n {label: 'Function'})
45
+ WHERE n.isEntryPoint = true
46
+ AND NOT EXISTS {
47
+ MATCH (n)-[:CALLS*1..3]->(t)
48
+ WHERE t.name STARTS WITH 'logger.'
49
+ OR t.name STARTS WITH 'tracer.'
50
+ OR t.name STARTS WITH 'metrics.'
51
+ }
52
+ RETURN n.name, n.filePath
53
+ `})
54
+ → entry points with NO telemetry within 3 hops = dark zones
55
+
56
+ 5. For each dark zone, codragraph_context to confirm and propose
57
+ minimum-viable instrumentation (one log line + one span)
58
+ ```
59
+
60
+ ## Coverage tiers
61
+
62
+ | Tier | What's covered | What it tells you |
63
+ |---|---|---|
64
+ | **None** | No telemetry within 3 hops of entry point | Flying blind under load |
65
+ | **Logs only** | `logger.*` reachable but no `tracer.*` / `metrics.*` | Can debug post-hoc, can't query prod |
66
+ | **Logs + metrics** | Counters / histograms emitted | Dashboards possible |
67
+ | **Logs + metrics + traces** | Spans tied to request flow | Full observability |
68
+ | **Structured + correlated** | All three with a request_id propagated | Best — can chase one user through everything |
69
+
70
+ ## Checklist
71
+
72
+ ```
73
+ - [ ] Listed telemetry-emitting helpers (logger / tracer / metrics)
74
+ - [ ] Resolved their direct callers (instrumented set)
75
+ - [ ] Listed critical processes / entry points
76
+ - [ ] Subtracted: which entry points have no telemetry within 3 hops?
77
+ - [ ] For each gap, propose minimum-viable instrumentation
78
+ - [ ] Tier-rate each critical flow (None / Logs / Metrics / Traces / Correlated)
79
+ ```
80
+
81
+ ## Example: "Audit observability on our checkout flow"
82
+
83
+ ```
84
+ 1. codragraph_query({query: "checkout payment process"})
85
+ → CheckoutFlow process: 7 steps (validateCart → reservePayment →
86
+ captureFunds → createOrder → notifyShip → emitReceipt → done)
87
+
88
+ 2. Telemetry helpers:
89
+ - logger.info, logger.warn, logger.error
90
+ - tracer.startSpan, span.end
91
+ - metrics.histogram, metrics.counter
92
+
93
+ 3. For each step in CheckoutFlow:
94
+ codragraph_context({name: "<step>"})
95
+ → check callees include any telemetry helper
96
+
97
+ - validateCart → logger.info ✓, tracer ✓, metrics ✗
98
+ - reservePayment → logger.info ✓, tracer ✓, metrics ✗
99
+ - captureFunds → logger.info ✓, tracer ✗, metrics ✗ ⚠
100
+ - createOrder → logger.info ✓, tracer ✓, metrics ✓
101
+ - notifyShip → ⚠ NOTHING (dark zone)
102
+ - emitReceipt → logger.info ✓
103
+ - done → logger.info ✓
104
+
105
+ 4. Gaps:
106
+ - notifyShip: entirely unobserved. Add tracer.startSpan + counter on
107
+ success/failure. Cheapest fix to close the gap.
108
+ - captureFunds: missing tracer span around the actual capture call.
109
+ Add for distributed-trace correlation with payment provider.
110
+ - validateCart, reservePayment, captureFunds: missing latency histograms.
111
+ Add metrics.timing for each.
112
+
113
+ Tier rating: Logs ✓, Metrics partial ⚠, Traces partial ⚠, Correlated ✓
114
+ (request_id is propagated end-to-end where instrumentation exists).
115
+ ```
116
+
117
+ ## Pitfalls
118
+
119
+ | Pitfall | Symptom | Fix |
120
+ |---|---|---|
121
+ | Telemetry behind a façade | Direct caller is your `obs.log()` wrapper, not `logger.info` | Search for the wrapper too |
122
+ | Conditional logging only on errors | "Looks instrumented" but emits nothing on the happy path | Audit success paths separately |
123
+ | Telemetry in middleware, missing in handler | Edge instrumentation doesn't show handler-internal state | Check both layers |
124
+ | Excessive logging in hot loops | Coverage looks great, dashboards drown in noise | Pair with codragraph-perf-hotspots; sample logs in hot paths |
125
+ ```
@@ -0,0 +1,129 @@
1
+ ---
2
+ name: codragraph-onboarding
3
+ description: "Use when a developer is new to a codebase and needs a guided walkthrough — entry points, functional areas, key flows, where to start contributing. Examples: \"I'm new to this repo\", \"where do I start\", \"give me a tour\", \"onboard me to this codebase\", \"what does this project do\""
4
+ ---
5
+
6
+ # Codebase Onboarding with CodraGraph
7
+
8
+ ## When to Use
9
+
10
+ - "I'm new to this codebase. Where do I start?"
11
+ - "Give me a tour of this project."
12
+ - "What does each part of this repo do?"
13
+ - "I want to fix a bug in `<area>` — what should I read first?"
14
+ - "I'm picking this project back up after 6 months."
15
+
16
+ ## Why CodraGraph helps here
17
+
18
+ A README tells you what the project *does*. Reading source top-down tells
19
+ you nothing for the first hour. CodraGraph already grouped your code into
20
+ **Leiden communities** during analyze — these are the natural functional
21
+ areas of the codebase, derived from the call graph rather than directory
22
+ structure. Pair them with the detected execution flows (Processes) and you
23
+ get a guided tour: each cluster is a "module", each process is a "story
24
+ running through it."
25
+
26
+ ## Workflow
27
+
28
+ ```
29
+ 1. READ codragraph://repo/{name}/context
30
+ → repo-level overview: file count, language mix, last index time
31
+
32
+ 2. READ codragraph://repo/{name}/clusters
33
+ → all functional areas (auth, payments, ingestion, …) with cohesion %
34
+ and dominant directories
35
+
36
+ 3. For each top-3 cluster (by symbol count):
37
+ READ .claude/skills/generated/<cluster-kebab-name>/SKILL.md (if --skills was run)
38
+ OR
39
+ codragraph_query({query: "<cluster label>"})
40
+ → entry points, key files, member symbols
41
+
42
+ 4. READ codragraph://repo/{name}/processes
43
+ → all detected execution flows (named processes that span the graph)
44
+
45
+ 5. For each process:
46
+ READ codragraph://repo/{name}/process/<processName>
47
+ → step-by-step trace: which symbol calls which next
48
+
49
+ 6. Pick a cluster the user wants to dig into:
50
+ codragraph_context({name: "<entry point of that cluster>"})
51
+ → callers + callees, full picture of the entry point
52
+ ```
53
+
54
+ > If `.claude/skills/generated/` is empty, run `codragraph analyze --skills`
55
+ > first to materialize per-community guides. They make onboarding
56
+ > dramatically faster.
57
+
58
+ ## Checklist
59
+
60
+ ```
61
+ - [ ] Repo overview (context resource)
62
+ - [ ] List clusters (clusters resource)
63
+ - [ ] Read top 3-5 cluster skills or query each cluster label
64
+ - [ ] List processes
65
+ - [ ] Walk top 2-3 processes step-by-step
66
+ - [ ] Pick one entry point and run context for the deep dive
67
+ - [ ] Summarize: "Here's the map. Start at <X> for <task>."
68
+ ```
69
+
70
+ ## Tour Structure
71
+
72
+ | Stage | Tool | Output |
73
+ | --- | --- | --- |
74
+ | Map | `clusters` resource | "10 functional areas, dominant: auth, ingestion, web" |
75
+ | Themes | per-community SKILL.md | Each area's purpose, key files, entry points |
76
+ | Stories | `processes` resource | "5 flows: SignupFlow, IngestPipeline, …" |
77
+ | Trace | `process/{name}` resource | Step-by-step call sequence |
78
+ | Deep dive | `context` | Pick one symbol, see all sides |
79
+
80
+ ## Example: "I'm new to CodraGraph itself, where do I start?"
81
+
82
+ ```
83
+ 1. READ codragraph://repo/CodraGraph/context
84
+ → 4325 symbols, 10556 relationships, 300 flows. TypeScript primary.
85
+
86
+ 2. READ codragraph://repo/CodraGraph/clusters
87
+ → Top clusters: ingestion (1240 symbols), graphstore (340), cli (290),
88
+ mcp (220), languages (180)
89
+
90
+ 3. READ .claude/skills/generated/ingestion/SKILL.md
91
+ → Entry points: runFullAnalysis, IngestionPipeline.run
92
+ → Key files: codragraph/src/core/ingestion/
93
+
94
+ 4. READ codragraph://repo/CodraGraph/processes
95
+ → Top flows: AnalyzeFlow, McpQueryFlow, GraphstoreCommitFlow
96
+
97
+ 5. READ codragraph://repo/CodraGraph/process/AnalyzeFlow
98
+ → 12 steps from CLI invocation through Phase 4 snapshot
99
+
100
+ 6. codragraph_context({name: "runFullAnalysis"})
101
+ → orchestrator that takes (repoPath, options, hooks) and runs the pipeline.
102
+ → Called by: analyzeCommand (CLI), eval-server, augment hook
103
+
104
+ Tour result: "Start at runFullAnalysis (codragraph/src/core/run-analyze.ts).
105
+ That's the orchestrator. The 12-stage pipeline lives under
106
+ src/core/ingestion/. Phase 4 graphstore is in src/core/graphstore/."
107
+ ```
108
+
109
+ ## Output Format
110
+
111
+ ```markdown
112
+ ## Codebase Tour: <repo>
113
+
114
+ ### Project shape
115
+ - N symbols across M files. Primary languages: …
116
+ - N functional areas (clusters), M execution flows.
117
+
118
+ ### Functional areas
119
+ 1. **<cluster>** — <symbolCount> symbols, dominant `src/<dir>/`. Purpose: …
120
+ 2. ...
121
+
122
+ ### Key flows
123
+ - **AnalyzeFlow** — 12 steps. Entry: `<symbol>`.
124
+ - ...
125
+
126
+ ### Recommended starting point for "<task>"
127
+ Read `<file>:<line>` (`<symbol>`). It's the orchestrator for <area>.
128
+ Once you understand it, walk the <flow> to see the whole story.
129
+ ```
@@ -0,0 +1,132 @@
1
+ ---
2
+ name: codragraph-perf-hotspots
3
+ description: "Use to identify likely performance hot paths from the call graph — top-N callees of entry points, fan-out functions, recursive cycles, and where to focus profiling effort. NOT a profiler — a structural pre-screen that narrows where to actually run a profiler. Examples: \"find perf hotspots\", \"hot paths\", \"top callees\", \"where should I profile\", \"functions called by every handler\""
4
+ ---
5
+
6
+ # Performance Hotspot Pre-Screen with CodraGraph
7
+
8
+ ## When to Use
9
+
10
+ - "Where should I focus my profiler?"
11
+ - "Which functions are on every request path?"
12
+ - "Find fan-out points — functions called from many places."
13
+ - "Are there recursive call cycles?"
14
+ - "List top N callees of the API request handler."
15
+
16
+ ## What this skill IS and ISN'T
17
+
18
+ CodraGraph builds a **static call graph** — it knows who *can* call
19
+ whom, not who *did* call whom in production. So this skill identifies
20
+ **structural hot path candidates**, not measured hotspots.
21
+
22
+ Use it as a **pre-screen** for actual profiling: "given my structural
23
+ hot path candidates, the profiler should focus here first." If you have
24
+ profiler data (pprof, flamegraphs, OpenTelemetry traces), CodraGraph
25
+ turns the names from that data into actionable callgraph context.
26
+
27
+ ## Workflow
28
+
29
+ ```
30
+ 1. Identify entry points:
31
+ codragraph_query({query: "request handler endpoint route main"})
32
+ → top entry-point candidates
33
+
34
+ 2. For each entry point, get top N callees ordered by depth-1 fan-in:
35
+ codragraph_cypher({query: `
36
+ MATCH (caller)-[:CALLS]->(callee)
37
+ WHERE callee.label = 'Function'
38
+ RETURN callee.name, count(DISTINCT caller) AS in_degree
39
+ ORDER BY in_degree DESC
40
+ LIMIT 20
41
+ `})
42
+ → callees called from many places = on many paths = candidate hot spots
43
+
44
+ 3. Cross-cut with processes:
45
+ READ codragraph://repo/{name}/processes
46
+ → functions appearing in MANY processes ARE on the hot path by definition
47
+
48
+ 4. Recursive cycle detection:
49
+ codragraph_cypher({query: `
50
+ MATCH path = (n)-[:CALLS*2..6]->(n)
51
+ RETURN n.name, length(path) AS cycle_len
52
+ ORDER BY cycle_len ASC
53
+ LIMIT 10
54
+ `})
55
+ → unbounded recursion = potential perf cliff under specific inputs
56
+
57
+ 5. With profiler output, translate names back to context:
58
+ For each top-N name from your flamegraph/pprof:
59
+ codragraph_context({name: "<sym>"})
60
+ → "this function is on N execution flows; called by M sites"
61
+ ```
62
+
63
+ ## Hot-path heuristics
64
+
65
+ | Signal | Meaning |
66
+ |---|---|
67
+ | Function called from > 10 distinct callers | High fan-in → optimize once, win everywhere |
68
+ | Function appearing in > 5 processes | On many request paths → request-time critical |
69
+ | Cycle of length 2-3 in CALLS edges | Mutual recursion — may overflow under depth |
70
+ | `await` chain of length > 8 in one process | Sequential I/O — candidate for parallelism |
71
+ | Function under cluster `database` / `network` | I/O-bound; profile network and DB calls separately |
72
+
73
+ ## Checklist
74
+
75
+ ```
76
+ - [ ] List entry points (codragraph_query for handlers/routes/main)
77
+ - [ ] Top-N callees by in-degree (Cypher)
78
+ - [ ] Cross-reference with processes (functions in many flows = hot)
79
+ - [ ] Cycle detection
80
+ - [ ] If profiler data exists, codragraph_context for each top hot symbol
81
+ - [ ] Prioritize: request-path + high in-degree + I/O-bound = first to optimize
82
+ ```
83
+
84
+ ## Example: "Find the hot paths in our HTTP handler chain"
85
+
86
+ ```
87
+ 1. codragraph_query({query: "express router handler"})
88
+ → 28 handler functions
89
+
90
+ 2. codragraph_cypher({query: `
91
+ MATCH (caller)-[:CALLS]->(callee)
92
+ WHERE callee.label = 'Function'
93
+ RETURN callee.name, count(DISTINCT caller) AS in_degree
94
+ ORDER BY in_degree DESC LIMIT 10
95
+ `})
96
+ → top in-degree callees:
97
+ - logRequest (28) ← every handler calls this
98
+ - getCurrentUser (22)
99
+ - db.query (18) ← I/O bound
100
+ - cache.get (15)
101
+ - serializeJson (28) ← every handler calls this
102
+
103
+ 3. READ codragraph://repo/CodraGraph/processes
104
+ → 5 processes; getCurrentUser appears in 4 of 5
105
+
106
+ 4. codragraph_context({name: "getCurrentUser"})
107
+ → 22 callers, calls db.query (cache miss path) and cache.get
108
+ → STRONGLY recommend: profile getCurrentUser first.
109
+ → Win-rate per opt: 22 callers × cache miss rate × DB latency.
110
+ ```
111
+
112
+ ## Output Format
113
+
114
+ ```markdown
115
+ ## Perf Pre-Screen: <scope>
116
+
117
+ ### Top hot-path candidates (structural)
118
+ | Function | In-degree | Processes | I/O type | Note |
119
+ |---|--:|--:|---|---|
120
+ | getCurrentUser | 22 | 4 | DB + cache | profile first |
121
+ | db.query | 18 | 5 | DB | hot for write paths |
122
+ | serializeJson | 28 | 5 | CPU | every handler — micro-opt territory |
123
+
124
+ ### Cycles detected
125
+ - `processStep ↔ enqueueRetry` — depth 2 cycle, unbounded under failure conditions
126
+
127
+ ### Profiler integration plan
128
+ 1. Collect pprof / flamegraph / OTEL trace under representative load
129
+ 2. Top-N hottest functions from profile → run codragraph_context on each
130
+ 3. Cross-reference with this static pre-screen
131
+ 4. Optimize where structural & measured hot paths overlap
132
+ ```