(Was previously 'repo-to-prompt', written in python, which was okay. But now the thing's charged with the Speed Force β‘οΈππ»)
Turn a code repository into a tidy "context pack" you can paste into an LLM β or feed into a RAG pipeline.
repo-context scans a repository and exports high-signal text bundles:
context_pack.mdβ a structured markdown doc you can paste into ChatGPT/Claude/etc.chunks.jsonlβ one chunk per line (great for embeddings + retrieval)report.jsonβ stats + what got included/skipped
It tries to keep the important stuff (READMEs, configs, entrypoints, core source) and skip the less impactful resources (generated files, vendor folders, giant binaries).
- You want an LLM to help with a repo without dumping your whole codebase into chat. π«©
- You want repeatable outputs (stable ordering + stable chunk IDs).
- You want basic protection against accidentally leaking secrets (optional redaction).
- Picks important files first (docs + entrypoints beat tests + build artifacts)
- Chunks code in a sane way (tries to split at functions/classes/modules when possible)
- Respects
.gitignoreby default - Can clone remote repos (GitHub / HuggingFace)
- Optional secret redaction (tokens/keys/password-y strings)
- Task-aware retrieval (
--task) with symbol/dependency expansion - Two-phase retrieval (BM25 + semantic rerank) with audit tags in output
- Module thread stitching with reserved token budget for related definitions/import-neighbors
- PR-focused mode (
--mode pr-context) with Touch Points / Entrypoints / Invariants - SQLite symbol graph export (
symbol_graph.db) for local graph-aware workflows - Guardrails in context packs (Claims Index + Missing Pieces heuristics)
- Local index workflow (
index/query) + portable code-intel export (codeintel) - Context diff mode (
diff) with text/markdown/json output formats
Grab the latest release from the GitHub Releases page and put repo-context somewhere on your PATH.
git clone https://github.com/wheevu/repo-context.git
cd repo-context
cargo build --release
# The binary will be at: target/release/repo-context
# Or install to ~/.cargo/bin
cargo install --path .Export a local repo:
repo-context export --path .Export from a remote repo:
repo-context export --repo https://github.com/owner/repoShow repo stats only (no export files):
repo-context info .repo-context export is interactive by default in terminals:
- Quick scan (fast, high-signal defaults)
- Architecture overview (stronger dependency/system context)
- Deep dive specific areas (repo-specific focus selection)
- Full context (largest practical context bundle)
In non-interactive sessions (CI/pipes), it automatically falls back to quick defaults.
Skip prompts explicitly:
repo-context export --path . --quickSmall + high-signal export (non-interactive)
repo-context export -p . \
--quick \
--include-ext ".rs,.toml,.md" \
--exclude-glob "tests/**,target/**"Architecture understanding for an unfamiliar repo
repo-context export -p . --task "overall architecture and dependencies" --mode bothDeep dive into a feature path
repo-context export -p . --task "trace auth refresh and token validation flow"RAG-only output
repo-context export -p . --mode rag -o ./embeddingsReproducible outputs for version-to-version diffs
repo-context export -p . --no-timestampStrict token-budget handling with always-include files
# hard-error if always-include files alone exceed --max-tokens
repo-context export -p . --max-tokens 50000
# explicitly allow always-include overflow
repo-context export -p . --max-tokens 50000 --allow-over-budgetBest stitching quality (index first, export second)
repo-context index -p .
repo-context export -p . --task "trace auth refresh flow"Build local index and query it repeatedly
repo-context index -p .
repo-context query --task "where are retries and backoff handled?" --expandPortable code-intel output from local index
repo-context codeintel --db .repo-context/index.sqlite --out .repo-context/codeintel.jsonCompare two exports
repo-context diff out/repo-a out/repo-b
repo-context diff out/repo-a out/repo-b --format markdown
repo-context diff out/repo-a out/repo-b --format jsonexport- create context artifacts (context_pack,chunks, report, graph)info- scan + ranking summary onlyindex- build local SQLite retrieval/symbol indexquery- retrieve task-relevant chunks from indexcodeintel- export portable SCIP-like JSON from indexdiff- compare two exports
Input source
-p, --path <PATH>local repository path-r, --repo <URL>remote repository URL (GitHub/HuggingFace)--ref <REF>branch/tag/SHA when using--repo-c, --config <FILE>config file path
Scope and filtering
-i, --include-ext <EXTS>extension allowlist (.rs,.toml,.md)-e, --exclude-glob <GLOBS>exclude globs--max-file-bytes <BYTES>per-file size cap--max-total-bytes <BYTES>total scan byte cap--no-gitignoreignore.gitignore--follow-symlinksfollow symlinks--include-minifiedinclude minified/bundled files
Retrieval and ranking
-t, --max-tokens <TOKENS>output token budget--allow-over-budgetallow always-include overflow--task <TEXT>task-aware reranking query--no-semantic-rerankdisable semantic rerank stage--semantic-model <MODEL>semantic model identifier--rerank-top-k <N>number of chunks for semantic reranking--stitch-budget-fraction <FLOAT>reserved budget for stitched context--stitch-top-n <N>top-ranked seed chunks for stitching
Chunking
--chunk-tokens <TOKENS>target chunk size--chunk-overlap <TOKENS>chunk overlap--min-chunk-tokens <TOKENS>coalescing threshold
Output and rendering
-m, --mode <MODE>prompt|rag|contribution|pr-context|both-o, --output-dir <DIR>output base directory--no-timestampreproducible output (no timestamp fields)--tree-depth <DEPTH>tree depth in rendered context pack--no-graphskipsymbol_graph.dboutput--quickskip guided menu and run non-interactive defaults
Redaction
--no-redactdisable secret redaction--redaction-mode <MODE>fast|standard|paranoid|structure-safe
<PATH>repo path to inspect-i, --include-ext <EXTS>extension allowlist-e, --exclude-glob <GLOBS>exclude globs--max-file-bytes <BYTES>per-file size cap--no-gitignoreignore.gitignore--follow-symlinksfollow symlinks--include-minifiedinclude minified/bundled files
-p, --path <PATH>local path to index-r, --repo <URL>remote URL to clone and index--ref <REF>branch/tag/SHA for--repo-c, --config <FILE>config file path--db <FILE>SQLite output path (default:.repo-context/index.sqlite)-i, --include-ext <EXTS>extension allowlist-e, --exclude-glob <GLOBS>exclude globs--max-file-bytes <BYTES>per-file size cap--max-total-bytes <BYTES>total scan byte cap--no-gitignoreignore.gitignore--follow-symlinksfollow symlinks--include-minifiedinclude minified/bundled files--chunk-tokens <TOKENS>chunk size target--chunk-overlap <TOKENS>chunk overlap--min-chunk-tokens <TOKENS>coalescing threshold--lspenrich with rust-analyzer symbol references
--db <FILE>index database path--task <TEXT>required retrieval query text-n, --limit <COUNT>max hits to show--lsp-backend <MODE>off|auto|rust-analyzer--expandinclude definitions/callers/tests/docs expansions
--db <FILE>index database path--out <FILE>output JSON path
<BEFORE> <AFTER>directories containing prior/current exports--format <FORMAT>text|markdown|json
-v, --verboseset log level to DEBUG-h, --helpand-V, --version
Outputs go to: <output-dir>/<repo-name>/
Files:
<repo-name>_context_pack.mdβ overview + tree + key files + chunked content<repo-name>_chunks.jsonlβ{ id, path, lang, start_line, end_line, content, ... }<repo-name>_report.jsonβ scan/export stats + skip reasons<repo-name>_symbol_graph.dbβ persisted symbol/import graph (unless--no-graph)
By default, it looks for one of these files in the repository root:
repo-context.toml,.repo-context.tomlr2p.toml,.r2p.tomlr2p.yml/.yaml,.r2p.yml/.yaml
CLI flags override config values.
Example config (`r2p.toml`)
[repo-context]
include_extensions = [".rs", ".toml", ".md"]
exclude_globs = ["tests/**", "target/**"]
chunk_tokens = 800
chunk_overlap = 120
min_chunk_tokens = 200
output_dir = "./out"
mode = "both"
tree_depth = 4
respect_gitignore = true
redact_secrets = trueBy default, repo-context can detect and replace common secrets with placeholders like:
[AWS_ACCESS_KEY_REDACTED]
You can also allowlist paths/strings or add your own patterns via config.
cargo test
cargo fmt
cargo clippy --all-targets --all-features
cargo build --release