Guide · Cursor
Why Cursor ignores your rules, and what actually enforces them
You wrote careful Cursor rules. The agent follows them for a while, then edits a file you said never to touch, or reintroduces a pattern you banned. It isn't a bug in your rules file. It's what rules files are.
Rules are context, not constraints
Cursor project rules (in .cursor/rules/), the older .cursorrules file, AGENTS.md and CLAUDE.md all do the same thing: add text to the model's context. The model weighs that text against everything else it's seeing: your prompt, the code, error messages, its own plan. When those pull in a different direction, a rule can lose.
Common reasons rules get ignored
- Too long. A 400-line rules file competes with itself. Short, specific rules survive better.
- Too vague. "Write clean code" can't be followed or checked. "Don't edit files in
src/payments/without asking" can. - Not attached. Rules scoped to certain files or attached on request may not be in context for the task at hand.
- Long sessions. As the conversation grows, early instructions carry less weight.
- Conflicts. A prompt that says "just make it work" quietly overrides "never touch the tests".
How to write rules that stick
- Keep the always-on rules to a screen: stack, commands, off-limits paths, the few rules you'd block a PR for.
- Make each rule checkable: a path, a command, a yes/no condition.
- Put the current task's scope at the top, and update it per task.
- Use one source of truth (
AGENTS.md) and generate the agent-specific files from it, so Cursor, Claude Code and Codex see the same rules.
Enforce the rules that matter
Some rules can only be guidance ("prefer composition"). Others can be checked after every change: which files changed, whether protected paths were touched, whether the behaviours you care about still work. Those should be checked, not hoped for.
npx stet-cli init # writes AGENTS.md from one charter
stet scope set "Add CSV export" --allow "src/export/**,tests/export/**"
# ...Cursor does the task...
stet guard # anything outside the scope or in protected paths?
stet check # do locked behaviours still pass?
Stet keeps AGENTS.md and CLAUDE.md in sync with the scope, locks and decisions, so the rules Cursor reads and the rules Stet checks are the same rules.
FAQ
Why does Cursor ignore my .cursorrules?
Rules files are added to the model's context and weighed against everything else it sees. Long, vague or conflicting rules, rules that are not attached for the current files, and long sessions all make it more likely the agent drifts from them.
Should I use .cursorrules or .cursor/rules?
Cursor's project rules live in .cursor/rules; the single .cursorrules file is the older format. Many teams also keep an AGENTS.md so other agents read the same rules.
How do I enforce Cursor rules?
Turn the important rules into checks that run on the diff: allowed paths for the task, protected paths, and commands that prove key behaviours still work. Run them at commit and in CI.
Put guardrails on your AI coding agent
Stet is a free, open-source CLI and MCP server for Claude Code, Cursor, Codex and Copilot. It runs locally: no account, your code never leaves your machine.
npx stet-cli init · Install · Setup guide · GitHub