ポッドキャストに戻るClaude
Claude Code 101
Claude Code のコンテキスト管理
is Claw's working memory.
は Claude のワーキングメモリです。
Every file it reads, every command it runs, every message you send, it all takes up space in the context window.
Claude が読み込むすべてのファイル、実行するすべてのコマンド、あなたが送るすべてのメッセージが、context window のスペースを占有します。
Think of the context window as the amount of space that Claude could hold in his memory.
context window とは、Claude がメモリに保持できるスペースの量と考えてください。
Whenever you enter a prompt, Claude reads a file, runs a tool call, gets a tool call result.
プロンプトを入力するたびに、Claude はファイルを読み込み、ツール呼び出しを実行し、ツール呼び出しの結果を取得します。
This is added on to the context window.
これらはすべて context window に追加されます。
And since there's only a finite amount you can put in the context window, it becomes extremely important to optimize this as much as possible.
context window に格納できる量は有限であるため、これを可能な限り最適化することが非常に重要になります。
Now, when you approach this limit, the context window is automatically compacted.
この上限に近づくと、context window は自動的に compact されます。
Compaction will summarize important details and remove the unnecessary tool call results and free up a lot of space in your context window.
Compact では重要な詳細を要約し、不要なツール呼び出しの結果を削除して、context window の多くのスペースを解放します。
Do note though that this could potentially lose details in your previous conversation.
ただし、これにより以前の会話の詳細が失われる可能性があることに注意してください。
You can run the compaction manually as well with the /compact command.
/compact コマンドで手動で compact を実行することもできます。
This will compact everything that you've done up to that point, which could be handy if you want to clear up context space, but also have a memory of what you previously worked on.
これにより、これまでに行ったすべてのことが compact されます。context のスペースを確保しながら、以前の作業の記憶も保持したい場合に便利です。
If you want to completely start from scratch without memory of what was previously worked on, you can also run /cle and that will remove everything starting from scratch.
以前の作業の記憶を持たずに完全にゼロから始めたい場合は、/clear を実行することもできます。これですべてが削除され、ゼロから始まります。
To check the state of your context, run the /context command.
context の状態を確認するには、/context コマンドを実行してください。
Here you'll get a big picture of how large your context size is, the different categories that are taking up the most context, and a graphic showing you all of this.
ここでは、context のサイズの全体像、最も多くの context を占有しているさまざまなカテゴリ、そしてこれらすべてを示すグラフィックを確認できます。
A general rule of thumb is when you're working on a specific feature and are going over the context window, but need to continue, then compact.
一般的な目安として、特定の機能に取り組んでいて context window を超えそうになっているが続ける必要がある場合は、compact を使用してください。
Keeping the context relevant for this feature is important when continuing development.
開発を継続する際には、この機能に関連した context を保持することが重要です。
If you have finished the plan and want to start on a new feature, then clear.
計画が完了して新しい機能を始めたい場合は、clear を使用してください。
You don't want the previous conversation to present bias in anything new that you want to create.
以前の会話が、新しく作成したいものに偏りをもたらしてほしくありません。
For things that you do want Claude to remember in other sessions, put it in the claw.md file.
他のセッションでも Claude に覚えておいてほしいことは、claude.md ファイルに記述してください。
That way, it doesn't have to rediscover things from scratch all over again.
そうすれば、毎回ゼロから再発見する必要がなくなります。
Be specific.
具体的に指定してください。
The irony behind writing a smaller prompt is that it in the long run, it will take up more context.
短いプロンプトを書くことの皮肉は、長期的に見るとより多くの context を消費するということです。
Without being explicit, Claude is forced to look around your codebase more and do its own thinking, which takes up a lot more context.
明示的に指定しないと、Claude はコードベースをあちこち調べて自分で考えざるを得なくなり、それによってより多くの context が消費されます。
window space than if you were just a little bit more clear with a sentence or two.
1、2 文で明確にした場合よりも多くのウィンドウスペースを占有します。
MCP servers load all of the tools available into context by default.
MCP サーバーはデフォルトで利用可能なすべてのツールを context に読み込みます。
So, if you have a lot of MCP servers for things that are unrelated to the project, it might be worth turning them off.
そのため、プロジェクトとは無関係な MCP サーバーが多数ある場合は、それらをオフにする価値があるかもしれません。
You can also try out skills, which works similarly to MCP servers, but doesn't put the entire thing into context, saving you space.
MCP サーバーと同様に機能しますが、すべてのコンテンツを context に読み込まないため、スペースを節約できる skills も試してみてください。
Sub agents run in parallel with your main agent but has a complete separate context window.
Sub agents はメインのエージェントと並行して実行されますが、完全に独立した context window を持っています。
So for tasks that require an answer without the journey like where is the authentication endpoints located, you can have the sub agent do the work and return just a summary to your main agent.
そのため、認証エンドポイントはどこにあるかなど、過程ではなく答えだけが必要なタスクの場合、sub agent に作業させてメインのエージェントには要約だけを返すことができます。
Managing context within cloud code is crucial.
Claude Code 内での context の管理は非常に重要です。
Use slash compact to summarize long sessions and slashclear to start fresh.
/compact を使用して長いセッションを要約し、/clear を使用して新たにゼロから始めましょう。
To use your context window effectively, be specific with what you want.
context window を効果的に使用するには、求めるものを具体的に指定してください。
Check what's using your current context window and use sub agents to delegate tasks you only need the answer for.
現在の context window を何が使用しているかを確認し、答えだけが必要なタスクには sub agents に委任してください。