Skip to content
Development
Command

/token-reducer

Build a compact context packet with preprocess, BM25-ranked FTS retrieval, adaptive vector fallback, reranked top-K chunks (default 3 from settings), relevance-floor filtering, and compression.

From plugin
claude-token-reducer
441 skill4 agents1 command1 hook
+1
Install
> /plugin marketplace add Madhan230205/token-reducer
> /plugin install claude-token-reducer@Madhan230205-claude-token-reducer

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/token-reducer

Context preview

What this command does when you run it.

Build a compact context packet with preprocess, BM25-ranked FTS retrieval, adaptive vector fallback, reranked top-K chunks (default 3 from settings), relevance-floor filtering, and compression.

Command definition

token-reducer.md
description: Build a compact context packet with preprocess, BM25-ranked FTS retrieval, adaptive vector fallback, reranked top-K chunks (default 3 from settings), relevance-floor filtering, and compression.
argument-hint: query [--inputs path1,path2] [--top-k 3-5] [--relevance-floor 0.15-0.25] [--hybrid-mode fallback|always] [--session-id id] [--json]
allowed-tools: [Read, Glob, Grep, Bash, Task]

token-reducer

Run the full token-slim pipeline and return a context packet suitable for Claude reasoning.

Input

User arguments:

`$ARGUMENTS`

Execution plan

1. If no explicit input paths are provided, default to current workspace root. 2. Run pipeline script in `run` mode. 3. Enforce FTS-first retrieval with BM25 scoring. 4. Run vector retrieval adaptively (fallback default), merge results, and keep top **K** reranked chunks (plugin default **3** via `settings.json` → `defaultTopK`). 5. Apply **`relevanceFloor`** so low-scoring chunks are not summarized. 6. Compress before response handoff.

Primary command

`python "${CLAUDE_PLUGIN_ROOT}/scripts/context_pipeline.py" run --inputs . --query "$ARGUMENTS" --hybrid-mode fallback --session-id default --top-k 3`

For stricter cost control, keep `--top-k 3` and a **specific** query (e.g. “Find the JWT validation function”) so irrelevant files score out before compression.

Notes

  • Prefer local pipeline to stay free-cost.
  • ANN acceleration is used automatically when `hnswlib` + `numpy` are available.
  • Use Context7 only when external library docs are needed.
  • Always return citations and estimated savings.
  • Large raw pasted query blobs are guarded; put logs/files in `--inputs`.
  • Default chunk size, word budget, `top-k`, and relevance floor are loaded from the plugin **`settings.json`** when `CLAUDE_PLUGIN_ROOT` is set (repo `settings.json` when running from a checkout).
Read more
Ships withclaude-token-reducer

⚡ 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.

Get the whole plugin
Stats
45
Stars
7
Forks
Maintained
Maintenance
Python
Language
MIT
License
4mo ago
Last commit
5mo ago
Created

Repo: Madhan230205/token-reducer