DEV Community

Piekwerk
Piekwerk

Posted on

7 reasons your agent ignores your rules (with fixes that stuck for me)

You write a rule, the agent follows it twice, then quietly stops. I
have debugged enough of these to say the cause is almost never
mystery or model quality. Rules get ignored for a handful of
specific, reproducible reasons. Here are seven, each with the way I
confirmed it and the fix that held.

1. The rule is a preference, not a command

Repro: write "prefer small functions" mid-file, give the agent a
refactor task, watch it produce 80-line functions. Preferences read
as flavor, and flavor gets dropped first under long context.

Fix that held: commands with triggers. "Functions over 40 lines need
a comment justifying the size" survives. "Prefer small functions"
does not.

2. It loads at the wrong time

Repro: a rule in always-on config about test factories, ignored
during a test-writing task. The rule was present the whole time and
still lost to more recent, more specific context.

Fix that held: scope it. Move stack-detail rules into glob-activated
files (Cursor's always_apply/globs distinction exists for this).
A rule that loads only when test files are open beats a rule that
loads always and applies never.

3. It fights the linter

Repro: "use double quotes" in config while prettier enforces single.
The agent obeys whoever checked last. You get coin-flip compliance.

Fix that held: delete the prose rule, keep the linter. Any rule the
machine can check does not belong in prose. Contradictions between
the two guarantee selective compliance.

4. Middle-of-file rules in long files

Repro: take a 400-line config, move one rule from line 380 to line
30, run the same task, watch compliance improve. Position matters
more than most people expect. Attention over long context is not
uniform.

Fix that held: the 300-line budget plus front-loading. Safety rules
and definition-of-done live in the first third of the file. History
and rationale live last, where dropping them costs least.

5. No example, just abstract instruction

Repro: "write commits in conventional style" gets inconsistent
results. The model has its own prior for "conventional" and yours
differs.

Fix that held: one concrete example per abstract rule:

feat(auth): add rate limit to login
fix: correct double-submit on checkout
Enter fullscreen mode Exit fullscreen mode

Two lines of example outperform two lines of explanation.

6. The rule has no verification path

Repro: "always run tests before committing" gets skipped in long
sessions. Nothing checks it, so nothing enforces it once attention
drifts.

Fix that held: either give it a hook (PreToolUse on git commit) or
move it into a definition-of-done block that the agent must echo
before finishing. Rules the session has to restate survive better
than rules it has to remember.

7. Too many rules competing for the same behavior

Repro: three rules touching commits (style, scope, when-to-commit).
The agent follows two, drops one, and you cannot tell which. Overlap
splits attention.

Fix that held: merge them into one block per behavior. One block,
three lines, ranked by importance. Competing rules lose to unified
ones.

The pattern across all seven

Ignored rules are almost always: preference-phrased, always-loaded,
unverified, or duplicated. The fixes are boring on purpose: command
phrasing, scoping, hooks, budgets, examples. None of it requires a
better model. All of it survives model upgrades, which is the point
of putting effort in config rather than prompts.

Related reading


Our kits apply all seven fixes by default: AgentConfig Studio. The Next.js kit is free (MIT).

Top comments (0)