Reduce Feature Flag Tech Debt
Find flags the code no longer checks, then archive or delete them only after the feature is gone from the repo.
This playbook is the sunset and cleanup half of Feature Lifecycle. It does not repeat the seven stages from idea to GA.
Why leftover flags hurt
Every unused flag is another name to learn, another dashboard row to scan, and another chance to toggle the wrong thing. Stale flags also hide the moment a feature became permanent — the check in code is the map for removing it.
Stale detection
Toggly tracks when your SDKs evaluate each flag:
- First Used: first check observed for that feature
- Stale Detection: if a feature has not been checked for a configurable period, Toggly marks it as stale
A stale mark means “no recent evaluations,” which usually means the check left the codebase — or traffic never hits that path. Confirm in source search before you remove anything.
The inactivity window is configurable. Review stale flags yourself before you archive or delete them in Production.
Keep the flag until the code is gone
Don't remove flags from Toggly immediately after deployment or when permanently enabling them. Keep the flags until you've removed the feature from your codebase. The feature flag checks in your code serve as markers that make it easy to find all parts of the feature when it's time to remove it. Use Stale Detection to identify flags that haven't been checked recently and may be ready for removal.
Search the repo for the feature key. Remove the branches, then come back to Toggly.
Archive vs delete
Feature Flags distinguish two ways to leave the active catalog:
- Archive: The flag is no longer used but kept for historical reference. Archived flags do not appear in SDK evaluations.
- Delete: Remove the flag from Toggly. From Features, open the flag's actions menu and choose Delete. Confirm in the dialog. This cannot be undone.
Archive when you want a recovery path. Delete when the flag must not return.
Do not archive a flag only because it is enabled at 100%. A permanent feature still needs the check in code until you remove that code.
A cleanup loop
- Scan for stale flags
- Search the codebase for each feature key
- If the check is still there, decide: remove the code, or keep the flag
- After the code is gone, archive (or Delete if you are sure)
- Repeat on a schedule so debt does not pile up
Best Practices
- Search before archive: Stale is a hint, not proof
- Archive before delete unless you must erase history
- Keep checks as markers until the feature is fully removed
- Name flags clearly so leftover keys are obvious in search — see Feature Flags
Next Steps
- Follow the full Feature Lifecycle
- Review Feature Flags cleanup guidance
- Track evaluations in Feature Usage Tracking