Try free

Last updated 13 October 2026

How to see the cost of a specific subagent

Identifying the cost of individual subagents

You run a complex task and Claude Code spins up a subagent to handle a specific refactor. When the task finishes, you wonder how much that specific delegation cost compared to the main session. By default, the terminal output groups the work together, making it hard to see if a subagent was efficient or if it burned through your budget on a recursive loop. This lack of transparency is a common pain point for developers working on large repositories where a single subagent might read dozens of files before writing a single line of code.

Knowing these costs matters when you build custom agents in the .claude/agents directory. If you are testing a new subagent that performs a WebSearch or heavy Read operations, you need a clear way to measure its impact before you integrate it into your daily workflow. Without a method to isolate these costs, you might find that a seemingly simple helper agent is actually the primary driver of your monthly token consumption. Understanding how to peel back the layers of a multi-agent session is the first step toward optimizing your developer budget and project efficiency.

Checking costs during the active session

The most direct way to see what you are spending is the /cost slash command. When you type this inside a session, Claude Code displays the total cost for the current session up to that point. This includes the tokens used by the main agent and any subagents it has invoked. The output usually breaks down the cost into input and output categories, which helps you see whether you are spending more on the instructions you send or the code the agent writes. It provides a clear snapshot of the financial impact of your current work.

If you want to isolate a subagent cost, run /cost immediately before you trigger the subagent and again immediately after it finishes. The difference between these two figures represents the cost of that specific subagent run. This manual snapshotting is the most reliable way to get a granular view without using external scripts. Because subagents often run quickly, having the /cost command ready in your command history allows you to check the delta with very little friction. It allows you to see exactly how much a task like generating unit tests or scanning for bugs costs in isolation.

It is also useful to check the cost when the agent is waiting for your permission. If a subagent asks to use the Edit tool on a large file, you can run /cost to see what the session has consumed so far. This context helps you decide whether to allow the edit or to hit Escape and refine your prompt to be more token-efficient. Monitoring these numbers in real time prevents the surprise of a high-cost session that you only discover after the work is already done. This practice keeps your development spending predictable and manageable.

Reviewing usage statistics for broader context

While /cost gives you currency values, the /usage command provides a broader view of token consumption. It shows you the total input and output tokens consumed during your work across all sessions. This is helpful for understanding if a subagent is pulling in too much project context through the Read or Glob tools. High input token counts often suggest that the subagent is reading large files repeatedly or that the session history has grown too long. Seeing the raw numbers helps you identify if the agent is being redundant in its data gathering.

By monitoring the output of /usage after a subagent exits, you can determine if you need to refine the instructions in your .claude/agents files. If the output tokens are consistently low but input tokens are high, the agent is spending most of its effort reading your project without producing much code. You might need to change your CLAUDE.md file to provide better guidance on which subdirectories are relevant to specific tasks. This ensures that subagents do not waste resources scanning parts of the repository that have nothing to do with their current objective.

Automating cost tracking with hook events

Claude Code supports hook events that trigger at specific points in the agent lifecycle. The SubagentStop hook is particularly useful for cost monitoring. You can configure hooks in your .claude/settings.json or .claude/settings.local.json file to perform actions when a subagent finishes its task. This allows you to build a more automated observation loop. While you cannot currently script a direct pipe from the internal billing meter to an external file via a hook, you can use these events to log when subagents are starting and stopping.

Setting up a Notification hook for the SubagentStop event ensures you do not forget to verify the spend after a long-running background task completes its work. This is especially helpful when you are working on multiple files and the terminal output is scrolling quickly. The notification serves as a prompt for you to run /cost and evaluate the efficiency of the subagent. By making cost checking a habit triggered by these hooks, you create a more disciplined approach to managing your API usage and overall project expenses.

Managing subagent behavior in configuration files

Every subagent you define as a markdown file in the .claude/agents directory can be optimized for cost. If you notice a specific subagent is too expensive, check its system prompt within that file. Often, providing a more restrictive set of instructions or limiting the tools it can use will prevent it from consuming unnecessary tokens. For example, if a subagent only needs to find information, you might restrict its ability to use the Write or Edit tools. This keeps the subagent focused and prevents it from taking expensive, unnecessary actions.

You can also control global behavior in ~/.claude/settings.json. By adjusting the permissions section, you can require manual approval for certain tools like WebSearch or WebFetch. This forces a pause where you can evaluate if the subagent is about to perform an expensive operation. This level of control is vital when working with subagents that might otherwise recursively search the web or download large amounts of documentation. Manual intervention is often the best way to keep costs from spiraling during complex automated tasks.

Consolidating context with the compact command

Subagents inherit the context of the main session. If your session history is long, every subagent call becomes more expensive because it must process that history as part of its input. The /compact command is your primary tool for reducing these costs. It summarizes the conversation and clears out the details, which lowers the token count for subsequent subagent calls. This makes the entire session leaner and more efficient. It is a good practice to run /compact before you know you are about to trigger a heavy subagent process.

You can also use the PreCompact hook to trigger specific actions before this summary happens. If you are worried about losing important subagent results during a compaction, you can use the /memory command to store key facts. This ensures the subagent has the information it needs without needing to re-read thousands of lines of history. By combining /memory and /compact, you maintain the intelligence of the session while drastically reducing the cost of every subsequent subagent invocation. This approach balances performance with financial efficiency.

Visualizing multiple agent costs simultaneously

When you are running many different tasks at once, tracking costs per subagent in a single terminal window becomes confusing. This is where adhdTerminal provides a significant advantage. It allows you to run multiple Claude Code sessions side by side as tiles on a wall, where each tile represents a separate project or sub-task. Each tile has its own color, number, and name, making it easy to distinguish between a documentation subagent and a refactoring subagent. You can see at a glance which agents are working and which are waiting for your input.

Because each tile in adhdTerminal tracks its own session, you can see the cost and status of different agents without them bleeding into each other. If one tile is running a subagent for a documentation task and another is refactoring a database, you can look at the individual tile to see the last exchanges and the current spend for that specific context. The free iPhone app also mirrors this wall, letting you check if a subagent has finished or see its current progress while you are away from your desk. This visual separation makes managing the total cost of a multi-agent workflow much more intuitive.

Using the resume command to audit past sessions

If you forgot to check the cost before closing your terminal, you can use claude --resume or the /resume slash command. This allows you to pick from a list of previous sessions and reopen them in the state you left them. Once you are back in the session, running /cost will show you the final total for that entire thread, including all subagent activity. This is helpful for doing a weekly audit of your spend. You can see exactly which project was the most expensive and drill down into the history to understand why.

Reviewing old sessions is a great way to perform a post-mortem on project spend. You can see which subagents were triggered by checking the history with the double Escape key combination. This helps you identify patterns where subagents might have been called unnecessarily or where they struggled with a specific task. You can then update your CLAUDE.md file with better instructions to prevent future waste. Using the claude --continue command in a specific folder is another way to quickly jump back into a context and check the running total before you add more tasks to the queue.

Questions people ask

Can I set a hard budget for a subagent?

No, Claude Code does not have a hard currency limit per subagent. You can use the /permissions command to set specific tools to require manual approval. This allows you to stop a subagent by pressing Escape if it attempts a tool call that you know will be expensive.

Does running /clear reset my billing for the project?

The /clear command starts a new session within the same directory, so the cost for that specific session starts from zero. However, your total account usage across all sessions is what determines your final bill. You can run /usage to see the cumulative token counts for your account.

Why are some subagent calls more expensive than others?

Costs vary based on the amount of context the subagent has to process. If the main session has a long history, the subagent must read all of that data as part of its prompt. Using /compact before calling a subagent reduces the input tokens and lowers the cost of the delegation.

Read next

More on claude code basics·All posts