index-codebase

A command that creates a searchable index of a project’s JavaScript and TypeScript source code. Semantic search finds code by meaning or intent, not only by exact words.

In plain words
What is it for?
Use it to check the current index, perform a first or incremental indexing run, refresh everything when needed, and then search the codebase semantically.
Why use it?
It makes it easier to locate relevant code in a large project and keeps the search index up to date when files change. The command reports what it indexed, skipped, removed, or could not process.

Command

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 commands/matteodante/claude-local-docs/index-codebase
Clone the repo
git clone --depth 1 https://github.com/matteodante/claude-local-docs
Per session 8 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 378 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.00008 $0.00378
Opus 5 $0.00004 $0.00189
Sonnet 5 $0.00002 $0.00076
Haiku 4.5 $0.00001 $0.00038

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

Security

Grade A, and why

index-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 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.

commands/index-codebase.md · 54 lines

What it actually says

Index Project Codebase

You are a codebase indexing agent. Your job is to index the project's source code so it can be searched semantically with search_code.

Steps

1. Check Current Status

Call get_codebase_status to see:

  • Whether any code has been indexed before
  • How many files are currently indexed
  • Language breakdown (TypeScript vs JavaScript)
  • Files that have changed since last index

2. Run Indexing

Based on the status:

  • First time: Call index_codebase with no parameters. This will index all JS/TS files.
  • Files changed: Call index_codebase with no parameters. Incremental indexing will only process changed files.
  • Force refresh: Call index_codebase with forceReindex: true to re-index everything.
  • Up to date: If no files have changed, tell the user the index is current.

3. Report Results

After indexing completes, report:

Codebase indexed!

  TypeScript: 45 files
  JavaScript: 12 files
  Total: 57 files, 320 chunks

  Indexed: 15 files (changed)
  Skipped: 42 files (unchanged)
  Removed: 0 files (deleted)

Use search_code to search your codebase semantically.

If there were errors, list them so the user can investigate.

Critical Rules

  • Always check status first — avoid unnecessary full re-indexing
  • Report per-language breakdown
  • Mention search_code is available after indexing
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 · 54 lines · 8 tokens per session scan A 432a772ac9b1

Subscribe to this mod's changes

index-codebase is a command published in the GitHub repository matteodante/claude-local-docs (5 stars, last pushed 6mo ago), licensed MIT. It adds 8 tokens to every session and 378 once invoked, about $0.0000 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-31.