This series will teach you the session management framework that Anthropics Claude Code team uses internally.
You used Claude Code . It worked perfectly for the first 20 minutes. Then things changed. Claude started forgetting what you told it to do. It repeated methods you had rejected. It conjured up a function that didn't exist in your codebase.
It's a phenomenon of "losing context"—and that's the biggest frustration for Claude Code users. Not because the model is bad, but because most people never learn how to manage their sessions.
This series will teach you the session management framework that Anthropic's Claude Code team uses internally. Based on the official guide by Thariq Shihipar (over 3400 likes on X) and refined with community-proven techniques, you'll learn 5 steps to keep your context clean, sessions efficient, and Claude sharp from the first prompt to the last.
What you will learn
- Explain the phenomenon of context degradation and why Claude Code's performance declines during long sessions.
- Apply the 5-step decision framework (Continue, Rewind, Clear, Compact, Subagent) after each iteration.
- Use /rewind instead of correction to keep the context clean and focused.
- Compare /compact with /clear and choose the appropriate strategy for each situation.
- Design a subagent workflow to isolate context for research, experimentation, and documentation.
- Develop a personal session management strategy using CLAUDE.md rules, logging, and proactive collapsing.
After this course, you will be able to
- Running Claude Code sessions for 2 hours and remaining sharp from start to finish - no more instances of AI confusion at the 45-minute mark.
- Use rewind, compact, and subagent intuitively – choose the right step in under 5 seconds.
- Session architecture design for complex projects - parallel sessions, context isolation, structured handovers
- Configure the CLAUDE.md rules so that Claude automatically manages its own context without manual intervention.
- Add "Claude Code mastery" to your development toolkit—a skill that is clearly demonstrated in code review speed and product deployment speed.
What you will build
Session Decision Handbook
A personalized reference card maps your common work scenarios to the optimal session operation—Continue, Rewind, Compact, Clear, or Subagent.
CLAUDE.md Session Configuration
A CLAUDE.md configuration ready for a production environment with context rules, compression policies, and session management automation tailored to your actual codebase.
Mastering the Claude Code session
Demonstrate your ability to manage Claude Code sessions, prevent contextual errors, and design multi-session workflows.
Prerequisites
- Basic experience with Claude Code (you've used it for at least a few sessions)
- Familiar with terminal commands (cd, ls, basic navigation)
Suitable candidates
- Developers use Claude Code but find sessions become chaotic or unreliable after more than 30 minutes.
- Experienced users want to understand why Claude's quality deteriorates and how to prevent it.
- The team leader is standardizing Claude Code's workflow across engineering teams.
- Anyone who encounters a 'contextual error' and wants an official solution from the Anthropic manual.
Why is your programming session failing (and how to fix it)?
Understanding contextual errors – why Claude Code has gotten worse over time – and previewing a 5-step framework to fix this problem.
The moment Claude Code stopped supporting it.
You spent 40 minutes in a programming session. Claude built the validation module perfectly. You asked him to write tests for that module. And he. wrote tests for a completely different function. A function that doesn't exist in your codebase.
You correct the error. It apologizes and tries again. It fails again. You correct it more forcefully. It starts repeating its previous responses exactly. Something has changed—and you can sense it, even if you can't name it. That's called: contextual error.
In this lesson, you will:
- Understanding what "contextual degeneration" actually is (and isn't).
- See why the 1 million token window doesn't solve the problem.
- Preview the 5-step framework you'll master in this course.
This course teaches you session management techniques used by Anthropic's Claude Code team. It's not theory – it's practical steps you can apply in your next work session.
Explain your context window.
Claude Code's context window is 1 million tokens. That's all the model can "see" at the moment when generating the next response:
- System prompt and CLAUDE.md file
- The entire conversation so far.
- Every tool call that Claude made and its output.
- All the files that Claude has read
Imagine it like a table. A million tokens is a huge table – enough room for hundreds of files, thousands of messages. But even a huge table can become cluttered.
The problem is that when your desk is covered in papers, it becomes harder to find the document you need. The model doesn't crash. It doesn't report errors. It just becomes. less sharp. Less accurate. More prone to missing details or making things up.
✅ Quick check : Which four things take up space in the Claude Code context window?
Answer : System prompt/CLAUDE.md, conversation history, output of tool call commands, and file contents.
Contextual degradation is real – and it's not a bug.
Studies on advanced models show that performance begins to degrade long before you reach the context limit. Some benchmarks show accuracy dropping at just 25% of the window. The practical threshold that most professional users have agreed upon: beyond 50-60% of the context, quality begins to decline.
This isn't just Claude's problem. It's how attention-driven models work. The more tokens compete for attention, the less focus each individual token receives. Old, irrelevant context—a debugging session from an hour ago, file read operations you no longer need—doesn't just sit there passively. It actively distracts the model.
Thariq Shihipar, a member of Anthropic's Claude Code team, stated frankly in his recent article: Contextual degradation is "observed as model performance decreases as context increases because attention is spread across more tokens, and old, irrelevant content begins to distract from the current task."
5-Step Framework (Preview)
Most people treat Claude Code like a chat window – they just keep typing. But after each response from Claude, you actually have five options:
- Continue — send another message (everything remains in context)
- Rewind — return to the previous point, ignoring everything that happened afterward.
- /clear — starts a completely new session
- /compact — to allow Claude to summarize the session, replacing the history with a summary.
- Subagent — assigning tasks to a separate agent with its own clean context.
Each action has a different impact on your context. The skill lies in knowing which action to choose – and that's what the next 7 lessons will teach you.
✅ Quick Check : If you've been debugging for 30 minutes and want to move on to a completely new task, which operation gives you the cleanest start?
Answer : /clear - it clears the context so you start over.
Why wouldn't 1 million tokens solve this problem?
When Claude Code scaled up to 1 million contexts, many people argued that session management was no longer important. More space = less cleanup. Right?
Wrong. A larger workbench means more room for clutter. The model still has to process every token in the window in each turn. And research shows that even with 1 million tokens, performance still drops at the same percentage – it just takes longer to reach that level.
The 1 million token window is a safety margin, not a license to dump everything into it. The best Claude Code users treat it as working memory that needs constant management – not an endless storage.
Key points to remember
- Contextual degradation is real: The quality of Claude Code gradually decreases as your gaming session lasts, even with 1 million tokens.
- The degradation begins when using about 50-60% of the context – long before the window is full.
- You have 5 moves after each turn, it's not just a matter of "keep typing".
- Session management is the number one skill that distinguishes frustrated users from skilled users.
- This course teaches the working framework that the Anthropic team uses.
Try this now: Self-check context state
Open Claude Code (or any Claude session in the terminal) and paste this prompt into the current session. It tells you if your current context is clean or experiencing problems – without having to restart.
Hãy đóng vai trò là người kiểm tra trạng thái phiên Claude Code của tôi. Tôi sẽ dừng điều khiển và để bạn kiểm tra phiên hiện tại. Hãy cho tôi biết liệu chúng ta có nên tiếp tục, tua lại, nén, xóa hay tạo một subagent hay không. Trong thông điệp này, hãy phân tích: 1. Điểm đánh giá chất lượng ngữ cảnh (1–5) - 5 = rõ ràng, mọi thông điệp đều được truyền đạt - 3 = có một số thông tin thừa nhưng vẫn sử dụng được - 1 = gây hiểu nhầm — các quyết định cũ mâu thuẫn với các quyết định hiện tại 2. 5 thành phần hữu ích nhất trong phiên hiện tại (đường dẫn file đã truy cập, quyết định đã đưa ra, mẫu mã đã hội tụ, ràng buộc đã được chấp nhận) 3. 5 thành phần không cần thiết nhất (khám phá bị bỏ dở, chỉnh sửa bị hoàn tác, đầu ra công cụ dài không còn liên quan, lạc đề) 4. Mâu thuẫn - Liệt kê bất kỳ nơi nào chúng ta nói một điều trước đó và điều ngược lại sau đó - Đánh dấu nơi tôi thực sự muốn giữ lại 5. Đề xuất bước tiếp theo kèm lý do: - Tiếp tục: phiên làm việc ổn định, hãy tiếp tục - Quay lại: nêu rõ lượt quay lại cụ thể - /compact: những gì một thao tác nén tốt sẽ bảo toàn; những gì nó sẽ bỏ qua - /clear: chỉ khi nhiệm vụ còn lại khác biệt về cơ bản so với những gì đã được thực hiện - Subagent: chỉ dành cho một cuộc điều tra độc lập hoặc sử dụng công cụ nặng nề có thể làm rối loạn ngữ cảnh chính 6. Nếu bạn đề xuất /compact, hãy soạn thảo ghi chú bàn giao mà tôi sẽ lưu vào .claude/notes/ TRƯỚC KHI nén, để những điều cần thiết vẫn còn ngay cả khi quá trình nén làm mất chi tiết: - Nhiệm vụ tôi đang làm (một câu) - Các file đã được sử dụng + lý do - Các quyết định quan trọng đã được chốt (kèm lý do) - Các câu hỏi chưa được giải quyết - Bước tiếp theo duy nhất 7. Nếu bạn đề xuất một subagent, hãy soạn thảo prompt subagent chính xác — độc lập, với các đường dẫn file và ràng buộc cụ thể mà subagent cần để nó không lấy ngữ cảnh từ phiên chính QUY TẮC BỀN VỮNG: - Không bao giờ đề xuất "cứ tiếp tục" nếu điểm sức khỏe ngữ cảnh là 2 hoặc thấp hơn - Không bao giờ đề xuất /compact nếu phiên chứa các quyết định chưa được cam kết có tải — nên lưu ghi chú bàn giao trước - Không bao giờ đề xuất /clear trong khi Có những công việc chưa được cam kết mà bộ nhớ của mô hình là bản ghi duy nhất — hãy bảo tôi cam kết và lưu ghi chú trước - Nếu phiên làm việc có liên quan đến các thao tác phá hủy (rm -rf, DROP TABLE, git reset --hard, force push) và kết quả của chúng chưa được xác nhận, hãy gắn cờ điều đó TRƯỚC KHI đề xuất bất kỳ hành động dọn dẹp nào - Nếu phiên làm việc vượt qua ranh giới tin cậy (ví dụ: dán mã NDA của khách hàng, tác động đến môi trường sản xuất, sử dụng thông tin đăng nhập), hãy đề xuất lưu bằng chứng và ghi chú trước khi dọn dẹp - Nếu tôi đang ở trên kho lưu trữ nhóm, hãy nhắc tôi rằng việc dọn dẹp phiên làm việc là RỦI RO CỦA TÔI — đồng nghiệp của tôi không thể thấy những gì trong cửa sổ ngữ cảnh - Không bao giờ đề xuất sử dụng subagent cho công việc chỉ yêu cầu kiến thức trong ngữ cảnh cha — subagent sẽ ảo tưởng về nó
What you will see : Contextual health scores from 1–5, top artifacts + burdens, conflict lists, clear next-step suggestions, and (if compressing or creating a subagent) accurate transfer notes or prompt subagent prompts – so that cleaning up the session becomes a purposeful action rather than a surprise.
-
Question 1:
After Claude has finished replying, how many session management options do you have?
EXPLAIN:
You have five different operations: Continue, Rewind, /clear, /compact, or create a subagent (delegate to a separate context). Most people only use Continue.
-
Question 2:
Claude Code has a context window of 1 million tokens. What does this mean in practice?
EXPLAIN:
The context window contains everything Claude processes for each response—your system prompt, conversation history, file contents, and tool output. A larger window means more space, but filling it completely will cause a loss of context.
-
Question 3:
What is the phenomenon of "contextual errors" in Claude Code?
EXPLAIN:
Contextual error is the phenomenon where a model's performance decreases as the context increases—attention is scattered across more tokens, and older content distracts from the current task. This isn't an error; it's a fundamental property of how attention-driven models work.
Training results
You have completed 0 questions.
-- / --
You've just finished reading the article "Mastering the Claude Code session" edited by the TipsMake team. We hope this article has provided you with many useful tech tips and tricks. You can search for similar articles on tips and guides. Thank you for reading and for following us regularly.