$npx -y skills add Borda/AI-Rig --skill query-codeQuery the codemap structural index — module deps/rdeps/central/coupled/path, symbol-level source extraction, function call graph (fn-deps, fn-rdeps, fn-central, fn-blast). TRIGGER: "what depends on", "who calls", "imports of", "dependency graph", "blast radius of", "list central
| 1 | <objective> |
| 2 | Python import-graph + symbol queries via `scan-query` CLI (on PATH after codemap install). |
| 3 | |
| 4 | Module: `central [--top N]`, `coupled [--top N]`, `deps <mod>`, `rdeps <mod>`, `path <from> <to>` |
| 5 | Symbol (~70–94% token reduction vs Read): `symbol <name> [--with-imports]`, `symbols <mod>`, `find-symbol <pat>` |
| 6 | Function call-graph (v3 index): `fn-deps <qname>`, `fn-rdeps <qname>`, `fn-central [--top N]`, `fn-blast <qname>` |
| 7 | qname format: `mypackage.auth::validate_token` |
| 8 | |
| 9 | NOT for: repo rebuild (use `/codemap:scan-codebase`); renaming symbols (use `/codemap:rename-refs`); non-Python files. |
| 10 | </objective> |
| 11 | |
| 12 | <workflow> |
| 13 | |
| 14 | ## Step 0: Index freshness (once per task — skip if already ran this turn) |
| 15 | |
| 16 | ```bash |
| 17 | # timeout: 5000 |
| 18 | export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" |
| 19 | _CM_PROJ=$(git rev-parse --show-toplevel 2>/dev/null | xargs basename 2>/dev/null || echo "cm") |
| 20 | python "${CLAUDE_PLUGIN_ROOT:-plugins/codemap}/bin/resolve_index_env.py" \ |
| 21 | --output-prefix "codemap-${_CM_PROJ}" 2>/dev/null |
| 22 | INDEX=$(cat "${TMPDIR:-/tmp}/codemap-${_CM_PROJ}-resolve-index-${CSID}" 2>/dev/null || echo "") |
| 23 | [ -n "$INDEX" ] && { [ -f "$INDEX" ] && STATE="present" || STATE="missing"; } || STATE="unresolved" |
| 24 | ``` |
| 25 | |
| 26 | Branch on `$STATE`. Auto-build opt-out via `SCAN_NO_AUTOBUILD=1` (set to run queries against index exactly as-is — no refresh, no full build); build wall-time echoed when it runs, keeps build cost separable from query cost. |
| 27 | |
| 28 | - `present` → refresh in place (honors the opt-out, echoes build time): |
| 29 | |
| 30 | ```bash |
| 31 | # timeout: 8000 |
| 32 | if [ "${SCAN_NO_AUTOBUILD:-0}" = "1" ]; then |
| 33 | echo "[codemap] SCAN_NO_AUTOBUILD=1 — using existing index as-is (no refresh)" |
| 34 | else |
| 35 | _CM_BUILD_T0=$(date +%s) |
| 36 | "${CLAUDE_PLUGIN_ROOT:-plugins/codemap}/bin/scan-index" --incremental |
| 37 | echo "[codemap] index built in $(( $(date +%s) - _CM_BUILD_T0 ))s" |
| 38 | fi |
| 39 | ``` |
| 40 | |
| 41 | - `missing` → no index to query yet; auto-build is refused when opted out: |
| 42 | |
| 43 | ```bash |
| 44 | # timeout: 5000 |
| 45 | if [ "${SCAN_NO_AUTOBUILD:-0}" = "1" ]; then |
| 46 | echo "! codemap index missing and SCAN_NO_AUTOBUILD=1 — refusing to auto-build." |
| 47 | echo " Build it manually first: /codemap:scan-codebase" |
| 48 | exit 1 |
| 49 | fi |
| 50 | ``` |
| 51 | |
| 52 | If not refused → run `scan-index` in the foreground (wait until it finishes), then re-read INDEX from tmpfile. (Not the `codemap:scan-codebase` skill — it is `disable-model-invocation:true`, user-slash-only; build via the `scan-index` binary.) |
| 53 | |
| 54 | - `unresolved` → surface error, stop |
| 55 | |
| 56 | ## Step 1: Query |
| 57 | |
| 58 | **Direction — choose before calling:** |
| 59 | - `rdeps <mod>` — callers: what imports X, blast radius of X |
| 60 | - `deps <mod>` — forward: what X imports |
| 61 | |
| 62 | Common mistake: "modules affected if X changes" = `rdeps` (callers), not `deps`. |
| 63 | |
| 64 | Missing binary fallback: |
| 65 | ```bash |
| 66 | SQ=$(python "${CLAUDE_PLUGIN_ROOT:-plugins/codemap}/bin/locate_scan_query.py" 2>/dev/null || echo "scan-query") |
| 67 | ``` |
| 68 | |
| 69 | ```bash |
| 70 | scan-query rdeps "mypackage.auth" # timeout: 5000 |
| 71 | scan-query symbol "MyClass.method" --with-imports # timeout: 5000 |
| 72 | scan-query fn-rdeps "mypackage.auth::validate_token" # timeout: 5000 |
| 73 | ``` |
| 74 | |
| 75 | | Goal | Command | |
| 76 | | --- | --- | |
| 77 | | callers / blast radius | `rdeps <mod> [--exclude-tests]` | |
| 78 | | forward deps | `deps <mod>` | |
| 79 | | central modules | `central --top 10` | |
| 80 | | import path | `path <from> <to>` | |
| 81 | | symbol source | `symbol <name> [--with-imports]` | |
| 82 | | all symbols in module | `symbols <mod>` | |
| 83 | | symbol search | `find-symbol <pattern>` | |
| 84 | | outgoing calls | `fn-deps module::function` | |
| 85 | | incoming calls | `fn-rdeps module::function [--exclude-tests]` | |
| 86 | | blast radius of current git change set | `diff-impact [--base REF]` | |
| 87 | |
| 88 | **Quality / coverage / test-graph queries** (each needs the index version noted — auto-build upgrades): |
| 89 | |
| 90 | | Goal | Command | Min index | |
| 91 | | --- | --- | --- | |
| 92 | | test files that mock a symbol via `patch()` | `mock-rdeps <mod::sym \ | mod>` | v4.1 | |
| 93 | | public symbols missing a docstring | `undocumented [<mod>] [--all]` | v4.4 | |
| 94 | | public symbols with no test callers and no mocks | `uncovered [<mod>] [--all] [--sort loc\ | name\ | module] [--t |