Meet us at AWS re:Invent and learn to automate your releases - Booth 1645 — Learn more

Skip to:
BlogEngineering
Feature flag debt at agent speed: Why manual cleanup won't scale

Dec 2, 2026

Feature flag debt at agent speed: Why manual cleanup won't scale

How to make flag cleanup a repeatable process that keeps pace with your releases.

Alexis Roberson
Senior Developer Educator

An engineer opens the flag list on a Monday morning and starts with the temporary flags left over from the last few releases. One still protects a checkout path that is mid-rollout. Another has already served a single variation everywhere that matters, and a cleanup change has been sitting in review for two weeks. A third looks finished in production, except a second repository still evaluates it.

Reviewing that queue is ordinary release work. Coding agents, and the release automation around them, can make it cheaper to wrap a change in a flag, which can mean more flags enter the codebase in a given month. If someone has to notice that a flag is ready, confirm it’s safe to remove, and get a cleanup change through review, the queue grows at the pace of releases and shrinks only when an engineer has time to come back to it. The useful question is which of those flags are still doing a job, and which are ready to be retired.

Flag debt begins with unresolved retirement decisions

Age is a poor way to determine whether a flag is ready to be retired. A flag created six months ago can still be a kill switch or an entitlement toggle, with no end date. A temporary flag from last week's release can already have finished its work and still be sitting in the code.

Follow one temporary flag, faster-checkout-estimate, which wrapped a new shipping-estimate path in a checkout service. The team rolled out the new path, watched it, and eventually served it as the only variation in every critical environment. They then faced a decision about the flag: Keep it, remove it, or wait until the evidence is complete.

A flag is still needed when it supports an active release or an ongoing operational requirement. If faster-checkout-estimate were still rolling out, or marked permanent as a kill switch, counting it as debt would send people after the wrong work. A flag is eligible for removal but waiting for review when the intended variation is consistent, the waiting period has passed, the flag is temporary and not a prerequisite, and the remaining code references are known. The only work left is the change that removes the conditional, and a review before that change deploys. A flag removal is blocked or uncertain when the release state, a dependency, or remaining usage prevents a safe removal decision. Production can look settled while another critical environment is missing evaluation data, or a second repository still references the flag.

A count of flags older than 30 days mixes all three states. Flag debt is the unresolved retirement work: the eligible flags that have not been cleaned up, and the blocked ones that have no recorded reason for waiting.

What makes a flag safe to retire?

Safe removal starts with evidence about how faster-checkout-estimate is actually used. The first check is whether every critical environment is serving the intended variation. LaunchDarkly applies archive-readiness and code-removal checks to the environments you mark as critical. If the new estimate is the only variation in production, and a staging environment you also marked critical is still split, removing the flag hardcodes a path that environment still uses.

The next checks are time. By default, a flag counts as “Launched” in an environment when it’s been evaluated in the past seven days, it’s toggled on, it serves only one variation, and its targeting has not changed for seven days. Those seven days give the team a window to roll the change back, or to keep watching metrics, before anyone treats the release as settled. The window is a project setting. The default LaunchDarkly lifecycle settings also require a flag to be at least 30 days old before it’s recommended as ready for code removal or archiving. This delay is the cost of keeping a rollback path open, and the default setting can be increased or decreased.

Dependencies and remaining references finish the picture. If faster-checkout-estimate is a prerequisite for another flag, removing it changes how that flag evaluates, and it can’t be archived until the dependency is gone. If the team marked it permanent, it should stay out of the retirement queue. If repositories are connected for code references, a flag is ready for code removal only when LaunchDarkly has found it in the code. If a shared pricing library still evaluates the same flag, cleanup is incomplete until that repository is included. A lack of evaluations is one signal that a flag has left the request path. By default, a flag counts as “Inactive” when it hasn’t been evaluated for at least seven days. That signal doesn’t prove the flag is gone from the code.

The last check is whether the cleanup preserves the behavior users already receive. The diff hardcodes the winning variation, deletes the unused path and its tests, and leaves a reviewer to confirm that production behavior is unchanged. Some findings block that change. A prerequisite, a permanent flag, or a missing reference in a repository Vega can’t see is designed to stop cleanup or prevent a pull request from being opened. Other findings are warnings. If a flag still serves more than one variation across critical environments, or if evaluations can’t be retrieved for one of those environments, Vega, the LaunchDarkly AI agent, can still open a cleanup pull request and record the concern. A developer still has to judge whether to deploy that change or close it and keep the flag.

When cleanup falls behind

Those checks tell you what to do with one flag. The operational problem starts when many flags reach the codebase in the same month, but cleanup still requires an engineer to pick up the work by hand.

Imagine a team that introduces 20 temporary flags in a month and completes cleanup for 12 of them. The remaining eight should not be counted as debt by default. Two are still rolling out. One is a prerequisite for a follow-up change. One is referenced in a second repository, and only the first cleanup pull request has been opened. The other four, including faster-checkout-estimate, have already passed every check. Their cleanup pull requests sit in the same review queue as feature work and bug fixes, long enough for the surrounding code to keep changing.

That is how the backlog develops. An eligible cleanup is a small, well-scoped change on the day it’s opened. A week later, it competes with work that has a tighter deadline. A flag with an unresolved dependency needs investigation before anyone can write the change, and that investigation is easy to put down. A flag that appears in two repositories needs two pull requests, reviewed and deployed together, or evaluations continue from the repository that was left behind. The longer faster-checkout-estimate waits, the more those repositories move on, and the harder it becomes to relearn why the flag existed and what the forward path is supposed to be.

The measures that make this visible are simple: how many flags are eligible and still waiting, how long they have been eligible, and why the blocked ones are blocked. A list that only reports age will hide those differences. A list that reports eligibility, wait time, and blockers shows whether retirement is keeping up, and where a flag is stuck. Manual cleanup is difficult to sustain at this volume because each of those steps depends on someone noticing the flag, making time for it, and holding the context long enough to finish.

Make flag retirement a repeatable operation

A process that keeps up has to run on a schedule. It should evaluate eligibility regularly, record why a flag remains blocked, produce a reviewable change for eligible flags, track failed or closed attempts, and confirm that the cleanup has deployed before anyone retires the flag configuration.

Release Autopilot's Auto-cleanup is built for that pattern: It clears flag debt with lifecycle-aware cleanup PRs and keeps your codebase manageable as change volume grows. Based on your configuration, it identifies flags that are ready for code removal and opens a pull request in each repository where it finds the flag. If faster-checkout-estimate appears in the checkout service and the pricing library, that’s two pull requests. Warnings can accompany them, and engineers remain responsible for reviewing the changes and deciding whether they deploy. If an attempt doesn’t open a pull request, or a pull request is closed without being deployed, later scheduled runs skip that flag. You retry from the Failed tab of the Cleanups dialog, or by starting cleanup from the flag.

Archiving the flag in LaunchDarkly is a later step, after the cleanup has deployed and evaluations have stopped. Automatic archival is in beta. It runs on your cleanup schedule, applies your own eligibility requirements, and waits a configurable grace period before archiving a flag that’s ready. It doesn’t remove the flag from your code.

Keep retirement moving with release volume

The Monday flag list looks different when that automated process is in place. Faster-checkout-estimate, once eligible, already has a cleanup change waiting for review, without depending on someone to notice it. The flag that is still rolling out stays in the still-needed column. The flag with a missing repository or an open prerequisite stays visible, with the reason attached, until that condition is resolved. Engineers then spend their time reviewing small, current diffs for flags that are ready, and investigating the blocked cases that actually need a person.

Maintaining release controls at higher change volume means treating retirement as ongoing engineering work, with clear eligibility criteria and a reliable process for acting on them. That’s how cleanup keeps pace with the releases you are already shipping.

Learn more about Release Autopilot, including Auto-cleanup.

Flaming pointer icon
Get started in minutes.

Learn how to scale seamlessly with LaunchDarkly as your project grows.

Letter in envelope icon
Sign up for our newsletter.

Get all the content, tips, and news you can use.

By supplying my contact information, I authorize LaunchDarkly to contact me with personalized marketing communications about our products and services. See our Privacy Policy for more details, or Opt-Out at any time.