Uber has removed more than 16,000 stale feature flags and over one million lines of code from its monorepos with a system called AutoClean. The work is done by AI agents, but deterministic tools, CI and a set of reviewer agents check every step, and any change that fails a check is thrown away.

    Engineers on the company’s AI Verification team described the system in a post on Uber’s engineering blog on October 20, 2026, and InfoQ wrote up the cleanup numbers on December 4.

    Why old flags stick around

    Feature flags were always meant to be temporary, a switch you flip during a rollout and take out once everyone has the new behavior. In practice the switch tends to stay, along with the conditional branches, config fields, function parameters and tests that grew up around it.

    Anyone who has looked after a long-lived codebase knows the type. Old code can hide a lot for a long time, as the 18-year-old UEFI flaw that AI tools from Google and Anthropic found recently showed.

    Uber says this leftover code adds tech debt and slows down anyone reading it, people and AI agents alike. A single cleanup can touch dozens of files, and some tests have to be deleted while others need rewriting.

    How AutoClean works

    Picking the flag

    AutoClean starts by asking Uber’s feature flag system of record for stale flags that are safe to remove. The blog’s example is a flag that has been fully rolled out and always evaluates to true. Uber hasn’t published the full selection criteria.

    The rewrite

    An agent with access to the whole codebase swaps the flag call for its constant value. It then follows that value through call sites, dead branches and unused parameters until nothing of the flag is left.

    The language model doesn’t simplify the boolean logic on its own. That step runs through PolyglotPiranha, Uber’s open-source code transformation tool, which the agent calls over the Model Context Protocol. The engineers chose a deterministic tool here because a small slip in boolean logic can change behavior without anyone noticing.

    Repairing CI failures

    Next, the diff goes through continuous integration, which the team treats as the source of truth. Failures go to fixers. The deterministic fixers go first and handle simple things like removing an unused default or clearing a lint error. Agent-based fixers take the harder calls, such as whether a test should be deleted or rewritten.

    Each fixer can only touch a limited set of files. The test fixer can edit test files and nothing else, so it can’t make a test pass by changing the production code that test is meant to check. The loop repeats until CI is green or the attempt limit runs out.

    CodeCourt

    Once CI passes, static checks look for mechanical leftovers, like a boolean function that now always returns true. Then CodeCourt runs four reviewer agents in parallel, each checking one property:

    • the diff only removes or simplifies code
    • observable behavior stays the same
    • only the requested flag was cleaned up, with no intent drift
    • the agent left no stray comments or reasoning traces behind

    If any one of them fails, the change is dropped before a person ever sees it.

    People still make the call

    Diffs that pass every check go to the team that owns the code. Reviewers there don’t have to check mechanical correctness line by line, so they can spend their time on the business question of whether the flag should come out now.

    For as long as most of us have been building for the web, review has worked best this way, with the machine catching the slips and people judging the intent.

    What Uber learned

    The lessons in the post are practical. Use deterministic tools anywhere a silent behavior change could happen, and limit each fixer’s reach so it can’t game CI.

    The team also found that agents chase the nearest signal, a green build, even when getting there breaks other requirements. It helped to split those requirements into separate properties. Several focused reviewer agents also did better than one agent reviewing a whole diff end to end.

    What comes next

    Uber hasn’t published a roadmap. It says only that AutoClean will keep up as new flags are added. Teams outside Uber can already use the deterministic part, since PolyglotPiranha is on GitHub under an Apache 2.0 license.

    More AI tools are also being pointed at old code to look for security bugs, as when an Anthropic scanner turned up a critical Drupal core flaw that attackers are now exploiting. Uber’s approach of checking the agent at every step is worth keeping in mind as that grows.

    Grace is a technical SEO specialist and web developer who writes about structured data, metadata, and site configuration for Webcode Tools. She helps websites improve how they appear in search results and on social platforms, and her guides explain the code behind it in a straightforward, practical way.