Claude Code Context Management: How to Get Better Results - Step-by-step guide for Level Up

Claude Code Context Management: How to Get Better Results

By Mark FershteynPublished Last updated 12 min readintermediate

Fix inconsistent Claude Code results with proper context management. Learn when to use /clear, /compact, and session handoffs for better AI output.


Claude Code context management is why some users get amazing results while others struggle with inconsistency. This guide explains how context works-and the techniques that produce dramatically better output.

If you've blamed Claude for giving you terrible results, you need to read this.

I'm not here to defend bad outputs. But after spending months frustrated with inconsistent results, I discovered something that changed everything:

Most of the time, the problem isn't Claude. It's how we're managing context.

Here's the uncomfortable truth I learned the hard way: I was getting inconsistent results because I didn't understand how Claude actually works. I'd have great sessions, then terrible sessions, and I couldn't figure out why. One day Claude would nail a complex task. The next day it would forget constraints I'd repeated three times.

I blamed the model. I blamed Anthropic. I blamed the "AI lottery."

Then I learned about context degradation, and suddenly everything made sense.

Context

This guide is based on insights from Eyad Khrais, a 7-year software engineer with experience at Amazon, Disney, and Capital One. When someone with that background explains why Claude Code behaves inconsistently, I listen. What follows are his techniques-plus the lessons I learned applying them.


The Dirty Secret About Context Windows

Claude Code's context window is the memory it uses for your conversation. Performance degrades starting at 20-40% capacity-not when the window is full. Most users wait too long to manage context, working with a degraded model without realizing it. Proactive context management is the key to consistently great results.

Here's what nobody tells you about context windows:

Performance doesn't degrade at 100% capacity. It degrades starting around 20-40%.

Read that again.

If you've been waiting until Claude says "context is getting long" to take action, you've already been working with a degraded model for a while.

0-20%Peak performance
good
20-40%Degradation begins
declining
40-100%Significantly degraded
Context window degradation happens earlier than you think

This explains so much frustration I had early on. I'd start a session, get great results, keep going... and then quality would mysteriously drop. I'd keep pushing, thinking "I'm not at the limit yet." But I was already past the point of degradation.

The model was struggling long before the compaction warning appeared.


Why /compact Doesn't Magically Fix Everything

If you've ever run /compact and then still gotten terrible output afterwards, here's why:

Compaction happens after the degradation has already occurred.

Think about it. When Claude compacts your conversation, it's summarizing content that was already processed by a degraded model. You're not restoring Claude to peak performance-you're locking in the degraded state.

What Actually Happens
Context getting long... let me run /compact
After compaction
Great, I've summarized our conversation. Now, where were we? Oh right, you wanted me to [proceeds to misunderstand the entire project]
Compaction doesn't undo degradation-it preserves it

This was a breakthrough moment for me. I had been relying on /compact as my safety valve. Run it when things get slow, keep working. But compaction wasn't fixing my problems-it was preserving them.

The summary Claude creates is only as good as the context that existed when it created that summary. If the model was already confused, the summary will be confused too.


Warning Signs Your Context Is Degraded

Before you can fix the problem, you need to recognize it. Here are the symptoms I've learned to watch for:

Context Degradation Symptoms
Suggesting rejected ideas
Claude proposes something you already said no to
Common
Forgetting constraints
Ignores rules you established earlier in the conversation
Common
Quality dropping
Outputs feel less precise, more generic than before
Subtle
Repeating questions
Asks things you already answered clearly
Obvious
Going in circles
Keeps revisiting the same problem without progress
Frustrating
Contradicting itself
Says one thing, then does the opposite
Confusing
If you see these, your context is likely compromised

The tricky part is that these symptoms appear gradually. You don't go from perfect to terrible in one message. It's a slow decline, which makes it easy to miss.

I've started paying attention to the first sign of confusion, not the third or fourth. By the time Claude is clearly struggling, I've wasted a lot of time already.


The /clear Command: Your Best Friend

Here's something that sounds completely counterintuitive:

Nine times out of ten, using /clear is actually better than not using it.

I resisted this for a long time. Clearing the context felt like throwing away work. I'd think: "But I've spent 30 minutes building up this conversation. All that context will be lost."

That's sunk cost fallacy talking.

The truth is, if your context is degraded, that conversation isn't helping you anymore. It's actively hurting you. Every new prompt is being processed by a confused model. You're fighting an uphill battle.

Starting fresh with a clear, focused prompt gets you better results faster than trying to salvage a degraded session.

Claude Code
$/clear
Context cleared. Ready for new conversation.

It's that simple. Two seconds, and you're back to peak performance.

When to Use /clear

Use /clear when:

  • You notice any of the warning signs above
  • You're switching to a completely different task
  • A session has been going for 30+ minutes of complex work
  • Claude keeps misunderstanding despite clear prompts
  • You're about to start an important task that needs peak performance

Don't fight degraded context. Clear it and start fresh.


The Copy-Paste Reset Trick

This is the workflow that changed everything for me. It combines the best of both worlds: the fresh start of /clear with the context preservation you need to keep going.

Degraded SessionQuality dropping
ask Claude
Get SummaryClaude writes it
/clear
Fresh StartPeak performance
The Copy-Paste Reset: Your secret weapon for long projects

Here's the full workflow, step by step:

Step 1: Ask Claude to Summarize Before You Clear

Here's the trick most people miss: don't try to manually copy important details. Ask Claude to write a summary for you.

Claude Code - Getting a Handoff Summary
Before I clear this conversation, please write a concise summary I can paste into a new session. Include: 1) Key decisions we made, 2) Current project state, 3) What I should work on next, 4) Any important file paths or constraints. Format it so I can paste it directly into my next message.
Creating Summary
Project Handoff Summary - Decisions: React + TypeScript frontend, PostgreSQL database, Tailwind CSS, mobile-first design. Constraints: Must work offline, no external APIs, WCAG 2.1 accessibility required. Current State: Header component complete, navigation working, auth flow implemented. Next Task: Build sidebar component with collapsible sections. Key Files: src/components/Header.tsx, src/lib/auth.ts, src/styles/globals.css. Notes: Using Zustand for state management, all API routes under /api/v1/.
Let Claude do the work of capturing context

Copy that summary to your clipboard. Claude just did the hard work of extracting what matters.

Tip

Pro tip: Save these summaries to a file like HANDOFF.md in your project. Then you always have context to resume from, even days later.

Step 2: Clear the Context

Now wipe the slate clean. This is the key step-you're getting back to peak model performance.

Claude Code
$/clear
Context cleared. Ready for new conversation.

Step 3: Start Fresh with Your Summary

Paste the summary Claude wrote into your new session. You now have:

  • A completely fresh context at peak performance
  • All important decisions preserved
  • Zero accumulated confusion
Claude Code - Fresh Session
[Paste Claude's summary here] - Now please continue with the sidebar component. It should have collapsible sections and match our existing Header component styling.
Peak Performance
I understand the full project context. Let me review the Header component to match its patterns, then build the sidebar with collapsible sections...
Starting fresh with perfect context

Why This Works So Well

What You Get from Copy-Paste Reset
Fresh context
Back to peak model performance
Critical
Perfect summary
Claude extracts exactly what matters
Saved time
No manual note-taking required
No lost context
Important decisions survive the reset
The best of both worlds
Key Insight

The key insight: You're not manually copying-you're asking Claude to write its own handoff notes. It knows what's important better than you do, because it's been tracking the whole conversation.


External Memory: Files That Survive Sessions

Here's a mental model shift that took me too long to understand:

Claude is stateless. Every conversation starts from nothing except what you explicitly give it.

The context window isn't persistent memory. It's more like a whiteboard that gets erased between sessions. If you want information to survive, you need to put it somewhere permanent.

That's where external memory files come in.

External Memory Files
SCRATCHPAD.md
Session-by-session progress notes
Essential
plan.md
Current project plan and status
Essential
book
CLAUDE.md
Project context and constraints
Foundation
decisions.md
Key decisions and their reasoning
Optional
Files that persist your progress and decisions

How to Use External Memory

Tell Claude to write to these files as you work:

Claude Code
Before we start, create a SCRATCHPAD.md file. As we work, update it with our progress, decisions, and any important notes. This helps us pick up where we left off.
Creating file
I'll create SCRATCHPAD.md and keep it updated throughout our session. I'll note key decisions, current progress, and anything we'll need to remember later.
Having Claude maintain external memory

When you start a new session, Claude can read these files and understand your project state without you re-explaining everything.

What to Put in Each File

SCRATCHPAD.md - Session notes and progress

## Session: January 11, 2026

### Completed
- Set up project structure
- Created header component
- Connected to database

### In Progress
- Sidebar navigation (started, needs icons)

### Decisions Made
- Using Tailwind instead of CSS modules (faster development)
- User data stored in PostgreSQL, not local storage

### Next Steps
- Finish sidebar
- Add routing
- Build dashboard cards

plan.md - The overall project plan

# Dashboard Project Plan

## Goal
Internal analytics dashboard for the sales team

## Phases
1. Foundation (complete)
2. Core components (in progress)
3. Data integration
4. Testing and polish

## Current Focus
Phase 2: Building sidebar and navigation

These files become your persistent memory. When context degrades, you clear it and start fresh-but your progress is preserved.


Scope Your Conversations

Here's a simple rule that prevents a lot of problems:

One conversation per feature or task. Don't use the same conversation for multiple unrelated things.

BadOne conversation for everything
GoodSeparate conversations per task
Scoped conversations stay focused and clear

When you use the same conversation for different tasks, you're:

  • Filling context with irrelevant information
  • Increasing the chance of confusion
  • Making it harder for Claude to focus
  • Speeding up degradation

I used to start a Claude Code session in the morning and use it all day for different things. That was a mistake. By afternoon, the context was a mess of unrelated tasks, and Claude's quality had tanked.

Now I start fresh conversations for each distinct task. It takes two seconds and makes a noticeable difference in output quality.

When to Start a New Conversation

  • Switching to a different feature or component
  • Moving from planning to implementation
  • Changing from one type of work to another (writing vs. coding vs. analysis)
  • After completing a major milestone

The Input Problem

This is the part nobody wants to hear, but it's true:

Bad input equals bad output. If you're getting bad results with a good model, your prompting needs work.

I spent months thinking Claude was the problem. Then I started looking at my own prompts, and... they weren't great.

Vague Prompt
Make this better
I'd be happy to help improve this. Could you clarify what specifically you'd like me to enhance? Are you looking for better performance, clearer code, improved documentation, or something else?
Vague input leads to vague output
Specific Prompt
Refactor this function to: 1) Handle the null case on line 15, 2) Add error logging for the API call, 3) Make variable names more descriptive. Keep the core logic the same.
Refactoring
I'll refactor the function addressing all three points. Starting with the null handling...
Specific input leads to specific output

Common Input Mistakes

Prompting Mistakes That Lead to Bad Output
Being vague
'Make this better' vs 'Fix the error handling on line 23'
Missing constraints
Not telling Claude what NOT to change
No verification criteria
Not explaining how to check if it worked
Too much at once
Asking for 10 things in one prompt instead of sequencing
No context
Expecting Claude to understand your project from nothing
Check if you're making these errors

Before blaming Claude, check your input:

  • Is your prompt specific enough?
  • Have you given sufficient context?
  • Are your constraints clear?
  • Have you explained what success looks like?

The Planning Connection

Poor planning is one of the fastest ways to bloat and degrade your context.

When you don't plan, you end up:

  • Having long back-and-forth discussions in your main context
  • Making and reversing decisions multiple times
  • Exploring dead ends that eat up context space
  • Confusing Claude with contradictory information
Key Insight

Plan Mode helps prevent context bloat. By separating planning from execution, you keep your implementation context clean and focused. The messy exploration happens in a planning session, and only the clear decisions make it into your execution context.

Here's the workflow that works:

  1. Session 1: Planning - Use Plan Mode to think through the approach. Explore options, make decisions, create a clear plan.

  2. Save the plan - Write it to plan.md or copy the final approved plan.

  3. Session 2: Execution - Start fresh, paste only the final plan, execute with clean context.

This separation keeps your execution context pristine. All the messy exploration and decision-making happened in a different session.

For a deeper dive into planning workflows, see our guide on Plan Mode best practices.


Quick Decision Tree: When to Take Action

When you notice something's off, use this decision tree:

ProblemQuality dropping?
Minor issueRephrase your prompt
ConfusionCopy-paste reset
Major confusionFull /clear + fresh start
Quick reference for context management decisions

Use Rephrase When:

  • Claude misunderstood once but seems otherwise fine
  • You can clarify in one message
  • The session is relatively fresh

Use Copy-Paste Reset When:

  • Claude is showing degradation symptoms
  • You have important context to preserve
  • You want to continue the same task

Use Full /clear When:

  • Claude is clearly struggling
  • You're switching to a different task
  • The conversation is a mess
  • You need peak performance for something important
Tip

When in doubt, /clear. It takes 2 seconds and gives you a fresh start at peak performance. The cost of clearing is almost always lower than the cost of fighting with degraded context.


The Stateless Mental Model

Everything in this guide flows from one fundamental truth:

Claude is stateless.

Every new message is processed based only on what's in the current context window. Claude doesn't remember your session from yesterday. It doesn't remember what you said an hour ago unless it's still in the context. It doesn't have feelings about being cleared.

Your messageCurrent input
+
Context windowWhat Claude 'remembers'
=
Claude's responseBased only on these
Claude's reality: stateless processing

This mental model changes everything:

  1. Don't be sentimental about context. It's not a relationship you're building. It's a working session that degrades over time.

  2. Invest in external memory. If something matters, write it to a file. Context can be cleared; files persist.

  3. Treat each session as fresh. Don't assume Claude remembers. Explicitly provide the context you need.

  4. Quality over continuity. A fresh session with clear context beats a long session with degraded context. Every time.


Summary: The Context Management Checklist

Before every session:

  • Is your CLAUDE.md up to date?
  • Do you have a clear, specific task in mind?
  • Are you starting fresh or continuing with clean context?

During the session:

  • Watch for degradation symptoms
  • Have Claude update external memory files
  • Keep tasks focused-one thing per conversation

When quality drops:

  • Don't fight it-recognize the signs early
  • Use the copy-paste reset workflow
  • Start fresh with curated context

For important tasks:

  • Plan first in a separate session
  • Save the plan externally
  • Execute with fresh, clean context

What to Do Now

Context management isn't complicated once you understand it. Here's how to start applying these techniques:

Today

  1. Try /clear right now. Start a fresh session and notice how responsive Claude is.
  2. Create a SCRATCHPAD.md for your current project.
  3. Pay attention to when quality starts dropping in your sessions.

This Week

  1. Practice the copy-paste reset workflow on a real task.
  2. Start scoping conversations - one task per session.
  3. Review your prompts - are they specific enough?

Ongoing

  1. Build the habit of clearing early and often.
  2. Maintain external memory files for all projects.
  3. Plan before executing for complex tasks.
Context

Keep learning:


Ready to Master Claude Code?

Understanding context management is the difference between fighting Claude and collaborating with it.

The techniques in this guide will immediately improve your results. But reading about them is different from practicing them with guidance.

Join AI Essentials for Business Leaders-our live bootcamp where we go hands-on with context management, prompting techniques, and real project workflows.

You'll leave with:

  • Practical experience managing context effectively
  • Prompting techniques that get consistent results
  • The workflows that separate power users from everyone else
  • Confidence to tackle complex projects without frustration

The gap between people who understand these concepts and everyone else is widening every week.

Reserve Your Spot

Ready to build agents that do the work?

The AI Agents Course: master Claude Code, Claude Cowork, and ChatGPT Codex, and leave with 5+ working agents built on your own work.

  • Self-paced + live builds
  • 5+ working agents
  • 12 months community
SEE THE AI AGENTS COURSE$795 · 100% money-back

Frequently Asked Questions

Why does Claude Code give inconsistent results?

Claude Code's performance degrades as its context window fills up-starting around 20-40% capacity, not at 100%. Long sessions accumulate noise from previous tasks, causing Claude to lose focus on your current work. The solution is proactive context management: clearing sessions regularly and starting fresh.

What is context window degradation?

Context window degradation is the gradual decline in AI output quality as the conversation history grows. As Claude's context fills with previous exchanges, it becomes harder to focus on what matters. Performance starts declining at 20-40% capacity-don't wait until you see warnings.

How do I clear context in Claude Code?

Use /clear to completely clear your context and start fresh. Use /compact to condense your conversation while preserving important context. Get a handoff summary before clearing to capture what Claude has learned, then paste it into your fresh session.

When should I start a new Claude Code session?

Start a new session when switching tasks, after completing a major milestone, when Claude starts giving inconsistent results, or proactively every few hours for long work. One session per task is the ideal pattern.

What is a handoff summary in Claude Code?

A handoff summary is a condensed capture of everything Claude has learned in a session-project context, decisions made, current state, and next steps. Ask Claude to create one before clearing context, then paste it into your fresh session to maintain continuity without the noise.

What is Claude Code context management?

Context management is the practice of actively controlling what's in Claude Code's memory (context window) to maintain peak performance. It includes knowing when to clear sessions, how to preserve important decisions via handoff summaries, and using external memory files like SCRATCHPAD.md. Without proper context management, Claude's output quality degrades silently as conversations grow longer.

BONUS RESOURCE

Finished reading?
Take it with you.

Get a downloadable checklist summarizing the key points from Claude Code Context Management: How to Get Better Results, plus weekly AI tips.

Printable quick-reference guide
Step-by-step action items
Weekly AI insights newsletter

Guide Checklist

PDF + Email Series

No spam. Unsubscribe anytime.