The complete guide to writing CLAUDE.md for vibe coding quality
CLAUDE.md is your project's instruction manual. Think of it like the onboarding document you'd give a new team member. Claude Code reads this file first when starting work and follows all the rules written in it.
Without CLAUDE.md, you'd repeat the same instructions every conversation — "Use TypeScript", "Write comments in English", "Include tests too". Write it once in CLAUDE.md, and Claude Code always follows these rules.
| Location | Scope | Example |
|---|---|---|
project-root/CLAUDE.md | This project only | Tech stack, coding rules |
~/.claude/CLAUDE.md | All your projects | Preferred language, style |
subfolder/CLAUDE.md | That folder only | Module-specific rules |
A good CLAUDE.md includes these 5 things:
# CLAUDE.md
## Project Overview
This is a personal blog website.
Built with Next.js 15 App Router, deployed on Vercel.## Tech Stack
- Framework: Next.js 15 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- DB: Supabase (PostgreSQL)
- Deployment: Vercel## Coding Conventions
- Components: Functional components only (no class components)
- File names: kebab-case (e.g., user-profile.tsx)
- Comments: Write in English
- Import order: React → Libraries → Internal modules## Commands
- Dev server: `npm run dev`
- Build: `npm run build`
- Test: `npm test`
- Lint: `npm run lint`## Don'ts
- Never commit .env files
- No `any` type usage
- Don't leave console.log in production code
- Never modify node_modules directly# CLAUDE.md
## Overview
Next.js 15 App Router web application.
## Tech Stack
- Next.js 15, TypeScript, Tailwind CSS
- Supabase (Auth + DB), Vercel deployment
## Commands
- `npm run dev` — Dev server (localhost:3000)
- `npm run build` — Production build
- `npm run lint` — ESLint check
## Conventions
- Server Components by default, 'use client' only when needed
- API routes under app/api/
- Environment variables in .env.local (never commit)
- Component files PascalCase, utilities camelCase
## Don'ts
- Don't overuse 'use client' (prefer Server Components)
- Use Tailwind utilities instead of inline styles
- No `any` type# CLAUDE.md
## Overview
Cross-platform mobile app built with React Native (Expo).
## Tech Stack
- Expo SDK 52, TypeScript
- React Navigation, Zustand (state management)
- Supabase (Backend)
## Commands
- `npx expo start` — Dev server
- `npx expo run:ios` — iOS build
- `npx expo run:android` — Android build
## Conventions
- Screen components: screens/ folder
- Shared components: components/ folder
- Platform-specific code: use Platform.select()
- Styles: use StyleSheet.create()
## Don'ts
- No web-only APIs (window, document)
- Don't bundle large images# CLAUDE.md
## Overview
REST API server built with FastAPI.
## Tech Stack
- Python 3.12, FastAPI, SQLAlchemy
- PostgreSQL, Alembic (migrations)
- Docker deployment
## Commands
- `uvicorn main:app --reload` — Dev server
- `alembic upgrade head` — DB migration
- `pytest` — Run tests
## Conventions
- Routes: routers/ folder, separated by domain
- Pydantic schemas: schemas/ folder
- Business logic: services/ folder
- Type hints required
## Don'ts
- Don't put business logic in route handlers
- Don't call sync I/O in async routes
- Don't write raw SQL strings (use SQLAlchemy ORM)| # | Bad (Vague) | Good (Specific) |
|---|---|---|
| 1 | "Write good code" | "Functions under 30 lines, single responsibility" |
| 2 | "Write tests" | "Add Jest tests in __tests__/ for each new function, minimum 2 cases" |
| 3 | "Handle errors" | "Wrap API calls in try-catch, show toast notification to user" |
| 4 | "Clean code" | "Remove unused imports, no console.log, meaningful variable names" |
| 5 | "Be secure" | "Validate all user input with zod, SQL via parameterized queries only" |
Good rules are ones AI can follow without judgment calls.
# CLAUDE.md
## Project
Monthly subscription AI writing assistant SaaS. MVP stage.
## Stack
Next.js 15, TypeScript, Tailwind, Supabase, Stripe
## Core Rules
1. All pages are Server Components by default
2. Client state uses Zustand (no Redux)
3. DB queries via Supabase JS Client only
4. Payment code must be server-side only
5. Env vars: NEXT_PUBLIC_ prefix only for public values
6. Commits: conventional commits (feat:, fix:, docs:)
## Priority
- Make it work > Perfect code
- User experience > Developer convenience
- Simple implementation > Scalable architecture (it's an MVP)# CLAUDE.md
## Project
My portfolio website. I'm a designer and this is my first time coding.
## Requests
- Add detailed comments to all code in plain English
- When new concepts come up, explain in simple terms
- Before running dangerous commands, explain first
- When changing files, tell me why
## Rules
- Readable code over clever code
- Minimal external libraries
- When errors occur, explain what went wrong simplyIf you're a non-developer, state "I don't know coding" in your CLAUDE.md. Claude Code will explain more patiently and ask for confirmation before risky operations.
Now that you know how to write CLAUDE.md: