{"slug": "one-tool-that-cuts-token-costs-40-80-for-claude-code-codex-opencode-and-openclaw", "title": "One Tool That Cuts Token Costs 40-80% for Claude Code, Codex, opencode, and openclaw", "summary": "According to the article, the tool token-goat reduces token costs by 40-80% for AI coding agents like Claude Code, Codex, opencode, and openclaw by addressing four structural inefficiencies: uncompressed screenshots, repeated file reads, context-losing session compaction, and verbose bash output. The open-source hook daemon automatically compresses images, provides session-aware read hints, injects structured manifests during compaction, and filters command output, with the author reporting 11.5 million tokens avoided and 59.7 MB of data blocked in just four hours of use.", "body_md": "The problem isn't your prompts\nIf you're running Claude Code, Codex, opencode, or openclaw and the API bill keeps climbing, you've probably tried writing tighter prompts. That's not where the waste is.\nFour structural patterns account for most of the token spend in a typical session:\nScreenshots at full resolution. The agent reads whatever images you paste or reference. A 3.3 MB screenshot from a high-DPI display lands in the model at full size. The model doesn't need native resolution to understand what's on screen.\nRepeated file reads. The agent re-reads files it already touched earlier in the session. A 600-line file read three times costs 1,800 lines of tokens. There's no built-in session memory to prevent the second or third read from running the full price.\nCompaction that loses context. When a session compacts, the summary doesn't know which files were actively edited or which symbols mattered, so the next request starts with the wrong picture and prompts more reads.\nBash output floods. Every pytest, npm install, docker build, or git log dumps hundreds of lines of passing-test names, deprecation warnings, and progress bars. The model processes all of it at full token cost.\nThese compound. On a session with 10+ file reads, a few images, and a test run, you're easily burning 3x the tokens you actually need.\ntoken-goat fixes all four\ntoken-goat (https://github.com/DFKHelper/token-goat) is a hook daemon for Claude Code, Codex CLI, opencode, and openclaw. Install once; it handles the rest.\nImage shrinking. Intercepts screenshots before they reach the model and compresses them. A 3.3 MB PNG becomes 84 KB, 97.4% smaller.\nSession-aware read hints. Tracks every file the agent reads in the session. When it's about to re-read one, it gets: \"you read lines 1–420 of auth.py 12 minutes ago.\" Most re-reads stop.\nCompaction assist. Before the session compacts, a hook builds a structured manifest — edited files, accessed symbols, key reads — and injects it into the compaction context. The next request starts with the right picture.\nBash output compression. Filters long-running command output before it hits the model. pytest goes from 150 passing-test lines to a failures-first view, 80–97% smaller. npm install collapses warnings by package. docker build keeps step headers and errors, drops the rest.\nIt's all automated, but you can also pull individual functions instead of whole files:\n_ token-goat read \"src/auth.py::login\"_\nOn a 2,000-line module, that's 85% fewer tokens than reading the full file.\nThe numbers\n100K wasted tokens per session runs about $0.30. Five sessions a week is $450/year. AI coding cost reduction at that scale comes from eliminating structural waste, not from writing shorter prompts. token-goat is free.\n4 hours of use on my machine: 59.7 MB of data that never hit the model, 11.5 million tokens avoided. And that was just version 0.1.\nInstall\nRequires uv (https://docs.astral.sh/uv/).\nuv tool install token-goat\ntoken-goat install\nWorks with Claude Code, Codex CLI, opencode, and openclaw. Windows, Linux, WSL, and macOS.", "url": "https://wpnews.pro/news/one-tool-that-cuts-token-costs-40-80-for-claude-code-codex-opencode-and-openclaw", "canonical_source": "https://dev.to/zelys_dfkhelper/one-tool-that-cuts-token-costs-40-80-for-claude-code-codex-opencode-and-openclaw-hh2", "published_at": "2026-05-20 22:18:23+00:00", "updated_at": "2026-05-20 22:33:10.811246+00:00", "lang": "en", "topics": ["developer-tools", "large-language-models", "artificial-intelligence", "open-source", "products"], "entities": ["Claude Code", "Codex", "opencode", "openclaw", "token-goat", "DFKHelper"], "alternates": {"html": "https://wpnews.pro/news/one-tool-that-cuts-token-costs-40-80-for-claude-code-codex-opencode-and-openclaw", "markdown": "https://wpnews.pro/news/one-tool-that-cuts-token-costs-40-80-for-claude-code-codex-opencode-and-openclaw.md", "text": "https://wpnews.pro/news/one-tool-that-cuts-token-costs-40-80-for-claude-code-codex-opencode-and-openclaw.txt", "jsonld": "https://wpnews.pro/news/one-tool-that-cuts-token-costs-40-80-for-claude-code-codex-opencode-and-openclaw.jsonld"}}