CLAUDE.md is the instruction file that tells Claude Code how to behave in your project. Get it right and Claude follows your rules. Get it wrong and Claude ignores everything.
Problem: CLAUDE.md files over 100 lines cause Claude to miss important rules. The longer the file, the more likely critical instructions are ignored.
Solution: Keep CLAUDE.md under 50 lines. Move detailed instructions to .claude/skills/ files (loaded on demand, saving tokens).
| Use Case | Lines | Safety | Focus |
|---|---|---|---|
| Beginner | 14 | ★★ | Basic safety rules |
| Autonomous | 24 | ★★★★ | Long-running, unattended |
| Team | 26 | ★★★ | Shared repo conventions |
| Production | 22 | ★★★★★ | Zero-tolerance safety |
| Learning | 14 | ★ | Explanations, minimal constraints |
# Project Rules
## Safety
- Never use rm -rf, git reset --hard, or git push --force
- Never commit .env files or API keys
- Always create a new branch before making changes
- Run tests before committing
## Code Style
- Follow existing code conventions
- Keep functions under 50 lines
# Autonomous Operation Rules
## Critical Safety
- NEVER delete files without explicit backup first
- NEVER push to main/master directly
- Stop and report if the same error occurs 3 times in a row
## Work Pattern
- Create a git branch for each task
- Commit after each meaningful change
- Run tests after every code change
## Context Management
- Save work state before context compaction
- Keep TODO items in tasks/todo.md
100+ line CLAUDE.md: Claude Code struggles with long instruction files. Split into CLAUDE.md (principles) + Skills (procedures).
Contradictory rules: "Write tests for everything" + "Move fast" without priority. Always state which wins.
Code snippets in CLAUDE.md: Wastes tokens on every turn. Put code in Skills files instead.
CLAUDE.md tells Claude the rules. Hooks enforce them at the process level.
# CLAUDE.md says "never rm -rf"
# This hook BLOCKS it:
npx cc-safe-setup --install-example destructive-guard
Auto-generate CLAUDE.md from your project:
npx cc-safe-setup --scan --apply
Detects your tech stack and creates appropriate rules + hooks
Learn more: Production Guide · All Tools