A 12-Line Conventions File Fixed Every Claude Coding Failure in My Experiment

V

Viktor Tr

Guest
I gave Claude Sonnet the same one-line coding task five times. And five times it filled the gaps with the same guesses: Decimal for money, ValueError for bad input, plus status and created_at fields I never asked for.

Then I gave it my real Order class and the input format. Not my team's conventions, just the data model. Five runs out of five, it stored $12.50 as 12.5 cents.

The fix? A 12-line conventions file and the helper files it points to. With those, every run passed all 8 of my hidden tests. I even buried them in 62,000 tokens of unrelated code, and all 5 runs still passed. The only thing that changed was the bill: about 6 times bigger, and that's with caching.

As an ML developer, I look at every prompt like a dataset with missing values. In this article I'll show you why, walk you through the experiment, and tell you honestly which part of my theory didn't hold up.

Garbage In, Garbage Out​


When I started working with ML, one of the first things I learned was:

"Your model is only as good as your data."

Missing features, wrong labels, noisy columns: the model doesn't care how clever your architecture is. It learns from what you give it, and nothing else.

Then I started coding with AI agents every day. And I noticed something funny.

People forget this rule the moment they open a chat window.

They type one line, get a bad answer, and say "the model is stupid". As an ML developer, I look at it differently. When my model gives bad output, the first thing I check is not the model. It's the input.

R4wsbPS5sLRmPKPzOZLOzxdFQOA2-zf83b72.jpeg



The Model Is a Function​


From an ML point of view, every response you get is:

Code:
output = f(weights, input)
  • weights: what the model learned during training. Billions of parameters. You can't change them.
  • input: everything in the context window right now. Your message, the files, the instructions, the chat history.

There is no third thing.

The model doesn't see your screen. It doesn't know what you discussed in yesterday's meeting. It doesn't remember the last session, unless something put it into the input again.

Notice something? Out of these two parts, you control only one. You can't retrain Claude. But you decide 100% of the input.

So when I say "you are responsible for the response", I don't mean it in a motivational way. I mean it mathematically. The input is the only variable you have.

R4wsbPS5sLRmPKPzOZLOzxdFQOA2-cj93beu.jpeg



Agents help here. They can read files and search the repo. But they decide what to read based on what you told them. A vague task sends them exploring in the wrong direction.

Missing Input = The Model Fills It With the Average​


This is the part that clicked for me as an ML dev.

What happens in a dataset when a feature is missing? You impute it. In pandas it's one line:

df.fillna(df.mean())

Mean, median, most common value. The gap gets the most typical thing.

A language model does the same.

When information is missing from the input, it usually doesn't stop and say "I don't know". It fills the gap with what is most likely, based on its training data. The statistical average of millions of projects it has seen.

That's where generic code comes from. Not your project, a typical one. Confident guesses about your database, your naming style, APIs that "usually" exist in libraries like yours.

R4wsbPS5sLRmPKPzOZLOzxdFQOA2-qja3b64.jpeg



Karpathy complained that models "make assumptions on your behalf and just run with them". From the ML side, this is not a bug. It's imputation. The model is doing what it was trained to do: predict the most likely continuation of the input it got.

That was my theory, anyway. I wanted to see it with real numbers.

The Experiment: One Task, Four Prompts​

The setup​


I wrote a tiny Python package called shoplite, with a few conventions that no model could guess from the outside. Here is its conventions file:

Code:
# shoplite conventions

- Money is always `shoplite.money.Money`, an integer number of cents.
  Never use `float` or `Decimal` for amounts. Parse strings with `Money.from_str`.
- Bad input raises `shoplite.errors.ValidationError(field, reason)`.
  Never raise `ValueError`, `KeyError` or your own exception classes.
- Read required keys with the helpers in `shoplite.validate`
  (`require`, `require_positive_int`). Don't index `raw[...]` directly.
- SKUs always go through `shoplite.validate.normalize_sku`.
- A parser for a nested object is a private function named `_parse_<thing>`
  in the same module (see `_parse_address` in customers.py).
- Standard library only. No pydantic, attrs or marshmallow.

Normal team rules. Your project has its own version, written down or not.

The task was one line:

Add a function parse_order(raw: dict) to shoplite/orders.py that turns a raw order dict from our API into an Order.

Then I wrote 8 hidden pytest tests the model never saw. They check the ids, that prices are Money, that the total is exact (2 × 12.50 + 3 × 0.10 = 25.30, a classic float trap), that SKUs get normalised, and that 4 kinds of bad input raise our ValidationError (3 of those tests also check the error's field).

I sent the task in four versions:


Condition

What the prompt contains

Input tokens

missing

only the one-line task

~650

contract

the task + the real orders.py with Order and OrderLine + the input format

~950

sufficient

the task + 6 relevant files, including the conventions + acceptance criteria

~2,200

noisy

the sufficient content, placed in the middle of real but unrelated Python modules

~62,700

The contract version is the interesting one. It's what many of us give an agent: here's the data model, here's the input, go. No team rules.

For the noise I used real standard library modules (csv, shlex, json and others), shown as vendor/*.py files. The "just paste the whole repo" approach.

Each call was claude -p --model sonnet (Claude Sonnet 5.5, through Claude Code 2.1.302, December 2026) with all tools turned off and a one-line system prompt, so the prompt was the model's whole world. No file reading, no searching. I asked for the full orders.py in one code block "and nothing else", dropped it into a clean copy of the package and ran the tests. 5 runs per condition, 20 in total.

The results​



missing

contract

sufficient

noisy

Amounts as Decimal

5/5

5/5

0/5

0/5

Raised ValueError or a subclass

5/5

5/5

0/5

0/5

Invented its own exception class

0/5

5/5

0/5

0/5

Used the require helpers

0/5

0/5

5/5

5/5

Used normalize_sku

0/5

0/5

5/5

5/5

All 8 tests pass

0/5

0/5

5/5

5/5

Cost of 5 runs

$0.08

$0.08

$0.05

$0.32

Before you say it: yes, the missing version can't pass. My tests use field names like order_id and qty that the one-line prompt never showed. So 0 of 8 there is expected, by design. What I wanted to see was what the model would put in the gap.

What "the average" looked like​


Here's the Order class from one of the missing runs:

Code:
@dataclass
class OrderItem:
    sku: str
    quantity: int
    unit_price: Decimal


@dataclass
class Order:
    id: str
    customer_id: str
    items: list[OrderItem] = field(default_factory=list)
    status: str = "pending"
    created_at: datetime | None = None

Clean, reasonable code. It's also the guess most tutorials would make. Just not my project.

What surprised me is how stable the guess was. In all five missing runs, the model:

  • used Decimal for money
  • raised ValueError for bad input
  • named the fields id and quantity (mine are order_id and qty)
  • added status and created_at fields that nobody asked for

Three runs out of five also added currency: str = "USD". Small details changed (four runs made the class frozen, two gave the fields defaults), but the shape was the same every time.

No run asked me a question. To be fair, my prompt said "nothing else", so a question wasn't really allowed. One run did add a note at the top: "I couldn't read the existing shoplite/orders.py, so the Order and OrderItem definitions below are assumptions." The other four didn't even warn me. They imputed and moved on.

Five samples only prove the guess is stable, not that it's the "average of the internet". But it sure looks like the typical answer.

What the conventions add​


Here's the part I like most. In the contract version the model saw my real Order class:

lines: tuple[OrderLine, ...] and total: Money

So it knew Money existed. It didn't know Money counts cents.

All five runs did the same thing: parse "12.50" with Decimal, then wrap it into Money(price). So $12.50 became Money(cents=Decimal("12.50")). That's 12.5 cents. Three of the five even left a comment saying they assumed Money takes a Decimal amount. Nobody checked, because nobody could.

The same pattern again:

  • all five invented the same exception, OrderParseError(ValueError), with the same name
  • all five wrote their own private _require helper, almost a copy of the require that already lives in validate.py
  • none of them normalised the SKU

Result: 1 test out of 8 passed in every run (the ids). The data model filled one gap. The conventions filled all the others.

With the sufficient prompt (about 2,200 tokens), every run used Money.from_str, our ValidationError, the helpers and normalize_sku. The model didn't get smarter. The input got complete.

The noise didn't break it (this time)​


I expected the noisy runs to fail sometimes. The Lost in the Middle paper found models use the middle of a long input worse than its start and end. Chroma's Context Rot report showed performance dropping as input gets longer, even when the task stays the same. So I put the relevant files right in the middle.

In 5 runs I saw no drop at all. My theory said noise would hurt, and these runs said no. (A small sample, see the limits below.) That's also why I'd read pieces like More Context Is Making Your AI Worse and How to Stop Context Rot in Coding Agents with one question in mind: what kind of noise, and how hard was the task?

What the noise clearly hurt was the bill: about 29 times more input tokens, and $0.32 against $0.05, so about 6 times more. That's with luck. The first noisy call alone cost $0.26, and the next four were cheap only because the same prompt hit the cache. Without it, closer to 24 times more. In a real agent session the junk changes every turn, so you don't always get that discount.

Limits​


This is a small experiment, and I want to be clear about what it does not show:

  • Small n. 5 runs per condition, one model, one task. 5 out of 5 can't rule out a failure rate of 1 in 3 or so.
  • Easy noise. The noise was clearly labelled as separate, unrelated files, and the task, a "Relevant files" header and the criteria sat together in one block. No old orders.py, no conflicting conventions. That harder case I didn't test.
  • Easy task. "Follow the files in front of you" is one hop. The context-rot research reports bigger drops on harder, multi-step tasks.
  • 2 lost calls. My first script version had a bug. One missing-condition reply had no code block, and the script threw it away without saving it. That one might have been a question. Another call was killed mid-flight. I made 22 calls in total, and 20 are in the results.

So the honest conclusion is: missing context hurt every time, even with the data model in the prompt. Labelled noise cost money, and in 5 runs it didn't cost quality.

So Is More Context Fine Now?​


Not quite. I still think in terms of feature selection.

When I train a model, I don't throw every column I have into it. Useless features cost compute and make debugging harder, even when accuracy stays the same. My experiment shows a 2026 model can ignore 62k tokens of junk when the relevant files are clearly labelled. Not that it does this for free, or on a harder task.

And real context junk is usually worse than mine: old versions of the same file, a chat full of an approach you dropped, docs for last year's API. That kind of noise looks relevant.

So the goal is still:

All the input the task needs. And as little as possible of what it doesn't.

In ML terms: high signal, low noise. My experiment just changes the order of priority for me. Missing signal is the expensive mistake. Extra noise is the cheaper one.

This is why people stopped saying "prompt engineering" and started saying "context engineering". Karpathy described it as the art of filling the context window with just the right information for the next step. (Anthropic has a good write-up on it too.)

What "All the Input Data" Means for a Project​


Here's my checklist. I think of it like the features of a dataset:

  1. The goal and the why. Not "add a login", but "add login with email so that teachers can see only their own classes". The why changes the solution.
  2. The constraints. Stack, versions, what you can't change, "no new dependencies".
  3. The relevant code. The files that matter, or at least where to look.
  4. The conventions. How you name things, how you handle errors, which helpers already exist. In my test, the data model alone wasn't enough without them.
  5. The full error. The whole stack trace, not "it doesn't work".
  6. Fresh docs. If a library changed after the model's training, give it the current docs.
  7. How to verify. The test command, or what the result should look like.
  8. What done means. Acceptance criteria. Otherwise "done" also gets imputed with the average.

Most of these don't change between tasks, so I don't type them every time. I put them in files: a short AGENTS.md for the project, specs and plans in docs/, and a scripts/verify.sh the agent can run. I wrote about this whole setup in my previous article, Agentic Coding Without the Chaos: How I Manage 13 AI Coding Agents.

The conventions file from my experiment is exactly the kind of file that belongs there. Twelve lines, plus the helper files it points to. With them, every run went from 1 of 8 to 8 of 8.

Debug the Input, Not the Model​


When a production model gives bad predictions, a good ML engineer checks the data pipeline before touching the architecture. I now do the same with AI agents. Before I say "the model is dumb", I ask:

  • Did it have the goal? Or only the task?
  • Did it see the right files and conventions? Or did it guess?
  • Did I give the full error?
  • Was the context full of old stuff from a long chat? (Then I start a fresh session.)
  • Did it have a way to check its work?

Most of the time, the answer is in this list. The model wasn't stupid. The input was incomplete.

And the nice part: if you fix the input in a file the agent reads every time, you don't fix one answer. You fix every future answer.

Final Thoughts​


Models got a lot better this year. My noisy runs show it: 62k tokens of labelled junk, and Sonnet still followed every convention.

But one thing didn't change, and I don't think it will:

A model can only reason about what's in front of it. Whatever isn't there, it fills with a guess. And the guess is the typical one.

So here's my ML-dev summary:

  • The model is a function. You control the input.
  • Missing input gets filled with the average. In my test: the same guess, 5 runs out of 5, even with my data model in the prompt.
  • Extra input mostly costs tokens and money, at least on easy tasks.
  • So give it everything the task needs, and don't pay for what it doesn't.

It doesn't matter which language you write in or which model you use. Building the full picture is your job.

Have you run similar tests? Especially with conflicting context instead of unrelated noise? I'd really like to see your numbers. I'm still learning this, like everyone else.

Sources​

 

Thread statistics

Created
Viktor Tr,
Replies
0
Views
7
Back
Top