Skip to content

Commit d284224

Browse files
authored
Merge pull request #61 from newjersey/docs/0406-feature-flags
Adding feature flag documentation
2 parents ca36b60 + a03dd52 commit d284224

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

src/content/docs/tech-recommendations/infrastructure.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,37 @@ If Terraform, use OpenTofu
5151

5252
Serverless is deprecated
5353

54+
## Feature flags
5455

56+
Feature flags allow us to change application behavior at runtime without redeploying code. In our stack, we use [AWS AppConfig](https://docs.aws.amazon.com/appconfig/latest/userguide/what-is-appconfig.html) to manage these changes safely, whether that’s rolling out a new feature, limiting exposure, or quickly turning something off if it causes issues.
57+
58+
At a high level, feature flags help separate deployment (shipping code) from release (exposing functionality), which gives us much more control over risk. [View this example AppConfig implementation for guidance within React](https://github.com/timwright12/example-aws-appconfig/).
59+
60+
### When to use feature flags
61+
62+
Feature flags are most useful when you need a level of control or reversibility that a normal deployment doesn’t provide. Use flags when you need controlled, reversible changes. For example:
63+
64+
- Gradual roll outs (releasing to a percentage of users before full launch)
65+
- Kill switches (quickly disabling a feature causing issues)
66+
- Decoupled deploy vs release (shipping code without immediately exposing it)
67+
- Environment-specific behavior (safely testing in staging or limited production cohorts)
68+
- Simple targeting (enabling for internal users, beta groups, or regions)
69+
70+
### When not to use feature flags
71+
72+
Not every toggle should be a feature flag. In fact, overusing them can make the system harder to reason maintain. Avoid using feature flags for to following:
73+
74+
- Permanent configuration (use environment variables or config files instead)
75+
- Short-lived development toggles (prefer local flags or mocks during development)
76+
- Core business logic branching (flags should not define fundamentally different code paths long-term)
77+
- Highly coupled UI logic (excessive flags in UI code can create hard-to-test states)
78+
- Anything you won’t clean up (if there’s no plan to remove it, don’t add a flag)
79+
- As a substitute for proper testing (flags shouldn't compensate for inadequate QA)
80+
81+
### Best practices
82+
83+
- Default to a safe state of `false` for features that are incomplete
84+
- Every flag should have a clear lifecycle and purpose
85+
- Use clear naming in your flags
86+
- Each flag should be as close the feature it is toggling a possible; avoid wrapping too much functionality in a flag.
87+
- Clean up flags regularly; unless you're using a killswitch flag, most types should not be long-lived in the code. Clean them up when your done.

0 commit comments

Comments
 (0)