Dead code Required
Remove flags that never change
Delete a feature flag once it is fully on or fully off, along with the branch that no longer runs.
How to do it
Keep every flag in one file, with an owner and an end date set when you add it. When the date passes, remove the flag, its setting and the losing branch in one change.
Example
# Bad: on for everyone since last year
if flags.enabled("new_checkout"):
new_checkout(cart)
else:
old_checkout(cart)
# Good: the flag and the old branch are gone
new_checkout(cart)
// Bad
if (flags.enabled('new_checkout')) newCheckout(cart);
else oldCheckout(cart);
// Good
newCheckout(cart);
How to check
A script lists flags past their end date and fails the build. In review, every flag has an owner and a date.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers architecture playbook: https://agentwranglers.se/playbook/architecture/dead-code/remove-stale-flags.