I profiled 315 Claude Code, Codex & Gemini CLI sessions (13,370 turns, 2.59B tokens) to see why "token-saving" wrappers barely move API bills—or spike them +111%.
Then I built eai: a Rust binary cutting billed spend 27–38% with zero quality loss.
What the telemetry showed:
1. CLI stdout wrappers target 6.8% of the problem
Across 315 real AI coding sessions, build, test, and git stdout accounted for only 6.8% of tool tokens. File reading accounted for 63.9%.
Most CLI token wrappers trim pytest or git output and celebrate "80% fewer bytes." Across a real 50-turn coding session, that barely dents API spend—and dropping a single error line costs more than you saved.
2. Why 1 dropped error line wipes out token savings
Each new token gets re-sent 54.4× on average across a session trajectory (sub-agent summaries get re-sent 233×).
At ~193k context, a single recovery turn burns ~21,300 cost-weighted tokens—wiping out the savings of 4 to 6 compressed CLI commands at once.
3. Naive history pruning spikes Claude API bills +9.2% to +111.8%
Anthropic prompt caching bills 0.1× for cache reads vs. 1.25× for cache writes.
Mutating conversation history on every turn invalidates the prompt prefix on every turn—converting cheap 0.1× cache hits into 12.5× more expensive cache writes.
4. How efficient-ai (eai) cuts billed spend without busting cache
Instead of naive stdout hacks, eai runs as a single local Rust binary across 4 empirical layers:
• eai audit --fix — Cuts idle prefix tokens by −67.9% (AGENTS·md, skills, MCP)
• eai outline — Tree-sitter AST code reads (−47% file-read tokens)
• eai squeeze — Cuts log noise by −92.6%, keeps 100% of errors + lossless .eai/logs/ spill
• eai proxy — Cache-safe batch masking at fixed K=12 turn boundaries
Paired replay across all 315 sessions (Exp 008):
• Claude Code (Sonnet): −27.1% billed USD
• Antigravity & Gemini CLI: −32.5% USD
• Codex CLI (GPT-5): −37.6% USD
• Hook latency: 7.3 ms median (Rust)
• MCP overhead: 248 idle tokens total for eai mcp
• Safety & privacy: 0 recovery loops, 100% local, zero cloud telemetry
New in v1.2.0: Live 0-LLM-token statusLine
Stacks cleanly under the default bar in Antigravity CLI and works natively in Claude Code:
eai ON · saved 48.2k (~$0.14) · $0.42 sess · cache 94% · ctx 58% · rec 0%
It flashes red on the exact turn your prompt cache busts, and ships with SHA-256 verified eai update.
Open-source (Apache-2.0), 10-second setup (eai init), and compatible with Claude Code, Cursor, Codex CLI, Antigravity & Gemini CLI.
Bookmark this before your next API bill spike—interactive prompt-cache cost simulator & GitHub repo in the reply below ↓
Immediate Self-Reply (Post Immediately Below)
Interactive prompt-cache cost simulator + full reproducible benchmarks (Exp 001–008):
hatimmakki.github.io/efficie…
GitHub repo + 1-line install (eai init):
github.com/hatimmakki/effici…
كل واحد يركز في شغلة وفي النهاية كلنا نبني منظومة كاملة.
واحد يبني وكلاء واخر يهندس skills and plugins واخر يبني ادوات توفير توكنز بدون التأثير ع الحودة.
وهذا مثال، اطلقته اليوم.
hatimmakki.github.io/efficie…
9
م. حتمس الأول retweeted
هذا تذكير لك
اذا ماقريت الكتاب، اقراه
واذا قريته مرة، اقراه ثانية
المستودع على GitHub + التثبيت بسطر واحد (eai init):
github.com/hatimmakki/effici…
#rustlang #ذكاء_اصطناعي
16
حللت 315 جلسة برمجة فعلية على Claude Code وCodex وGemini CLI (13,370 خطوة، 2.59B توكن) عشان أعرف ليش أغلب أدوات تقليل التوكنز ما توفر في فاتورة الـ API وأحياناً تزيدها.
وبنيت eai: أداة بـ Rust تنزّل الفاتورة الفعلية 27–38% بدون ما تأثر ع الجودة.
اللي كشفته الأرقام:
1. مخرجات build والـ git ما تمثل إلا 6.8% من استهلاك الأدوات
قراءة الملفات لحالها تستهلك 63.9% من التوكنز.
أغلب أدوات الـ CLI تقص مخرجات pytest أو git وتحتفل بـ "توفير 80% من النص". في جلسة حقيقية من 50 خطوة، هذا يادوب يفرق في الفاتورة ولو طار سطر خطأ واحد وقت القص، حتخسر أكثر مما توفر.
2. ليش ضياع سطر خطأ واحد يمسح كل التوفير؟
كل توكن جديد يدخل المحادثة ينعاد إرساله 54.4 مرة بالمتوسط طول الجلسة (وملخصات الـ sub-agents تنعاد 233 مرة).
لما يوصل الكونتكست حول 193k توكن، خطوة تصحيح وحدة بسبب خطأ ناقص تحرق قرابة 21,300 توكن موزونة بالتكلفة ، يعني تطيّر توفير 4 إلى 6 أوامر مضغوطة بضربة وحدة.
3. حذف الهيستوري في كل خطوة يرفع فاتورة Claude API بنسبة 9.2% إلى 111.8%
في Anthropic prompt caching، قراءة الكاش تكلف 0.1× بينما الكتابة تكلف 1.25×.
لما تعدّل أو تقص من سجل المحادثة مع كل خطوة، أنت فعلياً تكسر الـ prefix cache كل مرة، وتحوّل قراءات الكاش الرخيصة إلى كتابات أغلى بـ 12.5 ضعف.
4. كيف تنزّل أداة efficient-ai (أو eai) الصرف بدون كسر الكاش؟
بدل ترقيع مخرجات التيرمنال، تشتغل eai كملف باينري واحد بـ Rust على 4 طبقات مبنية على البيانات:
- أمر eai audit --fix، يقلص التوكنز الثابتة بالبداية بنسبة 67.9% (ملفات AGENTS·md والـ skills والـ MCP)
- أمر eai outline، يقرأ هيكل الكود عبر Tree-sitter AST (يوفر 47% من توكنز قراءة الملفات)
- أمر eai squeeze، يشيل 92.6% من إزعاج اللوقز مع إبقاء 100% من الأخطاء + حفظ اللوق الكامل في .eai/logs/
- أمر eai proxy، إخفاء ذكي على دفعات ثابتة كل K=12 خطوة عشان يحافظ على الكاش سليم
نتائج إعادة التشغيل على نفس الـ 315 جلسة (Exp 008):
- على Claude Code (Sonnet): نزول 27.1% من الفاتورة الفعلية بالدولار
- على Antigravity & Gemini CLI: نزول 32.5% بالدولار
- على Codex CLI (GPT-5): نزول 37.6% بالدولار
- سرعة الاستجابة: 7.3ms بالمتوسط (Rust hook)
- استهلاك eai mcp: فقط 248 توكن في وضع الخمول
- الاعتمادية والخصوصية: صفر حلقات تصحيح (recovery loops)، وتشتغل 100% محلياً على جهازك بدون أي telemetry سحابي
الجديد في إصدار v1.2.0: شريط حالة حي بدون استهلاك أي توكن
يركب مباشرة تحت الشريط الافتراضي في Antigravity CLI ويشتغل بشكل أصلي مع Claude Code:
eai ON · saved 48.2k (~$0.14) · $0.42 sess · cache 94% · ctx 58% · rec 0%
الشريط يولّع بالأحمر في اللحظة اللي ينكسر فيها الكاش، ومعاه أمر eai update بتحقق SHA-256.
الأداة مفتوحة المصدر (Apache-2.0)، التثبيت في 10 ثواني (eai init)، وتشتغل مع Claude Code وCursor وCodex CLI وAntigravity وGemini CLI.
احفظ البوست عندك قبل فاتورة الشهر الجاي، رابط المستودع على GitHub ومحاكي حساب تكلفة الكاش في الرد تحت 👇🏻
3
1
161
Interactive prompt-cache cost simulator + full reproducible benchmarks (Exp 001–008):
hatimmakki.github.io/efficie…
GitHub repo + 1-line install (eai init):
github.com/hatimmakki/effici…
#rustlang #buildinpublic
30
Replying to @FINANC_CPA
اوكي 👍🏻
انا بس مهتم اعرف اسم الشركة لانه قد انسى ما سيحدث بعد سنوات التقسيط، الاهم اني اعرف ايش هي الشركة علشان ما اتعامل معاهم اصلاً. والباب الي يجيك منه الريح سده واستريح
1
275
Replying to @assdais
جرب برنامج بيرفيومر ستوديو يساعدك على تحديد التركيز المناسب والمتوافق مع ifra والاتحاد الاوروبي.
hatimmakki.sa/support/perfum…
2
130
Replying to @Mohamed34132687
هذا الشخص اكثر داعية قليل ادب شفته في حياتي. الأنا عنده مبالغ فيها.
صح كلامه سليم، بس اسلوبه قذر ومنفر
165




