Convert Repomix/repominify output into compact AI-friendly codebase summaries using free LLMs.
Project description
savetoken ๐ช
Transform your Repomix codebase dump into a high-fidelity AI context brief โ ~83% fewer tokens than sending the raw zip, ~88% fidelity to the original.
Instead of pasting hundreds of thousands of tokens of source code into an AI,
savetoken produces a structured codebrief.md that the AI can reason about
just as effectively, at a fraction of the cost.
How it fits in your workflow
Your project
โ
npx repomix # pack codebase โ repomix-output.xml
โ
savetoken summarize repomix-output.xml # analyse โ codebrief.md
โ
Paste codebrief.md into your AI prompt # 17% of tokens, ~88% fidelity
Install
pip install savetoken
Requires Python 3.10+. Zero runtime dependencies โ stdlib only (ast, urllib, json, hashlib, re).
Quick start
# 1. Pack your codebase with Repomix
npx repomix
# 2. Generate context brief (Gemini Flash is free and recommended)
export GEMINI_API_KEY=your_key_here
savetoken summarize repomix-output.xml
# Output: codebrief.md โ paste into any AI prompt
Python API
from savetoken import SaveToken
st = SaveToken(provider="gemini", api_key="...")
summary = st.summarize("repomix-output.xml")
st.save(summary, "codebrief.md")
What's in the output
savetoken extracts seven categories of information, each via the most accurate method available:
| Section | Source | Fidelity |
|---|---|---|
| Strategic files (schemas, configs, entry points, tests) | verbatim | 100% |
| Hot functions (most-called by PageRank) | verbatim | 100% |
| File docs (module/class/fn docstrings, signatures, constants) | AST | ~95% |
| Execution flows (entry โ service โ repo โ db) | call graph trace | ~90% |
| Call graph (cross-file function calls, prod/test split) | AST | ~90% |
| Environment contract (all env vars, defaults, required) | AST | 100% |
| SQL schema (tables, columns, FKs, indexes) | AST | ~95% |
| Critical blocks (HACK/FIXME with ยฑ10 lines context) | verbatim | 100% |
No LLM is called for Python files. Docstrings and signatures are extracted directly from source โ zero hallucination, instant, cacheable. LLM calls are only used for: project overview, flow descriptions, and non-Python file summaries.
Providers
| Provider | Model | Free tier | Env var |
|---|---|---|---|
gemini โญ |
Gemini 2.0 Flash | โ Generous, 1M ctx | GEMINI_API_KEY |
groq |
Llama 3.3 70B | โ Fast | GROQ_API_KEY |
mistral |
Mistral Small Latest | โ Available | MISTRAL_API_KEY |
openai |
gpt-4o-mini | Paid | OPENAI_API_KEY |
deepseek |
deepseek-chat | Very cheap | DEEPSEEK_API_KEY |
Gemini is recommended โ 1M token context handles any codebase size.
CLI reference
savetoken summarize repomix-output.xml
savetoken summarize repomix-output.xml \
--provider groq \
--output codebrief.md \
--format markdown \
--lang pt \
--target-ratio 0.50 \
--flow-depth 5 \
--force # ignore cache, regenerate everything
savetoken cache-stats
savetoken clear-cache
| Flag | Default | Description |
|---|---|---|
--provider |
gemini |
LLM provider |
--output |
codebrief.md |
Output path |
--format |
markdown |
markdown or json |
--lang |
en |
Language for generated descriptions |
--target-ratio |
0.50 |
Max output/input token ratio |
--flow-depth |
5 |
Max hops in execution flow traces |
--force |
off | Bypass cache |
--cache-dir |
.savetoken_cache |
Cache directory |
--quiet |
off | Suppress per-file progress |
Caching
Every file is hashed by content. On re-runs, only changed files are
re-processed. The cache lives in .savetoken_cache/ โ commit it to share
across your team. Cache keys are schema-versioned: any model change
automatically invalidates stale entries.
savetoken cache-stats # entries, size, schema version
savetoken clear-cache
Real-world numbers (datalock โ 59 files, 271k tokens)
Raw codebase (zip): 271,252 tokens 100% fidelity 100%
savetoken output: 47,204 tokens 17% fidelity ~88%
Savings: 83%
Token breakdown:
- Strategic verbatim (11 files): 26%
- File Docs / AST (48 files): 44%
- Call graph (1,139 edges): 25%
- Flows, env, overhead: 5%
VS Code extension
Located in vscode-extension/. Commands:
- SaveToken: Summarize Codebase โ runs on
repomix-output.xml - SaveToken: Open Summary
- SaveToken: Clear Cache
Settings: savetoken.provider, savetoken.apiKey, savetoken.language,
savetoken.outputFile, savetoken.autoSummarizeOnRepomix.
Project structure
savetoken/
โโโ savetoken/
โ โโโ core.py Orchestrator โ full pipeline
โ โโโ models.py All dataclasses (FileSummary, Flow, etc.)
โ โโโ classifier.py STRATEGIC / AST / REGULAR / SKIP per file
โ โโโ budget.py Token budget allocation (post-classification)
โ โโโ analyzer.py AST call graph + inheritance (prod/test split)
โ โโโ ast_types.py Function signature extraction via AST
โ โโโ docstring_extractor.py Module/class/fn docstrings + constants (NEW)
โ โโโ ranker.py PageRank centrality โ hot functions
โ โโโ flows.py Execution flow tracer (BFS on call graph)
โ โโโ env_extractor.py Environment variable extractor
โ โโโ schema_sql.py SQL schema (Django/SQLAlchemy/Alembic/raw SQL)
โ โโโ critical_context.py HACK/FIXME blocks with ยฑ10 line context
โ โโโ deduplicator.py Remove cross-section redundancy
โ โโโ output.py Markdown + JSON renderers
โ โโโ cache.py File-based cache with schema versioning
โ โโโ cli.py CLI entry point
โ โโโ exceptions.py SaveTokenError hierarchy
โ โโโ providers/
โ โโโ base.py Abstract provider + prompts
โ โโโ gemini.py Gemini 2.0 Flash
โ โโโ groq.py Groq / Llama 3.3 70B
โ โโโ mistral.py Mistral Small
โ โโโ openai.py OpenAI-compatible (OpenAI, DeepSeek, Ollama)
โโโ vscode-extension/ VS Code extension
โโโ tests/ 117 unit + integration tests
โโโ examples/ Usage examples
โโโ pyproject.toml
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file savetoken-0.1.1.tar.gz.
File metadata
- Download URL: savetoken-0.1.1.tar.gz
- Upload date:
- Size: 48.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27cafd0c9f0c730e1a0678eaae8c63acdaad1147a38254d21c8a00adc9f41157
|
|
| MD5 |
08a05c517405c5197a8d1ac729bb5897
|
|
| BLAKE2b-256 |
e4c1573098ff486a468de8012f1ce7d6ae10ccfd3a2fd04692f2c31a3f541d7f
|
File details
Details for the file savetoken-0.1.1-py3-none-any.whl.
File metadata
- Download URL: savetoken-0.1.1-py3-none-any.whl
- Upload date:
- Size: 47.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fce2c332d6ad482b3dc38ee3ef04f1150a7800db2c93e220429dc5b68a49bb2c
|
|
| MD5 |
52989d66da54afb339a7b8bdb3a57229
|
|
| BLAKE2b-256 |
b9eee8bcb1f640041bdcba5952b4ba5baed19b8999381a97d822ba996f751b93
|