The .claude/ Ecosystem
.claude/ directory is where Claude Code stops being a command you run and becomes something you configure. Hooks, subagents, MCP servers, skills, path-scoped rules, all live here, all check into git, all compound across your team. Most engineers never look inside .claude/. The ones who do stop re-explaining the same rules at the start of every session.Product facts change. File names and settings keys here match the official documentation as of October 2026. Check the current docs before you rely on one that is not shown.
After this lesson, you will be able to:
- Navigate the .claude/ directory: settings.json, settings.local.json, agents/, skills/, rules/, commands/, and the hook scripts you keep beside them
- Distinguish project, user, and enterprise settings, and pick the right level for any rule
- Use settings.local.json for personal overrides without polluting the team's settings.json
- Read a settings.json end-to-end: permissions, hooks, MCP servers, environment variables
Before you start
#The Directory Layout
my-project/
├── CLAUDE.md
├── .mcp.json ← shared MCP server list (commit this)
└── .claude/
├── settings.json ← shared team config (commit this)
├── settings.local.json ← personal overrides (gitignored)
├── hooks/ ← your hook scripts (a convention, not a special folder)
│ └── format.sh
├── agents/ ← specialized sub-agents (Markdown files)
│ ├── code-reviewer.md
│ └── docs-writer.md
├── skills/ ← reusable workflows, one folder per skill
│ └── deploy-staging/
│ └── SKILL.md
├── rules/ ← path-scoped instructions
│ ├── api.md ← applies to api/**
│ └── frontend.md ← applies to src/components/**
└── commands/ ← custom slash commands (older pattern)
#settings.json: The Big One
{
"permissions": {
"allow": ["Bash(npm run lint)", "Bash(npm run build)", "Bash(pytest *)"],
"deny": ["Bash(rm -rf *)", "Bash(sudo *)"]
},
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{ "type": "command", "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/format.sh" }
]
}
]
},
"env": {
"NODE_ENV": "development"
},
"model": "sonnet"
}
The keys you will use most:
permissions: allow, deny and ask rules for tools such as Bash (security)hooks: an object keyed by event name (see the Hooks lesson)env: environment variables for sessionsmodel: the default model for this project, ideally as an alias such assonnet
There are many more keys, and the list grows. Check the settings reference for the current set.
settings.json. Share project servers in a .mcp.json file at the project root, or add one from the terminal with claude mcp add:{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "${DATABASE_URL}"]
}
}
}
claude mcp add. The MCP lesson covers this in detail.#Three Settings Levels
| File | Scope | Commit to git? |
|---|---|---|
~/.claude/settings.json | All your projects | Personal, never commit |
<project>/.claude/settings.json | This project, all team members | YES, commit it |
<project>/.claude/settings.local.json | This project, only you | NO, gitignore it |
| Managed settings | Org-wide, set by an admin | Pushed by the admin, users cannot override |
- Managed settings from your organization
- Command-line flags for the current session
settings.local.json(your personal project overrides).claude/settings.json(shared project settings)~/.claude/settings.json(your user settings)
deny rule at any level still applies even if a lower level allows the same thing. This is how an organization keeps a ban in place that no project file can lift. As of October 2026; verify the order in the settings documentation.#settings.local.json: Personal Overrides
Use this for things only YOU need:
- Personal environment values and paths
- Hooks that run YOUR linter setup
- Permission grants you need but the team shouldn't auto-have
{
"permissions": {
"allow": [
"Bash(open https://localhost:3000)",
"Bash(open Simulator.app)"
]
},
"env": {
"MY_EDITOR": "code"
}
}
.claude/settings.local.json to .gitignore:.claude/settings.local.json
#The Other Subdirectories
#hooks/
settings.json. Each script receives the event as JSON on stdin. (Full detail in the Hooks lesson.)#!/usr/bin/env bash
# .claude/hooks/format.sh: the hook receives the event as JSON on stdin
f=$(jq -r '.tool_input.file_path // empty')
case "$f" in
*.ts|*.tsx) npx prettier --write "$f" ;;
esac
exit 0
#agents/
/agents. A .yaml file here is not loaded. (Full detail in the Subagents lesson.)---
name: code-reviewer
description: Reviews a diff for quality, security and performance. Use after code changes.
tools: Read, Grep, Glob, Bash
model: sonnet
---
You are a senior code reviewer. Look for bugs, security issues,
performance regressions, missing tests and style violations.
#skills/
SKILL.md file, and the description tells Claude when to use it. You can also invoke one by name. (Full detail in the Slash Commands & Skills lesson.)---
name: deploy-staging
description: Deploy to staging with health checks. Use when asked to deploy to staging.
---
Walk through these steps:
1. Run npm run build
2. Run pytest
3. Push to the staging branch
4. Verify the deploy with curl staging.example.com/health
#rules/
Path-scoped instructions, loaded when Claude works on matching files. The frontmatter lists the paths that trigger them. Frontmatter keys evolve, so check the memory documentation for the current one.
---
paths:
- "api/**/*.py"
---
# API Conventions
- All endpoints use Pydantic for request/response
- All endpoints emit OpenTelemetry spans
- All errors use the StandardError schema in api/lib/errors.py
#memory/
~/.claude/projects/), not inside the repository. That keeps it personal and out of git. Rules you want the whole team to share belong in CLAUDE.md or .claude/rules/. (Full detail in the CLAUDE.md lesson.)#Hands-On
.claude/settings.json.*. The real engine is smarter about compound commands such as a && b, and Bash patterns are still a weak fence, which is why a hook (previous lessons) backs up the dangerous ones.Tests: Every test line should print OK. Then paste the allow and deny lists into .claude/settings.json under a permissions key, run claude in the project, and confirm that npm run build runs without a prompt and that a denied command is refused.
#Key Takeaways
- .claude/ is the project's Claude config home: settings, agents, skills, rules, commands. Hook scripts and the
.mcp.jsonfile sit beside it - Settings have several levels (managed, command line, local, project, user). More specific levels usually win, and a
denyrule at any level still applies - Always commit settings.json, always gitignore settings.local.json (it holds your personal choices and sometimes paths you do not want shared)
- A permissions allowlist buys speed: pre-approve safe commands so Claude does not keep asking
- MCP servers go in
.mcp.jsonorclaude mcp add, not in settings.json - Sub-agents are
.mdfiles and hooks are an object keyed by event: copy those shapes from the Subagents and Hooks lessons
#Quick Check
Your team uses Claude Code on a shared codebase. You want everyone to auto-approve `npm run *`, but YOU also want to auto-approve `open *` (for opening simulator) without forcing it on others. How?
A teammate commits `settings.local.json` 'because it has nice defaults.' What's the actual cost?