cd /news/ai-agents/adding-a-style-guide-made-my-coding-… · home › topics › ai-agents › article
[ARTICLE · art-175753] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

Adding a Style Guide Made My Coding Agent Reintroduce a Bug

A developer ran 14 self-contained Python bug-fix tasks through a local llama3.1:8b coding agent under three conditions — no repository instructions, a 10-line style guide, and a 150-line engineering standards file — and found the agent fixed all 14 with no instructions but only 13 with either instruction file. The dropped case was telling: without instructions the model wrote a clean fix from scratch, while with instructions it rewrote the buggy logic almost unchanged, suggesting the files shifted how the model read the existing code rather than causing the bug directly. All 42 completions were graded by running real pytest files in isolated subprocesses, with raw outputs and logs published in a public repository.

recommendation

When a coding agent must fix a self-contained bug, test it with and without your instruction file; here instructions cut passes from 14/14 to 13/14 by nudging the model to patch existing logic rather than rewrite it.

more in playbook: Working with AI coding agents
by read7 min views1 publishedNov 24, 2026

Fourteen small bug fixes, three instruction conditions, one failure that only showed up once I added rules.

I gave a coding agent fourteen tiny, broken Python functions and asked it to fix each one three times: once with no repository instructions at all, once with a short ten-line style guide, and once with a hundred-and-fifty-line "engineering standards" document covering the exact same ground. With zero instructions, it fixed all fourteen. With either instruction file, concise or verbose, it fixed thirteen. The one it dropped is the interesting part. Given no instructions, the model wrote a clean, correct fix from scratch. Given instructions that said nothing about this specific bug, it instead rewrote the buggy function's broken logic almost unchanged, just with an extra method chained on front. The instructions did not cause the bug. They changed how the model looked at the existing code, and that was enough.

I wrote this with AI assistance, and I fact-checked and edited every claim myself.

What I actually ran: 14 self-contained Python bug-fix tasks, 3 instruction conditions, 1 completion per task per condition, 42 completions total, one run, no repeated trials per cell. Model: llama3.1:8b running locally via Ollama, for 41 of 42 completions, free and zero cost. One completion (the first "no instructions" task) was served by Gemini's free tier before it hit a rate limit and the fallback chain dropped to the local model for the rest of the run. Grading was never done by eye or by asking a model to judge itself. Every candidate fix was extracted from the raw response and run against a real pytest file in an isolated subprocess; a pass means pytest actually exited zero. Every one of the 42 raw completions, every pytest log, and the two instruction files themselves are in coding-agent-instructions-experiment (Reproducibility section below).

Repository instruction files like CLAUDE.md or AGENTS.md have become a default move for anyone running a coding agent against a real codebase. The implicit bet is that more context about conventions and known pitfalls produces more reliable fixes. I wanted to test a narrower, falsifiable version of that bet: does prepending a repository instruction file change a coding agent's pass rate on small, self-contained bug-fix tasks, compared to giving it no instructions at all, and does making that file longer and more thorough change the answer?

I wrote 14 small Python functions, each with exactly one real bug drawn from a different family: off-by-one range bounds, a mutable default argument, the wrong exception type, an unstable sort key, accidental mutation of an input list, a missing dict default, a wrong recursion base case, a string-method mixup, a missing empty-input guard, a wrong boolean condition, an off-by-one slice, and an accumulator that overwrites instead of adding. Each task ships with its own pytest file that fails against the buggy version and passes against a correct fix. I verified all 14 bugs are real by running the buggy code against its own test before touching a model at all; every one failed as expected.

Each task went to the model three times, under three conditions:

The prompt always ended with the same instruction: return only the corrected function, as a single code block. I extracted the first fenced code block from the response (or the raw text if there was no fence), wrote it to an isolated temp directory next to that task's real pytest file, and ran python3 -m pytest in a subprocess with a 20-second timeout. A pass requires pytest to exit zero. Nothing was graded by a model, and nothing was graded by me reading the output and deciding it looked right.

Pass rate by instruction condition, 14 bug-fix tasks, one completion per task per condition. Image by author.

None: 14/14 (100%). Concise: 13/14 (92.9%). Long: 13/14 (92.9%).

That is the entire headline number, and I want to be direct about what it does and doesn't support. With one trial per task per condition, a single task flipping from pass to fail is the whole effect. That is not enough data to claim instructions reliably hurt pass rate in general. What it is enough data for, because it is a real, inspectable example from an actual run, is showing one specific way instructions can fail to help, or actively redirect a model's attention somewhere unhelpful, on a task they weren't written to cover.

The task both instruction conditions failed was string_strip_bug: write clean_username(name) to lowercase a username and strip only the leading and trailing whitespace, not the spaces inside it. The buggy version used .replace(' ', ''), which strips every space, not just the edges. Given no instructions, the model wrote name.lower().strip(), a clean, correct answer that doesn't resemble the buggy version's approach at all. Given either instruction file, it wrote name.strip().lower().replace(' ', ''), which adds a .strip() call but keeps the exact broken .replace() call from the original buggy code, and fails the same test the buggy version failed.

Neither instruction file mentions this bug family. The concise file names three pitfalls (off-by-one ranges, mutable defaults, wrong exception types); the long file names seven, adding accidental mutation, dict key errors, accumulator scoping, and rounding or empty-input edge cases. A string-method mixup isn't on either list. So this wasn't a case of the instructions actively misleading the model about this specific bug. It was a case of the model, once given a document full of rules to apply, appearing to lean more heavily on the existing buggy code's structure rather than writing past it, even on a bug the rules never addressed.

Going in, I expected one of two outcomes: either the instruction files would measurably raise the pass rate by flagging the exact pitfalls present in the task set, or they would make no difference because the tasks were simple enough that a capable model would get them right regardless. I did not expect a case where adding instructions made the model worse on a task those instructions didn't even cover.

The evidence that changed my assumption is sitting right there in the raw response diff. Without instructions, the model's fix bears no resemblance to the bug it's replacing: full rewrite, correct idiom, no trace of the original approach. With instructions present, in this one case, the model's fix is the original buggy line plus one small patch bolted onto the front. That is a shape I recognize from an earlier article in this series, where I showed a model its own failing code and its retry attempts sometimes reproduced the same bug rather than reasoning past it. Here, nobody showed the model its own prior failure. The instruction file alone was enough to shift it from "write a fresh answer" to "patch what's already there."

What I changed after seeing this: nothing in the experiment design, because the honest result is the result. What I'd change in a follow-up: more trials per cell so a single flipped task isn't the entire signal, and a task set deliberately including a few bugs the instruction file explicitly warns against, to separate "instructions that name the exact pitfall" from "instructions in general."

Every task, both instruction files, all 42 raw completions, the pytest logs, and the chart above are in coding-agent-instructions-experiment, part of my consolidated Medium reproducibility repo. Clone it, run python3 run_experiment.py with Ollama serving llama3.1:8b locally, and you'll get a free, zero-cost run of your own. It won't be byte-identical to mine; this model isn't pinned to a fixed seed. It should reproduce the general shape: a model that handles the bulk of small bug-fix tasks cleanly regardless of instructions, and occasional cases where instructions change the model's relationship to the existing code in ways a pass/fail count alone won't tell you about until you read the diff.

If you run this against your own repository's actual instructions file, the question worth asking isn't "does this help on average." It's: does your instruction file name the specific pitfalls your codebase actually produces, or is it mostly process philosophy that a model has to wade through to find the three lines that matter? On this run, that distinction was the whole difference between a file that could plausibly help and one that didn't.

If you've pasted your own CLAUDE.md or AGENTS.md back into a model and asked it to grade which lines are actually pulling weight on your real bug history, what did it keep, and what did it throw out?

── more in #ai-agents 4 stories · sorted by recency
── more on @llama3.1:8b 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/adding-a-style-guide…] indexed:0 read:7min 2026-11-24 · —