scan-codebase

scan-codebase is a skill for Claude Code, Codex from Borda/AI-Rig. It costs 81 tokens per session (2,360 once invoked), scanned A, original, Apache-2.0.

A Python code scanner that builds an index of imports, symbols, and code-dependency relationships. The index shows which files and functions may be affected by a change.

In plain words
What is it for?
Use it to create or refresh a Python codemap containing import graphs, symbols, and blast-radius measurements.
Why use it?
It makes code structure and possible change impact easier to inspect without reading every file manually.

Skill for Claude CodeCodex

Installs and runs on its own, but its text points at files inside its plugin — anything it tells you to read at a ${CLAUDE_PLUGIN_ROOT} path is only there once the plugin is installed. Installing the plugin gets both.

Part of the codemap-py plugin — 6 skills shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/borda/ai-rig/scan-codebase
Any agent
npx skills add Borda/AI-Rig --skill scan-codebase
Clone the repo
git clone --depth 1 https://github.com/Borda/AI-Rig

Made for: Claude Code, Codex.

Or install codemap-py, the plugin that ships this one along with the rest of its 6 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for scan-codebase

README.md
[![agentmods](https://agentmods.dev/badge/skills/borda/ai-rig/scan-codebase.svg)](https://agentmods.dev/skills/borda/ai-rig/scan-codebase)
Your own site
<a href="https://agentmods.dev/skills/borda/ai-rig/scan-codebase"><img src="https://agentmods.dev/badge/skills/borda/ai-rig/scan-codebase.svg" alt="Measured on agentmods" height="20"></a>
Per session 81 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,360 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00081 $0.02360
Opus 5 $0.00041 $0.01180
Sonnet 5 $0.00016 $0.00472
Haiku 4.5 $0.00008 $0.00236

Measured yesterday against content hash 558d1b2de0ea, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

scan-codebase scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/codemap-py/claude-skills/scan-codebase/SKILL.md · 138 lines

How it starts

The opening of the file, as written. The whole thing — 138 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python only: ast.parse extracts import graph + symbol metadata from all .py; non-Python excluded. Writes .cache/codemap/<project>.json; no external deps. Zero-Python project still writes empty index; queries return nothing.

Per module: import graph, blast-radius metrics, symbol list (classes/functions/methods + line ranges). Symbols let scan-query symbol / find-symbol return target source, avoiding full-file reads.

Agents/develop skills query via scan-query for deps, blast radius, coupling, symbol source before edits.

NOT for: querying existing index (use /codemap-py:query-code); integration health checks or wiring consumer integration (use /codemap-py:integrationcheck/plan/apply).

Step 1: Run the scanner

Build invocation from $ARGUMENTS. Pass supplied --root <path> and/or --incremental; never literal placeholders.

Unknown-flag check: before parse_scan_args.py, find $ARGUMENTS -- tokens except --root, --incremental. If any, print ! Unknown flag(s): <tokens> then Supported: --root <path>, --incremental; exit 1. Never AskUserQuestion: disable-model-invocation:true makes it unreachable. Rosters + shell must use exact Unknown flag(s) wording, no synonym. Preflight exit 1 is skill-local shortcut accepted in shared/capability-contract.md; CLI syntax errors remain §7.5 exit 2.

# timeout: 10000
export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}"
# tr|awk, not for-loop — zsh doesn't word-split unquoted vars, for-loop saw whole string as one token, "--root <path>" always false-flagged unsupported
# awk skips token after --root same as old _SKIP_NEXT; parse_scan_args.py handles quoted paths
_ARGS_UNKNOWN=$(printf '%s\n' "$ARGUMENTS" | tr ' ' '\n' \
  | awk '/^--root$/{skip=1;next} skip{skip=0;next} /^--incremental$/{next} /^--/{print}' | tr '\n' ' ')
_ARGS_UNKNOWN="${_ARGS_UNKNOWN% }"
[ -z "$_ARGS_UNKNOWN" ] || { printf "! Unknown flag(s): %s\nSupported: --root <path>, --incremental\n" "$_ARGS_UNKNOWN" >&2; exit 1; }
SETUP_STDERR="${TMPDIR:-/tmp}/codemap-setup-err-$$-${CSID}"
SCAN_STATE_FILE=$(python "${CLAUDE_PLUGIN_ROOT:-plugins/codemap-py}/bin/setup_scan_env.py" --arguments "$ARGUMENTS" 2>"$SETUP_STDERR")
if [ $? -ne 0 ] || [ -z "$SCAN_STATE_FILE" ]; then
  printf "! setup_scan_env.py failed"; [ -s "$SETUP_STDERR" ] && printf ": %s" "$(cat "$SETUP_STDERR")"; printf "\n"; exit 1
fi
# project-scoped — bare CSID collides across concurrent repos in one session
_CM_PROJ_SLUG=$(basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)")
printf '%s\n' "$SCAN_STATE_FILE" > "${TMPDIR:-/tmp}/codemap-state-ref-${_CM_PROJ_SLUG}-${CSID}"  # subsequent blocks read without knowing PID
# timeout: 400000
export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}"
_CM_PROJ_SLUG=$(basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)")
IFS= read -r SCAN_STATE_FILE < "${TMPDIR:-/tmp}/codemap-state-ref-${_CM_PROJ_SLUG}-${CSID}" 2>/dev/null || SCAN_STATE_FILE=""
[ -n "$SCAN_STATE_FILE" ] && [ -f "$SCAN_STATE_FILE" ] || { printf "! codemap state missing — re-run from the beginning\n"; exit 1; }
# -O owned-by-uid, ! -L not-symlink — defense-in-depth on mktemp; last check before sourcing (executed), fails closed on shared-TMPDIR collision
[ -O "$SCAN_STATE_FILE" ] && [ ! -L "$SCAN_STATE_FILE" ] || { printf "! codemap state file failed ownership/symlink check — aborting\n" >&2; exit 1; }
# shellcheck source=/dev/null
. "$SCAN_STATE_FILE"
# NUL-delimited — avoids eval; written by parse_scan_args.py
_ARGS_FILE="${TMPDIR:-/tmp}/codemap-scan-args-nul-$$-${CSID}"
python3 "${CLAUDE_PLUGIN_ROOT:-plugins/codemap-py}/bin/parse_scan_args.py" "$SCAN_ARGS_RAW" --nul-output "$_ARGS_FILE"
SCAN_ARGS=()
while IFS= read -r -d '' _arg; do
  SCAN_ARGS+=("$_arg")
done < "$_ARGS_FILE"
rm -f "$_ARGS_FILE"
# dispatcher, not the scan-index alias — alias leases in-engine too (graph.main wraps build+publish in rwgate.write_index), but it skips the dispatcher's interpreter probe (exit 127 on no eligible CPython) and is a deprecated shim, removed no earlier than 1.0.0. SCAN_BIN stays setup_scan_env.py's existence preflight (dispatcher needs the same binary present).
# PATH-literal first token — expansion-bearing form matches no bare-name allow prefix; absolute launcher is the interactive fallback
command -v codemap-py >/dev/null 2>&1 || { printf "! codemap-py not on PATH — run \"\${CLAUDE_PLUGIN_ROOT:-plugins/codemap-py}/bin/codemap-py\" index as one standalone command instead\n" >&2; exit 1; }
codemap-py index --timeout 360 "${SCAN_ARGS[@]}"
# capture rc BEFORE branching — inside `if ! cmd; then`, $? is the negated compound's status (always 0), never the scanner's
_SCAN_RC=$?
if [ "$_SCAN_RC" -ne 0 ]; then
    printf "! codemap-py index failed (exit %d) — index may be stale or incomplete\n" "$_SCAN_RC"
    # rm sentinel on failure — stale one misleads Step 2
    rm -f "${TMPDIR:-/tmp}/codemap-incremental-noop-${PROJ_SLUG}-${CSID}"
    exit 1
fi

Read the full file on GitHub · 138 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 138 lines · 81 tokens per session scan A 558d1b2de0ea

Subscribe to this mod's changes

scan-codebase is a skill published in the GitHub repository Borda/AI-Rig (26 stars, last pushed yesterday), licensed Apache-2.0. It adds 81 tokens to every session and 2,360 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

file-headers

MANDATORY for every coding agent (Claude Code, Codex, or any other) on every change-set — every applicable source file the agent creates or updates MUST start with the project's copyright/authorship header (file overview + exact author line). Use automatically whenever writing a new file or editing an existing one; do…

hoangsonww/Claude-Code-Agent-Monitor · 101 tokens

productivity-score

Calculate a productivity score using actual Agent Monitor metrics — session completion rates, cache efficiency (cacheread vs input), compaction pressure (baseline tokens), turn velocity (turncount / totalturndurationms), tool success ratio (PreToolUse vs PostToolUse), and the workflow intelligence API's complexity and…

hoangsonww/Claude-Code-Agent-Monitor · 67 tokens

budget-set

Define a spend budget for Claude Code and, optionally, create a cost alert rule that fires when usage crosses the limit, via POST /api/alerts/rules on the Agent Monitor dashboard. Reads current spend from /api/pricing/cost to size the budget sensibly and explains every rule field before writing. Use when setting a…

hoangsonww/Claude-Code-Agent-Monitor · 79 tokens

dashboard-status

Quick dashboard health and status overview — checks the Agent Monitor API (port 4820), reports session/agent/event counts from /api/stats, confirms WebSocket connectivity, reads the redacted hook status returned by /api/settings/info, and shows data freshness (last event timestamp). Use to verify the monitoring system…

hoangsonww/Claude-Code-Agent-Monitor · 69 tokens

dag-map

Render the multi-agent orchestration DAG for a session — parent→child subagent edges, tree depth, and fan-out — from the Agent Monitor workflow intelligence API. Cross-checks the orchestration dataset against the raw agent records and session detail. Use when visualizing how a session's agent structure was organized.

hoangsonww/Claude-Code-Agent-Monitor · 65 tokens

run-agent

Launch and supervise Claude Code or Codex through the CCAM Run API. Use when the user wants to start a monitored agent, select a model, approval policy, sandbox, or working directory, send a follow-up, inspect live output, resume a native session, or stop a dashboard-launched run.

hoangsonww/Claude-Code-Agent-Monitor · 64 tokens