Uber Autoclean Removes 1 Million Lines of Stale Code and 16,000 Feature Flags Uber's AutoClean agentic system has removed more than 16,000 stale feature flags and over 1 million lines of code across its monorepos, the company reported in a blog post. AutoClean pairs AI agents with Uber's PolyglotPiranha structural transformation engine, invoked through the Model Context Protocol, to replace flags with their permanent values and trace them through callers, parameters and conditionals, then routes failures through scoped fixers in CI before an agentic validation layer called CodeCourt checks each change for semantic preservation and no intent drift. Only changes passing all checks reach the owning team, which makes the final decision on removal. Uber has used AutoClean, an agentic system for removing stale feature flag code https://www.uber.com/us/en/blog/ai-code-cleanup/ , to clean up more than 16,000 flags and over 1 million lines of code across its monorepos. The system combines AI agents with deterministic code transformations, continuous integration CI , and independent validation to prepare changes for human review. Feature flags allow teams to gradually enable functionality or roll back changes. Once a rollout is complete, however, conditional branches, configuration fields, function parameters, and tests can remain in the codebase. Uber says this residue complicates maintenance and testing, and increases the code AI agents must inspect when working on related tasks. AutoClean connects to Uber’s feature flag management system to identify flags considered safe to remove. Its cleanup agent searches and edits the code, then uses PolyglotPiranha https://github.com/uber/piranha , Uber’s structural code transformation engine, through the Model Context Protocol https://modelcontextprotocol.io/docs/2026-07-28/getting-started/intro . The agent replaces a flag with its permanent value and traces that value through callers, parameters, and conditionals. Uber describes the division of work: Static tools handle deterministic rewrites well; AI is most useful for propagation decisions. PolyglotPiranha handles boolean and conditional simplification deterministically, rather than leaving potentially behavior-changing rewrites entirely to the language model. AutoClean overview Source: Uber Blog Post https://www.uber.com/us/en/blog/ai-code-cleanup/ The resulting change enters CI. When builds or tests fail, AutoClean routes failures through fixers, trying deterministic repairs before agent-based ones. Fixers have restricted scopes: a test fixer, for example, can edit test files but not production code. Uber says this prevents an agent from making a failing test pass by changing the behavior the test was intended to verify. The system repeats the repair and CI cycle until the change passes or reaches its attempt limit. Uber describes CI as the source of truth for the change. CI success is not the final safety check. AutoClean runs static checks and then CodeCourt, an agentic validation layer with separate reviewers for properties including no additions, semantic preservation, no intent drift, and no leftover agent artifacts. Each reviewer checks one property independently. If any check fails, the change is abandoned; only changes that pass all checks are sent to the owning team for human review. Muhammad Ali Akbar https://www.linkedin.com/in/murad-siddiqui/ , a software engineer, wrote in a LinkedIn discussion, The CI-as-source-of-truth part is what sold me. Deepanshu Udhwani https://www.linkedin.com/in/deepanshu-udhwani/ , also a software engineer, noted the difference between passing tests and ensuring a cleanup stays within its intended scope. No intent drift is a different check than no regression. Uber says a human reviewer makes the final decision on whether a flag is ready to be removed. AutoClean automates the investigation, rewrite, repair, and validation stages, while leaving that decision with the team responsible for the code.