Last updated 13 October 2026
Check the cost of your current Claude session
Monitor your investment in real time
You are running a complex refactor across twenty files. You wonder how much this specific session is costing you. Claude Code is an agentic tool that takes multiple steps to solve a problem. Each step involves sending tokens to a model. If the agent reads a large file, those tokens add to your bill. If it searches your entire directory with the Glob tool or the Grep tool, the file paths and names add to the context window. You need a way to track this spend before you reach the end of your budget.
Developers often fear the black box of command line agents. You might trigger a command and watch the agent crawl through your directory structure. Every file it touches increases the input cost for the next turn. Without clear visibility, you might spend more than you intended on a single task. Monitoring your usage helps you decide when to give the agent more information and when to stop a session that is becoming too expensive.
View the dollar amount with the cost command
The primary tool for monitoring your spend is the /cost command. You type this directly into the interactive session. The agent will respond with the total estimated cost for the current session in dollars. This figure is cumulative. It includes every turn from the moment you started the session until the current prompt. It provides a quick check when you feel a task is taking longer than expected or when the agent is performing many tool calls in a row.
The dollar amount is an estimate based on your current usage. It covers the input tokens sent to the model and the output tokens generated by the agent. This command is the fastest way to get a high level view of your financial investment in a specific coding task. If the number is higher than you like, you can change your approach or narrow the scope of the project.
Analyze token usage for better efficiency
If you want to see the numbers behind the dollar amount, use the /usage command. This command breaks down the session into raw tokens. It shows you the input tokens and the output tokens. It also tracks how many tokens were served from the cache. Cache hits are vital because they are significantly cheaper than fresh input tokens. If you see a high number of input tokens but very few cache hits, it might mean your project structure or your prompts are preventing efficient caching.
Understanding the ratio of cache to new input helps you optimize how you provide files to the agent. When you use the Read tool on the same file multiple times, the system tries to cache that content. The /usage command helps you identify if the agent is re-reading large amounts of data unnecessarily. This data allows you to make technical decisions about how you interact with the CLI to keep your costs under control.
Reduce spend by compacting your history
The cost of each turn in a session usually increases over time. This happens because the agent keeps the conversation history in its context window. Every file it has used with the Read tool or the Edit tool stays in that window for a period of time. When the context window gets full, you pay for all that data on every new turn. You can manage this by using the /compact command. This command tells the agent to summarize the conversation history. It keeps the important facts but removes the bulk of the old messages.
Compacting reduces the token count for future turns. It is a powerful way to lower your ongoing costs in a long session. You should use /compact when you have finished one part of a task and are moving on to the next. This clears the technical clutter while ensuring the agent still remembers the goals you have already achieved. It keeps the context window lean and prevents the price of each prompt from scaling out of control.
Start fresh to stop the bleed
Sometimes a session becomes too expensive to continue. If the agent is confused or the context is cluttered with irrelevant file content, use the /clear command. This command wipes the current session history while keeping you in the same folder. It resets the token count for the conversation back to zero. You can then start a fresh prompt with a clean slate. This is often more cost-effective than trying to fix a complex misunderstanding in a long, expensive session.
Starting over is a strategic choice. When you use /clear, the agent forgets previous mistakes and previous tool outputs. You can then provide a more precise prompt to get the job done in fewer steps. This avoids the compounding cost of an agent that is struggling with a large and messy context window. It is a reset button for both the logic of the agent and the cost of the session.
Track multiple sessions across your projects
Managing costs becomes harder when you run many projects at once. You might have one session doing a long migration and another fixing a small bug. Monitoring each terminal tab separately is a mental burden. This is where adhdTerminal provides a concrete benefit. It is a native app for macOS and Windows made by MINDBALANCER OU that runs many Claude Code sessions side by side as tiles on a wall. Each tile has a colour and a name. It shows if the session is working or waiting for you.
You can see the last exchanges of the conversation and project headlines on the tile itself. This is helpful for monitoring spend because you can see the status of every project at once. You do not have to switch between many terminal tabs to see which agent is still running or which one has finished a task. The app costs 99 dollars once and offers a 7 day free trial. It ensures you never forget an expensive agent that is stuck in a loop in a hidden window.
Use permission modes to review plans
You can control how the agent spends your money by changing the permission mode. You can cycle through modes by pressing Shift+Tab inside a session. In plan mode, the agent will describe what it intends to do but will not execute the tools yet. You can review the plan and decide if it is worth the cost. This prevents the agent from using tools like Edit or Write on many files before you have approved the specific approach.
You can also define specific tool permissions in your .claude/settings.json file. This allows you to limit what the agent can do without your explicit consent. By forcing a manual check on expensive operations, you ensure that every token spent on writing or searching is actually necessary. This manual oversight is one of the most effective ways to prevent accidental overspending on large codebases.
Optimize project instructions for lower overhead
The files you place in your repository also impact your cost. The CLAUDE.md file at the root of your project contains project instructions. Claude Code reads this file at the start of every session and refers back to it frequently. If this file is extremely large, you are adding that token overhead to every prompt you send. The same applies to a CLAUDE.md file in a subdirectory which applies to that part of the tree.
Keep these files focused on essential coding standards and build commands. Do not use them as a general knowledge base or a place to store large amounts of documentation that the agent does not need for every task. Every line in a project instruction file is a line you pay for repeatedly. Streamlining these files ensures your base cost for every turn stays as low as possible.
Manage the cost of external tool results
External tools like WebSearch and WebFetch can increase your token usage quickly. When the agent uses WebSearch to find documentation, it brings back text from the internet. This text is added to your session context. If the agent fetches a large web page with the WebFetch tool, your token count will spike. This data counts toward your input tokens for all subsequent turns in that session.
Always check the /cost after the agent performs an external search. If the results brought back are too large, consider using /compact immediately. This allows the agent to summarize the findings and clear the raw source text from the active context window. Keeping your context lean after a search task retains the information you need while discarding the expensive raw data that is no longer required for coding.
Questions people ask
How do I check the cost of a previous session?
You can use the command claude --resume to see a list of your previous sessions and reopen one. Once inside the session, use the /cost command to see the total spent during that specific conversation. The agent stores the history and usage data for each session independently in its local database.
Does the cost command include MCP server fees?
The /cost command tracks the tokens used by the Claude Code agent to communicate with the model. It does not account for external costs charged by third party MCP servers or API services the agent might access through those servers. You should check the individual billing dashboards for any external MCP tools you have configured in .mcp.json.
Can I set a hard spending limit inside Claude Code?
There is no native setting in Claude Code to set a hard dollar limit for a single session. You should monitor your usage manually with the /cost and /usage commands or check your account dashboard for global limits. Using adhdTerminal can also help you stay aware of multiple active sessions to prevent accidental overspending across many projects.
Read next
- Add build instructions to your CLAUDE.md fileImprove project context by adding specific build commands and environment requirements to your CLAUDE.md file for the AI to follow.
- Add common error fixes to CLAUDE.mdImprove project memory by adding a section for common errors and their fixes to your CLAUDE.md configuration file.
- Add custom shell aliases for Claude CodeSpeed up your workflow by creating shell aliases for common Claude Code invocations and project-specific startup commands.
- Add test commands to a CLAUDE.md fileUnderstand how to define specific test runners and environment flags in your CLAUDE.md file so the tool runs the correct test suite.