Claude Code 101 | Lesson 08「CLAUDE.md ファイル(The CLAUDE.md file)」
出典: Anthropic Academy / YouTube動画ID O0FGCxkHM-U / 2026-07-04
日本語ナレッジ(要点整理)
- CLAUDE.md は Claude Code の最重要機能の一つ。プロジェクトに関する永続的な記憶(persistent memory)を Claude Code に与える。
- 解決する問題:CLAUDE.md がないと Claude は毎回ゼロから始まる——コードベースを再探索し、必要な依存を推測し、既存の実装を把握し直す。時に誤った前提を置き、軌道修正が難しくなる。
- 仕組み:プロジェクトのルートに置く Markdown ファイル。セッション開始のたびに自動で読まれる。コードベースの「オンボーディングスクリプト」。内容はあなたのプロンプトに追記(appended)される。
- 例(本文の CLAUDE.md 例):スタック(Next.js 15 / App Router / Tailwind / Drizzle ORM)、コマンド(dev / test / lint)、コードスタイル(2-space indent、named exports、API ルートは
app/api/、可能なら server actions)を書く。すると「React コンポーネントを作って」で、Tailwind を使い規約に従うことを最初から知っている。
- CLAUDE.md はチームのためのもの。バージョン管理にコミットすべき。記憶ファイルには階層がある:
- Project-level CLAUDE.md:プロジェクトのルート。チームで共有。
- User-level CLAUDE.md:自分の設定フォルダ。自分専用・全プロジェクトに適用。個人的な好みはここへ。
- コツ:
- 訂正を記憶に保存する:同じ訂正(例:常に API ルートでなく server actions を使え)を繰り返すなら、明示的に memory に保存させる。次回から覚えている。
- プロジェクトドキュメントを参照させる:
@ 記号 + ファイルパスで参照(例:@README.md)。
- 最初は無しで始める:まず CLAUDE.md なしで始め、どこで繰り返し軌道修正するかを観察する。これで CLAUDE.md をコンパクトで必要な情報だけに保てる。準備ができたら
/init で Claude に生成させる。
日本語(本文の自然な全訳)
Claude Code の最も有用な機能の一つが CLAUDE.md ファイルです。これは、あなたのプロジェクトについての永続的な記憶を Claude Code に与えます。
それが解決する問題
CLAUDE.md ファイルなしで Claude Code を開くと、毎回ゼロから始まります。コードベースを再探索し、どんな依存関係が必要かを見極め、すでに実装されている機能を把握し直さなければなりません。時には前提を置いてしまい、それが Claude を正しい方向へ導くのを難しくします。
CLAUDE.md はこれを解決します。プロジェクトのルートに追加する Markdown ファイルで、Claude Code はセッションを始めるたびに自動的に読み込みます。あなたのコードベースのオンボーディングスクリプトだと考えてください。CLAUDE.md ファイルの内容は、あなたのプロンプトに追記されます。
例
典型的な CLAUDE.md ファイルはこんな形です。
# Project
This is a Next.js 15 app using the App Router, Tailwind, and Drizzle ORM.
# Commands
- Dev server: `pnpm dev`
- Run tests: `pnpm test`
- Lint: `pnpm lint`
# Code Style
- Use 2-space indentation
- Prefer named exports
- All API routes go in app/api/
- Use server actions instead of API routes where possible
とてもシンプルです。これで Claude Code に React コンポーネントを作ってと頼めば、スタイリングに Tailwind を使い、あなたのコード規約に従うことをすでに知っています。
CLAUDE.md はチームのためのもの
CLAUDE.md はバージョン管理にコミットできますし、そうすべきです——そうすればチームもその恩恵を受けられます。実は、誰のためのものかによって記憶ファイルには階層があります。
- Project-level CLAUDE.md は、プロジェクトのルートディレクトリに置きます。チームと共有されます。
- User-level CLAUDE.md は、あなたの設定フォルダに置きます。これはあなた専用で、すべてのプロジェクトに適用されます。個人的な好みはここに入れましょう。
コツ
訂正を記憶に保存する。もし同じ訂正を繰り返しているなら——たとえば「API ルートではなく常に server actions を使って」と言い続けているなら——その規則を memory に保存するよう明示的に Claude に頼みましょう。次にプロジェクトを開いたときには、それを知っています。
プロジェクトドキュメントを参照する。Claude に参照してほしいドキュメントがプロジェクトにあるなら、@ 記号にファイルパスを付けて使います。
## README.md
Please read if you need more info: @README.md
最初は無しで始める。私たちは、まず CLAUDE.md ファイルなしでプロジェクトを始めることをおすすめします。そうすれば、どこで絶えずモデルを軌道修正しているかが見えてきます。これによって、CLAUDE.md をコンパクトに、必要な情報だけに絞って保てます。準備ができたら、/init を実行して Claude に生成させましょう。
まとめ
イライラする Claude Code セッションと生産的なセッションの違いは、しばしばコンテキストに帰着します——そして CLAUDE.md ファイルこそが、そのコンテキストを提供する手段です。まずはスタック、好み、コマンドから始めて、進めながらそこに積み上げていきましょう。
英語逐語(動画字幕)
注:字幕の自動文字起こしでは「CLAUDE.md」がしばしば「claw.md」等と誤認識されています。読み替えてください。
One of the most useful parts of Claude Code is the claw.md file. It gives Claude Code persistent memory about your project.
When you open up Claude Code without a claw.md file, it's like it has to start fresh every single time. It has to re-explore your code base, understand what dependencies are needed, and the features that are already implemented. Sometimes it has to make assumptions, which makes it harder for us to steer Claude in the right direction. But, that's where claw.md comes in. It's a markdown file that you add to the root of your project, and Claude Code reads it automatically every time you start a session. It's like an onboarding script for your code base. Simply put, the contents of claw.md file are appended to your own prompt. You can run the /init command, which will make Claude generate one based off of your code base.
So, let's have a look at one. This is a Next.js 15 app using the app router, Tailwind, and Drizzle ORM. Command, dev server, run tests, lint, code style, use two-space indentation, prefer named exports, all API routes go in app/api, use server actions instead of API routes where possible. And it's pretty straightforward. Now, if I ask Claude Code to create a React component, it knows how to style it with Tailwind or any other CSS framework that I'm using. We can see that Claude does a better job at doing his job right off the bat versus having to understand where everything is at first.
And before you ask, the answer is yes. You share this in your version control for your team to use, but there's actually a hierarchy of memory files depending on who it's for. So, first you have your project-level claw.md that lives in the root directory of your project. You have a user-level claw.md that lives in your configuration folder. This one is just for you and goes across all your projects. So, put your preferences here, like how you write code comments.
First, if you have to correct Claude to do something like always use server actions instead of API routes, then explicitly ask Claude to save this to memory, so that when you come back to this project, it will know every single time. Second, if you have docs in your project that you want Claude to reference, just use the @ symbol with the file path. And third is we recommend you start off a project without a Claude.md file, you can see where you have to constantly course correct the model. This keeps your Claude.md file compact and contain only the necessary information that Claude can work with.
The difference between a frustrating Claude code session and a productive one comes down to the context and the Claude.md file is how you provide that context. Start with your stack, your preferences, and then commands, and just build from there as you go.