DEV Community

Cover image for My coding agent kept fixing things nobody asked it to fix, so I wrote it 12 rules
AheadKit
AheadKit

Posted on

My coding agent kept fixing things nobody asked it to fix, so I wrote it 12 rules

My coding agent does what I ask. Then it does more than I asked. It renames a function nobody asked it to rename, rewrites a file to fix one line, and writes an interface that looks like every other generated page on the internet. Then I spend the afternoon undoing the extra work.

The problem is not the model. The problem is that the agent has no rules about what "done" means. It guesses. And its guesses lean toward more: more code, more abstraction, more polish nobody requested.

So I wrote the rules down. Twelve of them, each one short enough to fit on a page. Keep changes small. Name things for what they are. Test before you claim something works. Write errors a person can act on. Check security smells before they ship. That kind of thing, each one with the exact behaviour it wants and the mistakes it is meant to stop.

What a rule looks like

The lean-code rule is the one I reach for first. It says: change the smallest amount of code that fixes the problem properly. Not the smallest amount that makes the test pass. The smallest amount that is correct. One change, one reason. A bug fix does not also rename variables or upgrade a dependency. Those are separate commits. And it has the rule of three: two similar blocks of code are fine, three is a pattern worth extracting. No framework for a problem that happened once.

I tried each rule on small demo projects before trusting it. A tiny Python CLI, a static page, a Node script. The before and after pairs are in the pack, done by hand so you can see the shape of the change. One example: the Node script used to die on a missing config file with a raw stack dump. After the error-handling rule, it exits with one plain sentence naming the problem and the fix. Same failure, different experience.

How they install

Each rule is a SKILL.md file. You drop the twelve files into .claude/skills in your project, wire them in with one of the two CLAUDE.md templates that come with the pack, and the agent carries them from then on. The same file layout works for Codex and Cursor, and the playbook walks through all three installs.

Two things I did not do. I did not copy the free skill repos and repackage them. Every file in the pack was written from scratch, from real practice. And I did not claim a live run I never did: there is no Claude Code install on the machine I built this on, so the install was validated structurally and in three demo repos, and the playbook says that plainly.

The full lean-code rule is free, so you can read one before deciding anything: the lean-code skill.

The whole pack is twelve skills, two templates and a 10-page playbook for $19 while it launches: Agent Skills Pack.


The full numbers behind this one are in the Agent Skills Pack. Everything I write here stays free, that part doesn't change. — Salam

More from AheadKit: programming books, packs and AI tools. Each page lists exactly what's inside before you pay.

Top comments (8)

Collapse
 
dosaygo profile image
dosaygo •

Putting the rule of three into an agent skill is handing the model a licence to duplicate: a human remembers where copy number one lives, whereas a coding agent starting a fresh session treats "two similar blocks are fine" as permission to invent a parallel helper instead of naming and extending the module already in the repo.

Collapse
 
aheadkit profile image
AheadKit •

That's the sharp version of it. The rule was written for someone who remembers where copy one lives, and a fresh session has no such memory, so 'two are fine' reads like permission to build the second one instead of finding the first. Going to run the same demo task with the wording changed to name-and-extend and see whether the parallel helper stops appearing. Does yours even look for the existing module first, or duplicate before it searches?

Collapse
 
dosaygo profile image
dosaygo •

Left to its defaults, a fresh session duplicates before it searches—generating a clean 30-line helper from scratch takes fewer tool calls than grepping an unfamiliar worktree and reading existing call sites. In our 22-session controller build, the agents didn't search and reject the existing bbz orchestrator; they read the task prompt and started writing a new adapter module on turn one.

Changing the rule to name-and-extend only holds when you make the search output a mandatory first line: the agent must print the exact file path and symbol it is extending before its first file write, or stop and ask if it cannot find one. AI Lint packages that pre-flight CHECKLIST.md and the AR-R2: Parallel Solutions reject doctrine for CLAUDE.md, AGENTS.md, and Cursor rules so coding agents search and extend existing modules before writing code (the free edition is for personal use only; a company team gets the paid packs or Company license): ai-lint.dosaygo.com/go/forum-20261...

Thread Thread
 
aheadkit profile image
AheadKit •

The mandatory first line is what makes name-and-extend enforceable instead of just a nicer sentence in the rules — without it the agent can nod and duplicate anyway. Did the print-the-path-first version actually stop it in your 22-session build, or is that the next run? If it held there I'd want to steal the exact wording.

Thread Thread
 
dosaygo profile image
dosaygo •

The 22 sessions were the run without it. None of those briefs named the orchestrator CLI we already had, so each session did the sensible thing with a blank page and wrote a new adapter. The rule was written the morning after. The rebuild that carried it went onto the existing CLI: the controller calls it now and holds no provider code of its own.

The wording, from the top of our rules file:

Build on what exists. Name what you extend before you write. If you cannot name it, stop and ask.

And the half that does the work, which lives in the task and not in the rules:

A brief names the thing to extend, with its path, in its first line. A worker whose brief names no target does not start building.

A rule in CLAUDE.md sends the agent looking; a path in the first line of the task means it starts with the file already named. Where the task can't carry one, make the agent's first output line the path and symbol, and discard any session that writes a file before printing it. It is still a markdown instruction the model follows, with no mechanical check behind it, so the check is yours, and it is one line to read where it used to be a whole diff.

The reject it pairs with, AR-R2 Parallel Solutions, and the pre-flight checklist around it are in the AI Lint App Pack: ai-lint.dosaygo.com/go/forum-20261...

Thread Thread
 
aheadkit profile image
AheadKit •

That first line is the whole trick. A rule in the file sends the agent looking, a path in the first line means it starts with the file already named. The discard rule is the sharp bit too, one line to read instead of a whole diff. Has the rebuild actually run sessions with it yet, or is the no-more-parallel-adapter part still the thing to prove?

Thread Thread
 
dosaygo profile image
dosaygo •

It has run every day since the 22nd. Every task brief opens by sending the session to the rules file and names the thing it builds on, and the controller work since then has gone through the one CLI.

What I won't hand you is a clean number. Nobody here has gone through that week of diffs counting near-duplicates, and one team on one codebase for a week is an anecdote.

The part that visibly changed is the brief, not the model. Writing the path in the first line makes whoever writes the task go and find the existing thing before any session starts, and that is where the second adapter dies: the author finds out the tool already exists. The model obeying the line is the smaller effect.

Your demo is a better test than our history. Same task, same repo, ten fresh sessions each way, count the sessions that create a new helper file. That gives you a rate with and without the first line, which is more than we have.

Thread Thread
 
aheadkit profile image
AheadKit •

The author finding it first is the part I'd been underweighting. The line does its work before the model ever sees the task, because someone had to go and find the thing first. Ten and ten it is, counting new helper files. Does it hold when the brief-writer is new to the repo and doesn't know what's in there, or does it need someone who already knows where to look?