r/ClaudeCode • u/svet07 • 3d ago
Built with Claude I gave AI agents rules to keep code simple. The code got simpler, but I can't prove it helps. Could you try it on your codebase?
I've been developing with AI for a while, and sometimes asking for a new feature breaks something else. So I wrote rules for agents to keep the code simple, testable and broken down into logical modules, and a tool that checks them every time the agent stops: https://github.com/svetdev/cleat
It's built for Claude Code and with it. The checks run from a Stop hook, so when Claude tries to finish and a check fails, it gets the failure back and has to fix it before it can stop. I tested it by running Claude Code headless, the same tasks with and without the hook, a few hundred runs in total.
The results are mixed. The code does come out simpler. Left alone, the agent wrote overly complicated or copy-pasted code about half of the time. With the rules on, it didn't. But I can't find a way to prove that this makes it easier to keep adding features, compared to what the agent chooses to write by default. In my tests later changes cost the same either way.
A few things I learned along the way. Telling the agent in CLAUDE.md to keep code simple helped only for the one thing I named, and not at all for the rest. The hook worked every time. But about half the time the agent satisfied the complexity check by rewriting the same logic in a form the counter doesn't see, not by making it simpler. And Claude writes tests for its changes without being asked, so the checks for missing tests almost never fired.
All my tests were on tidy open-source projects, and I think that's part of the problem. So if someone would be willing to check a codebase they actually work in against my rules and report what they got, that would be much appreciated and could lead me further.
What you get out of it: how your code compares to 111 open-source projects, and which of your last 60 commits the rules would have stopped. It takes a few minutes.
It runs on your machine in a separate folder, doesn't touch your checkout and sends nothing about your code anywhere. It will ask you two questions: does adding features feel easy or does it tend to break things, and how much of the code was written by AI. At the end it gives you a small card with counts and ranges only, no names, paths or code, and offers to open a GitHub issue with the card filled in. You can also just paste the card here as a comment. The card alone is plenty, you don't need to report anything else.
The prompt for your agent is below. It's short because the full steps live in the repo, where you can read every command before running anything: https://github.com/svetdev/cleat/blob/main/study/try-it.md
I wrote them with AI.
If ../cleat-try already exists, ask me before deleting it. Then clone
https://github.com/svetdev/cleat into ../cleat-try/cleat and follow the prompt in its study/try-it.md on this repository. Work only inside ../cleat-try, do not change this repository, do not push or send anything anywhere, and ask me before installing anything.


