BeginnerClaude Code

Context window management — when to /clear, /compact, or just keep going

Long sessions go bad in predictable ways. Here's how to keep Claude sharp.

Claude's context can hold a lot. That doesn't mean it should. The four rules for keeping long sessions lucid.

7 min read
claude-codecontextworkflowbest-practices

A long Claude session starts smart and ends muddy. The reason isn''t the model — it''s context dilution. Every irrelevant file, dead-end approach, and stale tool result you accumulated is still being read on every turn.

Knowing when to reset that context is most of the skill of using Claude well.

The three options

/clear — Reset the conversation completely. Fresh start, zero memory. Use when:

  • You''re moving to an unrelated task
  • You''ve gone down a rabbit hole and want a clean slate
  • The session has obvious confusion (Claude referencing files that don''t exist, suggesting things you already tried)

/compact — Summarize the conversation in place. Claude compresses what came before into a short summary; the rest is dropped. Use when:

  • You''re still on the same task but the context is bloating
  • You want to keep the conclusions but lose the noise
  • You''re approaching the context limit and don''t want to lose the thread entirely

Just keep going — Use when:

  • The conversation is still focused
  • You''ve loaded relevant files and they''re still relevant
  • The recent turns are building toward something useful

The four rules

1. Clear between unrelated tasks

The biggest mistake: doing a database migration, then immediately asking Claude to refactor the auth flow without /clear. Now Claude is reasoning about auth with migration context still loaded — it sometimes suggests "fixes" that reference the migration code, which makes no sense.

Rule: if the next task wouldn''t benefit from the current context, clear it.

2. Compact when you want to preserve the conclusion, not the journey

You spent 40 minutes debugging a flaky test. You finally found the cause — a race condition in the test setup. The conclusion is two sentences. The journey was 30 dead ends.

/compact. Claude summarizes: "We debugged a flaky test in auth.test.ts — race condition in setup; fix is to await seedDb()." The 30 dead ends are gone. You can now ask "apply the fix" without Claude re-considering the dead ends.

3. Read big files into a subagent, not the main context

If you ask Claude to "summarize all the components in src/components/" and there are 40 of them, the main agent reads all 40, polluting context for the next turn.

Better: spawn an Explore subagent. The subagent does the reading, returns a 200-word summary. Main context stays lean.

See subagents and parallel work.

4. Watch for the warning signs

Claude is degrading from context bloat when you see:

  • It references files you closed or never opened
  • It suggests fixes that contradict earlier turns
  • It gets vague when it was specific 10 turns ago
  • The replies get longer but say less

When you see two of those, /compact. When you see three, /clear.

The thing nobody tells you

You can run multiple Claude sessions in parallel — each in its own terminal tab — and they don''t share context. This is intentional. Use it.

Practical pattern:

  • Tab 1: long-running design discussion (don''t want to clear)
  • Tab 2: short tactical task ("rename this variable across files")
  • Tab 3: subagent-style "audit the current branch"

Each tab is its own context. Each is sharp. You don''t have to choose between depth and breadth.

Anti-pattern: hoarding context

Some users avoid /clear because they feel like they''re losing work. They aren''t. The work is in the codebase, the commit, the doc — not in the conversation. The conversation is scaffolding. Throw it away when it stops helping.

The same mindset that lets engineers delete code instead of keeping commented-out blocks lets operators clear conversations instead of nursing them.

Where to go next

Keep learning

Apply this with Waymaker

Get this article surfaced where you work

Inside Waymaker, this article shows up next to the right Signal page — so the lesson lands when you need it, not before.

No credit card required.