codebase-memory

A codebase knowledge graph for asking structural questions about a software project. A knowledge graph records how code elements such as functions, classes, and routes relate to one another.

In plain words
What is it for?
Use it to explore architecture, find functions or classes, see what calls a function, trace call chains, inspect source snippets, check indexing coverage, and run dependency or dead-code analysis.
Why use it?
It helps you understand unfamiliar code without searching through the whole project manually. It also makes caller, dependency, impact, and unused-code checks more focused.

Skill for Claude CodeCodex

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/narumiruna/pi-extensions/codebase-memory
Any agent
npx skills add narumiruna/pi-extensions --skill codebase-memory
Clone the repo
git clone --depth 1 https://github.com/narumiruna/pi-extensions

Made for: Claude Code, Codex.

Per session 98 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,170 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.00098 $0.02170
Opus 5 $0.00049 $0.01085
Sonnet 5 $0.00020 $0.00434
Haiku 4.5 $0.00010 $0.00217

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

Security

Grade A, and why

codebase-memory 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 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.

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.

deprecated/pi-cbmem/skills/codebase-memory/SKILL.md · 134 lines

How it starts

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

Codebase Memory — Knowledge Graph Tools

Graph tools return precise structural results in ~500 tokens vs ~80K for grep.

Always prefer MCP graph tools over grep, glob, or file search for code discovery.

Priority Order

  1. search_graph — find functions, classes, routes, and variables by pattern.
  2. trace_path — trace who calls a function or what it calls.
  3. get_code_snippet — read specific function or class source code.
  4. check_index_coverage — validate candidate paths and missed ranges before claims.
  5. query_graph — run Cypher queries for complex patterns.
  6. get_architecture — get a high-level project summary.

Quick Decision Matrix

Use project="@current" for eligible graph reads in the active checkout, or use the exact project="<name>" returned by list_projects. Never replace @current with its borrowed source project in later graph calls because the alias revalidates the worktree on every call.

Question Tool call
Who calls X? trace_path(project="<name>", function_name="X", direction="inbound")
What does X call? trace_path(project="<name>", function_name="X", direction="outbound")
Full call context trace_path(project="<name>", function_name="X", direction="both")
Find by name pattern search_graph(project="<name>", name_pattern="...")
Dead code search_graph(project="<name>", max_degree=0, exclude_entry_points=true)
Cross-service edges query_graph(project="<name>", query="<cypher>")
Impact of local changes detect_changes(project="<name>")
Risk-classified trace trace_path(project="<name>", function_name="X", risk_labels=true)
Text search search_code(project="<name>", pattern="...") or Grep

Current Worktree Resolution

  • index_status(project="@current") resolves an existing current-root index first.
  • In an unindexed linked worktree, @current borrows a canonical checkout graph only when both trees are clean, share one Git common directory and HEAD, and the graph-recorded Branch snapshot matches.
  • Keep using @current for search_graph, query_graph, trace_path, get_code_snippet, get_graph_schema, get_architecture, and index_status so each call revalidates the borrowed snapshot.
  • Inspect pi_cbmem_resolution; borrowed_canonical_base means the result is read-only borrowed graph evidence rather than a worktree index.
  • Borrowed get_code_snippet reads the reported lines from the current worktree.
  • Do not use @current with search_code, check_index_coverage, detect_changes, manage_adr, ingest_traces, delete_project, or index_repository.
  • For required coverage on borrowed evidence, call check_index_coverage once with the reported source project, read flagged paths from the current worktree, then rerun index_status(project="@current") before relying on the result. Do not use the reported source project for graph reads.
  • If @current rejects a dirty, divergent, stale, missing, or ambiguous context, do not bypass the guard with the canonical project name. Index the worktree or use current-root file reads and grep instead.
  • Treat borrowed coverage as best-effort because Codebase Memory exposes no immutable generation lease or complete semantic-input comparison.

Read the full file on GitHub · 134 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 · 134 lines · 98 tokens per session scan A 4593d85479e0

Subscribe to this mod's changes

codebase-memory is a skill published in the GitHub repository narumiruna/pi-extensions (472 stars, last pushed 2d ago), licensed MIT. It adds 98 tokens to every session and 2,170 once invoked, about $0.0005 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-08-30.

Related

Other skills, from other repositories

pi-tui-design

Create distinctive, crafted TUI components for pi using @mariozechner/pi-tui and @mariozechner/pi-coding-agent. Use when building interactive terminal UIs — custom components, overlays, dialogs, dashboards, widgets, data visualizations, animated elements, game-like interfaces, or any visual TUI work inside pi…

joelhooks/pi-tools · 139 tokens

session-search

Search and verify Joel's Pi, Claude, Codex, Cursor, Grok, and OpenCode session history. Use when asked to recover prior context, find exact transcript evidence, inspect session receipts, continue old work, or verify capture health. Prefer flowing recall before raw transcript search when the question is about prior…

joelhooks/pi-tools · 70 tokens

linear-tracker

Resolve project-local issue tracker routing and publish Linear issues safely. Use before creating Linear issues, PRDs, phase breakdown issues, or when deciding whether Linear/GitHub/local docs is the configured tracker. Enforces capability ≠ routing: Linear requires project-local policy, team association, auth, and…

joelhooks/pi-tools · 67 tokens

shortlink-qr

Create joel.dev shortlinks and QR assets. Use when Joel asks for a QR code, stage/demo shortlink, joel.dev redirect, link label that looks good in phone camera UI, or a copyable QR asset.

joelhooks/pi-tools · 51 tokens

session-capture

Historical pointer for the retired Codex-to-Central capture plugin. Use only to inspect legacy state during migration; current capture belongs to the joelclaw flowing-memory host adapter.

joelhooks/pi-tools · 40 tokens

multiline-description

This is a multiline description. It spans multiple lines. And should be normalized.

joelhooks/pi-tools · 20 tokens