Project Setup & CLAUDE.md

45 min beginner Lesson 2

Learning Outcomes

  • Understand what CLAUDE.md is and why it's the most important file in your project
  • Write an effective CLAUDE.md that shapes AI behaviour
  • Configure project-level settings and permissions
  • Set up directory conventions Claude understands
  • Share configuration across a team

Lesson Plan

Segment Duration Topic
Intro 3 min Why CLAUDE.md changes everything
Demo 10 min Creating your first CLAUDE.md
Explain 8 min What to include (and what not to)
Demo 10 min Settings, permissions, and .claude/ folder
Explain 7 min Team workflows and shared config
Demo 5 min Before/after comparison
Wrap-up 2 min Key takeaways

Before You Begin

Pre-work:

  • Complete Lesson 1
  • Have a project with at least 5-10 files to configure Claude for

Shopping List:

  • Claude Code installed and authenticated
  • A real project (not an empty folder — Claude needs something to work with)

1 What Is CLAUDE.md?

CLAUDE.md is a special file that Claude Code reads automatically at the start of every session. It's your project's instruction manual for AI — telling Claude:

  • What the project is and how it's structured
  • What conventions to follow
  • What patterns to use (and avoid)
  • How to run, test, and deploy the project

Without CLAUDE.md: Claude guesses based on what it reads. It might use the wrong patterns, wrong naming conventions, or wrong dependency versions.

With CLAUDE.md: Claude starts every conversation with your specific context already loaded. It's like briefing a new team member on day one.

# My Project

## Architecture
- Next.js 14 app router
- PostgreSQL via Prisma
- Tailwind CSS for styling

## Commands
- `npm run dev` — start development server
- `npm test` — run test suite
- `npm run lint` — check code style

## Conventions
- Use named exports (not default exports)
- Components in src/components/[feature]/
- API routes return { data, error } shape
NOTE
Key Insight
CLAUDE.md is the single highest-leverage file you can create for AI-assisted development. 5 minutes writing it saves hours of repeated corrections across sessions.

2 Creating Your First CLAUDE.md

Create the file in your project root:

cd ~/my-project
claude

Then ask Claude to help you write it:

> Analyse this project and create a CLAUDE.md file that describes 
> the architecture, conventions, and common commands. Base it on 
> what you can see in the codebase.

Claude will scan your project and generate a draft. Review it and refine:

> Good start, but:
> - We use vitest not jest
> - Add that we never use default exports
> - Add the database migration command: npx prisma migrate dev

Alternatively, write it yourself. Use this template:

# [Project Name]

## Overview
[One paragraph about what this project does]

## Tech Stack
- [Framework and version]
- [Database]
- [Styling approach]
- [Testing framework]

## Commands
- `[command]` — [what it does]

## Project Structure
- src/app/ — page routes
- src/components/ — shared UI components
- src/lib/ — utility functions
- src/types/ — TypeScript type definitions

## Conventions
- [Convention 1]
- [Convention 2]
- [Convention 3]

## Do NOT
- [Anti-pattern to avoid]
- [Thing that breaks the build]
TIP
Tip
Keep CLAUDE.md under 200 lines. It's loaded into context every session — a massive file wastes context space. Focus on the information that prevents the most common mistakes.

3 What Makes a Great CLAUDE.md

Include:

Section Why
Tech stack + versions Prevents wrong version APIs
Build/run/test commands Claude can run them for you
Naming conventions Consistent code generation
File structure Claude knows where things go
"Do NOT" list Prevents repeated mistakes
Example patterns Shows what correct code looks like

Exclude:

Don't Include Why
Full API documentation Too long, wastes context
Entire dependency list Claude can read package.json
Git history or changelog Irrelevant to current work
Obvious things "Use JavaScript" in a JS project adds nothing

The "Do NOT" section is critical:

## Do NOT
- Use `any` type in TypeScript — always specify types
- Import from barrel files (index.ts) — import directly from source
- Use class components — functional components only
- Add console.log — use our logger (src/lib/logger.ts)
- Modify database schema without a migration

This prevents the same mistakes from recurring across sessions. Every time Claude does something wrong that you have to correct, add it to the "Do NOT" list.

WARNING
Watch Out
Don't write a novel. Every line in CLAUDE.md uses context window space in every session. If you can remove a line without Claude making more mistakes, remove it.

4 The .claude/ Directory

Beyond CLAUDE.md, Claude Code uses a .claude/ directory for configuration:

.claude/
├── settings.json          # Project-level settings
├── settings.local.json    # Personal settings (gitignored)
└── commands/              # Custom slash commands

settings.json — shared team settings:

{
  "permissions": {
    "allow": [
      "Bash(npm test)",
      "Bash(npm run lint)",
      "Bash(npx prisma *)"
    ]
  }
}

This pre-approves specific commands so Claude doesn't ask permission every time.

settings.local.json — personal preferences (add to .gitignore):

{
  "permissions": {
    "allow": [
      "Bash(git *)"
    ]
  }
}

Custom commands in .claude/commands/:

<!-- .claude/commands/fix-lint.md -->
Run `npm run lint`, then fix all fixable issues automatically.
Show me what changed.

Then use with: /fix-lint in your Claude session.

TIP
Tip
Start with just CLAUDE.md. Add .claude/settings.json when you find yourself approving the same commands repeatedly. Add custom commands when you find yourself typing the same prompts repeatedly.

5 Team Collaboration

CLAUDE.md and .claude/settings.json should be committed to your repository. This means:

  • Every team member gets the same AI behaviour
  • New joiners get context immediately
  • AI behaviour evolves with the codebase (via PR reviews)
  • Conventions are enforced automatically

Team workflow:

  1. Initial setup: Senior developer writes first CLAUDE.md
  2. Evolution: Team members add to "Do NOT" list when AI makes mistakes
  3. Review: CLAUDE.md changes go through PR review like any code
  4. Onboarding: New developer installs Claude, runs it — immediately productive

Hierarchy of CLAUDE.md files: Claude reads CLAUDE.md files at multiple levels:

  • ~/CLAUDE.md — global (your personal preferences)
  • ./CLAUDE.md — project root (team shared)
  • ./src/CLAUDE.md — directory-specific (optional, for large monorepos)

All are combined, with more specific files taking precedence.

NOTE
Key Insight
CLAUDE.md is living documentation. It should change every week as you discover new conventions, fix repeated mistakes, and evolve the project. Set a reminder to review it monthly.

6 Before and After — Real Impact

Without CLAUDE.md — asking for a new component:

> Create a UserProfile component

Result: default exports, wrong folder, CSS modules (you use Tailwind), no TypeScript types. You spend 5 minutes correcting.

With CLAUDE.md — same request:

> Create a UserProfile component

Result: named export, correct folder (src/components/user/), Tailwind styling, proper TypeScript types, matches existing component patterns. Ready to use.

The ROI: 5 minutes writing CLAUDE.md × saved 5 minutes per interaction × 20 interactions per day = 100 minutes saved daily.

That's not an exaggeration for active AI users. The cumulative effect of not needing to correct conventions, file locations, and patterns adds up massively.


Questions & Answers

Q: Should CLAUDE.md be in .gitignore?
No — the project-level CLAUDE.md should be committed and shared. Only settings.local.json (personal preferences) should be gitignored.
Q: How often should I update CLAUDE.md?
Whenever Claude makes the same mistake twice. If you find yourself correcting the same thing across sessions, add it to CLAUDE.md so it doesn't happen again.
Q: Can CLAUDE.md be too detailed?
Yes. Over 200 lines starts to waste context. Focus on information that prevents mistakes. If Claude never gets something wrong, you don't need to document it.
Q: What if my team uses different AI tools?
CLAUDE.md is Claude-specific but the content is useful documentation regardless. You can maintain both CLAUDE.md and .cursorrules from the same source of truth.

Key Takeaways

  1. CLAUDE.md is your highest-leverage file — 5 minutes to write, hours saved
  2. Include: tech stack, commands, conventions, anti-patterns, examples
  3. Exclude: obvious info, full documentation, anything Claude can read from files
  4. The "Do NOT" list prevents repeated mistakes — add to it every time Claude errs
  5. Commit to git — share team conventions, evolve via PRs
  6. .claude/ directory for settings, permissions, and custom commands

Next Steps: In Lesson 3 — Creating & Editing Files, you'll learn how Claude creates, modifies, and manages files — the core of AI-assisted development.