<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rulestack</title>
    <description>The latest articles on DEV Community by Rulestack (@rulestack).</description>
    <link>https://dev.to/rulestack</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4025074%2F8c45f5e9-1af0-48b9-9e5d-8078f7eb4043.png</url>
      <title>DEV Community: Rulestack</title>
      <link>https://dev.to/rulestack</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rulestack"/>
    <language>en</language>
    <item>
      <title>How Cursor, Claude Code, and Codex actually load your project rules (and why yours get ignored)</title>
      <dc:creator>Rulestack</dc:creator>
      <pubDate>Sat, 11 Jul 2026 13:51:16 +0000</pubDate>
      <link>https://dev.to/rulestack/how-cursor-claude-code-and-codex-actually-load-your-project-rules-and-why-yours-get-ignored-1l1j</link>
      <guid>https://dev.to/rulestack/how-cursor-claude-code-and-codex-actually-load-your-project-rules-and-why-yours-get-ignored-1l1j</guid>
      <description>&lt;p&gt;Every AI coding tool now has a "project rules" file. Cursor has &lt;code&gt;.cursor/rules&lt;/code&gt;, Claude Code has &lt;code&gt;CLAUDE.md&lt;/code&gt;, OpenAI Codex has &lt;code&gt;AGENTS.md&lt;/code&gt;. Teams write them once, watch the agent ignore half of it, and conclude the feature is broken.&lt;/p&gt;

&lt;p&gt;Most of the time the feature isn't broken. The rules file is written for a human reader, and each tool consumes it differently. Here's how the three tools actually load rules as of mid-2026, and the writing habits that transfer across all of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cursor: rules are conditionally attached, not always read
&lt;/h2&gt;

&lt;p&gt;Modern Cursor rules live in &lt;code&gt;.cursor/rules/&lt;/code&gt; as &lt;code&gt;.mdc&lt;/code&gt; files with frontmatter (the old single-file &lt;code&gt;.cursorrules&lt;/code&gt; has been dropped from the current docs entirely — treat it as deprecated and migrate). The frontmatter decides &lt;em&gt;when&lt;/em&gt; the rule enters context:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Conventions&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;for&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;API&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;route&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;handlers"&lt;/span&gt;
&lt;span class="na"&gt;globs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;src/api/**/*.ts"&lt;/span&gt;
&lt;span class="na"&gt;alwaysApply&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;span class="nn"&gt;---&lt;/span&gt;

&lt;span class="p"&gt;-&lt;/span&gt; Every handler validates input with zod before touching the DB
&lt;span class="p"&gt;-&lt;/span&gt; Return typed error envelopes, never raw strings
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The part people miss: there are effectively four attachment modes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Always Apply&lt;/strong&gt; (&lt;code&gt;alwaysApply: true&lt;/code&gt;) — in context for every request&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Apply to Specific Files&lt;/strong&gt; (the mode older docs called "Auto Attached") — pulled in when a file matching &lt;code&gt;globs&lt;/code&gt; is referenced&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Apply Intelligently&lt;/strong&gt; (formerly "Agent Requested") — the agent reads the &lt;code&gt;description&lt;/code&gt; and &lt;em&gt;decides&lt;/em&gt; whether to fetch the rule&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Apply Manually&lt;/strong&gt; — only when you @-mention it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So if your rule has a vague description like "general best practices" and no globs, it sits in Apply Intelligently mode and the model has no reason to ever pull it. The rule isn't ignored — it was never loaded. Give globs to anything file-scoped, and write descriptions like an API doc: what the rule covers, when to use it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Claude Code: everything loads up front, so tokens are the budget
&lt;/h2&gt;

&lt;p&gt;Claude Code reads &lt;code&gt;CLAUDE.md&lt;/code&gt; automatically at session start: your user-level file (&lt;code&gt;~/.claude/CLAUDE.md&lt;/code&gt;), the project root file, and files from parent directories; deeper &lt;code&gt;CLAUDE.md&lt;/code&gt; files in subdirectories join when work touches those folders. You can also compose with imports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;See @docs/architecture.md for the module map.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The consequence of "loads every session" is that CLAUDE.md is a &lt;em&gt;context tax&lt;/em&gt;. Every line you add is a line the model carries through the whole session, whether it's relevant to the current task or not. Long, unprioritized files don't fail loudly — they just dilute attention until the instruction you cared about loses to noise.&lt;/p&gt;

&lt;p&gt;What works: keep the root file short and non-negotiable (build commands, hard constraints, "never do X because Y"), and push detail into imported or nested files that only load where they matter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Codex: AGENTS.md is a merge chain, deepest wins
&lt;/h2&gt;

&lt;p&gt;Codex looks for &lt;code&gt;AGENTS.md&lt;/code&gt; in your home config (&lt;code&gt;~/.codex/AGENTS.md&lt;/code&gt;), the repo root, and nested directories, merging as it goes — the file closest to the code being edited takes precedence on conflicts. AGENTS.md is also an open convention adopted by a growing list of tools, so it doubles as the vendor-neutral place for agent instructions.&lt;/p&gt;

&lt;p&gt;The failure mode here is the opposite of Cursor's: everything &lt;em&gt;does&lt;/em&gt; load, so people dump monoliths into the root file. Then a subdirectory rule silently overrides a root rule and nobody notices until the agent "randomly" changes behavior between folders. Treat the hierarchy as scoping, not duplication: repo-wide invariants at the root, module-specific conventions next to the module, and never state the same rule at two levels.&lt;/p&gt;

&lt;h2&gt;
  
  
  Five habits that transfer across all three
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Write imperatives at the decision site.&lt;/strong&gt; "Use keyword arguments for all function definitions" beats "code should be readable". The agent applies rules at the moment it makes a choice; phrase rules as the choice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Explain the why on negative constraints.&lt;/strong&gt; "Don't use &lt;code&gt;merge&lt;/code&gt;, use &lt;code&gt;rebase&lt;/code&gt;" gets pattern-matched away under pressure. "Don't create merge commits — this repo's tooling assumes linear history" survives, because the model can reason about when it applies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Pay the token tax deliberately.&lt;/strong&gt; All three tools ultimately stuff your rules into a context window. A 400-line rules file isn't 4x better than a 100-line one; it's usually worse. Prune anything the tool already does by default.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Scope rules to where they're true.&lt;/strong&gt; Glob-attached rules in Cursor, nested CLAUDE.md in Claude Code, per-directory AGENTS.md in Codex — all three give you locality. A rule that's only true for &lt;code&gt;src/api&lt;/code&gt; doesn't belong in the root file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Test rules like code.&lt;/strong&gt; After writing a rule, give the agent a task where the rule should fire and watch. If it doesn't fire, the fix is usually specificity or placement, not repetition. Rules files deserve version control, review, and occasional deletion — they drift out of date exactly like documentation because they &lt;em&gt;are&lt;/em&gt; documentation, just with a machine reader.&lt;/p&gt;

&lt;h2&gt;
  
  
  The one-hop rule
&lt;/h2&gt;

&lt;p&gt;A pattern that shows up in all three ecosystems: agents reliably follow one pointer, and quietly bail on two. A root rule that says "for API conventions, read &lt;code&gt;docs/api-rules.md&lt;/code&gt;" works. A root rule pointing to a doc that points to another doc doesn't.&lt;/p&gt;

&lt;p&gt;One carve-out: Claude Code's &lt;code&gt;@import&lt;/code&gt; syntax is mechanical, not judgment-based — imports expand recursively at load time (up to a documented depth of four hops), so chained &lt;code&gt;@&lt;/code&gt; imports do arrive in context. The one-hop rule is about &lt;em&gt;plain-text&lt;/em&gt; pointers, where the agent chooses whether to go read the file. If your rules need structure, either use a mechanical include where the tool offers one, or make each referenced file self-contained so a single hop is always enough.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I maintain &lt;a href="https://rulestack.gumroad.com?ref=devto" rel="noopener noreferrer"&gt;Rulestack&lt;/a&gt;, ready-to-use rule packs and skills for Cursor, Claude Code, and Codex, written and updated against each tool's current spec. If you'd rather start from a working baseline than a blank file, that's what it's for.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>productivity</category>
      <category>devtools</category>
    </item>
  </channel>
</rss>
