⚡ Cut Claude token usage by 90%+ — free, open-source, local-first context compression for Claude Code. Hybrid RAG (BM25 + ONNX vectors), AST chunking, reranking. No API needed.
FAQ
claude-token-reducer is a Claude Code plugin with 1 hand-picked skill for development work, indexed on Flowy. Install it with the command on its page. It includes token-reducer. Its skills do not fire on their own yet. Request auto-invocation to have Flowy route them as you prompt. Free and open source.
> /plugin marketplace add Madhan230205/token-reducer> /plugin install claude-token-reducer@Madhan230205-claude-token-reducer
Repo: Madhan230205/token-reducer
The open-source alternative to expensive context management tools.
Easy Install • Features • Documentation • Contributing
Every time you use Claude with a large codebase, you're paying for thousands of tokens that aren't relevant to your query. Most context management tools either:
Token Reducer is a local-first, intelligent context compression pipeline that:
┌─────────────────┐ ┌───────────────┐ ┌──────────────────┐
│ Your Codebase │────▶│ Token Reducer │────▶│ Compressed │
│ (50,000 tokens)│ │ Pipeline │ │ Context (500t) │
└─────────────────┘ └───────────────┘ └──────────────────┘
│
┌─────────┴─────────┐
│ - AST Chunking │
│ - BM25 + Vector │
│ - TextRank │
│ - Import Graph │
│ - 2-Hop Symbols │
└───────────────────┘
/plugin Command (Recommended)Step 1: Register the marketplace (one-time setup):
/plugin marketplace add Madhan230205/token-reducer
This registers the marketplace as Madhan230205-token-reducer.
Step 2: Install:
/plugin install token-reducer@Madhan230205-token-reducer
For project-scoped install:
/plugin install token-reducer@Madhan230205-token-reducer --scope project
Already ran Step 1 before? Just run
/plugin install token-reducer@Madhan230205-token-reducer— no need to add the marketplace again.
# 1. Clone into your Claude plugins folder
git clone https://github.com/Madhan230205/token-reducer.git ~/.claude/plugins/token-reducer
# 2. Install dependencies (optional but recommended for best results)
pip install -r ~/.claude/plugins/token-reducer/requirements-optional.txt
Windows users: Replace
~/.claude/plugins/with%USERPROFILE%\.claude\plugins\
Then open ~/.claude/settings.json and add:
{
"plugins": ["~/.claude/plugins/token-reducer"]
}
Restart Claude Code. Done.
What requirements-optional.txt installs:
| Package | Purpose |
|---|---|
sentence-transformers | Neural embeddings for smarter retrieval |
hnswlib / faiss-cpu | Fast approximate nearest-neighbor search |
tree-sitter + language grammars | AST-based code chunking (Python, JS, TS, Go, Rust, Java, C/C++, Ruby) |
If you skip this step, Token Reducer still works using hash embeddings and regex chunking — no ML libraries required.
No pip, no ML libs — runs immediately after cloning:
git clone https://github.com/Madhan230205/token-reducer.git
cd token-reducer
python scripts/context_pipeline.py run \
--inputs ./src \
--query "Find auth logic" \
--embedding-backend hash \
--db .cache/index.db
settings.jsonQuery → FTS(BM25) → (Vector fallback if needed) → Merge → Top 5 → Compress
Full pipeline:
PREPROCESS → INDEX → RETRIEVE → RE-RANK → COMPRESS → CONTEXT PACKET
# Index your codebase
python scripts/context_pipeline.py index --inputs ./src --db .cache/index.db
# Query with compression
python scripts/context_pipeline.py query \
--query "How does authentication work?" \
--db .cache/index.db \
--json
# One-shot: index + query
python scripts/context_pipeline.py run \
--inputs ./src \
--query "Find the database connection logic" \
--db .cache/index.db
All settings in settings.json:
{
"tokenReducer": {
"chunkSizeWords": 220,
"embeddingModel": "jinaai/jina-embeddings-v2-base-code",
"hybridMode": "fallback",
"astChunkingEnabled": true,
"textRankEnabled": true,
"lspFeatures": {
"importGraphEnabled": true,
"twoHopExpansionEnabled": true
}
}
}
| Setting | Default | Description |
|---|---|---|
chunkSizeWords | 220 | Target words per chunk |
embeddingBackend | "ml" | "ml" for neural, "hash" for zero-dep |
embeddingModel | jina-v2-code | Code-optimized embeddings |
hybridMode | "fallback" | "fallback" or "always" for vector |
astChunkingEnabled | true | Use tree-sitter AST parsing |
textRankEnabled | true | Graph-based sentence scoring |
importGraphEnabled | true | Track file dependencies |
twoHopExpansionEnabled | true | Auto-expand referenced symbols |
compressionWordBudget | 350 | Max words in compressed output |
Run without any ML libraries:
python scripts/context_pipeline.py run \
--inputs ./src \
--query "Find auth logic" \
--embedding-backend hash \
--db .cache/index.db
python scripts/apply_diff.py --input claude_response.txt --dir ./src
python scripts/apply_diff.py --input response.txt --dry-run
token-reducer/
├── .claude-plugin/plugin.json
├── .mcp.json
├── .env.example
├── settings.json
├── requirements-optional.txt
├── scripts/
├── hooks/
├── commands/
├── agents/
├── skills/
└── evals/
If anyone is interested in contributing, this project is open to contributions. Please see contribute.md for contribution guidelines.
git clone https://github.com/Madhan230205/token-reducer.git
cd token-reducer
pip install -e ".[dev]"
python scripts/context_pipeline.py self-test
MIT License — see LICENSE for details.
Star this repo if Token Reducer saves you money!
.claude-plugin/
marketplace.json
plugin.json
.env.example
.gitattributes
.github/
issue-bodies/
01-sync-repo-metadata.md
02-harden-release-workflow.md
03-add-ci-metadata-validation.md
release-intro.md
settings.yml
workflows/
ci.yml
publish.yml
.gitignore
.mcp.json
agents/
context-compressor.md
hybrid-retriever.md
noise-chunker.md
se-ops-delegate.md
BENCHMARK.md
Cargo.lock
Cargo.toml
CHANGELOG.md
commands/
token-reducer.md
contribute.md
evals/
evals.json
hooks/
hooks.json
userprompt_guard.py
LICENSE
Makefile
MARKETPLACE.md
PLAN_phase1_perf_overhaul.md
pyproject.toml
README.md
requirements-optional.txt
scripts/
apply_diff.py
context_pipeline.py
token_reducer/
__init__.py
ann.py
benchmark.py
chunker.py
cli.py
compressor.py
config.py
db.py
embeddings.py
models.py
pipeline.py
plugin_settings.py
retriever.py
settings.json
skills/
token-reducer/
references/
context7-integration.md
implementation-guide.md
SKILL.md
src/
lib.rs
tests/
__init__.py
test_chunker.py
test_db.py
test_e2e_cli.py
test_embeddings.py© 2026 Flowy · Free and open source
Built for Claude Code · Not affiliated with Anthropic