CLAUDE.md लिखने की Complete Guide: Project Configuration की Best Practices
Effective CLAUDE.md files लिखने की thorough guide। अपना tech stack, conventions, और project structure communicate करना सीखें और Claude Code की output quality maximize करें।
CLAUDE.md क्या है?
CLAUDE.md एक context file है जो Claude Code को आपका project समझने में help करती है। इसे अपने project root में रखें, और Claude Code हर session की शुरुआत में इसे automatically read करता है। एक अच्छी तरह लिखी CLAUDE.md Claude Code के responses की quality dramatically improve कर सकती है।
File Locations और Priority
CLAUDE.md files multiple locations में रख सकते हैं, और सभी load होती हैं:
~/.claude/CLAUDE.md # Global settings (सभी projects में shared)
./CLAUDE.md # Project root (team के साथ shared)
./CLAUDE.local.md # Local settings (.gitignore में add करें)
./src/CLAUDE.md # Subdirectory-level settings
- Global: आपकी personal coding style preferences
- Project root: Team-shared rules और tech stack
- Local: Git में commit न होने वाली personal settings
- Subdirectory: Specific modules के लिए additional context
Starter Template
यहाँ एक practical CLAUDE.md template है:
# Project Overview
E-commerce backend API। Order management, inventory, और user authentication handle करता है।
## Tech Stack
- Language: TypeScript 5.x
- Runtime: Node.js 22
- Framework: Fastify
- DB: PostgreSQL 16 + Prisma ORM
- Testing: Vitest
- CI: GitHub Actions
## Directory Structure
src/
routes/ # API endpoint definitions
services/ # Business logic
repositories/ # Data access layer
middleware/ # Auth, logging, error handling
utils/ # Utility functions
types/ # Type definitions
## Coding Conventions
- Arrow functions use करें
- Custom error classes के साथ हमेशा try-catch use करें
- Naming: camelCase (variables/functions), PascalCase (types/classes)
- File names: kebab-case
- Relative imports की बजाय path alias `@/` use करें
## Common Commands
- Tests run: `npm test`
- Type check: `npx tsc --noEmit`
- Lint: `npm run lint`
- DB migration: `npx prisma migrate dev`
- Dev server: `npm run dev`
## Important Rules
- prisma/schema.prisma change करने के बाद हमेशा migration create करें
- हर API endpoint में Zod validation schema होना चाहिए
- New routes routes/index.ts में register करें
Effective CLAUDE.md लिखने की Tips
1. Concise रखें
CLAUDE.md context window tokens consume करती है। Verbose explanations avoid करें और bullet points use करें।
# Bad example
This project uses TypeScript. TypeScript is a language developed
by Microsoft that adds types to JavaScript...
# Good example
- Language: TypeScript 5.x (strict mode)
2. जो नहीं चाहिए वो Document करें
Anti-patterns explicitly list करना surprisingly effective है।
## Prohibited
- `any` types नहीं
- Default exports नहीं (सिर्फ named exports)
- Debugging के लिए console.log नहीं (logger use करें)
- Existing tests कभी delete या skip न करें
3. Workflows Define करें
Claude Code को guide करें कि tasks कैसे approach करने चाहिए।
## New Feature Add करना
1. `src/types/` में type definitions create करें
2. `src/repositories/` में data access layer implement करें
3. `src/services/` में business logic implement करें
4. `src/routes/` में endpoints define करें
5. हर layer के लिए unit tests लिखें
6. `npm test` से verify करें कि सभी tests pass हैं
4. Tribal Knowledge Capture करें
Important information document करें जो कहीं और लिखी नहीं है।
## Project-Specific Notes
- `user_id` UUID v7 use करता है (time-sortable ordering के लिए)
- सभी price calculations `Decimal.js` use करनी चाहिए (floating-point errors avoid करने के लिए)
- Environment variables `src/config.ts` में centralized हैं — कभी directly process.env access न करें
Team Usage
.gitignore Setup
Personal settings version control से बाहर रखें:
# .gitignore
CLAUDE.local.md
Code Reviews में Include करें
CLAUDE.md को एक important project document treat करें। PR reviews में include करें और team के रूप में up to date रखें।
CLAUDE.md कब Update करें
- जब नई library add करें
- जब coding conventions change करें
- जब directories restructure करें
- जब notice करें कि Claude Code बार-बार same mistake कर रहा है
Conclusion
CLAUDE.md Claude Code को आपके specific project का expert बना देती है। /init से scaffold generate करके शुरू करें, फिर काम करते हुए refine करें। Team के साथ share करें ताकि सभी optimized Claude Code interactions का benefit ले सकें।