CClaude Code Catalog
All Patterns

CLAUDE.md Architecture Patterns

CLAUDE.mdIntermediate

CLAUDE.md files form a hierarchy: global (~/.claude/CLAUDE.md), project root, and subdirectory overrides. This pattern shows how to structure each layer for maximum reuse -- global for personal style and safety rules, project-level for stack-specific conventions, and directory-level for module-specific constraints. Includes templates for monorepos, microservices, and solo projects.

claude-mdconfigurationarchitectureconventions

Pattern Code

# CLAUDE.md Layered Architecture ## Layer 1: Global (~/.claude/CLAUDE.md) ```markdown # Global Rules (apply to ALL projects) ## Safety - Never commit .env files or secrets - Never run destructive git commands without confirmation - Never modify files outside the current project ## Style - Use TypeScript strict mode - Prefer functional patterns over classes - Commit messages: imperative mood, <72 chars ## Communication - Respond in Korean, code in English - Use structured output (headings, lists, tables) ``` ## Layer 2: Project Root (./CLAUDE.md) ```markdown # Project: E-Commerce Platform ## Stack - Runtime: Node.js 20 + TypeScript 5.4 - Framework: Next.js 15 (App Router) - Database: PostgreSQL 16 + Drizzle ORM - Testing: Vitest + Playwright ## Conventions - API routes: src/app/api/[resource]/route.ts - Components: PascalCase, co-located tests - Database migrations: drizzle-kit generate ## Forbidden - Do NOT use any ORM other than Drizzle - Do NOT add runtime dependencies without checking bundle size - Do NOT modify shared types in src/types/ without updating all consumers ``` ## Layer 3: Subdirectory (./src/components/CLAUDE.md) ```markdown # Component Rules - Every component must have a .test.tsx file - Use compound component pattern for complex UI - Props interface must be exported separately - Storybook story required for design-system components ``` ## Resolution Order 1. Subdirectory CLAUDE.md (most specific) 2. Project root CLAUDE.md 3. Global CLAUDE.md (least specific) - More specific rules override general ones - Safety rules from global always apply

Copy this pattern into your project configuration to implement.

Terminal Preview

CLAUDE.md Architecture Patterns

About CLAUDE.md Architecture Patterns

Claude Code patterns are proven architectural designs and workflow structures that help you tackle complex development scenarios. CLAUDE.md Architecture Patterns is a CLAUDE.md pattern at the Intermediate level that provides a tested, repeatable approach you can adapt to your projects for more efficient and consistent results.

Related Patterns