This guide explains how to build and use a local SQLite index for fast repository search and analysis. The index is not committed to Git.
The index speeds up:
- Searching for markers and concepts across the repository
- Locating entry points and dependencies
- Finding likely files for bug fixes and reviews
- Querying by language, marker type, or annotation
The index is stored in:
./local/repo-index.sqlite
This keeps it out of Git by default (the local/ directory is in .gitignore) and avoids merge conflicts.
You may override the location using environment variables if required.
- Python entry point:
scripts/repo-index.py - Library module:
scripts/repo_index_lib.py - Bash wrapper:
scripts/repo-index.sh
Use either script. The wrapper calls python3 and passes arguments through.
Build the index:
python3 scripts/repo-index.py buildRebuild (delete then build):
python3 scripts/repo-index.py rebuildIncremental update (re-index only files changed since the last build):
python3 scripts/repo-index.py updateClear the index:
python3 scripts/repo-index.py clearShow status:
python3 scripts/repo-index.py statusSearch:
python3 scripts/repo-index.py search "@entrypoint" --limit 50Optional environment variables:
_REPO_INDEX_ROOT=/path/to/repo
_REPO_INDEX_DIR=/path/to/index/dir
_REPO_INDEX_MAX_BYTES=1000000
_REPO_INDEX_EXTS=.cs,.ts,.js,.html,.css,.md,.sql,.json,.yml,.yaml,.sh,.ps1,.txt,.py,.csproj,.sln,.xml,.razor,.cshtml
_REPO_INDEX_EXCLUDED=.git,.vs,.obsidian,node_modules,bin,obj,coverage,dist,build,out,tmp,temp,wwwroot,local
Rebuild the index after any of the following:
- A marker migration pass (see
MARKER_MIGRATION.md) - Major code restructuring or file renames
- Adding a new sub-application or module
- Pulling significant changes from the remote
For day-to-day changes, use update instead of rebuild to re-index only modified files.
All text files matching the configured extensions are indexed. The default set covers: .cs, .ts, .js, .html, .css, .md, .sql, .json, .yml, .yaml, .sh, .ps1, .txt, .py, .csproj, .sln, .xml, .razor, .cshtml.
The indexer captures markers from both MARKERS.md and COMMENTING.md:
| Category | Patterns |
|---|---|
| Navigation | @entrypoint, @dependency, @maps_to, @config, @middleware, @background |
| Flow | Dispatches:, Handles:, Delegates to: |
| Agent work | @agent:test, @agent:security, @agent:review, @agent:refactor |
| Concepts | [[, ⚓ |
| Annotations | TODO, FIXME, BUG, BUGFIX, HACK, PERF, SECURITY, DEPRECATED |
Basic marker search:
python3 scripts/repo-index.py search "@entrypoint" --limit 20Find all files related to a concept:
python3 scripts/repo-index.py search "TaxCalculation"Find security-sensitive code:
python3 scripts/repo-index.py search "SECURITY"Find TODO items:
python3 scripts/repo-index.py search "TODO" --limit 100Find files that map to a database table:
python3 scripts/repo-index.py search "@maps_to"- Files larger than
_REPO_INDEX_MAX_BYTES(default 1 MB) are skipped. - Only UTF-8 text files are indexed.
- Marker hints like
@entrypoint,@maps_to,⚓,[[Concept]],TODO,SECURITY, etc. are captured in a dedicated column for fast filtering. - The index complements but does not replace the knowledge base in
./agentknowledge/. Use the index for full-text search; use the knowledge base for structured concept and decision queries.