記事一覧へ
.claude/フォルダを知っている開発者と知らない開発者の差は絶大だ。
Claude Codeを使っているほとんどの開発者は、他のAIツールと同じように使っている。プロンプトを打ち込み、レスポンスを受け取り、先に進む。
真剣にシステムを構築している開発者は、別のことを知っている。Claude Codeの本当の力は、打ち込むプロンプトではない。一言発する前にあらゆるインタラクションを形作る設定にある。
その設定が`.claude/`フォルダに住んでいる。
このフォルダはClaude Codeセットアップの頭脳だ。カスタムコマンド、プロジェクトメモリ、会話履歴、そして汎用AIをコードベース・規約・嗜好を知る開発パートナーに変える指示を保持している。
ほとんどの開発者はここに触れない。触れた人たちは、他の人には不可能に見えるものを構築する。
完全な解剖図がここにある。
---
## `.claude/`フォルダの構造
プロジェクトでClaude Codeを初期化すると`.claude/`フォルダが自動生成される:
```
your-project/
├── .claude/
│ ├── commands/
│ │ ├── deploy.md
│ │ ├── review.md
│ │ └── test.md
│ ├── memory/
│ │ └── project.md
│ ├── conversations/
│ │ └── [session-id].json
│ └── settings.json
├── CLAUDE.md
└── src/
```
**各ファイルの役割まとめ**
| ファイル | 役割 |
|---|---|
| `commands/` | 定義して再利用できるカスタムスラッシュコマンド |
| `memory/` | セッションをまたいで持続するプロジェクトコンテキスト |
| `conversations/` | Claudeが参照できるセッション履歴 |
| `settings.json` | Claude Codeの設定と環境設定 |
| `CLAUDE.md` | Claudeが最初に読むマスター指示ファイル |
---
## CLAUDE.md:プロジェクトで最も重要なファイル
CLAUDE.mdはプロジェクトのルートに置き、セッション開始時にClaude Codeが最初に読む。チームに加わった新しいシニア開発者に渡すオンボーディングドキュメントだと思えばいい。
CLAUDE.mdに書いたものはすべて、プロジェクトのあらゆる会話で常時コンテキストになる。繰り返さなくてもClaudeがこれらの指示に従う。
**本番対応のCLAUDE.mdテンプレート:**
```markdown
# CLAUDE.md — Claude Codeのプロジェクトインテリジェンス
## プロジェクト概要
これは[アプリ名]のNext.js 14アプリケーション。
スタック:TypeScript、Tailwind、Prisma、PostgreSQL、Vercel。
## アーキテクチャルール
- すべてのAPIルートは/app/api/に置く
- データベースクエリは/lib/db.tsのみを通す
- 生SQLは書かない——Prismaクライアントを使う
- すべてのコンポーネントはTypeScriptで/components/に置く
## コード規約
- 関数コンポーネントのみ——クラスコンポーネント禁止
- 常にasync/await、.then()は使わない
- すべての関数にJSDocコメントが必要
- すべてのAPIルートにエラーハンドリング必須
## テスト要件
- すべての新関数にテストを書く
- ユニットテストにはVitestを使用
- テストファイルはテスト対象ファイルの隣に置く
## 避けること
- インラインスタイル禁止
- TypeScriptの型にany禁止
- シークレットやAPIキーをコミット禁止
- 適用後にマイグレーションファイルを変更禁止
```
CLAUDE.mdが具体的であればあるほど、Claudeは数ヶ月プロジェクトにいたチームメンバーのように振る舞う。
---
## `commands/`フォルダ:カスタムスラッシュコマンド
`commands/`フォルダはオンデマンドで実行するカスタムスラッシュコマンドを定義する場所だ。このフォルダの各ファイルが`/コマンド名`で呼び出せるコマンドになる。
これはClaude Codeの最も強力で最も使われていない機能の一つだ。毎回複雑な指示を打ち込む代わりに、一度定義して一言で呼び出せる。
**例1:`/review`コマンド**
`.claude/commands/review.md`を作って`/review`コマンドを追加:
```markdown
# /review — 総合コードレビュー
このコマンドを実行したら、開いているまたは指定したファイルの完全なコードレビューを実施する。チェック項目:
## セキュリティ
- SQLインジェクション脆弱性
- XSS攻撃ベクター
- シークレットやAPIキーの公開
- 認証バイパスリスク
- 入力バリデーションの欠落
## パフォーマンス
- N+1データベースクエリパターン
- クエリ対象カラムのインデックス欠落
- Reactコンポーネントの不要な再レンダリング
- イベントリスナーのメモリリーク
## コード品質
- 40行を超える関数
- エラーハンドリングの欠落
- 抽象化できる重複コード
- TypeScriptのany型
## 出力フォーマット
各問題について:
1. ファイル名と行番号
2. 重大度:Critical / Warning / Suggestion
3. 問題の内容
4. コード例付きの修正方法
```
**例2:`/deploy`コマンド**
`.claude/commands/deploy.md`でデプロイ前チェック:
```markdown
# /deploy — デプロイ前チェックリスト
デプロイ前に自動でこのチェックリストを実行する。
## ステップ1:環境チェック
必要な環境変数がすべて.env.exampleに文書化されているか確認。コードにあって例ファイルにない変数をフラグする。
## ステップ2:マイグレーションチェック
保留中のデータベースマイグレーションがあるか確認。マイグレーションがライブデータベースでダウンタイムを引き起こす場合は警告。
## ステップ3:テストカバレッジチェック
最後のコミット以来追加された新関数でテストカバレッジのないものを特定。デプロイ前にテストを生成するか確認する。
## ステップ4:依存関係監査
既知の脆弱なパッケージをpackage.jsonで確認。重大な脆弱性があれば更新を提案。
## ステップ5:最終出力
すべての発見事項とともにデプロイサマリーを生成。GOまたはNO-GOの推奨と理由を提示。
```
**例3:`/feature`コマンド**
`.claude/commands/feature.md`で新機能を一貫してスキャフォールド:
```markdown
# /feature [機能名] — 機能スキャフォールド
機能名を与えられたら、プロジェクト規約に従って必要なすべてのファイルをスキャフォールドする。
## 作成するファイル
1. /app/api/[feature]/route.ts — APIエンドポイント
2. /components/[Feature]/index.tsx — メインコンポーネント
3. /components/[Feature]/[Feature].test.tsx — テスト
4. /lib/[feature].ts — ビジネスロジック
5. /types/[feature].ts — TypeScript型
## 各ファイルに含めること
- 適切なTypeScript型
- すべてのエクスポートにJSDocコメント
- エラーハンドリング
- 基本的なテスト構造
## スキャフォールド後
作成したすべてのファイルのサマリーを表示。ロジックを書く前に機能が実際に何をすべきか聞く。
```
---
## `memory/`フォルダ:持続するプロジェクトインテリジェンス
`memory/`フォルダはClaude Codeセッション間で持続する情報を保存する。ターミナルを閉じるとリセットされる通常の会話とは違い、メモリファイルはプロジェクトについての継続的なコンテキストをClaudeに与える。
これが同じことを繰り返さなくて済む仕組みだ。一度書けば、Claudeは永遠に覚えている。
**project.md — プロジェクトメモリファイル**
```markdown
# プロジェクトメモリ — [プロジェクト名]
## 現在のスプリント目標
- JWTでのユーザー認証を実装
- ダッシュボード分析コンポーネントを構築
- レガシーエンドポイントを新APIструктурに移行
## 既知の問題
- /api/usersエンドポイントが1000件以上でスロー——ページネーションが必要
- ダークモード切替がSafariで壊れている——issue #142を参照
- ステージング環境でメール送信がサイレントに失敗
## アーキテクチャ上の決定
- チームの習熟度からDrizzleではなくPrismaを選択
- モバイルサポートが必要なためセッションではなくJWT認証
- データベースではすべての日付をUTCで保存
## チーム規約
- PRはマージ前に少なくとも1人のレビュアーが必要
- コミットメッセージはconventional commitsフォーマットに従う
- フィーチャーブランチ命名:feat/[チケット番号]-[説明]
## 試みたが機能しなかったこと
- ユーザーセッションのRedisキャッシング——マルチリージョンで問題発生
- GraphQL——チーム速度が低下、RESTに戻す
```
プロジェクトの発展に合わせてこのファイルを定期的に更新する。最新であればあるほど、毎回のClaude セッションが有用になる。
---
## `settings.json`:設定と環境設定
`settings.json`ファイルはプロジェクトでのClaude Codeの動作を制御する:
```json
{
"model": "claude-opus-4-5",
"context": {
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"CLAUDE.md",
"package.json",
"prisma/schema.prisma"
],
"exclude": [
"node_modules/**",
".next/**",
"dist/**",
"**/*.test.ts"
]
},
"commands": {
"directory": ".claude/commands"
},
"memory": {
"enabled": true,
"directory": ".claude/memory"
},
"output": {
"format": "markdown",
"verbosity": "normal"
}
}
```
---
## 実世界のユースケース
プロのdeveloperが`.claude/`フォルダを使って真剣なシステムを構築している事例がここにある。
**セキュリティファースト開発チーム**:セキュリティチームが新しいエンドポイントごとにOWASPチェックを実行する`/security`コマンドを作成。CLAUDE.mdにスタックの既知の脆弱性を全記載。メモリはスプリントをまたいであらゆるセキュリティ決定を追跡。チームのすべての開発者が自動的に同じセキュリティ基準を得る。
**PR前の自動コードレビュー**:ソロ開発者がすべてのPRの前に実行する`/review`コマンドを作成。個人のコード規約をチェックし、カバーされていないコードパスのテスト提案を生成し、PR説明に添付できるレビューサマリーを生成。レビュー時間を半減。
**データエンジニアリングパイプラインチーム**:データチームがスキーマドキュメント全体を`memory/`に保存し、Claudeが常にデータの形状を知っている。カスタムコマンドが一般的な変換を処理。CLAUDE.mdでどのテーブルが追記専用vs変更可能かを文書化。Claudeがデータコントラクトを壊すクエリを提案することがない。
**デザインシステム適用**:フロントエンドチームがコンポーネントライブラリ全体をCLAUDE.mdに記載。Claudeはすべてのコンポーネント、すべてのprop、すべてのバリアントを知っている。`/component`コマンドがデザインシステムに自動的に一致する新コンポーネントをスキャフォールド。コードベース全体の非一貫な実装がなくなる。
**AIエージェント開発**:Claude搭載エージェントを構築するAIエンジニアがエージェントプロンプト、ツール定義、会話テンプレートを`.claude/memory/`に保存。`/agent`コマンドが標準構造で新エージェントをスキャフォールド。CLAUDE.mdがマルチエージェントアーキテクチャを文書化し、Claudeがシステムを壊すパターンを提案しない。
---
## 10分セットアップ:今すぐ始める
プロフェッショナルな`.claude/`フォルダをゼロから10分でセットアップするために必要なすべてがここにある。
**ステップ1:フォルダ構造を作成**
```bash
mkdir -p .claude/commands .claude/memory
```
**ステップ2:CLAUDE.mdを作成**
```bash
touch CLAUDE.md
```
プロジェクト概要、アーキテクチャルール、コード規約、避けることを追加。先ほどのテンプレートを出発点にする。
**ステップ3:最初のカスタムコマンドを追加**
```bash
touch .claude/commands/review.md
```
この記事の`/review`コマンドを追加。最初のファイルで実行して何を発見するか見てみよう。
**ステップ4:メモリファイルを開始**
```bash
touch .claude/memory/project.md
```
現在のスプリント目標、既知の問題、最も重要なアーキテクチャ上の決定を追加。毎週更新する。
**ステップ5:選択的に.claude/を.gitignoreに追加**
```
# .gitignoreに追加
# commandsとCLAUDE.mdはgitに保持——チームで共有
# conversationsは除外——個人的なもの
.claude/conversations/
```
commandsとCLAUDE.mdはバージョン管理してチームで共有すべき。会話履歴は個人的なものだ。
---
## 上級:動的メモリ更新
最も強力なパターンは、プロジェクトの発展に合わせてClaudeが自分自身のメモリファイルを更新することだ。CLAUDE.mdにこれを追加:
```markdown
## メモリ更新の指示
重要な決定が下されたすべてのセッション後:
1. その決定を.claude/memory/project.mdに追加
2. その決定がなぜ下されたかを含める
3. 検討した代替案を記録
4. 決定が再検討されるべきかフラグ
既知の問題が解決されたら、問題リストから削除する。
新しいパターンが出現したら、アーキテクチャ決定の下に文書化する。
```
これを設定すれば、Claudeは時間とともに自身のプロジェクトインテリジェンスを維持する。各セッションが前のセッションの上に積み重なる。使えば使うほど、その特定のプロジェクトについてスマートになる。
---
## 結論
`.claude/`フォルダは、Claude Codeをコード補完ツールとして使うか、真の開発パートナーとして使うかの分かれ目だ。
セットアップに10分かかる。見返りは無限に積み重なる。
書くカスタムコマンドはすべて、同じ指示を再び打ち込む手間を省く。追加するメモリエントリはすべて、再説明が必要なことを一つ減らす。すべてのCLAUDE.mdの改善は、Claudeがチームに数ヶ月いた開発者のように働くことを意味する。
ほとんどの開発者はこれを読んでもフォルダを作らないだろう。
今週セットアップした人たちは、もうなしでは働けなくなる。
---
@cyrilxbt をフォローしてAI/クリプトコンテンツを購読しよう

claude-setupai-thinkingai-industry
Claudeを10倍強力にする隠しフォルダ:開発者必見
♥ 325↻ 28
原文を表示 / Show original
Most developers who use Claude Code interact with it the same way they interact with any other AI tool.
They type a prompt. They get a response. They move on.
The developers building serious systems with Claude know something different. They know that the real power of Claude Code is not in the prompts you type. It is in the configuration that shapes every single interaction before you say a word.
That configuration lives in the .claude/ folder.
This folder is the brain behind your Claude Code setup. It holds your custom commands, your project memory, your conversation history, and the instructions that turn a generic AI into a development partner that knows your codebase, your standards, and your preferences.
Most developers never touch it. The ones who do build things that feel impossible to everyone else.
Here is the complete anatomy.
The .claude/ Folder Structure
When you initialize Claude Code in a project the .claude/ folder is created automatically. Here is what it looks like:
your-project/
├── .claude/
│ ├── commands/
│ │ ├── deploy.md
│ │ ├── review.md
│ │ └── test.md
│ ├── memory/
│ │ └── project.md
│ ├── conversations/
│ │ └── [session-id].json
│ └── settings.json
├── CLAUDE.md
└── src/
Quick Reference: What Each File Does
commands/ → Custom slash commands you define and reuse
memory/ → Project context that persists across sessions
conversations/→ Session history Claude can reference
settings.json → Claude Code configuration and preferences
CLAUDE.md → The master instructions file Claude reads first
The CLAUDE.md File: The Most Important File in Your Project
CLAUDE.md sits at the root of your project and is the first thing Claude Code reads when you start a session. Think of it as the onboarding document you would give to a new senior developer joining your team.
Whatever you put in CLAUDE.md becomes standing context for every conversation in your project. Claude will follow these instructions without you having to repeat them.
Here is a production ready CLAUDE.md template:
# CLAUDE.md — Project Intelligence for Claude Code
## Project Overview
This is a Next.js 14 application for [YOUR APP NAME].
Stack: TypeScript, Tailwind, Prisma, PostgreSQL, Vercel.
## Architecture Rules
- All API routes live in /app/api/
- Database queries go through /lib/db.ts only
- Never write raw SQL — use Prisma client
- All components must be in /components/ with TypeScript
## Code Standards
- Functional components only — no class components
- Always use async/await, never .then()
- All functions need JSDoc comments
- Error handling required in every API route
## Testing Requirements
- Write tests for every new function
- Use Vitest for unit tests
- Test files live next to the files they test
## What To Avoid
- Never use inline styles
- Never use any as a TypeScript type
- Never commit secrets or API keys
- Never modify migration files after they are applied
The more specific your CLAUDE.md the more Claude behaves like a team member who has been on your project for months rather than a blank slate AI.
The commands/ Folder: Your Custom Slash Commands
The commands/ folder is where you define custom slash commands that Claude executes on demand. Each file in this folder becomes a command you can call with /command-name.
This is one of the most powerful and most underused features of Claude Code. Instead of typing out complex instructions every time, you define them once and call them with a single word.
Example 1: The /review Command
Create .claude/commands/review.md to add a /review command:
# /review — Comprehensive Code Review
When this command is run, perform a complete code review of the
files I have open or that I specify. Check for:
## Security
- SQL injection vulnerabilities
- XSS attack vectors
- Exposed secrets or API keys
- Authentication bypass risks
- Input validation gaps
## Performance
- N+1 database query patterns
- Missing indexes on queried columns
- Unnecessary re-renders in React components
- Memory leaks in event listeners
## Code Quality
- Functions longer than 40 lines
- Missing error handling
- Duplicate code that could be abstracted
- TypeScript any types
## Output Format
For each issue found:
1. File name and line number
2. Severity: Critical / Warning / Suggestion
3. What the problem is
4. The fix with code example
Example 2: The /deploy Command
Create .claude/commands/deploy.md for pre-deployment checks:
# /deploy — Pre-Deployment Checklist
Before any deployment, run through this checklist automatically.
## Step 1: Environment Check
Verify all required environment variables are documented in .env.example.
Flag any variables in the code that are not in the example file.
## Step 2: Migration Check
Check if there are any pending database migrations.
Warn if migrations will cause downtime on a live database.
## Step 3: Test Coverage Check
Identify any new functions added since last commit with no test coverage.
Flag them and ask if I want tests generated before deploying.
## Step 4: Dependency Audit
Check package.json for known vulnerable packages.
Suggest updates for any critical vulnerabilities.
## Step 5: Final Output
Generate a deployment summary with all findings.
Give a GO or NO-GO recommendation with reasons.
Example 3: The /feature Command
Create .claude/commands/feature.md to scaffold new features consistently:
# /feature [FEATURE NAME] — Feature Scaffolding
When given a feature name, scaffold all the files needed
following our project conventions.
## Files to Create
1. /app/api/[feature]/route.ts — API endpoint
2. /components/[Feature]/index.tsx — Main component
3. /components/[Feature]/[Feature].test.tsx — Tests
4. /lib/[feature].ts — Business logic
5. /types/[feature].ts — TypeScript types
## Each File Should Include
- Proper TypeScript types
- JSDoc comments on all exports
- Error handling
- Basic test structure
## After Scaffolding
Show me a summary of all files created.
Ask me what the feature should actually do before writing logic.
The memory/ Folder: Persistent Project Intelligence
The memory/ folder stores information that persists between Claude Code sessions. Unlike a regular conversation that resets when you close the terminal, memory files give Claude ongoing context about your project.
This is how you stop repeating yourself. You write it once and Claude remembers it forever.
project.md — The Project Memory File
# Project Memory — [YOUR PROJECT NAME]
## Current Sprint Goals
- Implement user authentication with JWT
- Build the dashboard analytics component
- Migrate legacy endpoints to new API structure
## Known Issues
- The /api/users endpoint is slow above 1000 records — needs pagination
- Dark mode toggle broken on Safari — see issue #142
- Email sending fails silently in staging environment
## Architecture Decisions
- We chose Prisma over Drizzle for team familiarity
- Auth is JWT not sessions because we need mobile support
- All dates stored as UTC in the database
## Team Conventions
- PR must have at least one reviewer before merging
- Commit messages follow conventional commits format
- Feature branches named: feat/[ticket-number]-[description]
## What We Have Tried That Did Not Work
- Redis caching for user sessions — caused issues with multi-region
- GraphQL — team velocity dropped, switched back to REST
Update this file regularly as your project evolves. The more current it is the more useful every Claude session becomes.
The settings.json File: Configuration and Preferences
The settings.json file controls how Claude Code behaves in your project. Here is a production configuration:
{
"model": "claude-opus-4-5",
"context": {
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"CLAUDE.md",
"package.json",
"prisma/schema.prisma"
],
"exclude": [
"node_modules/**",
".next/**",
"dist/**",
"**/*.test.ts"
]
},
"commands": {
"directory": ".claude/commands"
},
"memory": {
"enabled": true,
"directory": ".claude/memory"
},
"output": {
"format": "markdown",
"verbosity": "normal"
}
}
Real World Use Cases
Here is how professional developers are using the .claude/ folder to build serious systems.
🔐 Use Case 1: Security-First Development Team
A security team creates a /security command that runs OWASP checks on every new endpoint. The CLAUDE.md file lists all known vulnerabilities in their stack. Memory tracks every security decision made across sprints. Every developer on the team gets the same security standards automatically.
🚀 Use Case 2: Automated Code Review Before PRs
A solo developer creates a /review command that runs before every PR. It checks for their personal code standards, generates test suggestions for uncovered code paths, and produces a review summary they can attach to the PR description. Cuts review time in half.
📊 Use Case 3: Data Engineering Pipeline Team
A data team stores their entire schema documentation in memory/ so Claude always knows the shape of the data. Custom commands handle common transformations. CLAUDE.md documents which tables are append-only versus mutable. Claude never suggests a query that would break their data contracts.
🎨 Use Case 4: Design System Enforcement
A frontend team puts their entire component library in CLAUDE.md. Claude knows every component that exists, every prop, and every variant. The /component command scaffolds new components that automatically match the design system. No more inconsistent implementations across the codebase.
🤖 Use Case 5: AI Agent Development
An AI engineer building Claude-powered agents stores their agent prompts, tool definitions, and conversation templates in .claude/memory/. The /agent command scaffolds new agents with their standard structure. CLAUDE.md documents the multi-agent architecture so Claude never suggests patterns that break the system.
The 10-Minute Setup: Get Started Right Now
Here is everything you need to set up a professional .claude/ folder from scratch in 10 minutes.
Step 1: Create the folder structure
mkdir -p .claude/commands .claude/memory
Step 2: Create your CLAUDE.md
touch CLAUDE.md
Then add your project overview, architecture rules, code standards, and what to avoid. Use the template from earlier in this article as your starting point.
Step 3: Add your first custom command
touch .claude/commands/review.md
Add the /review command from this article. Run it on your first file to see what it catches.
Step 4: Start your memory file
touch .claude/memory/project.md
Add your current sprint goals, known issues, and the most important architectural decisions. Update it every week.
Step 5: Add .claude/ to .gitignore selectively
# Add to .gitignore
# Keep commands and CLAUDE.md in git — share with team
# Exclude conversations — those are personal
.claude/conversations/
Your commands and CLAUDE.md should be version controlled and shared with your team. Your conversation history is personal.
Advanced: Dynamic Memory Updates
The most powerful pattern is having Claude update its own memory files as your project evolves. Add this to your CLAUDE.md:
## Memory Update Instructions
After every session where a significant decision is made:
1. Add the decision to .claude/memory/project.md
2. Include why the decision was made
3. Note any alternatives that were considered
4. Flag if the decision should be revisited
If a known issue is resolved, remove it from the issues list.
If a new pattern emerges, document it under Architecture Decisions.
With this in place Claude maintains its own project intelligence over time. Each session builds on the last. The longer you use it the smarter it gets about your specific project.
The Bottom Line
The .claude/ folder is the difference between using Claude Code as a fancy autocomplete and using it as a genuine development partner.
The setup takes 10 minutes. The payoff compounds indefinitely.
Every custom command you write saves you from typing the same instructions again. Every memory entry you add means one less thing you have to re-explain. Every CLAUDE.md improvement means Claude works more like a developer who has been on your team for months.
Most developers will read this and never create the folder.
The ones who set it up this week will never go back to working without it.
follow @cyrilxbt for more ai /crypto content