What is agentic terminal coding?
Agentic terminal coding is when an AI agent lives in your terminal and drives a multi-step coding task on its own — reading files, running shell commands, editing code, watching the output, and looping until the job is done. The "terminal" part is the interface: instead of a chat panel bolted onto an editor, the agent runs as a command-line process with direct access to your shell, your filesystem, and whatever tools you've wired in. Claude Code, OpenAI's Codex CLI, Aider, OpenCode and Gemini CLI all fit this shape. I've spent a lot of time watching these agents work, and the terminal framing changes the ergonomics more than people expect. A terminal agent isn't sandboxed behind an editor's API — it cangrep, cat, pytest, git diff, and pipe results into its own reasoning. That's enormously powerful. It's also why a terminal agent can quietly burn through a few dollars of tokens before you've finished your coffee.
This piece is a spoke of the broader agentic coding explainer. Here I'm zooming in on the terminal-resident variant specifically: what it is, why it's different from an IDE assistant, and where the cost actually comes from.
How is terminal coding different from an IDE assistant?
The difference is who owns the loop and how directly the agent touches your machine. An IDE assistant — inline completion, a sidebar chat, a "fix this" button — operates through the editor. The editor decides what context to hand the model, the model proposes an edit, and you (or the editor) apply it. The model is a passenger. A terminal agent is the driver. It decides which files to open, which commands to run, and what to do with the results, turn after turn. Concretely:| Trait | IDE assistant | Terminal agent |
|---|---|---|
| Interface | Editor panel / inline | Command-line process |
| Who picks the next action | Mostly you | The agent |
| Shell access | Limited / mediated | Direct |
| Context source | Editor selection + open tabs | Whatever the agent chooses to read |
| Typical loop length | 1 turn | Many turns |
What does the agent actually do in the terminal?
It runs a plan-act-observe loop, the same loop every agent uses, just with your shell as the action surface. A normal cycle looks like this:- Plan. Looking at the current transcript and the task, the model decides on a next step — "I need to find where the session token is parsed."
- Act. It calls a tool. In a terminal agent that's often a shell command:
rg "parseToken" -l, or reading a file, or running the test suite. - Observe. The command's stdout and stderr get appended to the context. A noisy test run or a verbose build log lands there in full.
- Repeat. The model reads the new observation and plans again.
npm run build and hits a wall of warnings will happily ingest all of it — and then re-ingest it on every subsequent turn. That's the output-filtering problem in its purest form.
Why does agentic terminal coding burn so many tokens?
Because the loop re-reads an ever-growing context on every turn, and the terminal's habit of producing large, raw command output makes that context grow fast. Let me make it concrete with real prices. As of mid-2026, Claude Opus 4.8 is $5 per million input tokens and $25 per million output; Sonnet 4.6 is $3 / $15; Haiku 4.5 is $1 / $5; GPT-5.5 is $5 / $30. Input is usually the dominant line item for agents, because the transcript-you-resend dwarfs the few hundred tokens the model writes back each turn. Walk through a modest debugging session on Sonnet 4.6:- Turn 1: agent reads the project tree (~3,000 input tokens).
- Turn 2: opens two files (~9,000 tokens now in context).
- Turn 3: runs the failing test, captures the traceback (~13,000 tokens).
- Turn 4: reads another file after tracing the stack (~17,000 tokens).
- Turn 5: makes an edit, re-runs the suite (~21,000 tokens).
How do you keep terminal-agent costs sane?
You shrink what enters the loop and you stop re-paying for what's already there. There are a few concrete levers:- Filter command output before it hits context. Don't let the agent read a 40,000-line build log. Truncate, summarise, or tail it. This is the single highest-leverage move for terminal agents because shell output is where the unbounded growth comes from.
- Read structure, not whole files. When the agent needs to understand a module, a skeleton — signatures, exports, types — is often enough, at a fraction of the tokens. Reach for the full body only when it's actually editing.
- Search semantically instead of dumping directories. Semantic code search lets the agent jump to the relevant function instead of reading the project tree and three candidate files to find it. See semantic search vs grep for the tradeoff.
- Load MCP tools lazily. Every connected MCP server's tool manifest sits in the context whether the agent uses it or not. Loading them on demand keeps the baseline prompt small. The best MCP servers for Claude Code roundup is worth a read if you're wiring several in.
- Lean on caching deliberately. Keep the stable parts of your prompt stable so the cache prefix survives between turns.
What goes wrong (anti-patterns)
A few failure modes show up over and over with terminal agents:- The build-log swallow. The agent runs a command that emits tens of thousands of lines, ingests all of it, and then re-sends it on every turn for the rest of the session. Watch for a sudden jump in per-turn input — that's almost always raw output that should have been filtered.
- The exploratory read spiral. When the task is underspecified, the agent hedges by reading broadly to reduce its own uncertainty before committing. Rational, but expensive. The fix is on your side: hand it the relevant file, the exact function, the precise error. The more you front-load, the less it spelunks.
- The phantom cache assumption. People enable prompt caching and assume the cost problem is solved. It isn't — caching only covers the stable prefix, and terminal agents constantly invalidate it with fresh observations. Caching is necessary, not sufficient.
- MCP manifest creep. Six connected servers, two ever used, all of their tool definitions taxing every single prompt. Load them lazily.
See also:
- Agentic coding — the pillar this spoke belongs to.
- How to reduce AI coding agent token usage — every lever, with numbers.
- Context engineering for AI coding agents — the discipline behind managing what the loop reads.
- Output filtering — the technique that tames noisy shell output.
Ranked #1 on the Token-Harness Optimizer Leaderboard.
Tokenade ranks #1 in the Token-Harness Optimizer Leaderboard — an end-to-end benchmark of agent token optimizers measured on real coding sessions. Set it up once, it works on every prompt. Works with Claude Code, Cursor, Codex, Copilot & more.