{"slug": "the-discovery-tax-why-coding-agents-waste-2500-tokens-before-writing-code", "title": "The Discovery Tax: Why Coding Agents Waste 2,500 Tokens Before Writing Code", "summary": "A developer-built task runner called run ships with a built-in MCP server that cuts Claude Code's test-discovery overhead from roughly 6 tool calls and 2,500 tokens to 1 tool call and about 100 tokens, according to the tool's author. The author attributes the savings to replacing file-by-file discovery (README, Makefile, package.json) with a structured registry of tool names, typed parameters and defaults defined in a Runfile. The tool is installable via Homebrew, yay or cargo.", "body_md": "## The Discovery Tax\n\nEvery Claude Code session starts the same way. You say “run the tests.” The agent says “I’ll look for how to run tests in this project.”\n\nThen it reads your README. Then your Makefile. Then your `package.json`. Then it tries `make test`. Wrong. `npm test`. Wrong project. It `cat` s the Makefile again, picks a different target, runs it with the wrong arguments. Eventually it gets there.\n\nSix tool calls. 2,500 tokens of context. Gone — before any real work begins.\n\nThat’s the discovery tax. You pay it every session. The agent forgets everything and starts over. Every time.\n\n## What it actually costs\n\nIt’s not just the wasted tokens. It’s the compound effect:\n\n- **Context pressure.** On long sessions you’re already fighting the context window. Burning 2,500 tokens on discovery means you hit compression sooner.\n- **Confidence degradation.** Each failed attempt leaves error messages in the context. The agent second-guesses itself. It starts hedging. “Let me try another approach…” You’ve seen this — the agent starts confidently, hits two errors, and suddenly every response begins with “I apologise for the confusion.”\n- **Your time.** You’re sitting there watching it fumble through files you could have pointed it at in seconds.\n\n## The refund\n\nWhat if the agent already knew your project’s tools before it started?\n\nThat’s what [MCP](https://modelcontextprotocol.io) is for. Instead of discovering tools by reading files, the agent gets a structured registry: tool names, descriptions, typed parameters, defaults. No reading. No guessing. No retries.\n\nI built a task runner called [run](https://runtool.dev) with a built-in MCP server. You define your tasks in a `Runfile`:\n\n```\n# @desc Run the test suite\n# @arg filter Optional test name filter\ntest(filter = \"\") {\n    cargo test --workspace --no-fail-fast $filter\n}\n\n# @desc Deploy to an environment\n# @arg env Target environment (staging|prod)\ndeploy(env) ./scripts/deploy.sh $env\n```\n\nAdd it to your Claude Code config:\n\n```\n{\n  \"mcpServers\": {\n    \"run\": { \"command\": \"run\", \"args\": [\"--serve-mcp\"] }\n  }\n}\n```\n\nNow the same interaction looks like this:\n\n```\nYou:    run the tests\nAgent:  [tool] mcp:run test → success\n```\n\nOne tool call. ~100 tokens. Same result next session.\n\n## The maths\n\n|  | Without MCP | With MCP | \n|---|---|---|\n| Tool calls to run tests | ~6 | 1 | \n| Context consumed | ~2,500 tokens | ~100 tokens | \n| Next session | Starts from scratch | Same registry | \n| Reliability | Varies by session | Deterministic | \n\nOver a day of coding sessions, that’s thousands of tokens and dozens of tool calls you’re not wasting on rediscovery.\n\nThe discovery tax is zero.\n\nFor the full picture — auto-truncation, security sandboxing, the deterministic skills layer — see [the deep dive](https://blog.jarv.dev/deterministic-toolbox-for-claude-code).\n\n```\nbrew install nihilok/tap/runtool\n# or\nyay -S runtool\n# or\ncargo install run\n```\n\n", "url": "https://wpnews.pro/news/the-discovery-tax-why-coding-agents-waste-2500-tokens-before-writing-code", "canonical_source": "https://blog.jarv.dev/the-discovery-tax", "published_at": "2026-09-26 12:48:14+00:00", "updated_at": "2026-09-26 13:01:03.279578+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "developer-tools", "ai-tools", "mlops"], "entities": ["Claude Code", "Model Context Protocol", "run", "Runfile", "Anthropic", "Homebrew", "cargo"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/the-discovery-tax-why-coding-agents-waste-2500-tokens-before-writing-code", "markdown": "https://wpnews.pro/news/the-discovery-tax-why-coding-agents-waste-2500-tokens-before-writing-code.md", "text": "https://wpnews.pro/news/the-discovery-tax-why-coding-agents-waste-2500-tokens-before-writing-code.txt", "jsonld": "https://wpnews.pro/news/the-discovery-tax-why-coding-agents-waste-2500-tokens-before-writing-code.jsonld"}}