90% Don't Know: The Complete Guide to Claude Code Best Practices Used Internally at Anthropic

@ClaudeCode_love
ЯПОНСКИЙ3 месяца назад · 16 апр. 2026 г.
2.0M
1.2K
110
4
3.2K

Суть

This guide explains how to manage Claude Code's 1-million-token context window using rewind, compact, and subagents to maintain high-quality AI responses during long coding sessions.

Do you have these problems when using Claude Code?

Claude Code Studio - inline image

・When the Claude Code session gets long, the quality of answers drops for some reason.

・What are the commands? I don't really understand the differences.

・I can't decide when to use subagents.

・The context is a total mess.

Right now, a post by Thariq (@trq212), an Anthropic employee, about "Claude Code session management and the 1-million-token context" is going viral with 540,000 views 😳

Claude Code Studio - inline image

So, for everyone having these issues, I'll break down and explain the content in an easy-to-understand way 👇

Original post here: https://x.com/trq212/status/2044548257058328723?s=20

■ Basics of the 𝗰𝗼𝗻𝘁𝗲𝘅𝘁 𝘄𝗶𝗻𝗱𝗼𝘄

First, as a prerequisite, the Claude Code context window is 1 million tokens.

Claude Code Studio - inline image

The context includes all of the following:

・System prompt

・Past conversation history

・All tool calls and their outputs

・Contents of loaded files

In other words, the longer the session, the more information piles up in this context.

■ What is 𝗰𝗼𝗻𝘁𝗲𝘅𝘁 𝗿𝗼𝘁?

Claude Code Studio - inline image

An important concept here is "context rot."

As the context grows, the model's attention is dispersed across many tokens, and old or irrelevant information becomes noise that starts interfering with the current task.

According to Thariq, context rot is observed starting around 300,000 to 400,000 tokens in the 1-million-token model. However, this is not a strict rule as it depends heavily on the task.

Since the context window has a hard cutoff, when you approach the limit, you need to summarize previous work and continue in a new context. This process is called "compaction."

■ Every turn is a "Turning Point"

Claude Code Studio - inline image

What should Claude Code do after finishing one task? This is actually the most important decision point.

Thariq lists five options:

𝟭. 𝗖𝗼𝗻𝘁𝗶𝗻𝘂𝗲

Send the next message in the same session. The most natural choice.

𝟮. /𝗿𝗲𝘄𝗶𝗻𝗱 (Double tap Esc Esc)

Go back to a past message and restart from there. Subsequent messages are deleted from the context.

𝟯. /𝗰𝗹𝗲𝗮𝗿 (New Session)

Summarize important information yourself and start a fresh session.

𝟰. /𝗰𝗼𝗺𝗽𝗮𝗰𝘁

Have the model summarize the conversation so far and continue on top of that summary.

𝟱. 𝗦𝘂𝗯𝗮𝗴𝗲𝗻𝘁𝘀

Delegate the next chunk of work to an agent with its own clean context, returning only the result to the parent session.

■ When to start a new session

Thanks to the 1-million-token context window, long tasks like building a full-stack app from scratch can now be executed more stably.

However, just because there is context space left doesn't mean you should continue the same session.

Thariq's rule of thumb is simple:

Claude Code Studio - inline image

🔥 "If you're starting a new task, you should start a new session."

There are exceptions. For example, writing documentation immediately after implementing a feature. If you start a new session, Claude Code has to re-read the files it just implemented, which is slow and costly. For tasks like documentation that don't require "high intelligence," it's more efficient to accept some context pollution and just continue.

Claude Code Studio - inline image

■ 𝗿𝗲𝘄𝗶𝗻𝗱 is the most underrated feature

Claude Code Studio - inline image

Thariq cites "rewind" as the best habit for good context management.

In Claude Code, you can go back to any past message and restart by double-tapping the Esc key (or using the /rewind command). Messages after that point are completely removed from the context.

Consider a specific scenario:

Claude Code Studio - inline image

Claude read five files and tried an approach that failed.

❌ Normal reaction: "That didn't work. Try X instead."

→ The entire log of the failed approach remains in the context.

✅ Better way: Rewind to just after the files were read and re-instruct with what you learned.

→ "Don't use approach A. The foo module doesn't expose that. Go directly with B."

By doing this, the tokens from the failed trial and error disappear, allowing a retry in a clean state.

Furthermore, using a "summarize from here" feature allows Claude to summarize its own learning and create a "memo from past self to future self."

■ The critical difference between /𝗰𝗼𝗺𝗽𝗮𝗰𝘁 and /𝗰𝗹𝗲𝗮𝗿

Claude Code Studio - inline image

When a session gets long, there are two ways to reduce weight. They seem similar but are completely different.

【/compact】

・The model summarizes the conversation and replaces the history with that summary.

・Lossy — what is important is left to Claude's judgment.

・You don't have to write anything, but Claude might miss something.

・You can provide instructions to guide it (e.g., /compact focus on auth refactor, remove test debugging).

【/clear】

・You write out the important information yourself and start a fresh session.

・Like: "Target is auth middleware, constraints are X, related files are A and B, approach Y is excluded."

・It takes effort, but the resulting context consists only of information you chose.

Choosing between them is a tradeoff between control and convenience.

■ Why 𝗰𝗼𝗺𝗽𝗮𝗰𝘁 fails

Claude Code Studio - inline image

When using long sessions, the quality of compact can become extremely poor.

According to Thariq, the biggest cause of a bad compact is "when the model cannot predict the direction of the work."

Example:

After a long debugging session, autocompact is triggered and summarizes the investigation.

→ If you then say "Fix that warning in bar.ts too," the information about that warning might have been dropped from the debug-focused summary.

Even more troublesome is the dilemma that due to context rot, the model is in its "lowest intelligence state" when executing compact. In other words, the lowest quality summary is generated at the moment when the most accurate summary is needed.

Now that we have a 1-million-token context, the best strategy is to run /compact yourself while you still have room, adding an explanation of what to do next.

■ When to use 𝗦𝘂𝗯𝗮𝗴𝗲𝗻𝘁𝘀

Claude Code Studio - inline image

Subagents are also a form of context management.

When Claude Code creates a subagent with the Agent tool, that subagent has its own clean context window. It does as much work as needed, summarizes the result, and returns it to the parent session.

The criteria is simple:

👀 "Will I need this tool output again later? Or is just the conclusion enough?"

If just the conclusion is enough, you should leave it to a subagent.

Claude Code calls subagents automatically, but giving explicit instructions is also effective:

・"Start a subagent and verify the work results based on this spec file."

・"Use a subagent to read and summarize how the auth flow is implemented in another codebase. Use that as a reference to implement it here."

・"Use a subagent to write documentation for this feature from the git diff."

By not bringing intermediate output into the parent context, you keep the context clean.

■ Summary: 5 Context Management Techniques

Claude Code Studio - inline image

Things you should always decide before sending the next message after Claude finishes a turn:

  1. Did the task change? → /clear for a new session
  2. Did the approach fail? → /rewind to return to just after file loading
  3. Is the session getting long? → /compact while you have room (with direction)
  4. Is it a task with lots of intermediate output? → Delegate to a subagent
  5. Can the context be used for related tasks? → Continue as is

In the future, Claude itself will help with these decisions, but for now, users making these judgments can significantly improve Claude Code's output quality.

Session management is subtle, but it's a skill that fundamentally changes the Claude Code experience 🔥

For those who found this article helpful:

Claude Code Studio - inline image

𝗖𝗹𝗮𝘂𝗱𝗲 𝗖𝗼𝗻𝗱𝗲 𝗦𝘁𝘂𝗱𝗶𝗼 @ 𝗝𝗮𝗽𝗮𝗻 (@ClaudeCode_love) is an account run by three Claude Code enthusiasts.

We post daily about practical CLI usage and automation.

We are currently co-developing an AI agent with a listed company.

Our usual content 👇

・Real product development cases using Claude Code and Claude

・Claude Code usage / Vibe Coding / organizing development trends

・Latest information on Claude Code from overseas

From development philosophy to design, implementation, and improvement, we summarize overseas and primary information to help you release working products, not just "finish making" them.

If you're interested, please follow and check us out! It'll be worth it!

Сохранение в один клик

Используйте YouMind для глубокого чтения вирусных статей с помощью ИИ

Сохраняйте источники, задавайте точные вопросы, обобщайте аргументы и превращайте вирусные статьи в полезные заметки в одном рабочем пространстве ИИ.

Исследовать YouMind
Для авторов

Превратите ваш Markdown в аккуратную статью для 𝕏

Когда вы публикуете длинные тексты, изображения, таблицы и блоки кода, форматирование в 𝕏 становится мучением. YouMind превращает полный черновик в Markdown в чистую статью, готовую к публикации в 𝕏.

Попробовать Markdown для 𝕏

Другие паттерны для анализа

Недавние виральные статьи

Смотреть другие виральные статьи