r/LLMDevs • • 1d ago

Discussion We need a benchmark for code maintainability

From human engineering experience, code maintainability matters a lot. Every team that has lived with a codebase for more than a few months has felt the compounding cost of tangled abstractions, global state, and fragile test setups.

With coding agents, that assumption is suddenly up for debate. A recent thread on X by Tom Sydney Kerckhove pushed back on the claim that unmaintainable code is not a problem when only agents are maintaining it.

The reason this argument keeps coming back is simple: LLMs can brute-force bad code. An agent can scan thousands of lines, trace side effects across poorly structured modules, and patch its way past a bug that would stall a human for hours. That problem-solving capacity hides the drag. Even when a codebase suffers from recurring bugs caused by patterns like mocking via monkey-patching, an agent often powers through the failure instead of refusing to touch the file.

Because the cost is obscured rather than obvious, intuition alone will not settle the debate. Until we prove and measure how much maintainability matters for LLMs, the doubt remains.

A Benchmark Design for Code Maintainability

Most coding benchmarks today measure greenfield generation or isolated bug fixes on existing repositories without connecting how a codebase was built to how expensive it is to change later.

Here is a two-stage benchmark design that holds the same model and harness constant across every run:

  1. Stage 1 — Build (v1): Give the agent a clear spec and have it implement v1 from scratch, verified against hidden tests. Measure tokens, wall-clock time, and total cost.
  2. Stage 2 — Two independent parallel tracks branching from that exact v1 codebase (so neither track contaminates the other):

    • 2a. Augment: In a fresh session of the same agent, add a v2 feature to the same codebase, verified against hidden v2 tests plus v1 regressions. Measure tokens, time, and cost.
    • 2b. Fix: On a clean copy of the v1 codebase, inject a set of LLM-planted bugs (subtle logic regressions, state mismatches, broken edge cases) and have a fresh session of the same agent diagnose and fix them. Measure tokens, time, and cost.

What This Lets Us Compare

Holding the model and harness fixed turns the codebase and its underlying stack into the variable under test. You can run the exact same v1 spec, v2 feature, and bug-planting protocol across:

  • Frontend frameworks (React vs. Svelte vs. Lit once the app grows past v1)
  • Backend and data layers (e.g. InstantDB vs. Supabase under v2 changes and state/permission regressions)
  • Languages and type systems (strict static types and compiler diagnostics vs. dynamic stacks)
  • Testing practices (monkey-patched mocks vs. clean dependency injection and integration tests)

A stack that looks fast to scaffold in Stage 1 might carry a steep token and latency tax in Stage 2a and 2b, or vice versa.

Cross-Model Matrix Extension

Once the pipeline exists, you can also lift the single-model constraint and run a cross-model matrix: build v1 with Model A, then run Augment and Fix with Model B. That tests whether frontier models write code that smaller, cheaper models can safely extend and debug—or whether some models produce clever, tightly coupled code that only the same frontier model can untangle later.

Curious what stacks, failure modes, or metrics you would want included in a maintainability benchmark like this.

15 Upvotes

14 comments sorted by

3

u/uriwa 1d ago

Full write-up with the benchmark diagram: https://prompt2bot.com/blog/benchmarking-code-maintainability

For context, I'm working on prompt2bot (https://prompt2bot.com), a platform for hiring AI for various purposes. More of my writing and projects: https://uriv.me

2

u/NotHerBot 1d ago

I'd add three or four successive feature changes on the same branch, with a fresh agent session for each and all earlier regression tests retained. A v1 can be cheap to extend once while each patch makes the next change more expensive. I'd report cost per round alongside the cumulative total, so that pattern stays visible.

1

u/Novel-Title-5287 1d ago

Useful info 👍

1

u/Other_Advance_3859 1d ago

Thanks for sharing, hope we can get more comments in the thread to get more insights.

1

u/r2k-in-the-vortex 1d ago

What maintainable code looks like is very different for AI coding. For example, imagine a code module with 10000 pure functions in it. Wtf, for manual programming this would be "here be dragons" territory.

But they are pure functions, you can have very good spec for them, test them very well and maybe even formally verify them en masse. The fact that there are 10k of them is basically irrelevant if their quality can be high, AI can do lookup just fine. This could be the most reliable part of your codebase.

1

u/fell_ware_1990 1d ago

This is still the pattern i see which happens every day in bigger code bases unless you run it with the whole battery of tests.

What i have found to be the most suitable solution in general is having a few agents going head to head about some stuff. Cause what i’f seen happening most of the time is. Or an agent is not willing to touch any other part of the code cause it’s not ‘his’ code or ‘his’ commit or something or it makes a 180 and fix all the code except the few lines where the bug is located.

So first off all i spend a lot of tokens on my own linters, which are mostly looking for the ‘bad’ example cases. While creating the code, also checking my ‘known’ bottleneck parts of the code. The big functions, nested logic and more.

Tickets agent handle get scoped by my own difficulty level based on those kind of stats i gather. I try to derive a max amount of change. While keeping a scanner around, which identifies the code the agent needs to touch. In there DB should be all or almost all other impacted parts. So the coding agent can plan the change, while a few other light agents check single line logic. Identifying over engineering, checking complete functions to see if it is actually doing one job and doing it correctly. While checking all known test + CI stats of those parts of the code.

If these get’s flagged, it means the agent can’t do the change just yet. It has to prove that, the lines of code are actually the cause of the harm.

Example: I was reviewing a PR with a one line change from a senior colleague who uses AI way too much but does not know how. It was a simple concat line he was trying to fix from the error that was shown.

By just digging into it a little, checking more cases. I did find that the concat which it did on a name that was displayed. To get the name of a secret. Where he did only allow certain lengths ( cause those parts should be ) but if somebody failed that namecheck or just a flaky GET would crash the concat and everything downstream. It was something like xyz-{variable}-xyz.

That variable was just available, it being wrong would already cause problems in different places as well. That secret has to be added with that name. More depends on it.

So i suggested, while other parts had nice variables. Do that here as well. Make that part hardcoded variable depending on the environment. So PRD always delivers PRD. Add a check at the part where the key get’s added manually……1 small script which makes the person adding the secret once a month ( told both to auto rotate but next PR i guess ) happy as well. Script > key > pass or fail. No need for concats anymore or checking if something has the correct value all the way down stream. Without any errors as well, or being able to search on it cause of the concat.

Basic example, but this is what the AI skipped. Looking a layer deeper, fixing the root issue ( or at least half of it ). These are the things i’m trying to catch before it codes. Fix those little things. Then break things up.

Last but not least. I have a whole lot of agents setup, that are with skills and data. Code owner for little parts of the code. So if the worker thinks he should change these, they actually have to discuss it and if allowed both prove that the core parts of the code have not changed.

1

u/sneakoo 1d ago

The two-stage design is the right shape, but stage 2 needs the test selection held constant too. If one track runs the full suite and the other runs only affected tests, the cost gap measures the harness, not the code. Lock the verification method down and the maintainability signal gets much cleaner.

1

u/novai-max 1d ago

Your stage 2 is measuring the right quantity - the cost of the next change - and there is a version of it you can run today without building the harness: diff size of the next real change.

Maintainability is mostly a claim about what it costs the next person to modify the file, and that cost is already recorded in git - how many lines the following commit touches, and how much of the file it has to read to do it. No synthetic v2, no planted bugs, and it runs retroactively over years of history.

It is not clean, because the next diff also depends on what feature came next rather than only on how good the code was. So you need pairs: N files changed by an agent and N comparable files not changed by it, then compare the following diff in each. Matched it says something real. Unmatched it mostly measures the roadmap.

Which makes it a cheap way to check the hypothesis before funding the expensive version. If real history shows no maintainability cost, the benchmark has nothing to find.

1

u/smittyplusplus 1d ago

Actually, it has been tested and demonstrated that better factored code bases that are more “maintainable” allow agents to get work done with something like 40% fewer tokens. So it’s important for agents also.

1

u/ArielCoding 1d ago

The benchmark should repeat each test several times, an AI agent can give different results on the same task, and one run per stack could look good or bad just by luck.

1

u/Alarming-Chart-1771 1d ago

One v2 feature feels too short to catch it tbh, the mess usually only starts hurting around the 4th or 5th change

1

u/Chamelon_DE 13h ago

Give the follow up change to a different model too, otherwise u might just measure how well an agent understand its own habits

1

u/ianreboot 12h ago

The planter needs the same treatment as the harness: bugs written by one model probably carry that model's habits, so a fixer from the same family can find them by shape rather than by reading the code. Plant with a different family from the one under test, and have a person confirm each planted bug is visible in the diff but not obvious from the test failure alone. Without that, part of what Stage 2b measures is how recognisable the planter is, and the cross-model results could move with whichever model wrote the bugs.