Uber’s AutoClean: A Breakthrough in Code Cleanup Automation
Uber has achieved a significant milestone in software engineering efficiency with its AutoClean system, a sophisticated agentic platform designed for the automated removal of stale feature flag code. This initiative has successfully purged over 16,000 feature flags and more than 1 million lines of obsolete code from Uber’s extensive monorepos. The system represents a novel approach, blending advanced AI agents with deterministic code transformations, robust continuous integration (CI) pipelines, and independent validation processes to prepare code changes for seamless human review.
Table of Contents
Feature flags are instrumental in modern software development, enabling teams to gradually roll out new functionalities or swiftly revert changes if issues arise. However, the residual code left behind after a feature’s complete rollout—including conditional branches, configuration fields, function parameters, and associated tests—can significantly complicate codebase maintenance and testing efforts. This technical debt also increases the burden on AI agents tasked with analyzing and modifying related code sections.
The Architecture of AutoClean: AI Meets Deterministic Transformation
At its core, AutoClean interfaces with Uber’s proprietary feature flag management system to identify flags deemed safe for removal. The system’s cleanup agent then meticulously searches and modifies the codebase. It leverages PolyglotPiranha, Uber’s powerful structural code transformation engine, accessed via the Model Context Protocol. This integration allows the agent to replace a feature flag with its permanent value and systematically trace that value’s propagation through all relevant callers, parameters, and conditional statements.
The division of labor within AutoClean is a key aspect of its success. Static tools excel at handling deterministic rewrites, while AI agents prove most valuable for complex propagation decisions. PolyglotPiranha, for instance, deterministically manages boolean logic and conditional simplifications, ensuring that potentially behavior-altering rewrites are not solely entrusted to the language model.
This intelligent combination of tools is crucial for maintaining code integrity. The resulting code changes are then submitted to the CI pipeline for rigorous testing. When builds or tests encounter failures, AutoClean employs a sophisticated repair strategy. It first attempts deterministic fixes before resorting to agent-based solutions. These fixers operate within strictly defined scopes; for example, a test fixer is confined to editing test files, preventing any modification of production code.
Ensuring Integrity: CI and Agentic Validation Layers
This scoped approach is vital to prevent an agent from compromising the integrity of a test by altering the behavior it was designed to verify. The system iteratively repeats the repair and CI cycle until the changes pass all checks or reach a predefined attempt limit. Uber emphasizes that CI serves as the ultimate source of truth for the validity of these code modifications.
However, CI success is not the final arbiter. AutoClean incorporates additional layers of validation, including static checks and its innovative CodeCourt system. CodeCourt functions as an agentic validation layer, featuring separate reviewers dedicated to specific properties such as ensuring no new code is introduced, preserving semantic integrity, preventing intent drift, and verifying the absence of leftover agent artifacts. Each reviewer independently assesses a single property.
Changes that fail any of these stringent checks are automatically abandoned. Only modifications that successfully pass all validation stages are forwarded to the owning development team for final human review. This meticulous process ensures that the code cleanup remains within its intended scope, a critical distinction noted by engineers like Deepanshu Udhwani, who highlighted that “no intent drift is a different check than no regression.” This focus on preserving original intent, not just preventing regressions, is a hallmark of advanced code cleanup automation.
Engineering Trade-offs and Field Readiness
The decision to remove a feature flag ultimately rests with the human team responsible for the code. AutoClean streamlines the entire process leading up to this decision—automating the investigation, rewrite, repair, and validation stages. This allows development teams to focus on the strategic aspects of code management rather than the laborious manual cleanup tasks.
The success of AutoClean underscores the growing importance of AI in managing complex software systems. As AI agents become more capable, tools like AutoClean will be essential for maintaining the health and efficiency of large-scale codebases. This trend aligns with the broader surge in demand for frontier intelligence, which unlocks significant growth opportunities across various AI applications, as highlighted in our recent report on the topic. The meticulous approach taken by Uber in validating these automated changes also touches upon broader AI security questions that business leaders are increasingly asking.
While AutoClean focuses on code cleanup, other areas of software development continue to face challenges, such as critical vulnerabilities in operating systems and networking infrastructure. For instance, recent patches for Android RCE flaws and critical vulnerabilities in HPE Networking demonstrate the ongoing need for robust security practices alongside development efficiency. The rigorous validation employed by AutoClean, particularly the independent review layers, could offer insights into developing more secure and reliable automated systems in the future.
The Verdict: Streamlined Development and Reduced Technical Debt
Uber’s AutoClean system represents a powerful advancement in managing technical debt. By automating the removal of stale code and feature flags, the platform significantly reduces the complexity of its codebase, improves developer productivity, and enhances the overall maintainability of its software. The system’s hybrid approach, combining AI’s pattern recognition with the precision of deterministic tools and the safety net of CI and independent validation, sets a new standard for automated code maintenance.
The commitment to human oversight for the final decision ensures that strategic judgment remains in the hands of experienced engineers. This balance between automation and human expertise is crucial for large-scale software operations. The successful cleanup of over a million lines of code is a testament to the effectiveness and scalability of AutoClean, paving the way for more efficient and cleaner software development practices across the industry.


