Coding
Feature flag cleanup
Detect stale or fully rolled out feature flags, then open PRs that remove dead branches and guard code.
feature-flagscleanupdead-codedevopscode-quality
[ workflow / coding ]
Feature flag cleanup
Feature flags pile up quickly. Cosmos scans LaunchDarkly, Statsig, Unleash, or a homegrown flag system for flags past removal date or fully rolled out for too long. For each stale flag, it traces usages, removes the guard and dead branch, updates tests, and opens a cleanup PR.
07 nodes
05 edges
Trigger[trigger]
Weekly schedule
Cron: Monday 08:00 UTC
AI Agent step[scan]
Flag scanner
LaunchDarkly / Statsig / Unleash
Decision
Stale flags found?
No
Bypass (already solved)[skip]
No stale flags
Nothing to clean up
Decision
Stale flags found?
Bypass (already solved)[skip]
No stale flags
Nothing to clean up
YES
AI Agent step[trace]
Trace usages
All code paths referencing flag
AI Agent step[remove]
Remove guard & dead branch
Inline enabled path · update tests
Output / Result[pr]
Open cleanup PR
Per flag, assigned to owner
Workflow prompt
Paste this into Augment to reproduce the workflow end-to-end.
Cosmos, weekly scan the feature flag service for flags that have been at 100% rollout for more than 14 days or whose scheduled removal date has passed. For each stale flag, trace all usages in the codebase, remove the flag check and the dead code path (keeping the 'enabled' branch logic inline), update or delete affected unit tests, and open a PR titled 'cleanup: remove <flag-name> flag'. Include a summary of files changed and confirm no references to the flag remain. Assign PRs to the team listed as flag owner.