Compress LLM output safely. Save tokens without breaking your code.
Project description
Brevix
Compress LLM output safely. Save tokens without breaking your code.
Brevix is a universal output-compression layer for LLM coding tools. It cuts response tokens 40-75% with a deterministic rule engine and verifies the compressed result still means the same thing as the original — so brevity never breaks correctness.
Works with Claude Code, Cursor, Windsurf, OpenAI Codex CLI, Google Antigravity, Gemini CLI, GitHub Copilot Chat, Aider, Continue.dev, Cline, Roo Code, Zed AI, Augment, Kilo, OpenHands, Tabnine, Warp, Replit, Sourcegraph Amp, plus any tool that reads AGENTS.md.
What Brevix gives you
| Capability | Brevix |
|---|---|
| Rule-based compression — Lite, Full, Ultra | ✅ |
| Adaptive Auto mode (picks safest aggressive level per response) | ✅ |
| Accuracy Guard — semantic similarity verification before emit | ✅ |
| Strict mode — auto-fall-back to original when meaning would be lost | ✅ |
| Protected regions — code, URLs, error quotes are never touched | ✅ |
File-level compression with .original backup (CLAUDE.md, AGENTS.md, …) |
✅ |
MCP middleware (brevix-shrink) — compresses tool/prompt/resource descriptions |
✅ |
Real Claude Code session-log token counts (stats --real --since 7d) |
✅ |
Statusline badge — [BREVIX] ⛏ X.Xk saved |
✅ |
| Subagents — investigator / builder / reviewer with terse output formats | ✅ |
Three-arm A/B eval harness with tiktoken o200k_base |
✅ |
20 platform install targets, idempotent BREVIX:BEGIN/END markers |
✅ |
| 100% local — no telemetry, no API calls in the engine | ✅ |
| Free + MIT | ✅ |
Brevix's edge: every compressed output is scored against the original locally. If similarity drops below your threshold, you get warned — or in strict mode, the original is emitted instead. No silent meaning loss on dense technical prose.
Install
One-liner (macOS / Linux / WSL)
curl -fsSL https://raw.githubusercontent.com/Yash-Koladiya30/brevix/main/install.sh | bash -s -- --all
Windows (PowerShell)
irm https://raw.githubusercontent.com/Yash-Koladiya30/brevix/main/install.ps1 | iex
Manual
pip install brevix # core
pip install 'brevix[guard]' # + semantic Accuracy Guard
pip install 'brevix[tokens]' # + accurate tiktoken counts
pip install 'brevix[all]' # everything
Plug into your LLM coding tool
brevix install --list # show all 20 targets
brevix install claude-code # Claude Code plugin layout
brevix install cursor # .cursor/rules/brevix.mdc
brevix install codex # AGENTS.md + .codex/hooks.json
brevix install gemini # gemini-extension.json + GEMINI.md
brevix install all # write rule files for every tool
Idempotent — re-running updates the Brevix block, leaves your other content alone.
Claude Code marketplace
/plugin marketplace add Yash-Koladiya30/brevix
/plugin install brevix@brevix
MCP middleware (compress upstream MCP server descriptions)
npm install -g brevix-shrink
Then wrap any MCP server in your Claude config:
{
"mcpServers": {
"fs-shrunk": {
"command": "npx",
"args": ["brevix-shrink", "npx", "-y",
"@modelcontextprotocol/server-filesystem", "/tmp"]
}
}
}
Usage
Slash commands (Claude Code, Cursor, etc.)
/brevix # toggle on (full mode)
/brevix lite # gentle compression
/brevix ultra # max compression
/brevix auto # pick best mode per response
/brevix off # disable
/brevix-commit # terse Conventional Commit message
/brevix-check # run Accuracy Guard on a snippet
/brevix-stats # show savings
For Codex CLI (no slash commands), use $brevix lite|full|ultra|auto|off.
CLI
# Output compression
brevix compress "Your verbose text here" --mode full
brevix compress - # stdin
brevix compress . --mode auto -v # adaptive picks best
brevix compress . --guard --strict --threshold 0.85
# File compression (memory files like CLAUDE.md, AGENTS.md, project notes)
brevix compress-file CLAUDE.md # writes .original.md backup
brevix compress-file CLAUDE.md --dry-run
# Stats
brevix stats # estimated, in-process
brevix stats --real --since 7d # parsed from Claude Code session logs
brevix stats --share # tweet-ready one-liner
brevix stats --reset
# Verification
brevix check "original" "compressed"
brevix count "how many tokens?"
# Install rules into a project
brevix install cursor
brevix install --list
Subagents (Claude Code)
agents/ ships three small, focused subagents that emit ~60% smaller tool results than vanilla agents:
- brevix-investigator — read-only code locator (
path:line — symbol — note) - brevix-builder — surgical 1-2 file edits with verification
- brevix-reviewer — bug-focused diff review (
path:line: 🔴 bug: …. fix.)
How Accuracy Guard works
- Compress output via the rule engine.
- Score the original vs compressed text with a local sentence-transformer (no API cost).
- If similarity ≥ threshold (default 0.85) → emit compressed. Otherwise warn, or in
--strictmode fall back to original. - Without
sentence-transformersinstalled, falls back to content-word containment (drops stopwords without penalty — fair to compression).
Result: compression you can trust on production code, specs, contracts.
Compression example
Before:
The reason your React component is re-rendering on every parent update is that you are passing an inline object as a prop. In JavaScript, every render creates a new object reference, even if the contents are identical. To fix this, wrap the object in
useMemoso the reference stays stable across renders.
After (full mode):
Inline object prop = new ref each render = re-render. Wrap in
useMemo.
Tokens saved: ~75%. Meaning preserved: ✅ (similarity 0.91)
Benchmarks
Reproducible three-arm A/B harness in evals/. Compares no-system-prompt vs "be terse" control vs Brevix on 10 developer prompts.
arm n median mean total vs baseline vs control
baseline 10 221 247.3 2473 — —
control 10 178 191.6 1916 22.5% —
brevix 10 119 128.4 1284 48.1% 33.0%
Run yourself:
pip install 'brevix[all]' anthropic
export ANTHROPIC_API_KEY=...
python evals/llm_run.py --model claude-sonnet-4-6
python evals/measure.py
The vs control column is the honest savings — what Brevix adds beyond "just be brief."
Roadmap
- Core compression engine (lite/full/ultra)
- Adaptive (auto) mode
- Accuracy Guard (semantic + content-word fallback)
- Local stats counter
- Multi-platform installer (20 targets)
- File-level compression (
brevix compress-file) - MCP middleware (
brevix-shrink) - Statusline badge + Claude Code hooks
- Subagents (investigator/builder/reviewer)
- Three-arm eval harness
- PowerShell installer + uninstaller
- VSCode extension UI
- Browser extension (claude.ai, chatgpt.com web)
- Two-way compression (compress prompts before send)
- Custom user-defined rule packs
- Web dashboard (team tier)
License
MIT — free for personal and commercial use.
Contributing
Issues and PRs welcome. See docs/CONTRIBUTING.md.
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 brevix-0.4.0.tar.gz.
File metadata
- Download URL: brevix-0.4.0.tar.gz
- Upload date:
- Size: 31.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c2bddbd25b8962ff72993d1b0d51e61adb5fa5a70cff130a3840559b6fc6d56
|
|
| MD5 |
4b799fbe78e2cc59ad3bfb50c795d728
|
|
| BLAKE2b-256 |
de157d525aec4e8c169833510776c532edaa7cc4ff7e73aa8643b960728992c4
|
Provenance
The following attestation bundles were made for brevix-0.4.0.tar.gz:
Publisher:
pypi.yml on Yash-Koladiya30/brevix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
brevix-0.4.0.tar.gz -
Subject digest:
2c2bddbd25b8962ff72993d1b0d51e61adb5fa5a70cff130a3840559b6fc6d56 - Sigstore transparency entry: 1437208362
- Sigstore integration time:
-
Permalink:
Yash-Koladiya30/brevix@bacec2e97692c9a6ceecfe42b8054c3683de6164 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/Yash-Koladiya30
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@bacec2e97692c9a6ceecfe42b8054c3683de6164 -
Trigger Event:
push
-
Statement type:
File details
Details for the file brevix-0.4.0-py3-none-any.whl.
File metadata
- Download URL: brevix-0.4.0-py3-none-any.whl
- Upload date:
- Size: 26.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac09628bb7cb0e7988c8f596269df70be9c9601a55ffd15a5a5279ede59f0dde
|
|
| MD5 |
f4d066cc67d122193fa17f744b7cf176
|
|
| BLAKE2b-256 |
e359978f6ef815fde7902609d5aec6fba7e58ab45b78f64b0bf27c5b75acea71
|
Provenance
The following attestation bundles were made for brevix-0.4.0-py3-none-any.whl:
Publisher:
pypi.yml on Yash-Koladiya30/brevix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
brevix-0.4.0-py3-none-any.whl -
Subject digest:
ac09628bb7cb0e7988c8f596269df70be9c9601a55ffd15a5a5279ede59f0dde - Sigstore transparency entry: 1437208365
- Sigstore integration time:
-
Permalink:
Yash-Koladiya30/brevix@bacec2e97692c9a6ceecfe42b8054c3683de6164 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/Yash-Koladiya30
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@bacec2e97692c9a6ceecfe42b8054c3683de6164 -
Trigger Event:
push
-
Statement type: