Most context-compression tools for AI coding agents are built for one-off repo dumps. You either paste 80k tokens of raw XML, or strip function bodies permanently—leaving the agent blind when it actually needs to edit a function.
Today I shipped Vicem v1.4.1 (npx -y vicem-cli)—still 0 npm dependencies, 0 network calls, and 779/779 tests passing—shifting Vicem from a manual handoff tool into an always-on, paper-backed context diet engine.
RAKKUNN
/
vicem
Zero-dependency AI agent context baton & diet suite. Hand off sessions between Claude Code, Codex, Gemini, and Cursor with 80% fewer tokens.
Vicem — Diet the Context, Pass the Baton
Hit Claude Code's 5-hour quota mid-feature? Or watching Cursor / Codex slow to a crawl after 150k tokens of context rot?
Vicem compacts your active coding session by 85.6–92.4% net effective tokens (Measured Eval — via Personalized PageRank + Submodular context selection, deterministic AST code skeletonization with
[pure]/[effects: ...]tags, and SHA-256-checked MCP rehydration), masks verboseBash/Readtool outputs in real time (PostToolUse), and hands off a hardened.vicem/BATON.mdacross Claude Code, Cursor, Codex CLI, Gemini CLI, Windsurf, Antigravity IDE, and Web AI in 3 seconds — with0npm dependencies and0network calls.⭐ Tip: Click Star (top-right) to bookmark this repo for the next time your coding agent hits a 5-hour quota limit or context rot.
🎬 15s Relay Overview — Watch in 1080p60 with sound (MP4) · All Links &…
1. Real-Time Observation Masking (PostToolUse Hook)
Recent agent research (The Complexity Trap, NeurIPS DL4C; AgentDiet / CoACT) showed a surprising result: masking verbose tool observations while preserving actions and root errors cuts agent costs in half without hurting solve rates—outperforming expensive LLM summarization.
With vicem init --agent-hooks, Vicem now installs a Claude Code PostToolUse hook (vicem hook observe) alongside PreCompact and Stop:
- Small outputs (< 300 tokens) pass through untouched with zero overhead.
-
Noisy
Bashtest/build logs are slimmed to failing assertions and user stack frames, with secrets scrubbed and indirect prompt injections defanged. -
Large
Readsource files are AST-skeletonized with deterministic[pure]/[effects: ...]/[unknown]tags. -
100% lossless raw output is archived under
.vicem/raw/, and live savings are tracked invicem stats.
You can also pipe anything directly in your terminal:
npm test 2>&1 | npx -y vicem-cli mask
2. Sound AST Side-Effect Propagation ([pure] vs [unknown] vs [effects: ...])
A sharp community review pointed out a classic static-analysis soundness trap: if a function calls an imported wrapper two hops away or an unresolved external helper, optimistically labeling it [pure] risks letting a sneaky fs-write slip past security audits.
v1.4.1 fixes both:
-
Multi-Hop Fixed-Point Cross-File Propagation:
SideEffectAnalyzer.propagateCrossFileEffectsnow iterates to a fixed point (up to 8 hops) across both intra-file and localimportcall chains (entry.ts -> mid.ts -> sink.ts). -
Conservative
[unknown]Fallback: Any function calling an unresolved external or unmapped helper is flagged[unknown](and propagated to callers) instead of[pure].
3. Mathematical Context Selection (PPR + Submodular)
Instead of naive Top-K file ranking (which wastes token budget on redundant sibling helpers), ContextFileRanker runs two zero-dependency graph algorithms over local imports:
-
Personalized PageRank (PPR) (HippoRAG 2 / CGM): Propagates seed salience (
error_log,prompt_mention,git_modified) across up to 3-hop dependency hubs via power iteration. - Budgeted Submodular Greedy Selection (PACMS / SESS): Maximizes unvisited module coverage while penalizing overlapping neighborhoods, giving a $(1 - 1/e)$ diversity guarantee under strict file/token budgets.
4. 5-Second AI-Readiness X-Ray (npx vicem-cli xray)
Want to see how many tokens your repo wastes—and whether any secrets or prompt-injection strings are hiding inside—before installing anything?
npx -y vicem-cli xray
It outputs a local scorecard (or --json) showing raw vs. reversible map tokens, estimated per-turn API cost, [pure] vs [effects] symbol counts, and scrubbed secrets/defanged injections—in under a second with zero network calls.
5. Measured Benchmarks (Apple M2 Pro, o200k_base, 5-Run Median)
End-to-End Cache Hit Rate (CHR) & Net Token Reduction (NTR)
Every NTR number below charges both the initial baton AND every vicem_rehydrate JSON-RPC response on a 71.4k-token polyglot JS/TS/Python corpus (npm run bench):
| Scenario | Raw → Net Tokens | Rehydrated | Cache Hit Rate (CHR) |
Net Savings (NTR) |
Build / Avg RPC |
|---|---|---|---|---|---|
S0-HotFix (Active Diff/Error) |
71,447 → 5,417 | 0 / 133 | 100% | -92.4% | 193 ms / 0 ms |
S1-Bugfix (2 symbols) |
71,385 → 5,630 | 2 / 134 | 98.5% | -92.1% | 157 ms / 16 ms |
S2-Refactor (5 roots + 1-hop) |
71,385 → 10,301 | 11 / 134 | 91.8% | -85.6% | 153 ms / 34 ms |
S3-Audit (Effect-Guided) |
71,385 → 5,742 | 4 / 134 | 97.0% | -92.0% | 157 ms / 10 ms |
-
Effect-Tag Ablation (
S3): Cuts security-audit rehydration RPCs from 10 → 4 (-60%). -
Honest Break-Even (
S4): Profitable up to ~63.4% codebase rehydration; when rewriting>70%of a file from scratch, read raw files directly.
Anonymized Architectural Comparison (87,460-token polyglot repo)
| Tool (Anonymized) | Footprint (Deps) | Median Time | Peak RSS | Output (o200k_base) |
Reduction | Reversible | Secret / Injection Guard |
|---|---|---|---|---|---|---|---|
Vicem v1.4.1 (diet) |
0.47 MB (0) |
133 ms | 55 MB | 1,051 tok | -98.8% | Yes (inline) | Redacted / Defanged |
Vicem v1.4.1 (vicem map) |
0.47 MB (0) |
161 ms | 77 MB | 8,678 tok | -90.1% | Yes (221 syms) | Redacted / Defanged |
Tool A (AST Packer, --compress) |
~102 MB (84) |
333 ms | 208 MB | 18,587 tok | -78.7% | No (one-way) | Secrets only / Leaked |
| Tool B (Python Repo Ingestor) | ~25 MB | 419 ms | 145 MB | 79,650 tok | -8.9% | Full raw dump | Leaked / Leaked |
| Tool C (XML Repo Packer) | ~102 MB (84) |
274 ms | 164 MB | 79,934 tok | -8.6% | Full raw dump | Leaked / Leaked |
| Baseline (Raw Concatenator) | ~0.2 MB | 36 ms | 18 MB | 87,537 tok | 0% | Full raw dump | Leaked / Leaked |
Try It Now
# 5-second repo AI-readiness & token waste scorecard
npx -y vicem-cli xray
# Enable live PostToolUse observation masking + PreCompact/Stop hooks
npx -y vicem-cli init --agent-hooks
# Guided Handoff GUI (desktop/local web)
npx -y vicem-cli gui
- GitHub: https://github.com/RAKKUNN/vicem
-
npm:
vicem-cli@1.4.1/@rakkunn/vicem@1.4.1
If you run npx -y vicem-cli xray on your own repo, drop your token reduction % in the comments!


Top comments (0)