Run /clear Between Tasks in Claude Code Instead of Letting Context Pile Up

often 30-60% on long sessions Beginner 1 min read

Claude Code (and chat-style assistants generally) are stateless under the hood: each turn resends the accumulated conversation, including every file you've read and every command's output, as input tokens. A session that started by reading a 2,000-line file, ran a failing test suite, and dumped a stack trace carries all of that forward into every subsequent message, even after you've moved on to a totally different feature.

Before: You debug a flaky test (reads several files, prints logs), get it green, then in the same thread say "now add a --json flag to the CLI." Every turn of the CLI work still ships the test files, the old logs, and the debugging back-and-forth as input. Twenty turns later you're paying for kilobytes of irrelevant history on each request.

After: Once the test is fixed, run /clear to reset the context window, then start the CLI task fresh. The new task only carries what it actually needs.

# finish debugging task
/clear
# now: "add a --json flag to the CLI"

Why it saves tokens: Input tokens are billed per turn, and conversation history is input. The cost of a stale 30,000-token context isn't paid once; it's paid on every message until you clear it. /clear drops that history to near zero, so a long working day becomes a series of short, cheap contexts instead of one ever-growing expensive one.

Two refinements. Use /compact instead of /clear when the next task genuinely builds on the last and you want a summary kept rather than a hard reset. And lean on prompt caching: Claude Code caches stable context (like CLAUDE.md), so cached reads are billed at a large discount, but caches expire and don't cover the churn of tool output mid-session, clearing is still the reliable lever.

Applies to: Claude CodeClaude
Don't just read it — build the habit

Get a fresh tip every morning

You're reading a free Beginner tip. Pro unlocks all 38 advanced tactics and sends a new one daily — $9/mo, cancel anytime.