How Cursor, Claude Code, and Codex actually load your rules
Cursor loads .mdc rules conditionally, Claude Code loads CLAUDE.md upfront, Codex merges AGENTS.md by directory depth. How each tool actually works and what rule-writing habits transfer across all three.
Nearly every AI coding tool now has its own 'project rules' file — Cursor's .cursor/rules, Claude Code's CLAUDE.md, and Codex's AGENTS.md — yet teams routinely write one, watch the agent ignore parts of it, and assume the feature is broken. In most cases the real issue is that these files are written for human readers while each tool actually consumes them through a distinct mechanism.
Cursor rules are conditionally attached via one of four frontmatter modes (Always Apply, Apply to Specific Files, Apply Intelligently, Apply Manually); vague descriptions and missing globs mean a rule simply never gets loaded. Claude Code, by contrast, loads CLAUDE.md in full at every session start, turning it into a constant token tax where excess length dilutes attention rather than failing outright. Codex merges AGENTS.md files down a directory hierarchy, with the file closest to the edited code winning conflicts — a setup that causes silent, confusing behavior shifts when teams dump everything into the root file instead of scoping it.
Across all three tools, the same habits hold up: write rules as imperatives at the point of decision, justify negative constraints so the model can reason about exceptions, avoid bloating files with defaults the tool already follows, scope rules to where they're actually true, and test rules the way you'd test code. A related 'one-hop' pattern also applies — agents reliably follow a single plain-text pointer but tend to drop chained references, though Claude Code's mechanical @import syntax is an exception.
For engineers, the takeaway is that rules 'not working' is usually a placement and phrasing problem rather than a tool limitation — rules written with the right scope, mode, and length load reliably across Cursor, Claude Code, and Codex alike.