ポッドキャストに戻るClaude
Claude Code 101
CLAUDE.md ファイル
[Music starts]
[Music starts]
One of the most useful parts of Claude Code is the claude.md file.
Claude Code の最も便利な機能の一つが CLAUDE.md ファイルです。
It gives Claude Code persistent memory about your project.
これにより、Claude Code はプロジェクトに関する持続的な記憶を持てます。
When you open up Claude Code without a claude.md file, it's like it has to start fresh every single time.
CLAUDE.md ファイルなしで Claude Code を開くと、毎回ゼロから始めなければなりません。
It has to re-explore your codebase, 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.
時には仮定を立てなければならず、Claude を正しい方向へ誘導するのが難しくなります。
But that's where claude.md comes in.
そこで CLAUDE.md が役立ちます。
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.
プロジェクトのルートに追加する Markdown ファイルで、Claude Code は毎回これを読み込みます。
It's like an onboarding script for your codebase.
コードベースのオンボーディングスクリプトのようなものです。
Simply put, the contents of claude.md file are appended to your own prompt. You can run the /init command which will make Claude generate one based off of your codebase.
簡単に言うと、claude.md ファイルの内容はあなたのプロンプトに追加されます。/init コマンドを実行すれば、Claude がコードベースを元に生成します。
So let's have a look at one.
では実際に見てみましょう。
This is a Next.js 15 app using the app router, Tailwind, and Drizzle ORM.
これは App Router、Tailwind、Drizzle ORM を使用した Next.js 15 アプリです。
Commands: dev server, run tests, lint.
コマンド:開発サーバー、テスト実行、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.
コードスタイル:2スペースインデント、名前付き export 優先、API ルートは app/api 配下、可能なら API ルートより Server Actions を使う。
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.
Claude Code に React コンポーネント作成を頼むと、Tailwindや他のCSSフレームワークでのスタイリング方法を最初から把握しています。
We can see that Claude does a better job at doing its job right off the bat versus having to understand where everything is at first.
すべてを最初から把握し直す必要がある場合と比べ、Claude が最初からより良い仕事をするのがわかります。
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 claude.md that lives in the root directory of your project.
まず、ルートディレクトリにあるプロジェクトレベルの CLAUDE.md があります。
You have a user-level claude.md that lives in your configuration folder.
設定フォルダにあるユーザーレベルの CLAUDE.md があります。
This one is just for you and goes across all your projects.
これはあなただけのもので、すべてのプロジェクトで有効です。
So put your personal 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.
第一に、Claude を修正する必要がある場合、例えば API ルートではなく常に Server Actions を使うなら、Claude に明示的にメモリへ保存させてください。次回プロジェクトに戻ると必ず覚えています。
Second, if you have docs in your project that you want Claude to reference, just use the @ symbol with the file path.
第二に、Claude に参照させたいドキュメントがある場合、@ 記号にファイルパスを続けて指定してください。
And third is we recommend you start off a project without a claude.md file so you can see where you have to constantly course correct the model.
第三に、まず claude.md なしでプロジェクトを始めるのをお勧めします。どこでモデルを修正する必要があるかが見えてきます。
This keeps your claude.md file compact and contains only the necessary information that Claude can work with.
これにより CLAUDE.md ファイルをコンパクトに保ち、必要な情報だけを含められます。
[Music transition]
[Music transition]
The difference between a frustrating Claude Code session and a productive one comes down to the context, and the claude.md file's how you provide that context.
思い通りにならない Claude Code セッションと生産的なセッションの違いは、コンテキストにあります。そのコンテキストを提供するのが CLAUDE.md ファイルです。
Start with your stack, your preferences, and then commands, and just build from there as you go.
スタック、好み、コマンドの順で始め、そこから積み上げていきましょう。