TL;DR
AI agents read your .cursorrules from the system prompt, but as you keep chatting the prompt gets diluted by the growing conversation history. Before you abandon the file, try (1) tightening the rule set, (2) reâinjecting the rules every few turns, and (3) splitting rules by file type. When you need to know what will break, a static rules file canât help - thatâs a blastâradius problem. For that class of safety, look at CodeFundiâs Convention Enforcer (waitâlist link below).
Why convention files get ignored over a long session
AI coding assistants operate on a single bounded context that consists of two parts:
| Component | Typical size limit (tokens) | What it contains |
|---|---|---|
| System prompt | ~2âŻk tokens (varies by model) | Your .cursorrules, role description, highâlevel policies |
| Conversation history | Up to the modelâs context window (e.g., 16âŻk tokens for Claudeâ3.5 Sonnet) | User messages, assistant replies, code snippets, diagnostics |
When a session starts, the system prompt is at the front of the context window, so the model can see the full rule set alongside the userâs first request. As you keep iterating, each new turn pushes older tokens further back. Once the total token count approaches the modelâs context limit, the oldest tokens are dropped (or, in some implementations, deprioritized by the attention mechanism).
Because the system prompt is static, its relative weight shrinks proportionally to the growing batch of userâassistant messages. In practice you can observe the drift after roughly 10â15 turns on a typical 8âŻkâtoken window: the model still knows the language syntax, but the nuance of âprefer snake_case for private varsâ fades, and the assistant reverts to its default coding style.
How to verify: Start a fresh session with a minimal
.cursorrulesthat forces a style (e.g., âalways useconstinstead ofletâ). After 12â14 edits, inspect the generated code. If the rule is no longer obeyed, you have reproduced the weighting effect.
Three things to try before reaching for a new tool
You donât need to abandon .cursorrules simply because the modelâs attention drifts. The following mitigations keep the rules in the active context without changing the underlying AI.
1. Write shorter, more specific rules
- Why: Long, verbose rules consume many tokens and get âsandwichedâ by later messages.
- How:
- Identify the core conventions you care about (e.g., naming, import ordering).
- Reduce each rule to a single imperative sentence, no more than 15 words.
- Use explicit keywords that the modelâs tokenizer recognizes (
snake_case,noâeval,eslintâcompatible).
| Bad (â70 tokens) | Good (â18 tokens) |
|---|---|
âAll JavaScript files in this repo should follow the Airbnb style guide, with the exception that we never use var, we always prefer const for values that never change, and we prefer let only when we need to reassign; also, use twoâspace indentation, and put a newline after each import statement.â | âUse const unless reassignment is required. Use twoâspace indentation. Add a newline after each import.â |
2. Reâinject the rules periodically
- Why: Reâadding the rules restores their position at the front of the context window.
- How:
- Store the trimmed rule block in a file (e.g.,
rules.txt). - After every N turns (NâŻ=âŻ5â7 for 8âŻkâtoken windows), send a systemâstyle message that repeats the rules verbatim.
- Prefix the message with a short note: âReâapplying .cursorrules for this turn.â
- Store the trimmed rule block in a file (e.g.,
Most agents treat a later system message as a supplementary prompt, effectively pushing the rule set back toward the top of the attention matrix.
3. Split rules by file type or domain
- Why: A single monolithic rule set forces the model to keep irrelevant rules in memory.
- How:
- Create separate rule files:
.cursorrules-js,.cursorrules-ts,.cursorrules-docker. - When you switch context (e.g., from a
.jsfile to a.Dockerfile), issue a system message that loads only the relevant subset. - Keep a master âglobalâ file for rules that truly apply everywhere (license headers, security constraints).
- Create separate rule files:
| File type | Example rule subset |
|---|---|
| JavaScript | Prefer const; twoâspace indentation; newline after imports |
| TypeScript | Prefer strict mode; explicit return types; no any`` |
| Dockerfile | Pin base image tags; use COPY --chown when possible |
By limiting the token budget to the active conventions, you reduce the chance of dilution.
Where a rules file structurally can't help
A .cursorrules file is essentially a styleâonly contract. It tells the agent how to format, name, or order code, but it does not give the agent any knowledge of the semantic impact of its edits.
Example:
You add a rule âNever delete a function that is exportedâ. The agent will happily obey the syntax, but it has no way to know whether a later edit will inadvertently break a downstream import because the file graph isnât part of the rules context. Detecting that requires a blastâradius analysis - the domain of CodeFundiâs core product, not a static convention file.
In other words, rules canât answer the question: âWill this change cause a runtime failure or a test break?â That is a different problem: what your rules can't catch. For that class of safety you need a dedicated analysis layer that evaluates dependency graphs, execution paths, and test coverage after each edit.
CodeFundiâs Convention Enforcer: a dedicated enforcement layer
Static rules are a good first line of defense, but they stop at syntactic compliance. CodeFundiâs Convention Enforcer sits between the AI agent and your repository, ingesting the same .cursorrules you already write and actively rejecting any change that violates them at commit time. Because the Enforcer runs after the agent proposes a diff, it can also query the blastâradius engine to flag edits that would break dependent modules.
- Zeroâoverhead integration: Drop a tiny config file in the repo root; the Enforcer watches the same Git hook that your CI uses.
- Realâtime feedback: The agent receives a rejection payload (e.g., âRemoved exported function
fooâ dependent modulebar.jswould failâ) and can immediately propose a safer alternative. - Separate concerns: The Enforcer does not replace the blastâradius service; it simply adds a convention gate before the change reaches the repository.
If youâre already wrestling with â.cursorrules not being followedâ, join the waitlist to get early access to the Enforcer and see how a live enforcement loop can keep your conventions alive across arbitrarily long sessions.
Join the Convention Enforcer waitlist â
FAQ
Why doesn't Cursor follow my .cursorrules file?
The rules live in the system prompt, which shares the same finite token window as the conversation history. As the session grows, the promptâs influence wanes, causing the model to default to its builtâin style heuristics.
How do I make my AI coding assistant follow conventions consistently?
- Keep rules short and specific.
- Reâinject the rule block every few turns.
- Scope rules to the current file type.
If you need guarantees beyond style (e.g., preventing breaking changes), add a postâgeneration enforcement step such as CodeFundiâs Convention Enforcer.
What is .cursorrules and how does it work?.cursorrules is a plainâtext file interpreted by the AI agent as part of the system prompt. Each line is treated as an instruction the model should prioritize when generating code. The file itself contains no executable logic; it merely shapes the modelâs attention during the current session.
Call to Action
If youâve hit the ceiling of what a static rules file can achieve, consider augmenting your workflow with a live enforcement layer. Join the Convention Enforcer waitlist today and be the first to plug a safety net into your AIâdriven development loop.
Note: The troubleshooting steps above are based on publicly documented behavior of transformerâbased coding assistants and on reproducible experiments with a standard 8âŻkâtoken context window. Results may vary with different model families or custom token limits.
Internal references:
- For a deeper dive into the limits of static rules, see a different problem: what your rules can't catch.
- To learn how to catch convention drift at review time, read our guide on catching drift at review time instead.