/codebase:index [--mode full|moderate|fast|cross-repo-intelligence] [--link <project|*>]from codebase
Build, refresh, or link the codebase index. [--mode full|moderate|fast|cross-repo-intelligence] [--link <project|*>]
Ships in codebase. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Index the current codebase or link cross-repository service boundaries using codebase-memory-mcp. This builds, refreshes, or links the semantic and structural graph that all other /codebase:* commands query.
| Argument | Type | Default | Description |
|---|---|---|---|
--mode | string | moderate | Indexing mode: full (all semantic signals, slowest), moderate (structural + semantic similarity), fast (structural only, fastest), cross-repo-intelligence (link cross-service edges across indexed projects) |
--link | string | optional | Target project name(s) (comma-separated) or * to link against using cross-repo-intelligence mode |
Prefer MCP first. If its tools are absent or the server is unreachable, automatically try the CLI without asking:
command -v codebase-memory-mcp
codebase-memory-mcp cli --json list_projects
Set codebase_transport to mcp or cli. All tool calls below use that transport. For CLI calls, pipe the same JSON arguments to codebase-memory-mcp cli --json <tool> via stdin; inspect isError and read the result from content[] text. Use each tool's --help for supported flags and output formats. Query and indexing errors are not transport failures: report them accurately, not as missing MCP. On a later MCP connection failure, retry through CLI. Preserve project selection, index settings, and consent rules; do not install anything automatically.
Resolve the transport above. Only if neither MCP nor CLI works, explain that indexing requires either a configured MCP server or the installed codebase-memory-mcp CLI, then exit.
Read .claude/codebase.local.md if it exists. Parse the YAML frontmatter for index_mode. If the file does not exist, use the default mode (moderate).
The --mode argument takes priority over the saved index_mode setting.
Determine the repository root path:
git rev-parse --show-toplevel
Standard Indexing (--link is omitted and --mode is full, moderate, or fast):
Call the codebase-memory-mcp index_repository tool with:
repo_path: the repository root pathmode: the resolved mode from Step 2Print progress:
Indexing codebase (moderate)...
Cross-Repo Linking (--link <project|*> is passed, or --mode cross-repo-intelligence is used without --link, which defaults to --link *):
list_projects and check index_status for the current repository (git rev-parse --show-toplevel).index_repository call on repo_path using the saved index_mode from .claude/codebase.local.md (or moderate by default) and update .claude/codebase.local.md.--link is *, set target_projects: ["*"]. Otherwise, resolve each comma-separated project token in --link against list_projects in order: (1) exact name match, (2) exact root_path match, (3) case-insensitive suffix or basename match on name or root_path. If any named target project is not found in list_projects, stop and print:
Target project "[project]" is not indexed yet. Run `/codebase:index` in that repository first.
index_repository with:
repo_path: the repository root pathmode: "cross-repo-intelligence"target_projects: ["<resolved-target-project>", ...] (or ["*"])On standard indexing success, print the results from the index_repository response (file count, timing):
✓ Indexed [N] files in [T]s
Run the `codebase:ask` skill to explore your codebase.
Write or update .claude/codebase.local.md with the current timestamp, mode, commit and uncommitted-edit hash (git rev-parse HEAD and { git diff HEAD; git ls-files -o --exclude-standard -z | xargs -0 git hash-object --; } | git hash-object --stdin, computed immediately before calling index_repository):
---
auto_index: ask
index_mode: moderate
last_indexed: [current ISO 8601 timestamp]
last_indexed_commit: [HEAD sha]
dirty_hash: [hash of tracked and untracked changes]
---
Preserve any existing auto_index value and projects: map if the file already existed. Only update last_indexed, last_indexed_commit, dirty_hash and index_mode.
On cross-repo linking success, do not overwrite index_mode, last_indexed, last_indexed_commit or dirty_hash in .claude/codebase.local.md on a link-only run (only update .claude/codebase.local.md if Step 3 also ran a standard full|moderate|fast index). Print:
✓ Linked [current_project] with [target_projects] ([N] cross-repo edges)
Run `codebase:capabilities` or `codebase:seams` with `--project` to explore cross-repo flows.
On failure, print the error from the MCP tool and do NOT update last_indexed:
Index failed: [error message]
Try running with --mode full if you're seeing stale results.
What SKILL.md sets; muted values are Claude Code's defaults
Use when the codebase index must be built, refreshed, or linked across repositories: 'index this repo', 'reindex', 'index is stale', 'link repos', or when other codebase skills report no index. This only builds or links the index; to answer questions use the other codebase skills (ask, graph, impact, architecture, tour, and so on).
npx claudepluginhub jskswamy/skills --plugin codebase12 skills in this plugin
/dead-codeFind code nothing uses, with each candidate verified. [<path>]