Skip to content

CLAUDE.md Line Limit: Fix Ignored Instructions After 100 Lines

Problem

When I added more rules to my CLAUDE.md file to improve Claude’s compliance, the instructions started getting ignored even more. I thought more rules would help, but it made things worse.

Here’s what happened:

My CLAUDE.md kept growing
# Original: 100 lines → Good compliance
# Added rules: 150 lines → Inconsistent compliance
# More rules: 190 lines → Instructions ignored

The core issue: instructions past about line 100 start getting treated as suggestions, not rules.

Environment

  • Claude Code (latest)
  • CLAUDE.md file: 190 lines with 40% redundancy
  • Project: TypeScript/Node.js

What happened?

I noticed Claude was ignoring my instructions, so I added more rules to CLAUDE.md. This created a vicious cycle:

The redundancy spiral
Claude ignores instruction
Developer adds more rules
File grows longer
Instructions at end get less weight
Claude ignores more instructions
Developer adds even more rules...

When I did a forensic audit of my CLAUDE.md, I found:

  • Original file: 190 lines
  • Redundancy detected: 40%
  • Critical rules buried: Lines 120-180
  • Result: Those rules were treated as suggestions

How to solve it?

I tried three approaches.

Solution #1: Audit and Trim

First, I removed redundant instructions:

Before: Redundant instructions
# Coding Style
Always use immutability.
Never mutate objects.
Make sure to never change objects in place.
# Testing
Write tests first.
Always write tests before implementation.
TDD is required.
After: Concise instructions
# Coding Style
Immutability: Create new objects, never mutate existing ones.
# Testing
TDD Required: Write tests first (RED-GREEN-REFACTOR cycle).

After trimming, my file went from 190 lines to 123 lines.

Solution #2: Prioritize Critical Instructions

I moved the most important rules to the first 50-100 lines:

Optimized CLAUDE.md structure
# Critical Rules (First 50 lines)
- Never commit without running tests
- No hardcoded secrets
- Always validate user input
# Secondary Rules (Lines 50-100)
- Use immutability patterns
- Follow TDD workflow
# Reference Material (After line 100)
- Common patterns
- Project-specific notes

Solution #3: Move Enforcement to Tooling

The most effective change was moving enforcement from CLAUDE.md to pre-commit hooks:

.git/hooks/pre-commit
#!/bin/bash
npm run lint || exit 1
npm run typecheck || exit 1
npm run test -- --coverage --coverageThreshold='{"global":{"lines":80}}' || exit 1

Now the environment enforces these rules, not Claude’s memory.

The reason

I think the key reason is LLM context attention patterns:

  1. Attention decay: Instructions beyond the first ~100 lines receive progressively less weight in the model’s decision-making

  2. Token dilution: More content means each instruction gets less “attention budget”

  3. No hard limit: There’s no technical constraint at 100 lines—it’s about attention distribution

The Reddit community consensus is clear: long instruction files decay fast. Enforcing behavior via tooling or tests beats hoping the model reads line 137.

Summary

In this post, I showed why CLAUDE.md instructions get ignored after ~100 lines and how to fix it. The key point is: stop adding rules when Claude ignores instructions. Instead, audit redundancy, prioritize critical rules in the first 100 lines, and build proper infrastructure for enforcement.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments