feature-flags
Original:🇺🇸 English
Translated
Use when feature flag tests fail, flags need updating, understanding @gate pragmas, debugging channel-specific test failures, or adding new flags to React.
13installs
Sourcefacebook/react
Added on
NPX Install
npx skill4agent add facebook/react feature-flagsTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →React Feature Flags
Flag Files
| File | Purpose |
|---|---|
| Default flags (canary), |
| www channel, |
| React Native, |
| Test renderer |
Gating Tests
@gate
pragma (test-level)
@gateUse when the feature is completely unavailable without the flag:
javascript
// @gate enableViewTransition
it('supports view transitions', () => {
// This test only runs when enableViewTransition is true
// and is SKIPPED (not failed) when false
});gate()
inline (assertion-level)
gate()Use when the feature exists but behavior differs based on flag:
javascript
it('renders component', async () => {
await act(() => root.render(<App />));
if (gate(flags => flags.enableNewBehavior)) {
expect(container.textContent).toBe('new output');
} else {
expect(container.textContent).toBe('legacy output');
}
});Adding a New Flag
- Add to with default value
ReactFeatureFlags.js - Add to each fork file (,
*.www.js, etc.)*.native-fb.js - If it should vary in www/RN, set to in the fork file
__VARIANT__ - Gate tests with or inline
@gate flagNamegate()
Checking Flag States
Use to view states across channels. See the skill for full command options.
/flagsflags__VARIANT__
Flags (GKs)
__VARIANT__Flags set to simulate gatekeepers - tested twice (true and false):
__VARIANT__bash
/test www <pattern> # __VARIANT__ = true
/test www variant false <pattern> # __VARIANT__ = falseDebugging Channel-Specific Failures
- Run to compare values
/flags --diff <channel1> <channel2> - Check conditions - test may be gated to specific channels
@gate - Run to isolate the failure
/test <channel> <pattern> - Verify flag exists in all fork files if newly added
Common Mistakes
- Forgetting both variants - Always test AND
wwwforwww variant falseflags__VARIANT__ - Using @gate for behavior differences - Use inline if both paths should run
gate() - Missing fork files - New flags must be added to ALL fork files, not just the main one
- Wrong gate syntax - It's , not
gate(flags => flags.name)gate('name')