Feature Flag Cleanup
Workflow for safely removing a fully-rolled-out feature flag from the codebase. Identifies all flag check points across all surfaces (Terraform, API, frontend), removes them while preserving the enabl
SKILL.md.claude/skills/flag-cleanup/SKILL.md
GitHubWhen to Use
Invoke this skill when:
- A release gate feature flag has been fully rolled out and is ready for removal
- A kill switch is no longer needed
- Technical debt cleanup of old feature flags
Step-by-Step Instructions
Step 1: Identify the Flag
- Get the flag name from the developer
- Search for all references across the codebase:
- Terraform SSM parameters:
infra/directory - API service layer:
api/src/services/andapi/src/ - Frontend hooks:
frontend/src/hooks/useFeatureFlag - Frontend components: conditional rendering based on the flag
- Tests: flag-dependent test branches
- Environment configs:
.envfiles, Docker configs
- Terraform SSM parameters:
- Document every file containing a flag reference in the blast radius template
Step 2: Verify Flag State
- Confirm the flag is currently ENABLED in production
- Confirm the flag has been enabled long enough (ask the developer)
- Confirm no active incidents related to the flagged feature
- If the flag is a kill switch, confirm the team agrees it's no longer needed
Step 3: Plan the Removal
For each flag reference, determine what happens when the flag is removed:
- Conditional code blocks: Keep the "enabled" branch, remove the "disabled" branch
- Test branches: Keep tests for the enabled behavior, remove flag-specific test splits
- Terraform SSM parameter: Mark for deletion
- Environment variables: Mark for removal from all configs
Use cleanup-checklist.md and blast-radius-template.md to track.
Step 4: Execute the Removal
Follow this order:
- Frontend: Remove flag checks, keep enabled UI
- API: Remove flag checks, keep enabled logic
- Tests: Remove flag-conditional test branches, keep enabled-path tests
- Terraform: Remove SSM parameter (or mark for next deploy)
- Config files: Remove env vars
Step 5: Verify
- Run full test suite (API + Frontend)
- Run linting and type checking
- Verify no remaining references to the flag name
- Run
/check-conventionson all modified files - Run the Quality Gate Pipeline skill
Conventions and Best Practices
- Always remove from application code first, infrastructure last
- Keep the "enabled" behavior — that's the production behavior
- Search for the flag name as a string literal, variable name, AND comment reference
- Check both camelCase and snake_case variants of the flag name
- Update any documentation that references the flag