$npx -y skills add Borda/AI-Rig --skill integrationManage codemap integration — 'check' audits installation health (scan-query reachable, index fresh, injection present), 'init' onboards codemap by discovering skills/agents, recommending injection sites, and wiring them in, 'demo' runs end-to-end validation: plumbing check + plai
| 1 | <objective> |
| 2 | |
| 3 | Three modes: `init` first-time onboard, `check` regularly to verify, `demo` end-to-end validation. Default (no args) → `check`. |
| 4 | |
| 5 | - **`check`** — fast diagnostic: find `scan-query`, verify index exists + fresh, run smoke test, audit which skill files have injection block. Prints `✓`/`✗`/`⚠` per check + one-line remediation. Pure bash — no model reasoning for happy path. |
| 6 | - **`init`** — interactive onboarding: build index if missing, discover installed skills/agents, score by codemap-value, present recommendation table, ask which to wire, insert injection block into each selected file. |
| 7 | - **`demo`** — end-to-end validation: plumbing check + index build if missing + plain-vs-codemap A/B on real tasks + telemetry diagnostic. |
| 8 | |
| 9 | NOT for: running structural query (use `/codemap:query-code`); pure plumbing without gain proof (use `check`); explicit standalone index rebuild (use `/codemap:scan-codebase` — `init` builds index as side-effect when missing, but not its purpose). |
| 10 | |
| 11 | **`--approve`** (init): auto-applies all High+Medium injection recommendations for files within codemap's own installed plugin root (`installPath` for codemap entry in `installed_plugins.json`), installs post-commit hook, skips interactive prompts. **Scope**: files belonging to other plugins always require interactive confirmation regardless of `--approve` — outside codemap's installPath. CHECK-tier items (`CHECK:` prefix) informational — never auto-applied. Codemap's installPath undeterminable from `installed_plugins.json` → `--approve` falls back to interactive for all candidates. |
| 12 | |
| 13 | </objective> |
| 14 | |
| 15 | <inputs> |
| 16 | |
| 17 | - **$ARGUMENTS**: optional — one of: |
| 18 | - Omitted or `check` — run diagnostic; print health status for all codemap integration points |
| 19 | - `init` — interactive onboarding: build index if missing, discover skills/agents, recommend injection sites, wire in selected files |
| 20 | - `init --approve` — non-interactive for files within codemap's own `installPath`; auto-applies all High+Medium recommendations + installs post-commit hook without prompting. Other plugins' files require interactive confirmation even under `--approve`. CHECK-tier items never auto-applied. installPath undeterminable → falls back to interactive. **⚠ Scope warning**: injects into cache files (see I2/I5 warning) — wiped on next plugin upgrade; re-run `check` after any upgrade, re-inject what it reports MISSING/OUTDATED. Recommended: run `init` (interactive) first to review candidates before `--approve`. `init` without `--approve` = guided interactive workflow; `init --approve` = `bin/inject_codemap.py` deterministic automation. |
| 21 | - `demo [--repo <path|url>] [--public] [--anonymize] [--keep-clone] [--output <path>]` — end-to-end validation; all flags optional; see `modes/demo.md` |
| 22 | |
| 23 | </inputs> |
| 24 | |
| 25 | <workflow> |
| 26 | |
| 27 | ## Mode detection |
| 28 | |
| 29 | Parse `$ARGUMENTS` (case-insensitive): |
| 30 | |
| 31 | - Starts with `check` or empty → **check mode** (Steps C1–C4) |
| 32 | - Starts with `init` → **init mode** (Steps I0–I6; I5 has sub-steps I5a, I5b) |
| 33 | - Starts with `demo` → **demo mode** |
| 34 | |
| 35 | > loads: modes/demo.md |
| 36 | |
| 37 | - Anything else → `AskUserQuestion`: "Unrecognized command `$ARGUMENTS`. Which operation?" Options: (a) `check` — audit integration health, (b) `init` — onboard interactively, (c) `init --approve` — onboard non-interactively (auto-applies all High+Medium without prompting), (d) `demo` — end-to-end validation with A/B gain proof |
| 38 | |
| 39 | ## CHECK MODE (Steps C1–C4) |
| 40 | |
| 41 | ### C1 — Locate scan-query |
| 42 | |
| 43 | Three-tier fallback (PATH → CLAUDE_PLUGIN_ROOT → newest cache install) handled by `bin/locate_scan_query.py`. |
| 44 | |
| 45 | ```bash |
| 46 | export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" # timeout: 5000 |
| 47 | _CM_PROJ=$(git rev-parse --show-toplevel 2>/dev/null | xargs basename 2>/dev/null || echo "cm") |
| 48 | SQ=$(python "${CLAUDE_PLUGIN_ROOT:-plugins/codemap}/bin/locate_scan_query.py") # timeout: 5000 |
| 49 | if [ -n "$SQ" ] && [ -x "$SQ" ]; then |
| 50 | printf "✓ scan-query: %s\n" "$SQ" |
| 51 | echo "ok" > "${TMPDIR:-/tmp}/codemap-${_CM_PROJ}-c1-status-${CSID}" |
| 52 | else |
| 53 | printf "✗ scan-query: not found\n" |
| 54 | printf " → Install: claude plugin install codemap@borda-ai-rig\n" |
| 55 | echo "failed" > "${TMPDIR:-/tmp}/codemap-${_CM_PROJ}-c1-status-${CSID}" |
| 56 | exit 1 |
| 57 | fi |
| 58 | `` |