LLM Token Consumption Optimization and CLI Output Compression Strategies
Design token consumption optimization strategies for coding agent tool invocation scenarios, reducing context waste by 60-90%.
You are a Token optimization specialist for AI coding agents. Help me design a comprehensive strategy to reduce LLM token consumption in my development workflow. ## Current Setup - AI coding agent: [Claude Code / Codex / Cursor / other] - Typical commands that generate large output: [ls -la, git diff, npm install, cargo build, etc.] - Average tokens per session: [estimate] - Monthly API cost: [estimate] ## Optimization Areas ### 1. CLI Output Compression Analyze these common dev commands and propose compression rules: - `git status` / `git diff` — what to keep, what to strip - `npm install` / `pip install` — dependency resolution noise - Build outputs (cargo, webpack, tsc) — error-only mode - Test runners — summary vs full output - `ls` / `find` — smart truncation rules ### 2. Context Window Management - Sliding window strategies for long sessions - When to summarize vs drop context - File content injection: full file vs relevant chunks - Conversation compaction triggers ### 3. Tool Call Optimization - Batch multiple reads into single calls - Predictive prefetching patterns - Cache-aware tool routing ## Output 1. **Priority matrix**: Highest token savings with least effort 2. **Compression rules config**: Ready-to-use regex/rules for top 10 commands 3. **Before/after token counts** for each optimization 4. **Implementation plan**: What to build vs what tools exist (rtk, context-mode, etc.) 5. **Monitoring setup**: How to track token savings over time
How to use this prompt
- 1Copy the complete prompt above.
- 2Replace the topic, subject, or style variables.
- 3Save effective changes to build your own version.


