DEV Community

Cover image for The Claude Code /clear Workflow That Lets You Run Forever
Mike Dolan
Mike Dolan

Posted on

The Claude Code /clear Workflow That Lets You Run Forever

Claude Code has a command almost nobody uses: /clear. It wipes the current conversation from Claude's context window and starts fresh. Zero tokens used. Full speed. Clean slate.

The reason nobody uses it: /clear is destructive. Everything you discussed is gone. All the decisions, all the context, all the reasoning. Gone.

Unless you have a persistent memory layer. Then /clear stops being destructive and becomes one of the most useful commands in Claude Code.

This is a short post about two things: the Claude Code status line (which tells you when to /clear) and why /clear is now safe to use if you have the right setup.

The Status Line You Should Enable

Claude Code has a built-in status line that most people never turn on. Mine shows:

Project:     claude-brain (dev branch)
Context:     36% used (compaction fires at 95%)
5hr window:  36% used, 20 hours until reset
Week:        8% used, resets Friday
Hint:        new task? /clear to save 359.3k tokens
Enter fullscreen mode Exit fullscreen mode

Breaking it down:

  • Context 36% - current context window usage. Compaction fires automatically around 95%. Watch this number and you'll know when the wall is coming.
  • 5hr window - your 5-hour rate limit window. Shows how much of your allocation is left before the next reset.
  • Week - weekly usage, resets Friday. Keeps you honest on your subscription.
  • /clear to save 359.3k tokens - tokens you'd free if you ran /clear right now.

That last number is the killer feature. It tells you exactly how much context debt you're carrying. 359,300 tokens of context debt means every single response is paying the cost of carrying that much history. When that number gets high, you should /clear.

How to Enable the Status Line

Add this to ~/.claude/settings.json:

{
  "statusLine": {
    "type": "command",
    "command": "claude-statusline"
  }
}
Enter fullscreen mode Exit fullscreen mode

Claude Code ships with a built-in claude-statusline command that renders the format above. If you want to customize it, the docs cover the full syntax for writing your own script. Two minutes to enable, game changer for long sessions.

What /clear Actually Does

/clear wipes everything from Claude Code's active context window. Not compacted. Not summarized. Gone.

This is different from auto-compaction. Compaction fires when you hit 95% context and tries to summarize everything into a shorter form so you can keep going. The summary is lossy. You lose detail, nuance, reasoning chains.

/clear is faster and cleaner. It throws everything away and starts fresh. No summary, no compression, no loss of fidelity. The next message starts with an empty context window.

The problem is that "empty" means you lose everything. The decisions you made. The context you built up. The debugging session from an hour ago. All gone. Which is why most people avoid /clear even when they should be using it.

The Fix: Persistent Memory

I built claude-brain, an open source persistent memory system for Claude Code. Six Python hooks capture every conversation losslessly to a local SQLite database. When /clear wipes the active context window, the brain database still has everything.

Here's what happens with /clear when the brain is running:

  1. You notice the status line shows ctx at 75% and /clear to save 200K
  2. You run /clear
  3. Claude's active context is wiped
  4. The brain database still has every word of your conversation
  5. You type your next message
  6. The user-prompt-submit hook runs automatically, searches the brain, and injects the top 5 relevant matches into Claude's context
  7. Claude sees your new message plus the most relevant history from before the clear
  8. You keep working with a lean context window and full access to your past decisions

Without the brain, /clear is destructive. With the brain, /clear is a productivity tool.

The Nuance: File Contents vs Discussion

Here's the honest tradeoff. The brain captures your conversation, but it does not keep large file contents in Claude's active context after /clear.

Example: you used the Read tool to load a 10,000 word chapter of a book you're editing. Claude gave you feedback. The feedback discussion is captured to the brain. You run /clear. Now:

  • The discussion about the chapter: still available via the brain, hooks inject relevant snippets on your next message
  • The chapter text itself: gone from active context

If you want to continue editing that chapter, Claude needs to re-read the file. One Read tool call and the chapter is back in context. Nothing is lost, but you pay the tokens again to load it.

So the rule of thumb is:

  • /clear when switching tasks: you were working on chapter 5, now you want to move to chapter 6. /clear, then Read chapter 6. Massive win. You freed all of chapter 5's tokens.
  • /clear when done for the day: you're switching projects or wrapping up. /clear. Huge win.
  • /clear when you're still actively working on a large file: works but wasteful. Claude re-reads the file, you pay the tokens back. Net zero, just extra work.

For pure discussion, planning, debugging, and decision-making, /clear with the brain is a pure win. The brain has everything and the hooks restore what matters.

The Workflow

Here's the full loop:

  1. Watch the status line. When ctx crosses 60-70%, you're approaching compaction.
  2. Check the "save" number. If /clear to save shows 200K+ tokens, you have real context debt.
  3. Decide if you're between tasks. If yes, /clear is a pure win. If you're mid-task on a large file, either finish that task first or accept you'll re-read the file.
  4. Run /clear. Clean slate, fast responses, no compaction wall coming at you.
  5. Keep working. The brain hooks automatically inject relevant history on your next message. You never re-explain yourself.

The result: you can run Claude Code for days without ever hitting auto-compaction. Every session stays fast. You decide when to reset instead of waiting for the wall.

Why This Matters

Auto-compaction is the worst failure mode in Claude Code. You hit 95% context, the system pauses, summarizes everything into a lossy form, and you lose details you didn't know you needed. With the status line you can see it coming. With the brain you can avoid it entirely by clearing on your terms.

The pattern is: status line tells you when to clear, brain makes clearing safe, you get the benefits of a fresh context window without losing the benefits of a long conversation.

Most Claude Code users have never used /clear once. If you install the brain, you'll use it every day.

Try It

The status line is native to Claude Code. Enable it in ~/.claude/settings.json with the config above. Two minutes, no install.

The brain is free and open source:

curl -fsSL https://raw.githubusercontent.com/mikeadolan/claude-brain/main/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

Works on macOS, Linux, and Windows.

GitHub: github.com/mikeadolan/claude-brain
Video: claude-brain in 85 seconds
Article 1: How I Built Persistent Memory for Claude Code
Article 2: Why I Use Claude Code for Everything
Article 3: The Session Protocol That Fixed Claude Code's Amnesia Problem
Article 4: Claude Code Compaction Kept Destroying My Work. I Built Hooks That Fixed It.

Top comments (0)