Claude コードのトークン使用量を減らすための実用的な 7 つの方法
この記事は、Claude Code のトークン使用量を削減しコストを最適化するための具体的な 7 つの実践的戦略と、コンテキスト管理の重要性について解説している。
キーポイント
タスク複雑度に応じたモデル切り替え
Opus、Sonnet、Haiku のコスト差を考慮し、単純な編集には Sonnet や Haiku を使い、複雑なアーキテクチャ判断のみ Opus を使用する戦略が推奨される。
CLAUDE.md の最適化
プロジェクトルールや設定を CLAUDE.md に記述することで、各チャットで重複して入力するトークンを削減し、セッション全体で一貫したコンテキストを提供できる。
不要なコンテキストの排除
過去のメッセージ履歴や不要なファイル参照がトークン消費を急増させるため、会話の短縮と関連性の高い情報のみを選択的に提供することが重要である。
サブエージェントの適切な活用
単純なタスクではオーバーヘッドが大きい可能性があるため、メインコンテキストの整理によるメリットが起動コストを上回る場合のみ使用すべきです。
具体的なファイルと行範囲の指定
曖昧な指示ではなく、特定のファイル名と行番号を明示的に指定することで、不要な探索や文脈再構築にかかるトークンを節約できます。
高コスト操作前にプランモードを活用する
Shift+Tab でプランモードに切り替え、実行前にステップごとの計画を確認・修正することで、試行錯誤によるトークン浪費を防ぐ。
/compact は反応的ではなく能動的に使用すべき
セッションが重くなるのを待たず、重要な情報が明確になった時点で早期に実行し、不要なノイズを除去して軽量化する。
影響分析・編集コメントを表示
影響分析
この記事は、LLM コスト管理において「プロンプトエンジニアリング」だけでなく「コンテキスト・マネジメント」が重要であることを示唆しており、開発現場における運用コスト削減の具体的な指針となる。特に大規模プロジェクトや長期間にわたるコーディング支援において、トークン使用量を抑制する実用的なアプローチを提供するため、即座に適用可能な価値が高い。
編集コメント
コスト意識の高い開発者にとって、トークン使用量を可視化・最適化する具体的な手法が示されており、実務即戦力となる内容です。

# イントロダクション
Claude Code は非常に有用ですが、人々が予想するよりもはるかに早く高額になる可能性があります。その理由は単純です。あなたがただ入力したプロンプトに対してのみ支払っているわけではないからです。多くの場合、Claude はセッションの残りの部分(以前のメッセージ、既に読み込んだファイル、ツール出力、CLAUDE.md などのメモリファイル、その他の背景指示など)も一緒に保持しています。そのため、トークン使用量が上昇し始めたら、実際の問題は通常プロンプトの書き方が悪いことではなく、文脈が整理されていないことにあります。
このトピックに関する一般的なアドバイスはそれほど役立ちません。「会話を短く保つ」のは正しいですが、実際に効果を生む具体的な方法までは示していません。本当に役立つのは、Claude Code がどのように文脈を構築するか、何が繰り返し送信されているか、そしてワークフローのどの部分が時間をかけて静かに無駄を増やしているかを理解することです。この記事では、コストを常に気にすることなく Claude Code を効率的に使用するための7 つの実践的な方法を見ていきます。それでは始めましょう。
# 1. タスクの複雑さに応じてモデルを切り替える
これはシンプルですが、非常に過小評価されています。すべてのタスクで最も高価な設定が必要とは限りません。API の請求体系では、Opus はトークンあたり Sonnet よりも 5 倍高いコストがかかります。サブスクリプションプランでは、重いモデルはクォータのウィンドウをより速く消費します。
/model sonnet # 日常業務:テスト作成、簡単な編集、
# コードの説明、リファクタリング
/model opus # 複雑なタスク:複数ファイルにわたるアーキテクチャ判断、
# 厄介なクロスシステム問題のデバッグ
/model haiku # クイック対応:参照、フォーマット変更、名前変更、
# その他反復作業
セッションは常に Sonnet で開始してください。本当に深い分析や複雑なリファクタリングが必要になった場合のみ Opus に切り替えてください。機械的な作業には Haiku を使いましょう。また、/effort コマンドで直接処理レベルを制御することもできます。単純なタスクでは、処理レベルを下げることでモデルが割り当てる思考予算(thinking budget)が減り、結果として出力トークンを節約できます。
# 2. CLAUDE.md を小さく有用に保つ
**
トークンを節約する最良の方法の一つは、すべてのチャットで同じプロジェクトルールを繰り返し入力しないことです。それがまさに CLAUDE.md の役割です。これは Claude がコードを読み始める前、タスクを読み始める前、そして何よりも先に読み込まれます。セッション全体を通じてコンテキストウィンドウに保持され、遅延読み込みや退去(eviction)は行われません。つまり、5,000 トークンの CLAUDE.md は、2 通のメッセージを送っても 200 通送っても、すべてのターンで 5,000 トークン分のコストがかかります。** そこで、安定した指示をここに記述しましょう:テストの実行方法、使用するパッケージマネージャー、フォーマットルール、重要なアーキテクチャ制約、Claude が触れてはならないディレクトリなどです。これにより、セッション間でのプロンプトの重複オーバーヘッドを削減できます。
もう一つの重要な点は、軽量に保つことです。会議の議事録や設計履歴、あるいは長い実装ガイドをそのまま貼り付けるのは避けてください。CLAUDE.md が巨大な脳内情報の羅列ではなく、参照テーブルのように機能したときに、最も良い結果が得られます。
# 3. 冗長な作業をサブエージェントに委譲する
これは文脈の増え方そのものを変えるため、非常に実用的なヒントの一つです。サブエージェントは、独自のコンテキストウィンドウで動作する孤立した Claude インスタンスです。サブエージェントが実行されると、ファイル検索やログダンプ、多段階推論など、すべての冗長な出力はその孤立した環境内に留まります。戻ってくるのは要約のみであり、これによりメインのスレッドを非常にクリーンに保つことができます。しかし、ここで多くの一般的なアドバイスが誤りを犯します。サブエージェントは自動的にコスト削減になるわけではありません。コミュニティによるテストでは、小規模なタスク、特に単純なシェル操作や迅速な git 操作においては、アーキテクチャ自体がプロンプト、ツール定義、追加のツール呼び出しラウンドトリップを通じてオーバーヘッドを追加するため、サブエージェントは非効率であることが示されています。したがって、実用的なルールは「何でもかんでもサブエージェントを使う」ことではなく、「メインコンテキストの雑多さを減らすことで得られるメリットが、起動時のオーバーヘッドを上回る場合にのみサブエージェントを使用する」というものです。
# 4. Claude に正確なファイルと行範囲を指定する
**
トークンを浪費する最も迅速な方法の一つは、問題が実際には 1 つまたは 2 つのファイルに存在しているにもかかわらず、Claude に「リポジトリ全体を調べて」と指示することです。タスクが曖昧であればあるほど、Claude は複数のファイルを開き、行き止まりを探検し、直接提供できたはずの文脈を再構築するためにトークンを消費する可能性が高まります。以下に例を示します。
元の指示:
"認証コードを確認して、何が間違っているか教えて。"
より良い指示:
"src/auth/session.ts の 30 行目から 90 行目を、src/api/login.ts の 10 行目から 60 行目と比較し、不一致の理由を説明してください。"
最初の例は自然に聞こえますが、しばしば高価な探索処理を引き起こします。
もう一つのヒントは、高コストな操作を行う前にプランモード(Plan Mode)を使用することです。Shift+Tab キーで切り替えることができます。プランモードでは、Claude は一切変更を加えずにステップバイステップの計画を出力します。その計画を確認し、不要な部分を削除してから通常モードに戻ります。これにより、トークン浪費の最大の原因である試行錯誤の実行(Claude が何かを試してエラーに遭遇し、各反復でトークンを消費しながら繰り返すプロセス)を排除できます。
# 5. /compact を反応的ではなく能動的に使用する
**
Claude はセッションを自動的に圧縮することもできますが、ユーザー自身で /compact コマンドを実行することも可能です。しかし、タイミングは人々が考える以上に重要です。
Claude が複数のファイルを点検し、コマンドを実行し、いくつかの誤った方向を探った頃には、セッションにはもはや重要ではない情報が大量に含まれていることが一般的です。それがコンパクト(圧縮)を行うべき適切なタイミングです。次のステップに余分なコンテキストを持ち込むのではなく、重要な部分が明確になった時点で会話を小さくし、はるかに軽量なセッションで続行します。
よくある間違いは、/compact コマンドを遅すぎたタイミングで使用することです。多くの開発者は、Claude が何かを忘れ始めたり、コンテキストの警告を表示したりするまで待ちます。その時点では、セッションはすでに過負荷状態にあり、要約もそれほど清潔で有用なものではありません。 早期に、つまりセッションがまだ「健全」なうちにコンパクトを行えば、要約ははるかに良くなります。重要な情報を保持し、ノイズを排除し、不必要なトークンをすべての将来のステップに引きずり込むのを防げます。
# 6. 最適化前に /context を確認する
**
最も過小評価されているアイデアの一つは、単に何がコンテキストを消費しているかを確認することです。多くのトークンの無駄は謎めいて感じられますが、高価な部分が目に見えるプロンプトではないことを思い出せば理解できます。それは以前 Claude が読んだ大きなファイル、蓄積されたツール出力、重いメモリファイル、あるいは追加のツールによるオーバーヘッドである可能性があります。
/context コマンドは診断ツールです。ワークフロー全体を変更する前に、実際に読み込まれているものや繰り返し再送信されているものを確認してください。多くの場合、最大の改善点はプロンプトをより良くすることではなく、すべてのターンに潜んでいて重さの原因となっている「静かなる犯人」を見つけることから生まれます。これが、盲目的な最適化を行わない方が良い理由です。まず、コンテキスト内に何があるかを確認し、実際に肥大化の原因となっている部分を削除または削減してください。
# 7. ツールセットアップをシンプルに保つ
Claude Code は多くの外部ツールやデータソースに接続できますが、これは強力である一方で、これらのツールが機能し始めると、より多くの接続されたツールはコンテキストのオーバーヘッドを増大させる可能性があります。あまりにも多くのツールやヘルパーが関与すると、モデルがタスクに必要な以上にオーバーヘッドを引きずることになります。セットアップを軽量に保ちましょう。実際の繰り返し問題を解決する統合を使用してください。単に可能だからといって、利用可能なすべてのスキルを Claude Code に読み込ませることは避けてください。
# 結びの言葉
Claude Code のトークン使用量を減らす最善の方法は、すべてのプロンプトを細かく監視することではありません。Claude が本当に必要とするものだけを認識するようにワークフローを設計することです。最大の成果は、自動コンテキストの制御、検索範囲の絞り込み、そしてノイズの多いサイドタスクがメインセッションを汚染するのを防ぐことから得られます。
プロンプトについてだけ考えるのをやめ、コンテキストアーキテクチャについて考え始めてください。
Kanwal Mehreen は、機械学習エンジニアであり技術ライターです。データサイエンスと AI と医療の交差点に対する深い情熱を持っています。彼女は「ChatGPT で生産性を最大化する」という電子書籍の共著者でもあります。APAC 地域の Google Generation Scholar 2022 に選出され、多様性と学術的卓越性を提唱しています。また、Teradata Diversity in Tech Scholar、Mitacs Globalink Research Scholar、Harvard WeCode Scholar としても認められています。Kanwal は変革の熱心な支持者であり、STEM 分野における女性のエンパワーメントを目的とした FEMCodes を設立しました。
原文を表示

# Introduction
**
Claude Code is really useful, but it can also get expensive much faster than people expect. The reason is simple. You are not only paying for the prompt you just typed.** In many cases, Claude is also carrying the rest of the session with it like earlier messages, files it already read, tool outputs, memory files like CLAUDE.md, and other background instructions. So when token use starts climbing, the real issue is usually not bad prompting. It is messy context.
A lot of generic advice on this topic is not that helpful. "Keep conversations short" is true, but it does not tell you what actually moves the needle. What actually helps is understanding how Claude Code builds context, what keeps getting resent, and which parts of your workflow quietly add waste over time. In this article, we will look at 7 practical ways that will help you to use Claude Code efficiently without constantly worrying about cost. So, let's get started.
# 1. Switching Models by Task Complexity
**
This one is simple but massively under-used. Not every task needs your most expensive setup. On API billing, Opus costs 5x more than Sonnet per token**. On subscription plans, heavier models drain your quota window faster.
/model sonnet # Day-to-day: writing tests, simple edits,
# explaining code, refactoring
/model opus # Complex: multi-file architecture decisions,
# debugging gnarly cross-system issues
/model haiku # Quick: lookups, formatting, renaming,
# anything repetitiveStart every session on Sonnet. Only switch to Opus when you genuinely need deep analysis or complex refactoring. Drop to Haiku for the mechanical stuff. You can also control effort level directly with /effort. For straightforward tasks, lowering the effort level reduces the thinking budget the model allocates, which directly saves output tokens.
# 2. Keeping CLAUDE.md Small and Useful
**
One of the best ways to save tokens is to stop retyping the same project rules in every chat. That is exactly what CLAUDE.md is for. It loads before Claude reads your code, before it reads your task, before anything. It persists in the context window for the entire session and is never lazy-loaded or evicted. This means a 5,000-token CLAUDE.md costs 5,000 tokens on every single turn, whether you send 2 messages or 200.** So, put your stable instructions there: how to run tests, which package manager to use, your formatting rules, important architectural constraints, and the directories Claude should avoid touching. This cuts repeated prompt overhead across sessions.
Another important part is to keep it lean. Do not paste meeting notes, design history, or long implementation guides into it. You will get the best results when CLAUDE.md works more like a lookup table than a giant brain dump.
# 3. Delegating Verbose Work to Subagents
**
This is one of the most genuinely helpful tips because it changes how context grows. Subagents are isolated Claude instances that run in their own context window. When a subagent runs, all its verbose output — file searches, log dumps, multi-step reasoning — stays isolated. Only the summary returns to your main conversation. This can keep your main thread much cleaner. But this is also where a lot of generic advice goes wrong. Subagents are not automatically cheaper.** Community testing shows that for small tasks, especially simple shell actions or quick git operations, a subagent can be wasteful because the architecture itself adds overhead through prompts, tool definitions, and extra tool-call round trips. So the practical rule is not "use subagents for everything." It is "use subagents when the saved main-context clutter is worth more than the startup overhead."
# 4. Pointing Claude to Exact Files and Line Ranges
**
One of the fastest ways to waste tokens is to ask Claude to "look around the repo" when the issue really lives in one or two files. The more vague the task, the more likely Claude is to spend tokens opening several files, exploring dead ends, and reconstructing context you could have handed it directly. Here is an example.
Original:
"Look through the auth code and tell me what is wrong."
Better:
"Compare src/auth/session.ts lines 30 to 90 with src/api/login.ts lines 10 to 60 and explain the mismatch."
The first one sounds natural, but it often triggers expensive exploration.
Another tip is to use plan mode before expensive operations**. Toggle it with Shift+Tab. In plan mode, Claude outputs a step-by-step plan without making any changes. You review the plan, cut anything unnecessary, then switch back to normal mode. This eliminates the biggest source of token waste: trial-and-error execution, where Claude tries things, hits errors, and iterates — with each iteration costing tokens.
# 5. Using /compact Proactively (Not Reactively)
**
Claude can compact your session automatically, and you can also run /compact yourself. But timing matters more than people think.
By the time Claude has inspected multiple files, run commands, and explored a few false leads, your session usually contains a lot of material that no longer matters. That is the right moment to compact. Instead of carrying all that extra context into the next step, you shrink the conversation once the important parts are clear, and then continue with a much lighter session.
A common mistake is using /compact too late. Many developers wait until Claude starts forgetting things or shows a context warning.** At that point, the session is already overloaded, and the summary is not as clean or useful. If you compact earlier, while the session is still "healthy," the summary is much better. You keep the key information, drop the noise, and avoid dragging unnecessary tokens into every future step.
# 6. Checking /context Before Optimizing
**
One of the most underrated ideas is simply looking at what is consuming context. A lot of token waste feels mysterious until you remember that the expensive part may not be the visible prompt. It may be a big file Claude read earlier, accumulated tool output, a heavy memory file, or the overhead of extra tooling.
The /context command is your diagnostic tool. Before changing your whole workflow, look at what is actually being loaded or repeatedly re-sent. In many cases, the biggest improvement does not come from better prompting. It comes from spotting one "quiet offender" that has been riding along in every turn. This is why it is better not to optimize blindly. First, inspect what is in your context. Then remove or reduce the parts that are actually causing the bloat.**
# 7. Keeping Your Tooling Setup Simple
**
Claude Code** can connect to many external tools and data sources, which is powerful — but more connected tooling can also mean more context overhead once those tools come into play. If too many tools or helpers are involved, the model can end up dragging around more overhead than the task really needs. Keep your setup lean. Use integrations that solve a real repeated problem. Do not load up Claude Code with every available skill just because you can.
# Final Thoughts
**
The best way to reduce Claude Code token usage is not to babysit every prompt. It is to design your workflow so Claude only sees what it genuinely needs. The biggest wins come from controlling automatic context, narrowing search scope, and preventing noisy side work from contaminating the main session.
Stop thinking only about prompts and start thinking about context architecture.**
Kanwal Mehreen is a machine learning engineer and a technical writer with a profound passion for data science and the intersection of AI with medicine. She co-authored the ebook "Maximizing Productivity with ChatGPT". As a Google Generation Scholar 2022 for APAC, she champions diversity and academic excellence. She's also recognized as a Teradata Diversity in Tech Scholar, Mitacs Globalink Research Scholar, and Harvard WeCode Scholar. Kanwal is an ardent advocate for change, having founded FEMCodes to empower women in STEM fields.
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み