Tools: Claude Code CLAUDE.md: the one file that makes your AI sessions 10x more consistent - Analysis

Tools: Claude Code CLAUDE.md: the one file that makes your AI sessions 10x more consistent - Analysis

Claude Code CLAUDE.md: the one file that makes your AI sessions 10x more consistent

What CLAUDE.md actually is

The 5 sections every CLAUDE.md needs

1. Project overview (3-5 lines max)

2. Tech stack (explicit versions)

3. Coding conventions

4. What NOT to do

5. Current context (update frequently)

Real example: before and after

Advanced: nested CLAUDE.md files

The rate limit problem with long CLAUDE.md files

Template you can use today

One more thing If you've been using Claude Code for more than a week, you've noticed the inconsistency problem. Monday: Claude remembers your project structure, follows your coding conventions, knows you prefer TypeScript strict mode. Friday: Same project, new session. Claude suggests JavaScript. Proposes a pattern you explicitly banned. Forgets your testing framework. The problem isn't Claude's memory. It's that you're not giving it one. CLAUDE.md is a markdown file you place at the root of your project. Claude Code reads it automatically at the start of every session. It's not magic. It's just a file that gets prepended to your context window. But that simple mechanic makes it the highest-ROI thing you can do for consistent Claude Code sessions. Now Claude will read it every time you open Claude Code in that directory. This single section eliminates the biggest source of Claude drift: not knowing where the boundaries are. Be explicit. Claude has trained on millions of codebases and will default to whatever it saw most often. Your constraints override that. This is where you encode your team's decisions. These are the rules that new developers take weeks to learn. Claude learns them in one file read. Negative constraints are often more important than positive ones. Claude is optimistic by default — it will add logging, install packages, and use any when it seems convenient. Explicit prohibitions stop this. This section changes week to week. It's where you put the "situational awareness" that would take 10 minutes to explain in every session. You: Add error handling to this payment webhook Claude: Here's the updated function. I added a try/catch and console.error for debugging, and used Promise.then() for the async chain. Three violations in one response. You: Add error handling to this payment webhook Claude: Here's the updated function using the Result pattern. I'm using your logger utility for errors. Note: I avoided modifying the deduplication logic since you mentioned PR #447 is pending. Claude is now working with your context instead of against it. Claude Code respects CLAUDE.md files at multiple levels: The nested file adds context when you're working in that subdirectory. Global rules still apply. Useful for monorepos where different packages have different conventions. Here's the tradeoff: every line in CLAUDE.md costs tokens. In every session. Forever. A 500-line CLAUDE.md will eat through your context window faster. Long sessions will hit limits sooner. The solution is to keep CLAUDE.md focused: project structure, non-negotiable conventions, current blockers. Move detailed documentation to separate files that you reference in CLAUDE.md: If you're hitting token limits and rate limits frequently despite this optimization, there's a practical workaround: use ANTHROPIC_BASE_URL to point to a service like SimplyLouie that provides the same Claude API at a much lower monthly cost. At ���️$2/month it makes running longer sessions daily economically sustainable. Copy this. Fill it in for your project. Commit it. Your sessions will be immediately more consistent. CLAUDE.md is also useful for onboarding human developers. New teammate? They can read your CLAUDE.md and get the same situational awareness Claude gets. It forces you to write down the unwritten rules. Document for the AI. Get human-readable docs for free. If you're spending too much on Claude subscriptions, SimplyLouie offers the same API at ✌️$2/month — useful for teams running multiple Claude Code sessions daily. Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to ? It will become hidden in your post, but will still be visible via the comment's permalink. as well , this person and/or

Command
Stack - Node.js 20.x (NOT 18.x) - TypeScript 5.4 with strict mode - Prisma 5.x for database (NOT raw SQL) - Jest for testing (NOT Vitest) - pnpm (NOT npm or yarn) COMMAND_BLOCK:

Stack - Node.js 20.x (NOT 18.x) - TypeScript 5.4 with strict mode - Prisma 5.x for database (NOT raw SQL) - Jest for testing (NOT Vitest) - pnpm (NOT npm or yarn) COMMAND_BLOCK:

Stack - Node.js 20.x (NOT 18.x) - TypeScript 5.4 with strict mode - Prisma 5.x for database (NOT raw SQL) - Jest for testing (NOT Vitest) - pnpm (NOT npm or yarn) COMMAND_BLOCK:

Conventions - Always use async/await, never .then() chains - Error handling: always use Result pattern, never throw - All database calls go through /src/db/client.ts - never import Prisma directly - Functions max 30 lines. If longer, break into helpers. - No comments that explain WHAT the code does. Comments explain WHY. COMMAND_BLOCK:

Conventions - Always use async/await, never .then() chains - Error handling: always use Result pattern, never throw - All database calls go through /src/db/client.ts - never import Prisma directly - Functions max 30 lines. If longer, break into helpers. - No comments that explain WHAT the code does. Comments explain WHY. COMMAND_BLOCK:

Conventions - Always use async/await, never .then() chains - Error handling: always use Result pattern, never throw - All database calls go through /src/db/client.ts - never import Prisma directly - Functions max 30 lines. If longer, break into helpers. - No comments that explain WHAT the code does. Comments explain WHY. COMMAND_BLOCK:

Do NOT - Do NOT add console.log for debugging (use the logger utility) - Do NOT modify /src/legacy/ - this is frozen code - Do NOT install new packages without asking first - Do NOT use `any` type in TypeScript - Do NOT add TODO comments - if it needs doing, do it now or create a GitHub issue COMMAND_BLOCK:

Do NOT - Do NOT add console.log for debugging (use the logger utility) - Do NOT modify /src/legacy/ - this is frozen code - Do NOT install new packages without asking first - Do NOT use `any` type in TypeScript - Do NOT add TODO comments - if it needs doing, do it now or create a GitHub issue COMMAND_BLOCK:

Do NOT - Do NOT add console.log for debugging (use the logger utility) - Do NOT modify /src/legacy/ - this is frozen code - Do NOT install new packages without asking first - Do NOT use `any` type in TypeScript - Do NOT add TODO comments - if it needs doing, do it now or create a GitHub issue COMMAND_BLOCK:

Current focus Migrating from Stripe v2 webhooks to v3. Reference: /docs/stripe-v3-migration.md Known issue: webhook deduplication is broken in production. Fix is in PR #447. Do NOT touch the deduplication code until PR #447 is merged. COMMAND_BLOCK:

Current focus Migrating from Stripe v2 webhooks to v3. Reference: /docs/stripe-v3-migration.md Known issue: webhook deduplication is broken in production. Fix is in PR #447. Do NOT touch the deduplication code until PR #447 is merged. COMMAND_BLOCK:

Current focus Migrating from Stripe v2 webhooks to v3. Reference: /docs/stripe-v3-migration.md Known issue: webhook deduplication is broken in production. Fix is in PR #447. Do NOT touch the deduplication code until PR #447 is merged. COMMAND_BLOCK: your-project/ ├── CLAUDE.md # Global project rules ├── src/ │ ├── payments/ │ │ └── CLAUDE.md # Payment-specific rules │ └── auth/ │ └── CLAUDE.md # Auth-specific rules COMMAND_BLOCK: your-project/ ├── CLAUDE.md # Global project rules ├── src/ │ ├── payments/ │ │ └── CLAUDE.md # Payment-specific rules │ └── auth/ │ └── CLAUDE.md # Auth-specific rules COMMAND_BLOCK: your-project/ ├── CLAUDE.md # Global project rules ├── src/ │ ├── payments/ │ │ └── CLAUDE.md # Payment-specific rules │ └── auth/ │ └── CLAUDE.md # Auth-specific rules COMMAND_BLOCK:

Architecture See /docs/architecture.md for the full system diagram. Key constraint: all external API calls go through /src/gateway/ — never directly. COMMAND_BLOCK:

Architecture See /docs/architecture.md for the full system diagram. Key constraint: all external API calls go through /src/gateway/ — never directly. COMMAND_BLOCK:

Architecture See /docs/architecture.md for the full system diagram. Key constraint: all external API calls go through /src/gateway/ — never directly. COMMAND_BLOCK: # Project: [NAME] [2-3 sentence description of what this does and what it owns]

Stack - [Runtime + version] - [Language + version] - [Key frameworks + versions] - [Test framework] - [Package manager]

Conventions - [Async pattern] - [Error handling pattern] - [File organization rule] - [Naming conventions]

Do NOT - [Most common mistake #1] - [Most common mistake #2] - [Frozen files/directories]

Current focus [What's happening this week. Update every Monday.] [Active PRs that Claude should know about] [Known issues Claude should avoid touching] COMMAND_BLOCK: # Project: [NAME] [2-3 sentence description of what this does and what it owns]

Stack - [Runtime + version] - [Language + version] - [Key frameworks + versions] - [Test framework] - [Package manager]

Conventions - [Async pattern] - [Error handling pattern] - [File organization rule] - [Naming conventions]

Do NOT - [Most common mistake #1] - [Most common mistake #2] - [Frozen files/directories]

Current focus [What's happening this week. Update every Monday.] [Active PRs that Claude should know about] [Known issues Claude should avoid touching] COMMAND_BLOCK: # Project: [NAME] [2-3 sentence description of what this does and what it owns]

Stack - [Runtime + version] - [Language + version] - [Key frameworks + versions] - [Test framework] - [Package manager]

Conventions - [Async pattern] - [Error handling pattern] - [File organization rule] - [Naming conventions]

Do NOT - [Most common mistake #1] - [Most common mistake #2] - [Frozen files/directories]

Current focus [What's happening this week. Update every Monday.] [Active PRs that Claude should know about] [Known issues Claude should avoid touching]" style="background: linear-gradient(135deg, #6a5acd 0%, #5a4abd 100%); color: #fff; border: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 600; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 12px rgba(106, 90, 205, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1); position: relative; overflow: hidden;">

Copy

# Create it touch CLAUDE.md COMMAND_BLOCK: # Create it touch CLAUDE.md COMMAND_BLOCK: # Create it touch CLAUDE.md COMMAND_BLOCK: # Project: PaymentService Node.js microservice handling Stripe webhooks and subscription state. Part of a larger monorepo. This -weight: 500;">service owns the `payments` database schema. Do NOT modify anything outside /src/payments/. COMMAND_BLOCK: # Project: PaymentService Node.js microservice handling Stripe webhooks and subscription state. Part of a larger monorepo. This -weight: 500;">service owns the `payments` database schema. Do NOT modify anything outside /src/payments/. COMMAND_BLOCK: # Project: PaymentService Node.js microservice handling Stripe webhooks and subscription state. Part of a larger monorepo. This -weight: 500;">service owns the `payments` database schema. Do NOT modify anything outside /src/payments/. COMMAND_BLOCK:

Stack - Node.js 20.x (NOT 18.x) - TypeScript 5.4 with strict mode - Prisma 5.x for database (NOT raw SQL) - Jest for testing (NOT Vitest) - pnpm (NOT -weight: 500;">npm or yarn) COMMAND_BLOCK:

Stack - Node.js 20.x (NOT 18.x) - TypeScript 5.4 with strict mode - Prisma 5.x for database (NOT raw SQL) - Jest for testing (NOT Vitest) - pnpm (NOT -weight: 500;">npm or yarn) COMMAND_BLOCK:

Stack - Node.js 20.x (NOT 18.x) - TypeScript 5.4 with strict mode - Prisma 5.x for database (NOT raw SQL) - Jest for testing (NOT Vitest) - pnpm (NOT -weight: 500;">npm or yarn) COMMAND_BLOCK:

Conventions - Always use async/await, never .then() chains - Error handling: always use Result<T, E> pattern, never throw - All database calls go through /src/db/client.ts - never import Prisma directly - Functions max 30 lines. If longer, break into helpers. - No comments that explain WHAT the code does. Comments explain WHY. COMMAND_BLOCK:

Conventions - Always use async/await, never .then() chains - Error handling: always use Result<T, E> pattern, never throw - All database calls go through /src/db/client.ts - never import Prisma directly - Functions max 30 lines. If longer, break into helpers. - No comments that explain WHAT the code does. Comments explain WHY. COMMAND_BLOCK:

Conventions - Always use async/await, never .then() chains - Error handling: always use Result<T, E> pattern, never throw - All database calls go through /src/db/client.ts - never import Prisma directly - Functions max 30 lines. If longer, break into helpers. - No comments that explain WHAT the code does. Comments explain WHY. COMMAND_BLOCK:

Do NOT - Do NOT add console.log for debugging (use the logger utility) - Do NOT modify /src/legacy/ - this is frozen code - Do NOT -weight: 500;">install new packages without asking first - Do NOT use `any` type in TypeScript - Do NOT add TODO comments - if it needs doing, do it now or create a GitHub issue COMMAND_BLOCK:

Do NOT - Do NOT add console.log for debugging (use the logger utility) - Do NOT modify /src/legacy/ - this is frozen code - Do NOT -weight: 500;">install new packages without asking first - Do NOT use `any` type in TypeScript - Do NOT add TODO comments - if it needs doing, do it now or create a GitHub issue COMMAND_BLOCK:

Do NOT - Do NOT add console.log for debugging (use the logger utility) - Do NOT modify /src/legacy/ - this is frozen code - Do NOT -weight: 500;">install new packages without asking first - Do NOT use `any` type in TypeScript - Do NOT add TODO comments - if it needs doing, do it now or create a GitHub issue COMMAND_BLOCK:

Current focus Migrating from Stripe v2 webhooks to v3. Reference: /docs/stripe-v3-migration.md Known issue: webhook deduplication is broken in production. Fix is in PR #447. Do NOT touch the deduplication code until PR #447 is merged. COMMAND_BLOCK:

Current focus Migrating from Stripe v2 webhooks to v3. Reference: /docs/stripe-v3-migration.md Known issue: webhook deduplication is broken in production. Fix is in PR #447. Do NOT touch the deduplication code until PR #447 is merged. COMMAND_BLOCK:

Current focus Migrating from Stripe v2 webhooks to v3. Reference: /docs/stripe-v3-migration.md Known issue: webhook deduplication is broken in production. Fix is in PR #447. Do NOT touch the deduplication code until PR #447 is merged. COMMAND_BLOCK: your-project/ ├── CLAUDE.md # Global project rules ├── src/ │ ├── payments/ │ │ └── CLAUDE.md # Payment-specific rules │ └── auth/ │ └── CLAUDE.md # Auth-specific rules COMMAND_BLOCK: your-project/ ├── CLAUDE.md # Global project rules ├── src/ │ ├── payments/ │ │ └── CLAUDE.md # Payment-specific rules │ └── auth/ │ └── CLAUDE.md # Auth-specific rules COMMAND_BLOCK: your-project/ ├── CLAUDE.md # Global project rules ├── src/ │ ├── payments/ │ │ └── CLAUDE.md # Payment-specific rules │ └── auth/ │ └── CLAUDE.md # Auth-specific rules COMMAND_BLOCK:

Architecture See /docs/architecture.md for the full system diagram. Key constraint: all external API calls go through /src/gateway/ — never directly. COMMAND_BLOCK:

Architecture See /docs/architecture.md for the full system diagram. Key constraint: all external API calls go through /src/gateway/ — never directly. COMMAND_BLOCK:

Architecture See /docs/architecture.md for the full system diagram. Key constraint: all external API calls go through /src/gateway/ — never directly. COMMAND_BLOCK: # Project: [NAME] [2-3 sentence description of what this does and what it owns]

Stack - [Runtime + version] - [Language + version] - [Key frameworks + versions] - [Test framework] - [Package manager]

Conventions - [Async pattern] - [Error handling pattern] - [File organization rule] - [Naming conventions]

Do NOT - [Most common mistake #1] - [Most common mistake #2] - [Frozen files/directories]

Current focus [What's happening this week. Update every Monday.] [Active PRs that Claude should know about] [Known issues Claude should avoid touching] COMMAND_BLOCK: # Project: [NAME] [2-3 sentence description of what this does and what it owns]

Stack - [Runtime + version] - [Language + version] - [Key frameworks + versions] - [Test framework] - [Package manager]

Conventions - [Async pattern] - [Error handling pattern] - [File organization rule] - [Naming conventions]

Do NOT - [Most common mistake #1] - [Most common mistake #2] - [Frozen files/directories]

Current focus [What's happening this week. Update every Monday.] [Active PRs that Claude should know about] [Known issues Claude should avoid touching] COMMAND_BLOCK: # Project: [NAME] [2-3 sentence description of what this does and what it owns]

Stack - [Runtime + version] - [Language + version] - [Key frameworks + versions] - [Test framework] - [Package manager]

Conventions - [Async pattern] - [Error handling pattern] - [File organization rule] - [Naming conventions]

Do NOT - [Most common mistake #1] - [Most common mistake #2] - [Frozen files/directories]

Current focus [What's happening this week. Update every Monday.] [Active PRs that Claude should know about] [Known issues Claude should avoid touching]