Project Configuration: CLAUDE.md
What: A markdown file in your project root that gives Claude persistent context.
Location: /project-root/CLAUDE.md (or .claude/CLAUDE.md)
What to Include
# Project: [Name] ## Overview Brief description of what this project does. ## Tech Stack - Frontend: React 18, TypeScript, Tailwind - Backend: Node.js, Express, PostgreSQL - Testing: Jest, Playwright ## Architecture - /src/components - React components - /src/api - API routes - /src/utils - Shared utilities ## Conventions - Use functional components with hooks - Prefer named exports - Tests go in __tests__ folders - Use kebab-case for file names ## Common Commands - `npm run dev` - Start development server - `npm test` - Run tests - `npm run build` - Production build ## Important Notes - Never commit to main directly - All API keys are in .env (not committed) - Database migrations are in /migrations
Why It Matters
- Claude reads this automatically at session start
- Reduces repeated context in prompts
- Ensures consistent code style
- Documents tribal knowledge
Memory: memory.md
What: A file where Claude stores learnings that persist across sessions.
Location: .claude/memory.md
Example Content
# Memory ## Learned Preferences - User prefers verbose error messages - Always run tests before committing - Use conventional commits format ## Project Discoveries - The auth module has a bug with special characters (ticket #123) - Performance issues traced to N+1 queries in /api/users - Design system colors are in /src/theme/colors.ts ## Session Notes - 2025-02-10: Refactored payment module, tests passing - 2025-02-11: Started work on dashboard feature
Subagents: Parallel Execution
What: Spawn separate Claude instances to work on tasks in parallel.
When to Use
- Independent tasks that don't block each other
- Research while coding
- Testing while refactoring
How to Invoke
You: "Work on the login page while a subagent writes tests for the API"
Best Practices
| Do | Don't |
|---|---|
| Use for truly independent tasks | Use for sequential dependencies |
| Merge results intentionally | Let subagents conflict |
| Give clear, scoped instructions | Give vague, overlapping tasks |
Hooks: Automation Triggers
What: Shell commands that trigger automatically at specific events.
Hook Events
| Event | When It Fires | Example Use |
|---|---|---|
PreToolUse |
Before Claude uses a tool | Validate commands |
PostToolUse |
After Claude uses a tool | Run linter after edits |
Notification |
When Claude wants to notify | Send Slack message |
Stop |
When Claude finishes | Run test suite |
Example: Auto-run Tests After File Changes
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"command": "npm test --watchAll=false"
}
]
}
}
Example: Log Failures for Learning
{
"hooks": {
"PostToolUse": [
{
"matcher": "Bash|Execute",
"command": "if [ $EXIT_CODE -ne 0 ]; then echo \"$(date -Iseconds) | $TOOL | $COMMAND | Exit: $EXIT_CODE\" >> .claude/failures.log; fi"
}
]
}
}
Slash Commands
Essential Built-in Commands:
| Command | What It Does |
|---|---|
/help |
Show available commands |
/clear |
Clear conversation context |
/compact |
Summarize and compress context |
/config |
View/edit configuration |
/cost |
Show token usage and costs |
/doctor |
Diagnose setup issues |
/init |
Initialize CLAUDE.md for project |
/mcp |
Manage MCP servers |
/memory |
View/edit memory |
/review |
Review recent changes |
/revert |
Undo recent file changes |
Plan Mode vs. Auto Mode
Plan Mode (Recommended for Learning)
claude --plan
- Claude proposes actions before executing
- You approve or modify the plan
- Safer for complex or risky changes
Auto Mode (For Trusted Tasks)
claude --auto
- Claude executes without asking
- Faster for routine tasks
- Use with good test coverage
Hybrid Approach
- Start projects in plan mode
- Switch to auto for familiar patterns
- Return to plan for critical sections
Tips from Power Users
- Start with the end in mind — "Create a working login page" is better than "Help me code"
- Give Claude the full picture — Share error messages completely, include relevant file context, explain the why not just the what
- Iterate, don't restart — Build on what Claude produces; refine rather than re-prompt
- Let Claude read first — "Read the codebase and understand the patterns before making changes"
- Use Claude for code review — "Review this PR for bugs, security issues, and style"
- Automate the boring stuff — Tests, documentation, boilerplate. Claude is tireless for repetitive tasks
- Trust but verify — Run the tests, review the diff, understand the changes