Usage wiki: when limits reset and how to save tokens

When limits reset and how to make them last longer. Browse by topic, with separate answers for Codex and Claude, based on official docs with quotes and links.

Long sessions use more tokens: /compact or /clear?

Use /clear when you switch tasks and /compact only in the middle of one. Every message re-reads the whole conversation, so the longer the session, the more each line costs. /clear costs nothing; /compact is a large request in itself.

Codex

Use /new to start a new chat for a new task, and /compact when one task has grown long.

Codex usage follows context size: the larger the input, the more it uses. Cached input counts at a tenth of regular input and cache writes are free, but the longer the conversation, the larger that share gets. Type /new (or /clear) when you switch tasks, and the context starts from zero; if the same task has to continue but is already long, /compact turns the chat into a summary. /status shows token usage and how much context is left, and /resume brings back an old chat.

What the official docs say

Model choice, context, reasoning, tool use, retrieval, and caching all affect usage, so prompt length alone isn't a reliable estimate.
OpenAI Developers · Codex pricing
Charges are based on the model used and the actual input, cached input, and output tokens consumed.
OpenAI Help Center · ChatGPT Rate Card
Codex does not charge for cache writes.
OpenAI Help Center · ChatGPT Rate Card
/new: Start a new chat inside the same CLI session.
OpenAI docs · Developer commands
/compact: Summarize the visible chat to free tokens.
OpenAI docs · Developer commands
/status: Display session configuration and token usage.
OpenAI docs · Developer commands

Claude

Use /clear when you switch tasks; it costs nothing. Use /compact only mid-task; it is a large request in itself.

Claude Code sends the whole conversation with every request, and every tool call is another request. With caching, the history is re-read at the cached rate, about a tenth of regular input, so one line typed into a session that has been open all day still pays for all of it. The /usage panel says it this way: "Longer sessions are more expensive even when cached. /compact mid-task, /clear when switching to new tasks." The cache lasts an hour on a subscription and five minutes once you are on usage credits; after a longer break, your first message reprocesses the full context at the regular rate, and that is the most expensive message. Run /rename before /clear so you can find the session with /resume. /compact accepts a note on what to keep, such as /compact keep only test output and code changes, and a section titled # Compact instructions in CLAUDE.md makes that a standing rule.

What the official docs say

With prompt caching, Claude Code re-reads that history at the cached token rate, so a one-line question in a session that has been open all day still draws usage for the whole conversation.
Claude Code docs · Manage costs effectively
Cache misses: your first message after a break longer than the cache lifetime misses the cache and reprocesses your full context. The lifetime is an hour on a subscription and drops to five minutes once you're drawing on usage credits
Claude Code docs · Manage costs effectively
Compaction: /compact reads the conversation it summarizes, so compacting a large context is itself a large request. When you want a fresh start instead of continuity, /clear costs nothing
Claude Code docs · Manage costs effectively
Use /clear to start fresh when switching to unrelated work. Stale context wastes tokens on every subsequent message. Use /rename before clearing so you can easily find the session later, then /resume to return to it.
Claude Code docs · Manage costs effectively
cache_read_input_tokens — Tokens served from cache on this turn, billed at roughly 10% of the standard input rate
Claude Code docs · How Claude Code uses prompt caching

Web search, large files, long logs: keep them out of the context

One search is cheap. What costs is putting a whole web page, a whole file or a whole log into the context: once it is there, every later message pays for it again.

  1. For a single fact, ask for a search, not a full-page fetch; fetch only when you need the full text. On Claude, web search and web fetch both count toward your limits, and summarizing a 10,000-word article costs far more than one search. Research runs many searches in a row and uses more still.

  2. Name the file and the function, and give a line range if you can. "Fix the login function in auth.ts" reads one file; "improve this code" sets off a wide scan.

  3. Filter logs and test output before the agent sees them. In Claude Code a PreToolUse hook can make a test command return only the failing lines, and the official costs page has a ready script. The simplest way is to grep the error lines yourself and paste those.

  4. Hand jobs with long output (running tests, fetching docs, reading logs) to a subagent: the long output stays in its context and the main session gets a summary. This saves context in the main session; the total tokens are not always lower.

  5. Codex: provide only the relevant files, and narrow the sources when you can.

What the official docs say

Usage of web search and web fetch counts toward your usage limits.
Claude Help Center · Enable and use web search
asking Claude to summarize a 10,000-word article will use substantially more of your context window than a regular web search query.
Claude Help Center · Enable and use web search
Instead of Claude reading a 10,000-line log file to find errors, a hook can grep for ERROR and return only matching lines, reducing context from tens of thousands of tokens to hundreds.
Claude Code docs · Manage costs effectively
Vague requests like "improve this codebase" trigger broad scanning. Specific requests like "add input validation to the login function in auth.ts" let Claude work efficiently with minimal file reads.
Claude Code docs · Manage costs effectively
Limit source material. Provide only relevant files and, when possible, narrow the sources or date range.
OpenAI Developers · Codex pricing

Common misconceptions

  • /compact saves tokens, so run it whenever you like

    It does not. /compact has to read the whole conversation before it can write the summary, so the larger the context, the larger that one request. It fits the middle of a task you are going to continue. When you switch tasks, use /clear, which costs nothing.

  • With caching, a session can stay open all day at almost no cost

    Not so. Caching only lowers the price of re-reading to about a tenth. The whole history is still read on every message, and the longer it is, the larger that share. On a subscription the cache also lasts just an hour; come back after a longer break and the first message reprocesses the full context at the regular rate.

  • Web search burns tokens, so avoid it

    It is not the search. A search brings back a few snippets. What costs is fetching whole pages, reading whole files and pasting whole logs: that content stays in the context and is re-read on every later turn.

Tips

  • Before you switch tasks, run /rename, then /clear; /resume takes you back. On Codex, use /new and /resume.
  • Use /compact only mid-task, and add what to keep, for example /compact keep only test output and code changes.
  • Leaving for more than an hour? Wrap up what you are doing first. On Pro and Max, when Claude Code offers to resume a large session from a summary, accept it; later messages then skip the full history.
  • Run /context in Claude Code or /status in Codex at any time to see how full the context is.
  • Stop /loop tasks and shut down teammates when they are done. Each run in an idle session carries the whole context.
  • Claude Code flags long context or cache misses in /usage once either reaches 10% of recent usage. When you see that flag, it is time to /clear.

Codex reset announcements · Claude reset announcements