📜

AI Ignoring CLAUDE.md, AGENTS.md or Cursor Rules

You wrote clear rules ('always use pnpm', 'never edit migrations', 'run tests before finishing') and the agent ignores them anyway. This is not usually a broken file. Rules files like CLAUDE.md, AGENTS.md, and Cursor's .cursor/rules are delivered to the model as context, not as enforced configuration, and the model decides how much weight each instruction gets for the task at hand. Long files dilute the important rules, conflicting instructions cancel each other out, and in Cursor the rule type determines whether a rule is loaded at all (a rule set to apply intelligently only loads when the agent judges its description relevant). Placement matters too: a file in the wrong folder, a plain .md in .cursor/rules instead of .mdc, or a legacy .cursorrules file can all mean the rule never reaches the model. The fix is to confirm the rule is actually loaded, shorten and sharpen what you keep in it, and move anything that must happen every time into deterministic tooling such as hooks, linters, and CI, which do not depend on the model remembering.

Recommended toolSymphony by WixA coordinated team of AI agents for your business, led by Maestro.Get your AI team

Affiliate link, we may earn a commission at no extra cost to you.

Symptoms You Might See

⚠️

The agent uses a package manager, framework, or style your rules forbid

⚠️

Rules are followed at the start of a session but forgotten later

⚠️

Some rules in the file are obeyed and others never are

⚠️

Cursor rules apply in one chat but not another

⚠️

The agent edits files your rules say are off limits

⚠️

Asking the agent to repeat your rules shows it never saw them

Common Causes

Rules are context, not configuration

CLAUDE.md and similar files are added to the conversation as instructions the model weighs alongside everything else. When a rule seems unrelated to the current task, or conflicts with the immediate request, the model can deprioritize it. Nothing in the file is mechanically enforced.

The file is too long

A rules file of hundreds of lines mixes critical constraints with background notes and style preferences. Important rules get diluted, and every always-loaded line also consumes context on every request.

Wrong Cursor rule type or format

Cursor project rules live in .cursor/rules as .mdc files with frontmatter. A rule set to apply intelligently only loads when the agent decides its description is relevant, glob-scoped rules only load for matching files, and manual rules only load when referenced. Plain .md files in that folder are not treated as project rules.

Long sessions and compaction

Deep into a long session, early instructions carry less weight and may be summarized away when context is compacted. Rules that were followed in the first few turns drift later.

File in the wrong place or conflicting files

Rules in a subfolder may only apply when working in that folder, and nested AGENTS.md files combine with their parents. Conflicting instructions between a root file, a nested file, a legacy .cursorrules, and your prompt leave the model to guess which wins.

Step-by-Step Fixes

1

Confirm the rule is actually loaded

When to try: First, before rewriting anything

Ask the agent at the start of a session: 'List the project rules you are currently following.' If a rule is missing, it is a loading problem, not a compliance problem. In Claude Code, the memory command shows which CLAUDE.md files are in use; in Cursor, check the rules panel in settings.

2

Fix Cursor rule type and format

When to try: When a Cursor rule works inconsistently

Make sure each rule is an .mdc file in .cursor/rules with valid frontmatter. Set alwaysApply: true only for the one or two rules that must load on every request, give intelligently applied rules a precise description, and use globs for file-specific rules. Migrate any legacy .cursorrules content into project rules.

3

Cut the file to what matters

When to try: When the file is more than a screen or two long

Keep the always-loaded file short: the handful of rules that are truly non-negotiable, written as direct, specific instructions ('Use pnpm, never npm or yarn'). Move background, architecture notes, and preferences into separate files that load only when relevant.

4

Make rules specific and testable

When to try: When rules are obeyed loosely or not at all

Replace vague rules ('write clean code') with checkable ones ('functions over 50 lines must be split', 'never edit files under db/migrations'). Specific rules are easier for the model to apply and easier for you to verify.

5

Enforce critical rules with hooks

When to try: For rules that are broken repeatedly

For anything that must happen every time, use deterministic tooling instead of relying on the model. Claude Code hooks can run a formatter after edits, block writes to protected paths, or run tests before a task is marked done. Hooks execute at the shell level and do not depend on the model's judgment.

6

Back rules with linters and CI

When to try: For any rule a tool can check

Encode style, import, and dependency rules in your linter, formatter, and CI pipeline. If the agent breaks a rule, the build fails visibly and the agent can see and correct the error instead of the violation slipping through.

7

Restart or restate in long sessions

When to try: When rules drift after many turns

Start a new session for each distinct task, or restate the key rule in the prompt when it matters ('Remember: no changes to migrations'). Fresh sessions reload rules at full weight, which long compacted sessions do not.

How to Prevent This

✓

Keep the always-on rules file short and limited to true non-negotiables

✓

Use the correct rule type and file location for your tool

✓

Turn must-happen rules into hooks, lint rules, or CI checks

✓

Start fresh sessions per task so rules load at full strength

When to Contact Support

Rules being weighed rather than enforced is expected behavior, so there is nothing for support to fix in most cases. File a report on the Cursor forum or the Claude Code GitHub repository if a rule is confirmed loaded (the agent can list it) but is consistently ignored on simple, directly relevant tasks, or if an always-apply rule does not load at all. Include the rule file, the tool version, and a minimal reproduction.

Frequently Asked Questions

Why does Claude Code ignore my CLAUDE.md?▼

CLAUDE.md is delivered as context for the model to weigh, not as enforced configuration, so rules that seem unrelated to the current task or conflict with the request can be deprioritized. Long files dilute important rules, and long sessions weaken early instructions. Keep it short and specific, and move must-follow rules into hooks.

Why is Cursor not following my rules?▼

Check the rule type and format first. Project rules must be .mdc files in .cursor/rules. Rules set to apply intelligently only load when the agent thinks the description is relevant, glob rules only load for matching files, and manual rules only load when referenced. Use always apply for the few rules that must load every time.

Does .cursorrules still work?▼

The legacy .cursorrules file has been superseded by project rules in .cursor/rules and is kept mainly for backward compatibility. Migrate its contents into .mdc rules so you can control when each rule applies.

What is the difference between CLAUDE.md and AGENTS.md?▼

CLAUDE.md is Claude Code's project instruction file. AGENTS.md is a plain Markdown convention read by several agents, including Cursor and Codex, where nested files combine with their parents. Both are context, not enforcement, so the same keep-it-short advice applies.

How do I force an AI agent to always follow a rule?▼

You cannot guarantee it through instructions alone. For must-follow rules, use deterministic tooling: Claude Code hooks to block or run actions, linters and formatters for style, and CI checks that fail the build. The agent then sees a hard error rather than a suggestion.

Other Common AI Errors

⚠️

ChatGPT Not Working

Service Issues

🚦

Rate Limit Exceeded

Usage Limits

📏

Context Length Exceeded

Input Limits

🔥

Model Overloaded

Service Issues

Don't stop here

What to read next

Hand-picked guides our readers explore right after this one.