scan-codebase

scan-codebase is a skill for Claude Code from Borda/AI-Rig. It costs 27 tokens per session (3,316 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 Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: names the AskUserQuestion tool.

Runs only inside its plugin — its command needs a path that Claude Code sets for a plugin’s own hooks and for nothing else. Install the plugin, not this.

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

Good fit Use it to create or refresh a Python codemap containing import graphs, symbols, and blast-radius measurements.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add Borda/AI-Rig
Claude Code
/plugin install codemap-py

Made for: Claude Code.

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/github.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/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for scan-codebase

Your own site · 80×15
<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="Reviewed on agentmods" width="80" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,316 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00027 $0.03316
Opus 5.5 $0.00011 $0.01326
Sonnet 5.5 $0.00005 $0.00663
Haiku 4.5 $0.00003 $0.00332

Measured 17d ago against content hash e3ba2f1e6315, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 17d ago.

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 · 174 lines

How it starts

The opening of the file, as written. The whole thing — 174 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 codemap-py query symbol / find-symbol return target source, avoiding full-file reads.

Agents/develop skills query via codemap-py 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:integration — audit/plan/apply); non-code input (contracts, prose, config-only review). On out-of-scope input: state scope mismatch and stop — never answer "for reference only" with partial findings.

Step 1: Run the scanner

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

Unknown-flag check: setup_scan_env.py validates $ARGUMENTS with the same tokenizer that extracts --root (quoted paths stay one token). Any -- token except --root <path> and --incremental → it prints ! Unknown flag(s): <tokens> then Supported: --root <path>, --incremental and exits 5; the block prints that stderr unchanged and exits 1. Never AskUserQuestion: disable-model-invocation:true makes it unreachable. --root with no value (would silently fall back to default-root scan): ! --root requires a value + same Supported: line; exit 1 — distinct message, never the Unknown flag(s) wording.

Step 1 exits non-zero → report its error and stop; never run Step 2 or Step 3.

# timeout: 400000
PLUGIN_ROOT=$(python "${CLAUDE_PLUGIN_ROOT}/bin/resolve_plugin_root.py" --plugin-name codemap-py) || exit $?; export PLUGIN_ROOT
export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}"
_CM_PROJ_SLUG=$(basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)")
SETUP_STDERR=$(mktemp "${TMPDIR:-/tmp}/codemap-setup-err-XXXXXXXX") || exit 1
SCAN_STATE_FILE=$(python "$PLUGIN_ROOT/bin/setup_scan_env.py" --arguments "$ARGUMENTS" 2>"$SETUP_STDERR")
_SETUP_RC=$?
# 5 = $ARGUMENTS rejected — stderr already holds the exact pinned wording; a prefix would bury it
# Rosters + shell require exact Unknown flag(s) wording; skill-local exit 1 is accepted in shared/capability-contract.md, while CLI syntax errors remain exit 2.
[ "$_SETUP_RC" -eq 5 ] && { cat "$SETUP_STDERR" >&2; exit 1; }
if [ "$_SETUP_RC" -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
# the helper validates this private 0700 user-owned directory before writing state
_SCAN_TMP=$(dirname "$SCAN_STATE_FILE")
# clear before the scan so a failed run never inherits earlier success
rm -f "${_SCAN_TMP}/codemap-scan-ok-${_CM_PROJ_SLUG}-${CSID}"
printf 'SCAN_STATE_FILE=%s\n' "$SCAN_STATE_FILE"
# -O owned-by-uid, ! -L not-symlink — defense-in-depth on mktemp; last check before reading, 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; }
unset PROJ_SLUG SCAN_BIN SCAN_ARGS_RAW PROJ_NAME
while IFS='=' read -r _SK _SV; do
  case "$_SV" in \'*\') ;; *) printf "! codemap state incomplete — re-run /codemap-py:scan-codebase\n" >&2; exit 1;; esac
  _SV=${_SV#\'}; _SV=${_SV%\'}; _SV=${_SV//\'\\\'\'/\'}
  case "$_SK" in
    PROJ_SLUG) PROJ_SLUG=$_SV;;
    SCAN_BIN) SCAN_BIN=$_SV;;
    SCAN_ARGS_RAW) SCAN_ARGS_RAW=$_SV;;
    PROJ_NAME) PROJ_NAME=$_SV;;
  esac
done < "$SCAN_STATE_FILE"
[ "${PROJ_SLUG+x}${SCAN_BIN+x}${SCAN_ARGS_RAW+x}${PROJ_NAME+x}" = "xxxx" ] || { printf "! codemap state incomplete — re-run /codemap-py:scan-codebase\n" >&2; exit 1; }
# NUL-delimited — avoids eval; written by parse_scan_args.py
_ARGS_FILE="${_SCAN_TMP}/codemap-scan-args-nul-$$-${CSID}"
# unchecked failure left SCAN_ARGS empty → silent default git-root full scan reported as success
python "$PLUGIN_ROOT/bin/parse_scan_args.py" "$SCAN_ARGS_RAW" --nul-output "$_ARGS_FILE" && [ -f "$_ARGS_FILE" ] || { printf "! parse_scan_args.py failed — scan not started\n" >&2; exit 1; }
SCAN_ARGS=()
while IFS= read -r -d '' _arg; do
  SCAN_ARGS+=("$_arg")
done < "$_ARGS_FILE"
rm -f "$_ARGS_FILE"
# dispatcher, not deprecated scan-index alias (removed ≥1.0.0): alias leases in-engine too (graph.main wraps build+publish in rwgate.write_index) but skips interpreter probe (exit 127, no eligible CPython)
# SCAN_BIN stays setup_scan_env.py's existence preflight — dispatcher needs same binary
# PATH-literal first token — expansion-bearing form matches no bare-name allow prefix; absolute launcher = interactive fallback
command -v codemap-py >/dev/null 2>&1 || { printf "! codemap-py not on PATH — run \"\$PLUGIN_ROOT/bin/codemap-py\" index as one standalone command instead\n" >&2; exit 1; }
codemap-py index --timeout 360 "${SCAN_ARGS[@]}"
# capture rc BEFORE branching — in `if ! cmd; then`, $? = negated compound status (always 0), never 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 "${_SCAN_TMP}/codemap-incremental-noop-${PROJ_SLUG}-${CSID}"
    exit 1
fi
printf 'ok\n' > "${_SCAN_TMP}/codemap-scan-ok-${_CM_PROJ_SLUG}-${CSID}"

Read the full file on GitHub · 174 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. 17d ago Changed · +29 lines · -54 tokens per session e3ba2f1e6315
  2. 1mo ago Changed dd94e6ded1aa
  3. 1mo ago Changed fb14de27a62c
  4. 2mo ago Changed · +7 lines 4dfd8ec5567b
  5. 2mo ago Changed d8f0aa7423f9
  6. 2mo ago Changed baf60a6ce233
  7. 2mo ago 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 (31 stars, last pushed yesterday), licensed Apache-2.0. It adds 27 tokens to every session and 3,316 once invoked, about $0.0001 per session on Opus 5.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

scan-codebase compared with skills from other repositories

scan-codebase next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
scan-codebaseBorda/AI-RigSkill31yesterdayApache-2.0A27Claude Code
i18n-parityhoangsonww/Claude-Code-Agent-MonitorSkill1.2kyesterdayMITA95Claude Code, Codex
file-headershoangsonww/Claude-Code-Agent-MonitorSkill1.2kyesterdayMITA101Claude Code
productivity-scorehoangsonww/Claude-Code-Agent-MonitorSkill1.2kyesterdayMITA67Claude Code, Codex
dashboard-statushoangsonww/Claude-Code-Agent-MonitorSkill1.2kyesterdayMITA69Claude Code, Codex
dag-maphoangsonww/Claude-Code-Agent-MonitorSkill1.2kyesterdayMITA65Claude Code, Codex
regression-watchhoangsonww/Claude-Code-Agent-MonitorSkill1.2kyesterdayMITA82Claude Code, Codex