Skip to content
gentic.news — AI News Intelligence Platform
Connecting to the Living Graph…

Listen to today's AI briefing

Daily podcast — 5 min, AI-narrated summary of top stories

Developer deleting lines from a code file in an editor, with a large CLAUDE.md document shrinking down beside a…

Cut Your CLAUDE.md from 312 Lines to 67

Cut your CLAUDE.md to under 100 lines. The 67-line version outperformed the 312-line one because Claude ignores irrelevant rules. Only keep rules that prevent repeated mistakes.

·11h ago·5 min read··25 views·AI-Generated·Report error
Share:
Source: dev.tovia devto_claudecodeMulti-Source
How do I write a CLAUDE.md that Claude Code actually follows?

Delete 75% of your CLAUDE.md. A 67-line file outperforms a 312-line one because Claude treats rules as context, not commands — irrelevant lines get ignored and push real rules out of the context window. Only keep rules that prevent repeated mistakes.

TL;DR

Shorter CLAUDE.md files work better. Delete 75% of your rules and Claude will follow the rest.

Key Takeaways

  • Cut your CLAUDE.md to under 100 lines.
  • The 67-line version outperformed the 312-line one because Claude ignores irrelevant rules.
  • Only keep rules that prevent repeated mistakes.

The Technique: Delete, Don't Add

Everyone says your CLAUDE.md should encode every rule you want Claude Code to follow. That's wrong.

The best CLAUDE.md is the shortest one that gets the agent to your bar. Rules you wrote and never enforced become noise that pushes the real instructions out of the cache window.

The proof: one developer's file went from 312 lines (barely worked) to 142 lines (worked better) to 67 lines (the version Claude actually follows).

Why It Works: CLAUDE.md Is Context, Not Commands

Claude Code injects your CLAUDE.md as a user message into the conversation. It attaches a system reminder saying roughly: "This context may or may not be relevant to your current task. Only reference it when actually relevant."

Claude decides which rules apply. The longer your file and the more irrelevant content it contains, the higher the probability that useful rules get skipped.

A single bad line cascades like dominoes:

One wrong instruction
    -> Every research step follows the wrong lead
        -> Plans built on bad research drift further
            -> Code written from drifted plans breaks in production

The reverse holds too. One correct line saves time across every session.

How To Apply It: The 3-Rewrite Method

Rewrite 1: Cut everything Claude can infer from code.

Why Does CLAUDE.md Matter More Than Any Other Config? technical diagram for CLAUDE.md Best Practices

Delete: "This project uses TypeScript" (you have tsconfig.json). Delete: "Python uses snake_case" (standard convention). Delete: "Please write high-quality code" (unverifiable, changes nothing).

Rewrite 2: Cut everything you've never enforced.

If you wrote a rule and Claude ignored it for 3 weeks, the rule is noise. Delete it.

Rewrite 3: Cut everything that isn't about repeated mistakes.

Hacker News comment from Boris on the Claude Code team: "If there is anything Claude tends to repeatedly get wrong, not understand, or spend lots of tokens on, put it in your CLAUDE.md. I add to my team's CLAUDE.md multiple times a week."

The file is supposed to be small enough that you can edit it mid-task.

The 6 Rules That Survived

The final 67-line file contained only six rules:

CLAUDE.md Best Practices: Karpathy's 4 Principles + 6 Ready-to-Use Templates (2026) technical illustration for AI Workflow Pro readers

  1. Build commands Claude cannot guess from code (e.g., pnpm test:e2e --filter=@app/web)
  2. Code style deviations from conventions (e.g., your team bans default exports)
  3. Test runner and framework details Claude can't infer
  4. Branch naming conventions and PR habits
  5. Why you made an architecture decision (not just "use X" but "use X because Y")
  6. Counter-intuitive gotchas and dev environment quirks

The Four-Layer Scope System

Your CLAUDE.md isn't one file. It's four layers that stack (later layers don't override earlier ones):

CLAUDE.md Best Practices: Karpathy''s 4 Principles + 6 Ready-to-Use Templates (2026) technical illustration for AI Workflow Pro readers

Managed policy /Library/Application Support/ClaudeCode/CLAUDE.md Entire organization User instructions ~/.claude/CLAUDE.md You, across all projects Project instructions ./CLAUDE.md or ./.claude/CLAUDE.md Team-shared, in Git Local instructions ./CLAUDE.local.md You, current project, not in Git

Pro tip: For domain-specific rules, use .claude/rules/ with paths: constraints. They only load when Claude touches matching files. This solved the classic problem of a database spec being ignored during frontend edits.

Anti-Pattern Checklist

Run this audit on your existing CLAUDE.md:

  • Is it over 100 lines? Cut it.
  • Does it contain "prefer" or "please"? Rewrite or delete.
  • Does it state what's already in tsconfig.json, package.json, or README? Delete.
  • Does it contain more than 2 all-caps IMPORTANT lines? Reduce to zero.
  • Can you edit it mid-task without scrolling? If not, it's too long.

Try It Now

Open your current CLAUDE.md. Delete everything except:

  1. Build/test commands Claude can't guess
  2. Style deviations from conventions
  3. Architecture decisions and the why
  4. Gotchas that have burned you more than once

If you're at 67 lines, you're done. If you're at 300, you know what to do.


Source: dev.to

[Updated 26 Aug via devto_claudecode]

The guide also draws on teardowns of five real-world files, including Karpathy's 185K-star behavioral principles, Anthropic's internal config, and Dan Abramov's commit message constraints — showing even elite setups follow the same trim-or-ignore pattern. It introduces the router pattern for projects that outgrow a single file, plus six role-specific templates (frontend, backend, solo founder, content creator, data analyst, student) so you can start from a matching base rather than boilerplate. The HumanLayer founder Kyle's domino analogy is credited explicitly [per AI Workflow Pro].

Sources cited in this article

  1. AI Workflow Pro
Source: gentic.news · · author= · citation.json

AI-assisted reporting. Generated by gentic.news from 1 verified source, fact-checked against the Living Graph of 4,300+ entities. Edited by Ala SMITH.

Following this story?

Get a weekly digest with AI predictions, trends, and analysis — free.

AI Analysis

Claude Code users should treat CLAUDE.md as a living document that shrinks over time, not grows. The instinct to add rules when Claude misbehaves is backwards — the fix is usually to delete competing rules that create noise. Start using the `.claude/rules/` directory with `paths:` constraints for domain-specific rules instead of cramming everything into the root file. This keeps the main file under 100 lines while still giving Claude the context it needs when touching specific modules. Second, adopt the "edit mid-task" workflow. When Claude repeats a mistake, add the correction to CLAUDE.md immediately — but only if it's something Claude can't infer from the codebase. If you can't defend a line's existence with a specific failure it prevents, delete it. The 67-line file isn't minimal for its own sake; it's the size that maximizes the probability every rule gets applied because nothing competes for attention in the context window.
This story is part of
The Protocol Schism: Anthropic's MCP Stack vs. OpenAI's Agent Lock-In
How a developer convention is splitting AI into two incompatible ecosystems, with Meta and Google caught in the middle

Mentioned in this article

Enjoyed this article?
Share:

AI Toolslive

Five one-click lenses on this article. Cached for 24h.

Pick a tool above to generate an instant lens on this article.

Related Articles

From the lab

The framework underneath this story

Every article on this site sits on top of one engine and one framework — both built by the lab.

More in Opinion & Analysis

View all