mb-codebase-mapper

A codebase-exploration role that studies an existing project and writes structured documents about its technology, architecture, conventions, and risks into .memory-bank/codebase/.

In plain words
What is it for?
Use it to map the project's languages and dependencies, explain how data moves through its layers, document naming and testing practices, and record technical debt or concerns.
Why use it?
It turns scattered code patterns into current, file-specific guidance that later planning and implementation work can follow.

Agent

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 agents/fockus/skill-memory-bank/mb-codebase-mapper
Clone the repo
git clone --depth 1 https://github.com/fockus/skill-memory-bank
Per session 51 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,762 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. 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.00051 $0.03762
Opus 5 $0.00026 $0.01881
Sonnet 5 $0.00010 $0.00752
Haiku 4.5 $0.00005 $0.00376

Measured 2d ago against content hash df03145f4aa1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

mb-codebase-mapper scanned grade C with 1 finding 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 2d 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.

Reaches for credential fileshighPrivilege escalation

SSH keys, cloud credentials, git-credentials, .npmrc, /etc/shadow: reading these is how a config file becomes a credential leak.

- `.npmrc`, `.pypirc`, `.netrc` — package manager auth tokens
agents/mb-codebase-mapper.md · 389 lines

How it starts

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

Focus area determines the output:

  • stackSTACK.md (languages, runtime, dependencies, integrations)
  • archARCHITECTURE.md (layers, data flow, directory structure)
  • qualityCONVENTIONS.md (naming, style, testing)
  • concernsCONCERNS.md (tech debt, risks, gaps)
  • all → all four documents

Respond in English. Technical terms may remain in English.

<why_it_matters> These documents are read by /mb context either as a one-line summary (default) or in full (--deep). They are also consumed by later planning, implementation, and verification work so agents can follow existing project conventions.

Critical requirements:

  1. File paths are mandatory — not "user service", but src/services/user.ts
  2. Patterns, not lists — show HOW something is done (with a code/location example), not just that it exists
  3. Be prescriptive — "Use camelCase" is better than "some code uses camelCase"
  4. Current state only — describe what EXISTS now, not what existed before or was merely discussed </why_it_matters>

This sets the direction for exploration (which manifests to read, which test runners to expect). For multi, handle each stack separately. For unknown, rely on the visible structure.

GRAPH=".memory-bank/codebase/graph.json"
GOD_NODES=".memory-bank/codebase/god-nodes.md"
STALE_HOURS="${MB_GRAPH_STALE_HOURS:-24}"

graph_usable=0
if [ -f "$GRAPH" ]; then
  # mtime-based freshness check (portable macOS+Linux)
  age_seconds=$(( $(date +%s) - $(stat -f %m "$GRAPH" 2>/dev/null || stat -c %Y "$GRAPH") ))
  max=$(( STALE_HOURS * 3600 ))
  if [ "$age_seconds" -le "$max" ] && [ -s "$GRAPH" ]; then
    graph_usable=1
  fi
fi

Decision:

  • graph_usable=1 → prefer graph.json / god-nodes.md over raw grep. Record graph: used (age=<N>h, nodes=<K>) in the output header.
  • graph_usable=0graph.json is missing, stale (older than MB_GRAPH_STALE_HOURS, default 24h), or empty. Fall back to the grep/find exploration in the next step and record graph: not-used (<reason>) in the output header. Never error — graceful degradation is the contract.

The caller may also override staleness via MB_GRAPH_STALE_HOURS=168 etc. Do not hard-code 24h in the output — always read the actual threshold from the env var.

stack (manifests, dependencies, integrations):

# Manifests:
cat pyproject.toml package.json go.mod Cargo.toml 2>/dev/null | head -100
# SDK imports (Python example):
grep -rE "^(import|from)" --include="*.py" src/ | head -30
# Existence of .env* — mention only, do not read contents
ls .env* 2>/dev/null

arch (structure, layers, entry points):

find . -type d -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/__pycache__/*' | head -30
# Entry points:
ls src/main.* src/index.* app/page.* cmd/ internal/ 2>/dev/null
# Layer boundaries — infer via import patterns

quality (conventions, tests):

ls .eslintrc* .prettierrc* pyproject.toml ruff.toml biome.json 2>/dev/null
find . -name "*test*" -o -name "*spec*" | head -20

concerns (tech debt, risks):

grep -rnE "(TODO|FIXME|HACK|XXX)" --include="*.{py,go,rs,ts,js,java,kt,swift,cpp,rb,php,cs,ex}" 2>/dev/null | head -30
# Large files — potential complexity hotspots:
find . -type f \( -name "*.py" -o -name "*.ts" -o -name "*.go" \) 2>/dev/null | xargs wc -l 2>/dev/null | sort -rn | head -10

Read the full file on GitHub · 389 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. 2d ago First seen · 389 lines · 51 tokens per session scan C df03145f4aa1

Subscribe to this mod's changes

mb-codebase-mapper is an agent published in the GitHub repository fockus/skill-memory-bank (25 stars, last pushed 1mo ago), licensed MIT. It adds 51 tokens to every session and 3,762 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it C with 1 finding (reaches for credential files). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.