agentleFS
BostonOrangeBostonOrange/claude-code-framework/skills/index/SKILL.md

index

Skill2 starsChanged 6 months agoMITView on GitHub

Build or refresh a vector index of the codebase at `.claude/state/codebase.db` for semantic search via `/search`. Opt-in for large codebases (>50k LOC); small projects get sufficient awareness from `.claude/state/architecture.md` + Grep

  • Reads credentials

8 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Run bash .claude/hooks/codebase-index.sh stats first.

    line 42
  2. Distinctive:

    After completion, surface to the user:

    line 62

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Index — Build the Codebase Vector Index

For codebases where Grep + architecture.md aren't enough — typically >50k LOC — /index builds a SQLite + sqlite-vec index that powers /search. The index is gitignored, lives at .claude/state/codebase.db, and updates incrementally on subsequent runs.

Usage

/index                              full build (only files not yet indexed; subsequent runs are incremental)
/index --full                       force re-embed every file (use after changing chunking config)
/index --include='\.cls$|\.trigger$' index only Apex files (Salesforce)
/index --provider=local             use Ollama local embeddings instead of Voyage/OpenAI
/index stats                        show index size, file count, age
/index purge                        delete the index entirely

Setup

The index requires an embedding provider. Pick one before first run:

ProviderSetupCost (1M LOC)QualityPrivacy
voyage (default)export VOYAGE_API_KEY=... (signup)~$2.50 one-time, $0.05/incremental commitBest for codeAPI
openaiexport OPENAI_API_KEY=...~$0.50 one-timeGoodAPI
localollama pull nomic-embed-text && ollama serveFree, ~6hr initial on MacLowerAll local

Configure via env vars (typically in .env or shell profile):

export CLAUDE_FRAMEWORK_EMBED_PROVIDER=voyage   # or openai, local
export VOYAGE_API_KEY=<your-key>

Process

Phase 1: Verify provider config

Run bash .claude/hooks/codebase-index.sh stats first. If no index, check $CLAUDE_FRAMEWORK_EMBED_PROVIDER and the corresponding API key. If unset, prompt the user to configure before proceeding.

Phase 2: Run the index command

bash .claude/hooks/codebase-index.sh index [args]

The script:

  1. Walks the working tree via git ls-files (respects .gitignore)
  2. Filters by include globs (defaults to common code extensions; configurable via --include)
  3. For each file: computes git SHA, skips if already indexed at that SHA (incremental)
  4. Chunks the file into 40-line windows with 8-line overlap
  5. Embeds each chunk via the configured provider
  6. Stores (file_path, line_start, line_end, content, sha, embedding) in SQLite

Streaming progress to stderr: indexing: <path> per file.

Phase 3: Report

After completion, surface to the user:

  • Files indexed (count)
  • Chunks created (count)
  • DB size
  • Time elapsed
  • Cost estimate (if cloud provider)

Phase 4: Suggest next action

  • First-time index: "Run /search 'natural language query' to test the index. Try queries you'd otherwise grep for but can't ('where do we handle invoice numbers?')."
  • Incremental refresh: "Re-indexed N changed files in <time>. Index is current."

State Files

FilePurposeLifecycle
.claude/state/codebase.dbSQLite index with chunks + embeddingsBuilt by /index; incremental on subsequent runs; purge with /index purge

Gitignored under .claude/state/.

When /index Earns Its Place

Project sizeRecommendation
<10k LOCSkip. Grep + architecture.md is sufficient.
10-50k LOCOptional. /search becomes useful for "where do we…" queries.
50k-500k LOCRecommended. Grep alone misses semantic neighbors.
500k-5M LOCStrongly recommended. The framework was extended for this scale specifically.
>5M LOCRequired. Plus consider GitNexus or similar for precise call graphs.

Salesforce-Specific Notes

For a Salesforce org indexed via SFDX:

/index --include='\.cls$|\.trigger$|\.cmp$|\.html$|\.js$|\.flow-meta\.xml$'

Tags Apex / LWC / Flow content distinctly (the chunk's file_path carries the metadata type via extension). Searches can filter:

/search "rate limit logic" --include=apex

Initial index of a 1M-line org takes ~2-4 hours via Voyage; subsequent commits are seconds. Plan for "kick it off, walk away."

Edge Cases

ScenarioBehavior
First run with no provider configuredHalt; tell user to set CLAUDE_FRAMEWORK_EMBED_PROVIDER and API key
API key unset for selected providerHalt with the exact env var name
git ls-files returns emptyHalt with "not in a git repo or no tracked files"
Chunking config changedPass --full to force re-embed
Network failure mid-indexResume on re-run (incremental skip catches already-indexed files)
Hitting rate limitsAdd sleep between API calls; configurable via CLAUDE_FRAMEWORK_INDEX_RATE_LIMIT (future)
Salesforce 1M+ LOCPlan for hours; run in background (nohup ... &); check progress with /index stats

Related

  • /search — query the index built by this skill
  • .claude/state/architecture.md — broad map (refreshed by /improve); complements semantic search
  • /impact — precise per-symbol cascade analysis (uses Grep, not the vector index)
  • templates/hooks/codebase-index.sh — the bash engine

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.