claude

Claude Code's 4-Level Instruction Hierarchy Revealed

Claude Code uses a four-level instruction hierarchy consisting of system prompts, user instructions, task context, and runtime constraints to process and

Someone figured out Claude Code loads instructions in a 4-level hierarchy that basically acts as a security checkpoint for every project.

The order:

  1. /etc/claude-code/CLAUDE.md (company-wide rules)
  2. ~/.claude/CLAUDE.md (your personal defaults)
  3. ./CLAUDE.md (project team settings)
  4. ./CLAUDE.local.md (local overrides)

The global ~/.claude/CLAUDE.md is pretty powerful since it applies to every single project automatically. Smart move is putting security rules there - stuff like “never commit API keys” or “always add tests before merging.”

Project-level files inherit everything from global, so you set standards once and they follow you everywhere. The local file is gitignored, perfect for machine-specific paths or personal preferences that shouldn’t affect teammates.

Turns out this hierarchy prevents the “oops, different rules per project” problem. Set your non-negotiables in ~/.claude/CLAUDE.md and override only when projects actually need different behavior.