What does this solve?
Claude Code limits is remembered in the same place: the agent stops in the middle of a task and reports that access has been exhausted, although everything was working an hour ago. Three different mechanisms are hidden under the word “limit”, and their treatment is also different - one helps /clear, from another expectation, from a third change of payment scheme. As long as they are mixed together, any action looks like fortune telling. Below is a division of these mechanisms and specific levers for each.
How it works
Limiter first: context window
How much text fits in one conversation. The system part and contents are added to the window CLAUDE.md, tool definitions of all connected MCP servers, the entire history of moves, read files and outputs of executed commands. When there is little free space left, automatic compression is triggered: the story is replaced by its retelling, details are lost. The context refers to one session and is reset to /clear.
Limiter two: subscription quota
How much work an account can do in a period. Sliding window mechanics: consumption is taken into account for the last period of time and is gradually released, rather than being reset to zero according to the calendar schedule. A longer period works on top of a short window, and the older model has a separate and more rigid ceiling than the younger ones. The common pool is shared with all areas of the account - the chat in the browser spends the same quota as the agent in the terminal.
Limiter three: rate limits API
When paying upon delivery, the ceiling is not in the volume per window, but in the speed: requests per minute, entry and exit tokens per minute. Exceeding comes with a 429 response with header retry-after —the client waits and repeats itself. The level of limits rises along with the accumulated expenses on the account.
There is also a fourth, less noticeable: the length of one answer. The model will not produce a sheet of infinite size in one move, so “rewrite the entire file into 4000 lines” hits this limit before the quota.
What counts
Tokens, not messages. Each move re-sends the entire accumulated context, so the cost of the hundredth move in a long session is several times higher than the cost of the first. Caching smoothes the picture: an unchanged prefix (system part, CLAUDE.md, tool definitions) is charged cheaper - as long as it is not touched. Edit CLAUDE.md or connecting a new MCP server in the middle of work resets the cache, and the next move is paid in full.
What inflates consumption the most
- Reading entire files where searching by pattern would suffice. One large data file can take up a significant portion of the window in one instrument call.
- Output of tests and builds without a filter: a thousand-line stack goes into the context completely and remains there until the end of the session.
- Connected and unused MCP servers: their tool descriptions are loaded into the context at the start of each session, even if no tool is called.
- Bloated
CLAUDE.md: it is paid every time you launch it. - Screenshots and images are an expensive input compared to text.
- Subagents: each works in its own window and returns a summary, saving the main context, but the total consumption of tokens increases.
- Parallel sessions in several terminals - multiplying the cost by the number of windows.
How to connect
Setting up observations and frames takes five minutes and is done once.
See the context. Inside the session:
/context
Shows a breakdown: how much the system part takes, how much tools MCP, how much CLAUDE.md, how long is the correspondence itself and how much free space is left. This is the main diagnostic screen.
See quota and money.
/usage # состояние квоты на подписке и момент обновления окна
/cost # накопленная стоимость сессии при оплате по факту
Set the counter to permanent display. The status bar is configured with the command /statusline or field statusLine in settings.json —the model, branch and context filling are displayed there so that the approach to the limit can be seen without a separate command.
Place frames.
/model # переключить движок: рутина не требует старшей модели
/mcp # посмотреть подключённые серверы и отключить лишние
/clear # начать чистую сессию между несвязанными задачами
/compact # сжать историю принудительно, с указанием, что сохранить
The /compact Instruction accepted: /compact сохрани решения по схеме БД и список изменённых файлов. Without it, compression itself decides what is important and regularly throws out what it needs.
Cut down sources.
Keep CLAUDE.md short - there is room in it for assembly commands, prohibitions and agreements, and not for retelling the architecture. Large directories should be placed in separate files and loaded upon request. In the permission settings, allow targeted searches in advance so that the agent does not ask for confirmation and does not pull entire files “just in case.”
For non-interactive runs limit chain length by flag --max-turns and ask for machine-readable output, not a long story.
Useful scripts
- Before starting a new task -
/clearso that the previous context is not paid in each next move. - Before long refactoring -
/contextto see that half of the window is already occupied by descriptions of unused tools. - Routine run of linter and tests - on the younger model, the older one remains for analysis of the architecture.
- Long command output - immediately after
greportail, and not entirely in context. - A task consisting of several independent parts - subagents, so that the analysis of someone else's code does not end up in the main window.
- Running into a quota in the middle of work -
/compactwith instructions and switching to a younger model instead of waiting.
Limitations
The subscription limit is not removed by money within the same level: either waiting for a window, or a higher level, or switching to payment upon delivery helps.
Context compression always loses detail. After several automatic compressions in a row, the agent begins to ask again what they decided an hour ago - at this point it is cheaper to start a clean session and briefly retell the result than to compress further.
The cache does not last long and breaks due to any changes to the stable prefix. The habit of correcting CLAUDE.md mid-session is more expensive than it seems.
It is impossible to calculate the cost of a task in advance: it depends on how many files the agent decides to read and how many times the tests fail. You can only plan on an order of magnitude.
There is no separate “code only” limit: the pool is shared with other applications in the account.
One line rule: the context is treated with the command /clear, quota - by waiting or changing the payment scheme, speed - by pause and repeat; first identify the limiter, then act.
How to check the result
Basic measurement takes two minutes. In a fresh project session:
/context
Remember the share of occupied space before the first question. If it is already large, the source is visible in the same breakdown - usually these are MCP servers or CLAUDE.md. Disable an extra server via /mcp, log out, log in again and compare.
Next - control at work. Run a typical task to completion, then:
/cost # при оплате по факту
/usage # на подписке
Repeat the same task in a clean session on the younger model and compare both numbers with the quality of the result. Measuring on your own repository answers the question about the model more accurately than any general reasoning.
Context hygiene check: after two or three tasks in a row without /clear open again /context. An increase in occupied space between tasks that are not related to each other is a direct sign that the quota is spent on sending history, and not on work.
