ai newsSa., 17. Okt.
EilmeldungReplit is no longer working with Anthropic, CEO says

What an Empty Prompt Costs: Measure the Baseline Tokens of 4 Coding Agent CLIs

Book: LLM Observability Pocket Guide Also by me: Thinking in Go (2-book series) — Complete Guide to Go Programming + Hexagonal Architecture in Go My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub OpenAI's docs for c

dev.toFreitag 23:01 · 16.10.9 Min. Lesezeit
Bild: dev.to

OpenAI's docs for codex exec --json print a sample usage line: 24,763 input tokens, 24,448 of them cached, and 122 output tokens ( Codex non-interactive docs ). The page doesn't say what prompt produced it. Whatever it was, the model read about 200 tokens for every token it wrote.

Every coding agent CLI sends a prefix before your task says a word: its system prompt, the definitions of its built-in tools, the tools of the MCP servers you configured, and every instruction file it found on the way in. A fresh session sends that prefix again, and so does every headless run in CI.

Don't copy anyone's number for this, including the two samples quoted here. The prefix moves with the CLI version, the model, your global config and the folder you start in. So measure it: a one-word prompt through Claude Code, Codex, GitHub Copilot CLI and OpenCode, then the same prompt after adding one MCP server and one AGENTS.md. Every number in your table comes from your own machine.

The system prompt and built-in tools belong to the vendor. MCP servers and instruction files are yours.

MCP servers behave differently per CLI. Claude Code defers MCP tool definitions by default: "Only tool names and server instructions load at session start" ( MCP docs ). OpenCode's docs warn the opposite way: an MCP server "adds to the context," and some, like the GitHub MCP server, "tend to add a lot of tokens" ( OpenCode MCP docs ). Copilot CLI ships with the GitHub MCP server built in ( GitHub docs ). Codex's MCP page doesn't describe deferral either way ( Codex MCP docs ), which is one more reason to measure.

Instruction files are where an "empty" prompt stops being empty. Each CLI reads more files than its own:

Read the last two rows twice. Without a global OpenCode file, your personal ~/.claude/CLAUDE.md rides along in OpenCode too, and a repo's CLAUDE.md lands in Copilot CLI's prefix as well as Claude's.

Your one-word prompt is the small part of the first request.

Start in an empty git repo, so no project file sneaks in. Your global files still load, and that's the point: this is the baseline you pay for today.

mkdir -p ~/tmp/baseline && cd ~/tmp/baseline git init -q Enter fullscreen mode Exit fullscreen mode Claude Code and OpenCode also search parent folders, so check that ~ and ~/tmp hold no CLAUDE.md or AGENTS.md ( Claude Code memory docs, OpenCode rules ). Codex stops at the git root.

Claude Code. --output-format json returns usage, total_cost_usd and a per-model modelUsage breakdown ( headless docs, cost tracking ). The cost is a client-side estimate, not your bill. The commands below use jq to read the JSON.

claude -p "ping" --output-format json > claude-1.json jq '.usage,.total_cost_usd' claude-1.json jq '[.usage.input_tokens,.usage.cache_creation_input_tokens,.usage.cache_read_input_tokens] | add' claude-1.json Enter fullscreen mode Exit fullscreen mode That second command matters. In Anthropic's usage object, input_tokens counts only what came after the last cache breakpoint, so the full input is the sum of all three fields ( prompt caching docs ). Read input_tokens alone and the baseline looks tiny. Also check.num_turns: if the agent ran a tool to answer ping, the usage covers more than one model request and counts the prefix more than once.

For a floor without your hooks, plugins, MCP servers and CLAUDE.md, add --bare. It needs ANTHROPIC_API_KEY, because bare mode skips your subscription login ( headless docs ).

Codex. codex exec --json streams JSONL, and turn.completed carries input_tokens, cached_input_tokens, output_tokens and reasoning_output_tokens ( docs ).

codex exec --json "ping" > codex-1.jsonl jq -c 'select(.type=="turn.completed") |.usage' \ codex-1.jsonl Enter fullscreen mode Exit fullscreen mode Here the cached count sits inside the input count: OpenAI's caching guide subtracts cached tokens from input to get the uncached part. So input_tokens is your prefix plus the one-word prompt, as long as the turn made a single model call.

Copilot CLI. The programmatic reference documents --output-format json but no usage fields. Its -s flag suppresses stats, so leave it off and the stats print after the reply ( reference ).

copilot -p "ping" 2>&1 | tee copilot-1.txt Enter fullscreen mode Exit fullscreen mode GitHub's changelog says /usage, and the summary printed when a session ends, include "a break down of token usage for each model" ( changelog ). Check whether your -p output prints the same breakdown. For the split by layer, start copilot and type /context. It lists System Prompt, Custom Instructions, System Tools, MCP Tools and Messages separately ( GitHub docs ).

OpenCode. opencode run --format json emits raw JSON events ( CLI docs ). OpenCode records each step's tokens as input, output, reasoning and cache.read / cache.write. In a session posted to OpenCode's tracker, the stored step showed input 209 and cache read 18,944, so add the cache fields to input.

opencode run "ping" --format json > opencode-1.jsonl jq -c 'select(.type=="step_finish") |.part.tokens' \ opencode-1.jsonl Enter fullscreen mode Exit fullscreen mode If that prints nothing, you may be on a v2 build where step_finish never reaches stdout ( open report ). opencode stats --days 1 reads token usage from your stored sessions instead.

Run each command twice within a few minutes. The first run tends to write the prefix to the cache, and the second reads it back. On Claude models, cache reads bill at 0.1x the input rate or less ( Anthropic ), so a cold first session costs more than a warm repeat.

Here is which number to write down from each CLI:

Now add the two things most repos grow first. For the MCP server, use the reference "everything" server. Its README calls it "a test server for builders of MCP clients." Or use a server you actually run.

For the memory file, write a short AGENTS.md. Better still, copy the one from a work repo. In this repo all four CLIs read it, since there's no CLAUDE.md here or above it (Claude Code needs v2.1.277 or later for that).

cat > AGENTS.md << ' EOF ' # Project rules - Run `npm test` before you say a task is done. - Never edit files under migrations/ without asking. EOF Enter fullscreen mode Exit fullscreen mode Claude Code takes a one-off server with --mcp-config, and with -p it waits for the server to connect before the first turn ( headless docs ). Save this as mcp.json:

{ "mcpServers": { "everything": { "type": "stdio", "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-everything" ] } } } Enter fullscreen mode Exit fullscreen mode Then run it twice: once as shipped, once with tool search off, so you see what deferral saves you.

claude -p "ping" --output-format json \ --mcp-config mcp.json > claude-2.json ENABLE_TOOL_SEARCH = false claude -p "ping" \ --output-format json --mcp-config mcp.json \ > claude-2-upfront.json Enter fullscreen mode Exit fullscreen mode ENABLE_TOOL_SEARCH=false loads every MCP tool upfront ( MCP docs ). The gap between those two files is the price of one server's tool definitions on every fresh session. Claude Code skips that cost by default.

Codex: register the server, then rerun the Run 1 command into codex-2.jsonl. Delete the [mcp_servers.everything] table from ~/.codex/config.toml when you're done.

codex mcp add everything -- \ npx -y @modelcontextprotocol/server-everything Enter fullscreen mode Exit fullscreen mode Copilot CLI: add the server with /mcp add, or put the same mcpServers block, with "type": "local", in ~/.copilot/mcp-config.json ( GitHub docs ). Rerun, then check /context to see the MCP Tools line grow. Remove the everything entry from ~/.copilot/mcp-config.json when you're done.

OpenCode: put the server in the repo's opencode.json and rerun.

{ "$schema": "https://opencode.ai/config.json", "mcp": { "everything": { "type": "local", "command": [ "npx", "-y", "@modelcontextprotocol/server-everything" ], "enabled": true } } } Enter fullscreen mode Exit fullscreen mode Turn the delta into money The gap between Run 1 and Run 2 is what one MCP server and one memory file add to every session start. Multiply it the way your bill does: prefix tokens, times fresh sessions per day, times your model's input or cache-write rate, plus cache reads for every later turn that re-sends the prefix. Headless runs count, and so do parallel agents. Claude Code's docs say agent-team teammates "load CLAUDE.md, MCP servers, and skills automatically" ( costs docs ).

How that turns into money depends on the plan. On a Claude Pro or Max subscription, the dollar figure in /usage "isn't relevant for billing purposes," but the tokens still draw down your plan limits ( costs docs ). On Copilot, plans moved to GitHub AI Credits on June 1, 2026, "calculated based on token consumption, including input, output, and cached tokens" ( GitHub changelog ). Annual Pro and Pro+ plans stay on premium requests until they expire ( same changelog ). On an API key, every token is billed.

If the delta surprises you, the fixes are boring. Claude Code's docs suggest moving workflow-specific instructions out of CLAUDE.md into skills that load on demand, and keeping CLAUDE.md under 200 lines ( costs docs ). Turn off MCP servers you aren't using. Check your global files, because they ride along in every repo.

I build Hermes IDE, so weigh this section with that in mind. Hermes runs each agent in a real terminal by default, and for every session it shows spend: the cost the agent reports, or an estimate from its transcript, marked as estimated, with token totals ( README ).

Since 2.3.4, released October 15, 2026, there's also a context meter: it shows how full the conversation is and offers Compact when it gets close to full. Send the same ping as the first message of a session, and the context meter, the token total and the cost show your baseline before you've given the agent any real work. In the screenshot below, pressing the Context chip above a Claude Code session opened Claude Code's own /context breakdown, and each session's context gauge sits in the sidebar.

Hermes 2.3.4: Claude Code's /context breakdown (44.4k of 1M tokens, 4%) after pressing the Context chip, with per-session context gauges in the sidebar and the token total and estimated cost in the status strip.

Hermes adds a layer of its own. Its project scan points the agent at a context file, kept within a token budget you can set per project, and saved memory facts and pinned files reach every later session ( README ). Run the ping in a Hermes session and in a plain terminal on the same repo, and the difference shows what Hermes adds to the first request, if anything.

Hermes 2.3.4: Codex and Claude Code side by side, each in its own hermes/ worktree, with each session's status, context use, cost and branch in the sidebar.

Hermes is free, source-available under BSL 1.1, and runs on macOS, Windows and Linux. It isn't affiliated with Nous Research, Anthropic, OpenAI or any agent vendor. Download it or read the source on GitHub.

Measuring the baseline is the first token-cost question. The next ones are which session, tool call or teammate spent the rest, and whether the spend bought better answers. That's what the LLM Observability Pocket Guide covers: picking the tracing and evals tools that answer those questions for your team. If you'd rather watch the gauges than parse JSON, Hermes IDE puts them next to each agent.

Quelle: dev.to (dev.to). Original öffnen