Guide Configuration

CLAUDE.md Setup Guide

CLAUDE.md files give AI agents context about your project. They're read automatically by Claude Code and can be referenced by other AI tools.

# what_is_claude_md

A CLAUDE.md file is a markdown file that provides instructions and context to AI agents working in your codebase. Think of it as a README specifically for AI.

File Locations

  • ~/.claude/CLAUDE.md — Global instructions (all projects)
  • ./CLAUDE.md — Project root (project-specific)
  • ./src/CLAUDE.md — Directory-specific overrides

# basic_example

Start with the essentials. A minimal CLAUDE.md that covers the basics:

# Project Instructions

## Project Overview
Brief description of what this project is and its goals.

## Tech Stack
- Framework: Next.js 14
- Styling: Tailwind CSS
- Database: PostgreSQL with Prisma
- Auth: NextAuth.js

## Coding Standards
- Use TypeScript for all new files
- Follow existing code patterns
- Run `npm run lint` before committing
- Write tests for new features

## File Structure
- `src/components/` - Reusable UI components
- `src/app/` - Next.js app router pages
- `src/lib/` - Utilities and helpers
- `prisma/` - Database schema

## Common Commands
```bash
npm run dev      # Start development server
npm run build    # Production build
npm run test     # Run tests
npm run db:push  # Push schema changes
```

# advanced_example

A more comprehensive CLAUDE.md with patterns, verification steps, and context:

# Claude Code Instructions

## Identity
You are working on [Project Name], a [description].
Owner: [Your Name]

## Critical Rules
- NEVER commit without asking first
- ALWAYS run tests before marking tasks complete
- Use existing patterns - check similar files first
- Keep changes minimal and focused

## Project Context
This is a [type] application that [purpose].
Key users: [who uses this]
Main goal: [what it achieves]

## Verification Pipeline
After every change:
1. Read back the file to verify
2. Run linter: `npm run lint`
3. Run tests: `npm test`
4. Check build: `npm run build`

## API Keys & Secrets
- Never log or display API keys
- Use environment variables
- Check .env.example for required vars

## External Services
- Database: [connection details]
- API: [endpoint patterns]
- Auth: [provider info]

## Common Patterns

### Creating a new component
```tsx
// src/components/MyComponent.tsx
interface Props {
  // Define props with types
}

export function MyComponent({ prop }: Props) {
  return (
    // JSX
  );
}
```

### API Route Pattern
```ts
// src/app/api/resource/route.ts
import { NextResponse } from 'next/server';

export async function GET() {
  // Handle GET
}

export async function POST(req: Request) {
  const body = await req.json();
  // Validate with Zod
  // Handle POST
}
```

# global_claude_md

Your global CLAUDE.md at ~/.claude/CLAUDE.md applies to all projects. Use it for personal preferences that don't change between projects:

# Global Claude Instructions

## Who I Am
[Your name and role]

## My Preferences
- Concise responses, no unnecessary preamble
- Show code examples over lengthy explanations
- Ask before making destructive changes
- Commit messages in conventional format

## My Environment
- OS: [Windows/macOS/Linux]
- Editor: [VSCode/Cursor/etc]
- Terminal: [bash/zsh/PowerShell]
- Node version: [version]

## Common Workflows

### Starting a new feature
1. Create a branch: `git checkout -b feature/name`
2. Implement the feature
3. Write tests
4. Create PR

### Debugging
1. Check error logs first
2. Add strategic console.logs
3. Use debugger if needed
4. Remove debug code before commit

## Aliases & Scripts
```bash
# My common commands
alias gst='git status'
alias gc='git commit'
alias dev='npm run dev'
```

## Projects
- ~/code/project1 - Main SaaS app
- ~/code/project2 - Marketing site
- ~/code/tools - CLI utilities

# best_practices

Be Specific

Instead of "follow best practices," say "run npm run lint before committing"

Include Patterns

Show code examples for common patterns in your project

Document Constraints

List things the agent should NOT do (e.g., "never modify package-lock.json directly")

Keep It Updated

Review and update as your project evolves

Don't Include Secrets

CLAUDE.md may be committed to git. Never put API keys or passwords here.

# works_with

While designed for Claude Code, this pattern works with many AI tools:

Native Support

  • • Claude Code (automatic)
  • • Cursor (.cursorrules)
  • • Aider (.aider.conf.yml)

Manual Reference

  • • ChatGPT (paste as context)
  • • Claude.ai (upload file)
  • • Any LLM (include in prompt)