ARC-60Recommended
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. Take the end date and owner from the register in Keep every flag in one register.
Examples
Python 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)
TypeScript example
// 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.
Sources
Related rules
- ENG-25 Separate deploying from releasing in Engineering
- ENG-45 Keep every flag in one register in Engineering
- ENG-49 Reusing an old flag for new behaviour in Engineering
- ARC-59 Delete code that nothing uses in Clean code and architecture
- TST-57 Test both states of every live flag in Testing
- APP-49 Read feature flags before the first paint in Web app interface
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/architecture/structure/remove-stale-flags">Agent Wranglers clean code and architecture playbook</a>. In code you write, add a comment next to it with the same link.