Foundry

Blog

How to Stop Burning Through Tokens on AI Coding Projects

Why AI coding agents eat your usage limits so fast, and how to finish a real project without paying for another plan.

Josh Bradford

3 min read


If you burn through a weekly usage allowance in a couple of days on one repo, your session habits are the likely cause. Project size usually has less to do with it.

Why tokens disappear so fast#

Every message to an AI agent sends a lot more than what you typed. It includes the conversation so far, the files the agent read, tool output and its own instructions. The longer a session goes, the more gets resent with every single message.

So a session that's been running for hours costs way more per message than a fresh one, even if you're asking for something small.

Start fresh sessions often#

This is the biggest single fix.

Give the agent a project file so it doesn't re-learn everything#

Agents start each session knowing nothing. Without a context file, they spend tokens reading your whole project to figure out what it is.

Keep a short file in the project root (like CLAUDE.md or AGENTS.md, depending on the tool) with:

Short is the point. A huge context file gets sent every session and costs you every time.

Point it at the right files#

"Fix the jumping" makes the agent search the whole project. "The jump in player/movement.gd doesn't reset after landing on slopes" sends it straight there. Specific prompts are cheaper and get better results.

Don't paste giant logs#

A thousand lines of console output costs a lot and mostly gets ignored. Paste the error and the few lines around it. If you need the agent to look at a big log, have it search for the error instead of reading the whole thing.

Plan first, then build#

Ask for a short plan before any code: what files it'll change and how. Fixing a bad plan costs a few messages. Fixing a bad 600-line change costs a lot more, plus the tokens to undo it.

Keep files smaller#

Agents often read a whole file to change one line. A 3,000-line game.js gets read over and over. Splitting big files into smaller ones by feature makes every edit cheaper.

Use the right model for the job#

If your tool lets you pick, use a smaller, cheaper model for simple stuff like renaming, small fixes and boilerplate, and save the biggest model for hard problems and planning. A lot of usage goes to tasks that never needed the top model.

Turn off what you're not using#

Every connected MCP server adds something to each request. Claude Code now loads a server's tool definitions only when they're needed (tool search, on by default), which cuts most of that cost, but each server's name and instructions still go out with every message. Agents without on-demand loading send every tool definition, every time. Either way, if you have ten connected and use two, disconnect the rest for that project.

Should you upgrade?#

Upgrading buys more room, but if your sessions are long and unfocused, a bigger plan runs out a little later. Try the habits above for a few days first. If you're still running out with short, focused sessions, then the project does need more, and upgrading is worth it.

Summary#

Start a fresh session per task, keep a short project context file, point prompts at specific files, paste only relevant error lines, and review a plan before generating code.

Comments

Loading comments