記事一覧へ
.claudeフォルダの解剖
CLAUDE.md、カスタムコマンド、スキル、エージェント、パーミッションの完全ガイドと適切な設定方法。ほとんどのClaude Codeユーザーは.claudeフォルダをブラックボックスとして扱っています。
■ 2つの.claudeディレクトリ
1. プロジェクトレベル(プロジェクトルートの.claude/)- gitにコミットされるチーム設定
2. グローバル(ホームディレクトリの~/.claude/)- 個人設定とセッション履歴
■ CLAUDE.md:コアファイル
システム内で最重要ファイルで、セッション開始時にClaudeのシステムプロンプトに直接読み込まれます。含めるべきもの:ビルド・テスト・lintコマンド、主要なアーキテクチャ上の決定、非自明な落とし穴、インポート規則と命名パターン、ファイルとフォルダ構造。
■ ルールフォルダの整理
.claude/rules/フォルダで指示をモジュール化:code-style.md、testing.md、api-conventions.md、security.md。パススコープルールはYAML frontmatterで特定ファイルにのみ適用。
■ カスタムコマンド
.claude/commands/の各Markdownファイルがスラッシュコマンドになります。review.mdというファイルは/project:reviewを作成します。
■ スキル vs コマンド
コマンドは明示的なユーザー呼び出しを待ちます。スキルは会話を監視し、タスクの説明が一致すると自動的にトリガーします。
■ エージェント
.claude/agents/で複雑な定期的ワークフロー用のサブエージェントペルソナを定義。各エージェントは分離されたコンテキストウィンドウ、制限されたツールアクセス、オプションのモデル設定を持ちます。
■ settings.jsonのパーミッション
推奨allowリスト:npm run *、git *、Read/Write/Edit/Glob/Grep。推奨denyリスト:rm -rf、curl、.envファイル。
■ グローバル~/.claude/ディレクトリ
個人CLAUDE.md(全プロジェクトで読み込まれる)、セッション履歴、個人コマンド・スキル・エージェントを含みます。

claude-setupclaude-workflowai-thinking
.claudeフォルダの完全解剖ガイド
♥ 10,447↻ 1,506🔖 41,202👁 9,888,873
原文を表示 / Show original
Anatomy of the .claude/ folder
A complete guide to CLAUDE.md, custom commands, skills, agents, and permissions, and how to set them up properly. Most Claude Code users treat the .claude folder like a black box.
Two .claude Directories
The system includes two distinct locations:
1. Project-level (.claude/ in your project root) - Team configuration committed to git
2. Global (~/.claude/ in home directory) - Personal preferences and session history
CLAUDE.md: The Core File
The most critical file in the system, CLAUDE.md loads directly into Claude's system prompt at session start. It should contain:
- Build, test, and lint commands
- Key architectural decisions
- Non-obvious gotchas
- Import conventions and naming patterns
- File and folder structure
Should NOT contain:
- Full documentation links
- Long theoretical explanations
Recommendation: Keep CLAUDE.md under 200 lines to maintain instruction adherence.
CLAUDE.local.md
Create CLAUDE.local.md in your project root. Claude reads it alongside the main CLAUDE.md, and it's automatically gitignored so your personal tweaks never land in the repo.
Rules Folder Organization
The .claude/rules/ folder breaks instructions into focused, modular files:
- code-style.md
- testing.md
- api-conventions.md
- security.md
Path-scoped rules use YAML frontmatter to activate only for matching files:
---
paths:
- "src/api/**/*.ts"
---
Custom Commands
Every markdown file in .claude/commands/ becomes a slash command. A file named review.md creates /project:review.
Key feature: The ! backtick syntax executes shell commands and embeds output into prompts, making commands genuinely functional rather than template-based.
Skills vs. Commands
Critical distinction:
- Commands wait for explicit user invocation
- Skills watch conversations and trigger automatically when task descriptions match
Skills are packaged in subdirectories with supporting files, while commands are single files.
Agents for Specialized Work
Define subagent personas in .claude/agents/ for complex, recurring workflows. Each agent has:
- Isolated context window
- Restricted tool access
- Optional model preference (Haiku for read-only tasks, Sonnet for complex work)
Settings.json Permissions
The settings.json file inside .claude/ controls what Claude is and isn't allowed to do.
Structure includes:
- $schema reference for VS Code validation
- allow list (runs without confirmation)
- deny list (blocked entirely)
- Unspecified commands prompt for confirmation
Recommended allow list:
- Bash(npm run *) for script execution
- Bash(git *) for version control
- Read, Write, Edit, Glob, Grep for file operations
Recommended deny list:
- Destructive commands like rm -rf
- Network commands like curl
- Sensitive files like .env
Global ~/.claude/ Directory
Contains:
- Personal CLAUDE.md (loads in all projects)
- Session transcripts and auto-memory in projects/
- Personal commands, skills, and agents
Implementation Progression
1. Run /init and refine generated CLAUDE.md
2. Create .claude/settings.json with appropriate permissions
3. Build 1-2 custom commands for frequent workflows
4. Split CLAUDE.md into modular rules as it grows
5. Add ~/.claude/CLAUDE.md for personal preferences
CLAUDE.md is your highest-leverage file. Get that right first. Everything else is optimization.