Token Optimization

Use when you need to reduce token usage, lower API cost, fit work within a context window, or speed up an expensive/slow agent loop. Triggers on phrases like "optimize tokens", "reduce token usage", "save on cost", "fit in context", "context too long", "running out of tokens", "prompt caching", "compact the context", "agent is too expensive", "shrink the prompt", "cheaper model", "tokens-per-task". Provides a layered tactic catalog — measurement (heuristic counting and budget allocation), prompt-side levers (caching, system-prompt diet, tool-definition pruning), context management (compression, observation masking, file-system offload), agent-loop patterns (parallel tool calls, batch operations, model routing by complexity), and output-side controls (depth tiers, stop sequences, structured output). Project-agnostic and provider-agnostic; works across Claude Code, Codex CLI, Cursor, Gemini CLI, and Copilot.

bm629 18f53f6 6 files · 50.9 KB Updated

File contents

bm629/agent-skills/tree/main/skills/token-optimization commit 18f53f600e

Frequently asked questions

npx skillmds@latest add bm629/token-optimization