AI development
A nightly crew of AI agents: maintenance while you sleep
Every night a crew of agents removes dead code, fills test gaps and measures search visibility. How it is set up, and why it is only safe behind gates.
Maintenance is the work that always yields to something more urgent. Dead code stays. Tests lag behind the features. The translation for a new screen is missing in three of five languages. Nobody chooses that — it is simply what happens when real features also have to be built.
For a few months now that work has continued overnight at our end. A crew of AI agents works through its set tasks each night on a dedicated nightly branch. If everything is green, that branch reaches the main branch without human intervention. In the morning there is an email describing what happened and what went wrong. Here is how it works and why we think it is safe.
What can a crew of AI agents do overnight?
A nightly crew delivers its work as commits on a nightly branch, merged automatically when the gates are green: removing dead code, filling in missing translations, adding tests where money is calculated, and measuring and improving the search visibility of the public sites. What such a crew does not do is build features — the maintenance agents may remove and rewrite code but not change behaviour, and that line is exactly what makes it safe. The gain is therefore not in doing more cheaply what you were already doing, but in work that otherwise does not happen at all.
The crew
There are three kinds of maintenance agent, and the distinction matters more than the numbers. Agents for security and tax review run alongside them.
Maintenance agents run on a schedule. One runs every night: the test writer. The dead-code sweeper, the duplication hunter, the test pruner and the framework optimiser each get one night a week, with a deeper pass through old code. They may remove and rewrite code, but they may not change behaviour. That is the line everything else rests on.
Watch agents run every night, outside the rotation, because their source lives outside the repository. The most important one reads Search Console and Bing Webmaster Tools each morning for the public sites, spots regressions and applies the improvement itself.
Sync agents maintain the things that drift apart if left alone: the translations, and the knowledge base behind the in-app assistant.
Alongside those sits one agent that is allowed to change behaviour: the builder that picks work off the kanban board. It may do so only because a human approved the ticket. That is an organisational guardrail rather than a technical one, and it is the most important of the lot.
The guardrails
An agent alone in your codebase at night is exactly as safe as the gates around it. These four do the work.
A worktree per project
Every project has its own git worktree and a branch per night, and the agents run in it one after the other. They therefore cannot work in the same files at once, and a failed run leaves no half-finished work in the main checkout. The builder has a worktree of its own.
Gates you cannot route around
Tests green, typecheck green, build green. On the bookkeeping product that means more than seven thousand tests (7,320 on 30 October 2026). An agent that wants to get through has exactly one option: actually doing it properly.
The temptation to “just adjust” a failing test is as strong for an agent as for a human under deadline. So the agents’ instructions forbid changing a test to get their own change green. That is an agreement, not a technical gate.
Small enough to check
A run stays small enough to check. Every agent has a nightly budget; only the SEO agent gets a longer campaign run every few nights.
Automatic merging depends on what can break
This is the guardrail we nearly got wrong. On the marketing sites the run may merge and publish on its own: we decided that on 3 September 2026, because a site does not touch the running application and a mistake is reverted within a day.
The application itself does not get that freedom: what changes its behaviour goes past a human. We confused the two for a while because the configuration file in the repository claimed something different from the hosting platform itself.
What it delivers
The honest answer: less spectacular than it sounds, and more than we expected.
What it does not do is build features. It is not allowed to, and that should stay that way.
What it does do is hold back the slow decay. Over a few months: thousands of lines of dead code removed, dozens of missing translations filled in, tests added where money is calculated, and a series of small SEO improvements we would never have picked up ourselves because each one is individually too small to spend an evening on.
The most valuable part may be something else entirely: the morning email. A short summary every day of what happened, what went red and what was left undone. That is a daily health check on a codebase you are otherwise not looking at, and we would not have had it otherwise.
What we would do differently
Start with one agent, not eight. For the first fortnight, repairing the crew cost more time than the crew returned. One agent behind a good gate is worth more than six behind a mediocre one.
Let failure fail loudly. The first version caught errors politely and moved on to the next agent. The result was a green morning email while three runs had quietly done nothing. A run that fails should turn the email red.
Budget for maintaining the maintenance. The crew is software too, with the same tendency to decay. It now sits behind the same gates as everything else.
If you take one thing from this, make it this: what is interesting about agents running overnight is not that they are cheap. It is that they do work which otherwise does not happen at all — and that is a different kind of gain from doing faster what you were already doing.
Would this kind of automation work inside your own product? That conversation usually starts with AI that takes over real work, or with moving an existing platform forward without letting maintenance slide.