EAI efficient-ai
315 SESSIONS · 2.59B TOKENS v1.2.0

Same quality.
27–38% lower
API bills.

One zero-dependency Rust binary (eai) and native plugins for Claude Code, Antigravity, Gemini CLI, Codex CLI, and Cursor. Cuts full-session spend across fixed K=12 cache boundaries with lossless .eai/logs/ recovery.

Inspect 315-session Exp 008 proof
−37.6%
Codex USD · −32.5% Gemini · −27.1% Claude (Exp 008)
+111.8%
Naive per-turn pruning cache-bust spike (Exp 007)
7.3 ms
Median Rust hook · 248 tok MCP idle
SYNTHETIC LCP MODEL · T=1 TO T=40 · CLAUDE SONNET
Naive Prune (M=6) Vanilla Baseline eai Stack
TURN 40 / 40 · ILLUSTRATIVE LCP SIMULATION (HOVER TO INSPECT)
Naive: $1.71 (48% cache) Vanilla: $0.97 (96% cache) eai: $0.55 (88% cache)
curl -fsSL https://raw.githubusercontent.com/hatimmakki/efficient-ai/master/install.sh | sh && eai init

Why Single-Stream Token Wrappers Backfire

VERIFIED EXP 003 · 315 SESSIONS · 13,370 TURNS · 2.59B TOKENS

Wrappers that only trim git or pytest stdout target less than 7% of tool exposure. When lossy filters drop one needed error line, a single recovery turn wipes out four to six compressed commands.

Where Tool Tokens Actually Come From (First-Occurrence Share)

FILE READING = 63.9% VS. BUILD / TEST / GIT = 6.8%
File Reading (63.9%): 41.4% Read + 22.5% cat/sed/head Search (9.0%): rg/grep/find/Glob MCP Tools (7.9%): 60.0× amplification Build / Test / Git (6.8%): where typical wrappers stop Sub-agents & Other (12.4%): sub-agent returns re-sent 233×
54.4×

Quadratic Turn Re-Send

Every new token injected early is re-sent 54.4× on average across the trajectory, and sub-agent returns to parent sessions are re-sent 233×.

66.7%

Cache Reads Dominate Cost

Across 2.59B measured tokens, 97.78% of raw tokens (and 66.7% of billed USD) are 0.1× prompt-cache reads, while 1.83% cache writes eat 20.1% of spend.

21,300

Recovery-Loop Tax

At ~193k mean context, one extra turn caused by a dropped error line burns ~21,300 cost-weighted tokens, erasing 4–6 compressed commands.

+111.8%

Per-Turn Pruning Trap

Sliding-window pruning mutates the prefix every turn, turning 0.1× reads into 1.25× cache writes and raising Claude bills by +9.2% to +111.8%.

Prompt-Cache & Cost Simulator

ILLUSTRATIVE SYNTHETIC LCP MODEL · CALIBRATED TO EXP 003–008

Synthetic single-session projection distinct from the verified 315-session Exp 008 replay (−27.1% Claude, −32.5% Gemini, −37.6% Codex). Adjust your agent and session parameters to see both the fareboard and top timetable recompute live.

Active layers synced with top timetable: 01 Prefix · 02 Outline · 03 Squeeze · 04 Batch Mask.
Run eai proxy --simulate session.jsonl locally to replay your own real transcripts.
SYNTHETIC MONTHLY BILL PROJECTION / DEVELOPER FIXED BOUNDARY K=12 · M=6
1. Vanilla Baseline
1.80M raw tok/sess · 95.5% cache hit
$58/mo
2. Naive Per-Turn Pruning (M=6) CACHE BUST
Cache hit collapses to 47.7%; cache writes explode every turn
$103/mo (+76%)
3. Full efficient-ai Stack (All 4 Layers Active) CACHE SAFE
0.59M raw tok/sess · 88.0% cache hit preserved
$33/mo (−43%)
Estimated savings: $25/month ($300/year) per developer
Illustrative LCP model calibrated from Experiments 003–008 (zero recovery loops, byte-identical local spill).
Install eai

Empirical Technique Leaderboard

EXPERIMENTS 001–008 · REPRODUCIBLE ON PUBLIC CORPUS

Every positive win and every myth we busted is backed by executable scripts in experiments/ and paired multi-turn trajectory replay.

Technique / Tool Layer Stream / Component Impact Full-Session / Cost Impact Quality Risk Proof

4-Layer Lossless Pipeline & Local CLI

100% LOCAL RUST BINARY · ZERO CLOUD TELEMETRY

Each station targets the next largest token-amplification driver in empirical order, never dropping diagnostics silently and never sending session data off your machine.

01

Static-Prefix Diet

−67.9% IDLE

Runs before turn 1 to audit and minify AGENTS.md, skill metadata, and MCP schemas. Built-in eai mcp stays at 248 idle tokens across 4 tools.

$ eai audit . --include-user --fix
02

Tree-Sitter AST Outline

−47.2% READS

Targets the 63.9% file-read share on files >200 lines: prints symbol signatures with [Lstart-Lend] spans, then fetches only the needed symbol.

$ eai outline file.py --symbol parse
03

Lossless Stream Squeeze

−92.6% LOGS

Compresses verbose test/build noise across 15+ runners while keeping 100% of errors, guards 3× stuck loops (H7), and spills raw bytes to .eai/logs/.

$ eai squeeze -- pytest -v
04

Cache-Aware Batch Proxy

−37.6% USD

Opt-in local proxy compacting old tool outputs (>6 turns) only at fixed K=12 turn boundaries, protecting 0.1× prompt-cache reads across providers.

$ eai proxy --provider anthropic

One Binary.
Zero Cloud.
Cleanly Reversible.

Inspect your real spend before changing a single config file, track Before vs. After savings per repository, or pause/uninstall anytime.

Read Full Docs
eai analyze --since 14d Auto-discovers Claude Code, Antigravity, Gemini CLI & Codex transcripts with estimated USD.
eai init Auto-detects installed agents, merges hooks safely, writes lean rules & captures baseline.
eai impact --project . Strict repo-scoped Before vs. After proof: USD/session, cache hit rate & recovery rate.
eai dashboard Offline local web UI on 127.0.0.1:7420 with live charts, project switcher & SVG export.
eai share --out proof.svg Generates a privacy-sanitized SVG efficiency proof card with zero code or path leaks.
eai doctor / eai uninstall Verifies <10 ms hook latency and prefix health, or cleanly strips all managed blocks.