Setup indexing
Install a greppable code index so agents locate files/symbols without rescanning the project every session — generates an index.sh (dirs/files/symbols with file:line, per repo or workspace member), wires .gitignore + CLAUDE.md, offers a SessionStart refresh hook, then runs a validation pipeline (syntax, edge-case sandbox, measured recall check, staleness detection, optional A/B benchmark). Use whenever the user wants to set up code indexing, complains that the agent re-scans/re-explores the whole project to find things, asks to make agent search faster/cheaper, or mentions a project index, code map, symbol index, or ctags-like setup for agents.From its SKILL.md
npx -y skills add Myra-Agents/skills --skill setup-indexingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
6.5 KB, ~1.5k tokens by cl100k_base, as published. Nobody here has run it
Setup code indexing for agents
Install a per-repo greppable index at .claude/index/<member>.md with three
sections — ## dirs, ## files, ## symbols (path:line:definition) — so an
agent answers "where is X?" with one grep on one file instead of fanning
Glob/Grep/Read across the tree. Measured effect on a real multi-repo workspace:
same accuracy as free exploration, ~30% less context processed, ~40% less wall
time, zero junk matches (worktree/vendored copies excluded by construction).
The work has two halves and the second is not optional: install, then validate with measurements. Every gate in the validation pipeline exists because skipping it shipped a real bug at least once.
1. Survey the project (before writing anything)
- Layout: single repo, or a workspace whose members are separate gitignored
clones (check
.gitignorefor directory entries like/app/)? Each indexed unit needs its own.git. - Submodules:
cat .gitmodulesin each member.git ls-filesdoes not descend into them — the template handles this, but you need to know they exist to verify they got indexed. - Languages: the template covers TS/JS (incl. routes), Rust, Go, shell,
Python, and extensionless node/sh/python shebang executables. Anything else
(Ruby, Java, C#…) needs a
PAT_*+ anall_symbolsline — POSIX ERE only (must run on BSD grep), anchor definitions, favor recall over precision. - Existing tooling: if the project already has ctags/LSP index generation, prefer extending that over installing a parallel system — surface the choice to the user.
2. Install
- Copy
assets/index.sh.templateto the project root asindex.sh,chmod +x. SetMEMBERS_ALL:"root"alone for a single repo; append member dir names for a workspace ("root app shared hub"). Adapt the header comment to the project's voice. - Add
/.claude/index/to.gitignorebefore the first run — otherwise the root index lists itself and every regeneration dirties the tree. - Run
./index.sh. Read one generated file's header and spot-check a few symbol lines before proceeding.
Why the template is the way it is (don't simplify these away):
- Targets stock macOS bash 3.2 + BSD tools under
set -euo pipefail. The|| trueon grep pipelines is load-bearing: grep exits 1 on no-match, which under pipefail truncates the index mid-write and leaves a header that makes--checklie "fresh". git ls-files(tracked +--others --exclude-standard) instead of find/rg: excludes worktrees, node_modules, build output by construction — this is where the measured quality win comes from.- Header carries HEAD and a working-tree fingerprint: HEAD alone misses
uncommitted edits, so line numbers drift while
--checksays fresh. grep -e "$pat" --: a dash-prefixed filename otherwise becomes a grep option and silently empties the whole batch.sort -u | cut -c1-250: embedded-blob consts (multi-KB single lines) would drown every grep that touches them.
3. Wire it up
-
CLAUDE.md (project root) — add a section so every session learns the index exists; without this the index is dead weight. Pattern:
## Code index — locate things WITHOUT scanning the repos `.claude/index/<member>.md` (gitignored, generated by `./index.sh`) is a greppable index: `## dirs`, `## files`, `## symbols` (path:line:definition). **Before reaching for Glob/Grep across the tree, grep the index first:** ```bash grep -n "SomeSymbol" .claude/index/<member>.md # symbol → file:line ./index.sh --check || ./index.sh # refresh if stale (seconds) ``` -
Member CLAUDE.md files (multi-repo only): a short conditional note — "when this clone lives inside the <workspace> dev workspace, a greppable index of this repo is at
../.claude/index/<m>.md…". Conditional phrasing matters: standalone clones must not be misled. One commit per member repo; ask before pushing. -
SessionStart hook (optional, recommended): auto-refresh at session start. Do not edit
.claude/settings.jsonyourself — permission classifiers (rightly) block agents self-modifying startup config; it was denied when attempted. Give the user the JSON and let them add it:{ "hooks": { "SessionStart": [ { "hooks": [ { "type": "command", "command": "\"$CLAUDE_PROJECT_DIR\"/index.sh --quiet 2>/dev/null || true", "async": true, "timeout": 120, "statusMessage": "Refreshing code indexes" } ] } ] } }async: trueso a 2-second regeneration never blocks session start; the previous index stays usable meanwhile. Without the hook the setup still works — the CLAUDE.md instruction makes agents run--checkthemselves.
4. Validate
Read references/validation.md and run the gates: (1) syntax + full run,
(2) edge-case sandbox (empty/flat/dash-file repos), (3) measured recall
check — 8 elements picked by independent exploration, ≥7/8 locatable via
the index alone, any fully-missing category is a fail regardless of score,
(4) staleness detection (uncommitted-edit fingerprint), (5) optional A/B
benchmark when the user wants numbers.
Gate 3 is the heart. The first build of this system scored 8/8 on four repos and 4/8 on the fifth — every miss was a category (non-exported JS defs, extensionless node executables) invisible to the initial patterns. Only the measurement caught it.
5. Report
Summarize: files installed, index sizes + generation time, validation table
(gate / pass / one-line evidence), what was skipped, and the hook JSON if the
user hasn't applied it yet. Remind: regenerate after big refactors;
--check is cheap (~0.1s) and catches drift including uncommitted edits.
What ships with it: 6 files
19.4 KB alongside SKILL.md
assets/
- index.sh.template7.3 KB
evals/
- evals.json2.7 KB
references/
- validation.md5.1 KB
- .gitignore15 B
- LICENSE1.0 KB
- README.md3.3 KB