Static-Prefix Diet
−67.9% IDLERuns 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.
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.
curl -fsSL https://raw.githubusercontent.com/hatimmakki/efficient-ai/master/install.sh | sh && eai init
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.
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×.
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.
At ~193k mean context, one extra turn caused by a dropped error line burns ~21,300 cost-weighted tokens, erasing 4–6 compressed commands.
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%.
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.
eai proxy --simulate session.jsonl locally to replay your own real transcripts.
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 |
|---|
Each station targets the next largest token-amplification driver in empirical order, never dropping diagnostics silently and never sending session data off your machine.
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.
Targets the 63.9% file-read share on files >200 lines: prints symbol signatures with [Lstart-Lend] spans, then fetches only the needed symbol.
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/.
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.
Inspect your real spend before changing a single config file, track Before vs. After savings per repository, or pause/uninstall anytime.
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.