• Never add Co-Authored-By lines
Build
• bun install && bun run build && node scripts/prerender.mjs
`
The root CLAUDE.md stays lean — under 50 lines ideally. The @imports pull in detailed conventions only when Claude is working in the relevant area. Imports are recursive: @docs/frontend-conventions.md can itself reference @docs/design-tokens.md.
The architectural principle this enables: keep detailed conventions in the same directory as the code they govern. An api/CLAUDE.md imported from the root can describe API-specific patterns without polluting the global context. A scripts/CLAUDE.md can explain pipeline conventions without every developer session loading them.
The practical constraint: not every tool supports @imports equally, and Claude processes referenced files on demand rather than up front. For instructions that must always be in context, they belong in the root CLAUDE.md directly. For conventions that only matter when working in specific areas, @imports are the right tool.
One pattern that's emerged from heavy @import users: a compact-instructions section in the root CLAUDE.md that tells Claude what to preserve during compaction. Because CLAUDE.md is re-injected after every compaction (it lives in the system prompt, not conversation history), this section survives context resets and keeps long sessions on track.
`markdown
Compact Instructions
When compacting, always preserve:
• Current task and files modified
• Any constraints I've stated in this session ("don't modify migration files")
• The list of completed steps in multi-step tasks
`
!Nested file structure with @import arrows flowing from sub-documents into a clean root CLAUDE.md
Try It Yourself
Step 1: Run the self-audit
Open your CLAUDE.md and mark each line with one of three labels:
• [essential] — Claude would make a concrete mistake without this
• [hook] — This is mandatory enforcement, not advisory guidance
• [noise] — Claude already does this, or it belongs in documentation
Delete every [noise] line immediately. Move every [hook] line to your hooks configuration.
Step 2: Check your line count
`bash
wc -l CLAUDE.md
`
Target: under 100 lines. Acceptable: up to 150. Above 200: you have context budget problems.
Step 3: Add one compaction preservation section
At the bottom of your root CLAUDE.md:
`markdown
Compact Instructions
When compacting, preserve: active task description, files modified this session,
any hard constraints I've stated ("don't change the API contract"), completed steps.
`
!Developer running the self-audit: marking each CLAUDE.md line as essential, hook, or noise
Step 4: Move the details to @imports
Take any section that applies only to a specific subsystem and extract it:
`bash
Create a sub-CLAUDE for your scripts directory
mkdir -p scripts
cat scripts/CLAUDE.md << 'EOF'
Scripts Directory
• All scripts run with Node 20
• Use ES modules (import/export), not CommonJS
• Environment variables from .env.local via dotenv
• Never hardcode API credentials
EOF
`
In your root CLAUDE.md, replace the deleted section with:
`markdown
Scripts
• See @scripts/CLAUDE.md for script conventions
`
Step 5: Set up the three most common hooks
`bash
In your .claude/settings.json
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [{"type": "command", "command": "cd $PROJECT_ROOT && npm run lint --silent 2&1 | head -20"}]
}
],
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [{"type": "command", "command": "if echo '$CLAUDE_TOOL_INPUT' | grep -q 'no-verify'; then echo 'blocked: --no-verify not allowed'; exit 2; fi"}]
}
]
}
}
`
Step 6: Run /init on a fresh project
For any new project, start with:
`
/init
``
Claude Code reads your project structure and generates a starter CLAUDE.md. Edit it to fit the 100-line target before adding anything. It's much easier to keep it lean from the start than to prune a file that's grown to 400 lines.
The before/after difference is measurable. Teams that trim to under 100 lines report that their most important rules — the ones that caused repeated corrections when violated — suddenly hold across long sessions. Not because Claude got smarter. Because it's no longer wading through 800 lines of noise to find the 10 rules that matter.
The file that makes Claude follow your rules is the one that only contains your rules.