The other day, I was working a project with Claude Code and using API pricing. I asked Claude to review a PR I was looking at.
A simple PR, just a few hundred line diff.
The cost? $70!!!
I ordinarily am pretty efficient with my token usage, so this was a shocking number to see.
What happened was obvious in hindsight, and it boiled down to subagents. Read on to learn what happened, and how to control your subagent cost with a very simple setting.
Claude can spin off its own subagents #
Subagents in Claude Code are an important way to manage context, which in turn improves performance.
You can manually ask Claude to spin off subagents when relevant, or you can trust it to handle subagent creation on its own.
Claude might make a subagent to handle a task like “find how user authorization is handled and report back step-by-step instructions on adding a new authorized feature.”
Any subagent runs in parallel, and it gets its own context window! When it’s done, the result is returned to the parent, and the main context window isn’t littered with the entire journey.
So what happened to my PR review?
Claude spun off 25 subagents! 25!!! This was truly nuts for the task at hand, but I suspect that having reasoning/effort set to “max” is to blame. The biggest problem was that I was using Opus for the main thread.
As a result, each of the 25 subagents was also using Opus. This is 100% to blame for costs getting so high so fast, and the fix is pretty simple.
If you’re a power user of coding agents, you’re obviously in the right spot. I spend dozens of hours researching each of these guides so you have a shortcut to building software with AI. I’d love to have you join us and get notified when we share more tutorials like this.