How I stop AI coding agents breaking my project
I like AI coding agents. I do not like when they rewrite a file that was already fine, hard-code a key "just for now", or try the same broken fix five times.
The fix was not a smarter model. It was a short set of house rules the agent reads at the start of every session.
What kept going wrong
- Wholesale rewrites of files that only needed a small change.
- Scope creep: renaming and reformatting unrelated code.
- Secrets in client bundles or committed
.envfiles. - Missing auth on new routes that "worked" in the happy path.
- Debug spirals: five near-identical attempts, each worse than the last.
None of that is mysterious. Without priorities, "make it work" quietly beats "don't break security" and "stay in scope".
The rules that helped
- Rule priority
When instructions clash, follow the higher one and say which you followed:
- Security guardrails - never broken, even if asked.
- The task I asked for, in scope.
- Stack conventions.
- Working style preferences.
- How to work
- Read the files you will change (and their callers) first.
- Make the smallest change; never rewrite a working file wholesale.
- Ambiguous request: ask one short question, then proceed.
- Two failed attempts at the same bug: stop, summarise what you tried, ask before a third.
- Security always on
- Secrets only in server-side env.
- Check the caller on sensitive paths.
- No destructive git,
rm -rf, or--forceunless explicitly requested. - Run the real tests; do not skip them to go green.
- What to report when done
What changed, what you ran, and what you did not verify. That last line is the one that saves evenings.
Where to put the rules
Put the shared text in AGENTS.md. Point CLAUDE.md at it with @AGENTS.md. Add a thin always-on Cursor rule under .cursor/rules/ if you want the security lines loaded in every Cursor chat.
A free MIT starter with those files, a 10-point pre-launch checklist and three prompts is here: github.com/theodorecreatesco/vibe-coding-rules-starter
Copy the three files into a project, open a new chat, and ask what the top rules are. If the agent cannot name the priority and the security lines, the files are in the wrong place for that tool.
The optional paid upgrade with more stacks and a one-command installer is the Vibe Coding Rules Kit on Etsy. I use the free starter on small repos and the kit when a project spans several tools.
What I do not do any more
- Paste a 400-line "constitution" into every tool's file.
- Trust "done" without seeing the commands that were run.
- Let the agent take a third blind swing at the same bug.
Short rules, ranked once, read every session. That is the whole method.
Comments
No comments yet. Start the discussion.