---
title: "Do We Really Need All These Lines? How to Tell If Your AI Agent Writes Too Much Code (2026)"
description: "AI coding agents write code that works and is still too long. Here is how to spot verbose agent code, five checks to measure it, and one rule that stops it from spreading through your repo."
date: "2026-11-22"
tags: [ai, agents, claude-code, code-quality, code-review, opinion]
sources:
  - title: "SlopCodeBench: Benchmarking How Coding Agents Degrade Over Long-Horizon Iterative Tasks (Orlanski et al., March 2026)"
    url: "https://arxiv.org/html/2603.24755"
  - title: "More Code, Less Reuse: Investigating Code Quality and Reviewer Sentiment towards AI-generated Pull Requests (2026)"
    url: "https://arxiv.org/html/2601.21276"
  - title: "Humans are Missing from AI Coding Agent Research (2026)"
    url: "https://arxiv.org/pdf/2608.12355"
  - title: "Debloating The AI-Grown Codebase (Maxim Saplin, DEV Community)"
    url: "https://dev.to/maximsaplin/debloating-the-ai-grown-codebase-2om"
  - title: "The perverse incentives of Vibe Coding (UX Collective)"
    url: "https://uxdesign.cc/the-perverse-incentives-of-vibe-coding-23efbaf75aee"
  - title: "Engineering leader post on AI agents writing too much code (LinkedIn)"
    url: "https://au.linkedin.com/in/spilarek"
  - title: "jscpd: copy/paste detector"
    url: "https://github.com/kucherenko/jscpd"
  - title: "Knip: find unused files, dependencies and exports"
    url: "https://knip.dev"
  - title: "Overview of .NET source code analysis (Microsoft Learn)"
    url: "https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview"
  - title: "Claude Code hooks reference"
    url: "https://docs.claude.com/en/docs/claude-code/hooks"
agent_task: "Run the shrink test on the most recent change you made in my repo: make it about 30% shorter without changing behavior, keep every test passing, and show me what you cut. Then add a one-line 'least code' rule to the top of my root CLAUDE.md."
skill_name: "agent-shrink-test"
---
The PR works. The tests pass. It is also 400 lines for a 100-line job (example numbers, but you have seen this PR).

This is the slop nobody flags in review. The code is not wrong. There is just too much of it. A March 2026 benchmark, [SlopCodeBench](https://arxiv.org/html/2603.24755), found agent code is **2.2x more verbose** than human code in the same 48 open-source repos. Worse: the human code stayed flat over time. The agent code got worse with each change.

So ask the question every reviewer should ask: **do we really need all these lines?**

## Table of Contents
1. [What Too Much Code Looks Like](#what-it-looks-like)
2. [How to Find Out](#how-to-find-out)
3. [Why It Gets Worse](#why-it-gets-worse)
4. [What Others Are Seeing](#what-others-see)
5. [The One Rule](#the-one-rule)
6. [Try It This Week](#try-it)

---

## What Too Much Code Looks Like {#what-it-looks-like}

Verbose agent code has a look. Once you see it, you see it everywhere.

- **Wrappers nobody asked for.** A helper class around one function call.
- **A try/catch around every call.** Errors get caught, logged and swallowed.
- **Null checks on values that cannot be null.** The type system already says no.
- **Comments that repeat the code.** `// increment counter` above `counter++`.
- **Options nobody uses.** Config flags and parameters for cases that will never happen.
- **A second copy of code that already exists.** The agent did not look, so it wrote it again.

---

## How to Find Out {#how-to-find-out}

You do not need a new tool. You need five checks.

1. **The shrink test.** Give the agent its own code back and say: "Make this 30% shorter. Do not change behavior. All tests must still pass." If it can, the first version was too long. This is the one to try today.
2. **The diff ratio.** Compare the size of the change to the size of the task. A one-line bug fix should not touch six files.
3. **The duplication scan.** Run [jscpd](https://github.com/kucherenko/jscpd) on the repo. It finds copy-paste blocks across files and languages.
4. **The dead code scan.** Run [Knip](https://knip.dev) for TypeScript, or turn on the [.NET code analyzers](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview) for C#. Unused exports and parameters are a clear sign of extra code.
5. **The "why" check.** Pick any 10 lines from the PR. Say why each one exists. If you cannot, delete it and run the tests.

---

## Why It Gets Worse {#why-it-gets-worse}

The agent copies what it sees. The SlopCodeBench authors found that each edit keeps and extends the bad patterns from earlier edits.

So one bloated PR is not one problem. It is a template. The next task reads it, learns from it and writes more of the same. **Your repo is the prompt.**

And reviewers miss it. A [2026 study of agent pull requests](https://arxiv.org/html/2601.21276) found reviewers reacted more positively to AI code than to human code, even though the AI code had more duplication. It looks clean, so it gets merged.

---

## What Others Are Seeing {#what-others-see}

I am not the only one asking this.

- **Researchers measured it.** A [2026 paper on agent patches](https://arxiv.org/pdf/2608.12355) compared agent fixes to the real fixes. When agent patches ran long, two AI judges named verbose implementation (like extra variables that do nothing) as a top cause, in about 60% of the long patches that still solved the bug.
- **Someone tried the shrink test for real.** Maxim Saplin [cut about 40% of the lines](https://dev.to/maximsaplin/debloating-the-ai-grown-codebase-2om) from an AI-grown codebase in a weekend, with no loss of features. His point: the bloat comes from accumulation, a little more with every agent turn.
- **Engineering leads are changing their review question.** [One engineering leader on LinkedIn](https://au.linkedin.com/in/spilarek) says the bigger risk is not bad code but too much code, and that "did we need to change that much?" is becoming a key review question.
- **There is a cost angle too.** A [UX Collective essay](https://uxdesign.cc/the-perverse-incentives-of-vibe-coding-23efbaf75aee) argues that token pricing gives tools little reason to push for short code, and that verbose code then becomes context for the next request.

Different people, same finding: working code is not the same as the right amount of code.

---

## The One Rule {#the-one-rule}

Put one line at the top of your root `CLAUDE.md`:

```markdown
Write the least code that solves the task. Delete before you add.
```

Claude Code reads the root `CLAUDE.md` on every task, so the rule reaches every folder. Folder-level `CLAUDE.md` files can add local detail, but this line stays on top.

One caution: `CLAUDE.md` is advice, not enforcement. For rules you cannot let slide, add a [hook](https://docs.claude.com/en/docs/claude-code/hooks). A simple one flags any change over a set number of lines and asks for a reason before it continues.

---

## Try It This Week {#try-it}

Fewer lines is not the goal. Fewer lines you cannot explain is the goal.

Pick your last agent PR. Run the shrink test. If the agent cuts 30% and the tests still pass, you just found your slop. Then add the rule and stop it from spreading.

---

## TL;DR {#tldr}

| Problem | Fix |
|---------|-----|
| Agent code works but is too long | Run the shrink test: 30% shorter, same tests |
| Big diffs for small tasks | Check the diff ratio |
| Copy-paste and dead code | Run jscpd and Knip (or .NET analyzers) |
| Bloat spreads to the next task | Your repo is the prompt. Clean it up |
| No standing rule | One line at the top of root `CLAUDE.md`, backed by a hook |

- SlopCodeBench found agent code is 2.2x more verbose than human code, and it gets worse with each edit.
- Reviewers tend to miss it because it looks clean.
- The shrink test is a five-minute way to find out.

---

**More posts:**
- [Overwhelmed Yet? How to Manage AI Agents When You're the Bottleneck (2026)](/blog/agent-overload-human-bottleneck-2026)
- [How to Track Token Usage in Claude and OpenAI (Python Tutorial, 2026)](/blog/track-token-usage-claude-openai-api)
- [MCP vs API: What's the Difference, and Why Claude Uses MCP (2026)](/blog/mcp-vs-api-whats-the-difference-claude)

---

*// hereshecodes.com*
