Feature Flags
Feature flags are an essential tool for continuous delivery and dark launching. However, in most codebases, feature flags become tech debt:
- Developers forget to remove flags after a feature is fully launched.
- Tests only verify the flag enabled state, leaving the disabled state broken.
- Dead branches linger in the codebase forever.
Anchors treats Feature Flags as first-class architectural entities.
1. Declaring Flags in Anchors
Section titled “1. Declaring Flags in Anchors”Feature flags are declared in dedicated .flag.md files:
---flag: NEW_CHECKOUT_FLOWstatus: activedefault: falsesunset_milestone: v2.4.0---
# NEW_CHECKOUT_FLOW
Enables the redesigned one-step checkout wizard with instant payment processing.2. Dual-State Scenario Enforcement
Section titled “2. Dual-State Scenario Enforcement”When a feature is governed by a flag, Anchors requires tests for both states:
- Behavior when the flag is ON.
- Fallback behavior when the flag is OFF.
In your Gherkin .feature file:
@flag:NEW_CHECKOUT_FLOW=enabledScenario: User checks out with one-step wizard Given the feature flag "NEW_CHECKOUT_FLOW" is enabled When the user clicks "Instant Checkout" Then the one-step modal is displayed
@flag:NEW_CHECKOUT_FLOW=disabledScenario: User checks out with legacy flow Given the feature flag "NEW_CHECKOUT_FLOW" is disabled When the user clicks "Checkout" Then the standard multi-step form is displayed3. Key Feature Flag Gates
Section titled “3. Key Feature Flag Gates”flag-covered: Ensures all flagged code paths have corresponding tests for both ON and OFF states.flag-scenario-exists: Verifies that flag scenarios exist in feature files.flag-scenarios-complete: Prevents partial test coverage of flagged features.flag-scenario-grammar: Enforces standard@flag:tag syntax.