Skip to content

Your AI writes slop. Your codebase taught it how.

Agents never sat in code review. Lint rules, an instruction file, and a clean repo teach them now.

Someone pastes a screenshot into the team channel. It’s agent-written code. A try block that catches every exception and does nothing with it. Two helper functions that already exist three folders over. A comment above a one-line function explaining what the one line does. Skull emojis roll in. „This is why I still write my own code.“ Somebody announces that models will never understand clean code.

The code is bad. But I’d ask the person who posted it one question. What did you give it to work with?

Look at the screenshot again. No lint rule blocked the swallowed exception. No instruction file told the agent to keep comments to a minimum. And the duplicated helpers came from the repo itself, because agents copy what the neighboring files do, and a codebase that already tolerates near-duplicates grows more of them. An agent starts fresh every session. The only taste it gets is whatever fails a check, whatever sits in a file it reads, and whatever it sees in your code.

I’ve had agents make a mess in my own products. A smarter model never fixed it. What fixed it was lint rules whose error messages talk to the agent, a short instruction file, and a cleanup of the code the agents were copying. The rule has to come before the cleanup, and I’ll get to why.

If your AI writes slop, the joke is on you. You built the environment it works in, and that’s the part you can fix.

the codebase is the loudest prompt

Start with the duplicated helpers, because they show the mechanism best. An agent working in your repo looks at how the neighboring files do things and does the same. Great when the neighbors are good. A disaster when they aren’t.

If the repo already holds two near-identical date formatters in different folders, a third one looks like house style. Every copy the agent adds becomes one more neighbor for the next session to imitate. Mess spreads. And the code tends to beat whatever you wrote down. If your instruction file says „use the new client“ but forty files still use the old one, I wouldn’t bet on the instruction file.

Comments are worse, because the agent reads them as fact. Picture a comment that says „retries are handled by the HTTP client,“ written back when that was true. Someone ripped out the retry middleware months ago and never touched the comment. The agent takes the comment at its word, skips the retry, and ships code that falls over on the first network blip. It didn’t hallucinate anything. It believed you.

An outdated comment used to be a small annoyance. Now it’s a prompt you forgot you wrote.

your taste only ever lived in people

A teammate who’d been around for a while would have known that comment was stale. The agent can’t know that, and it’s the shift people miss when they post the screenshot.

Before agents, taste moved through people. Code review enforced the guidelines one comment at a time, and a lot of it never got written down at all. A pairing session. A „why’d you do it this way?“ at someone’s desk. That was the real job of a good senior or staff engineer, even if no career ladder spelled it out. You were good because the people around you got better.

Now picture a senior who does the opposite. They screenshot the junior’s worst PR, post it in the channel, and use it as proof of how great an engineer they are. We’ve all worked with that person. Nobody thought they were the best engineer on the team. We thought they were a bad teammate.

That’s the energy behind most AI slop dunking. A lot of the people posting those screenshots say their edge is precise, elegant code. Whatever that means. With humans, review papered over the vagueness, and a junior who sat next to you for a year absorbed your taste without either of you noticing.

An agent gets none of that. Your job now is to make it succeed without lowering the bar, because the code still has to be maintainable, reliable, and secure. You fix the environment in order of reliability, starting with the one layer the agent can’t ignore.

first move: make it impossible

Every time I catch an agent doing something weird, my first question is whether a lint rule can make it never happen again.

Custom linters used to be a project. You learned your linter’s plugin API, walked an AST, wrote tests for the rule, and then argued with the team about whether it was worth maintaining. Most teams never bothered. Now the agent that made the mistake can write the rule that forbids it, usually in minutes.

Take the swallowed exception from the screenshot. In Semgrep that’s a few lines of YAML:

rules:
  - id: no-swallowed-exceptions
    languages: [python]
    severity: ERROR
    message: >
      Exception swallowed with `pass`. Catch the specific
      exception type and handle it, or let it propagate.
    pattern: |
      try:
          ...
      except $E:
          pass

For this exact pattern you don’t even need a custom rule, since Ruff ships S110 and BLE001. Turn the built-ins on first and write custom rules for the house rules nothing ships with. Either way, run them locally and in CI, and the pattern can’t merge anymore. This beats everything else for two reasons. A rule is deterministic. It doesn’t care whether the agent read your docs, how full its context window got, or which model you’re running this week. It fires every single time.

The second reason gets underrated. The error message is an instruction that shows up at the exact moment of the mistake. Agents read linter output and fix what it tells them, so write the message for the agent. Say what’s wrong and what to do instead. „Catch the specific exception type“ gives it a next step. „Bad pattern“ gives it nothing.

Watch the escape hatch, though. Every linter has one. In Semgrep it’s a # nosemgrep comment, and an agent chasing a green build will reach for it. Require a written reason next to every suppression and make new ones stand out in review, or „impossible“ quietly becomes „optional.“

second move: write it down

Some things a linter can’t express, or can’t express cheaply. „Don’t write a comment that restates the code.“ „Prefer composition over a new base class.“ „Handlers never talk to the database directly.“ That last one you can often enforce with an import-boundary checker, so try that first.

Whatever survives goes into the instruction file. CLAUDE.md, AGENTS.md, whatever your tool loads on startup. The format that works for me is blunt. Don’t do this. Do this instead.

## Comments
- Keep comments to a bare minimum. Never restate what the code does.

## Errors
- Don't catch broad exceptions. Handle the specific error or let it propagate.

My own global instruction file has a comments section that says almost exactly the first rule.

Treat this layer as weaker than a lint rule, because it is. The agent reads it most of the time and follows it most of the time. Most is not always. That’s why something lands in the markdown file only after I’ve decided it can’t be a check. Keep the file short, too. Every line competes with every other line for the model’s attention, and a 900-line instruction file is a document nobody follows, human or agent.

third move: write the rule, then pull the weeds

Rules and instructions stop new mess. They do nothing about the mess the agent is already copying. So the third move is gardening. You keep pulling bad code out of the codebase, because whatever stays in becomes a template for the next thousand lines.

My own repos needed it. I had mess in several products, and a good chunk of it came from agents I’d given too little structure. Tighter lint rules came first, then cleaning up what the agents had already produced. And yes, I did the cleanup with more AI agents. That isn’t a contradiction. An agent with a clear rule and a clear target is excellent at boring, repetitive cleanup.

Here’s why the order matters. A new lint rule run against an existing codebase prints every violation, which is your cleanup worklist, already itemized. Hand that list to agents, fix the violations, merge. Now the rule is green and stays green, and the weed can’t grow back. Clean up first without the rule and you’ll be cleaning the same mess again next month.

The duplicated helpers get the same treatment. Merge them into one, delete the rest, and point the instruction file at the survivor. A copy-paste detector in CI keeps the next duplicate from sneaking back in. The stale retry comment goes too. Fix it or delete it. Every comment you keep is one more sentence that can drift out of date and start lying to the agent, which is the best argument I know for writing fewer of them.

That cleanup is why I trust the agents now. Today I hand them more and more of the work.

„this is just babysitting“

The obvious pushback goes like this. If I have to write lint rules and instruction files and garden the codebase, why not just write the code myself?

Because you did this exact work for every junior you ever onboarded, and each time you got one person out of it. A lint rule applies to every agent session, every teammate, and every future hire, for as long as it’s in CI. The instruction file gets read on every run. A clean module gets copied correctly every time something new is built next to it. I can’t think of work a senior engineer has done with a better return.

It doesn’t fix everything, though. Rules over-fire. Sometimes ignoring an exception really is the right call, which is what that suppression comment with a written reason is for. Rules pile up and need pruning like any other code. And some failures are the model hitting its limits, which no environment fixes. That’s why I still read the code that matters. But each surprise turns into a rule instead of a recurring argument, and the surprises get rarer as the environment gets better.

so who’s the joke on

Next time someone drops agent slop in the channel, skip the skull emoji. Trace it back to whatever let it through, and fix that instead of the screenshot.

That screenshot doesn’t prove the model is bad. It’s a to-do list, and it has your name on it.

DSGVO Cookie Consent mit Real Cookie Banner