Menu
InfoQ Architecture·December 4, 2026

Architecting Autonomous Code Cleanup: How Uber AutoClean Removes Stale Code and Feature Flags at Scale

Uber details AutoClean, an agentic system that combines AI agents with deterministic code transformations to safely remove stale feature flags and millions of lines of code across large monorepos. The architecture relies on CI as the source of truth, bounded fixers, and an independent validation layer known as CodeCourt to prevent regressions and intent drift.

Read original on InfoQ Architecture

Large-scale software repositories frequently accumulate technical debt in the form of dormant feature flags, obsolete conditional branches, and unused configurations. Uber introduced AutoClean, an agentic system designed to automate the lifecycle termination of stale feature flags and remove over a million lines of dead code without introducing regressions.

Architectural Components of AutoClean

  • Feature Flag Management Integration: Connects to centralized feature flagging services to identify flags ready for permanent removal.
  • AI Agents & Model Context Protocol: Interacts with language models to reason about complex conditional value propagations and code semantics.
  • PolyglotPiranha: A deterministic structural code transformation engine that handles mechanical code rewrites safely.
  • Continuous Integration (CI) Pipeline: Serves as the primary source of truth and validation engine for all generated code changes.
  • CodeCourt Validation Layer: An independent multi-agent review architecture that validates properties such as semantic preservation and absence of intent drift.

Combining Deterministic Engines with AI Reasoning

A core architectural challenge in automated refactoring is avoiding unpredictable modifications caused by unconstrained generative AI. AutoClean solves this by enforcing a strict division of labor: deterministic transformation tools handle exact syntax rewrites, boolean evaluations, and dead-branch elimination, whereas AI models manage complex propagation decisions across disparate files and function signatures.

ℹ️

Restricted-Scope Fixers

When automated code transformations break the build or tests, AutoClean routes the failures through scoped fixers. For instance, a test fixer is strictly permitted to modify test suites but cannot touch production code, eliminating the risk of an agent making a test pass by incorrectly altering the underlying business logic.

Multi-Agent Validation via CodeCourt

Passing CI is treated as a necessary baseline rather than a final guarantee of correctness. AutoClean introduces CodeCourt, a secondary validation layer composed of specialized, independent agentic reviewers. Each reviewer assesses isolated invariant properties—such as no added code artifacts, zero intent drift, and absolute semantic preservation—before the pull request is ever presented to human engineers for final sign-off.

feature flagscode refactoringagentic workflowsmonorepocontinuous integrationstatic analysistechnical debtautomation

Comments

Loading comments...

Want the fundamentals behind stories like this? Take the free System Design Academy course with certificate.