Debug feature flag tests, update flags, and add new React gates.
Copy the install command and let the AI configure it · recommended for beginners
Please install the "feature-flags" skill from askskill: 1. Download https://raw.githubusercontent.com/facebook/react/main/.claude/skills/feature-flags/SKILL.md 2. Save it as ~/.claude/skills/feature-flags/SKILL.md 3. Reload skills and tell me it's ready
Help me analyze why this feature flag test is failing. I will provide the error message, related test code, and current flag configuration. Please identify likely causes and suggest fixes with example changes.
A diagnosis of the failure, the relevant flag or test logic, and actionable fixes.
Explain how the @gate pragma works in this test, what runtime conditions it controls, and what I should watch for when changing feature flags.
An explanation of @gate syntax and behavior, including its impact on test coverage and execution paths.
I want to add a new feature flag to a React project. Tell me which files to update, how to name the flag, how to add tests, and how to avoid breaking existing channels or environments.
A step-by-step checklist for adding the flag, code change suggestions, test coverage guidance, and compatibility considerations.
| File | Purpose |
|---|---|
packages/shared/ReactFeatureFlags.js | Default flags (canary), __EXPERIMENTAL__ overrides |
packages/shared/forks/ReactFeatureFlags.www.js | www channel, __VARIANT__ overrides |
packages/shared/forks/ReactFeatureFlags.native-fb.js | React Native, __VARIANT__ overrides |
packages/shared/forks/ReactFeatureFlags.test-renderer.js | Test renderer |
@gate pragma (test-level)Use when the feature is completely unavailable without the flag:
// @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)Use when the feature exists but behavior differs based on flag:
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');
}
});
ReactFeatureFlags.js with default value*.www.js, *.native-fb.js, etc.)__VARIANT__ in the fork file@gate flagName or inline gate()Use /flags to view states across channels. See the flags skill for full command options.
__VARIANT__ Flags (GKs)Flags set to __VARIANT__ simulate gatekeepers - tested twice (true and false):
/test www <pattern> # __VARIANT__ = true
/test www variant false <pattern> # __VARIANT__ = false
/flags --diff <channel1> <channel2> to compare values@gate conditions - test may be gated to specific channels/test <channel> <pattern> to isolate the failurewww AND www variant false for __VARIANT__ flagsgate() if both paths should rungate(flags => flags.name), not gate('name')Check feature flags, compare channels, and debug inconsistent release behavior.
Fix lint, formatting, and common code issues before passing CI.
Run Flow type checks and fix React type errors quickly.
Extract and verify React error messages and codes to debug unknown warnings.
Validate code changes before commit and check React contribution requirements.
Write and run Markdown-driven end-to-end tests for Relay apps.
Update an existing feature to new behavior with tests, implementation, review, and gated commit.
Orchestrate end-to-end new feature delivery with research, TDD, review, and gated commits.
Compare two versions and flag vanished commitments for safer review.
Systematically reproduce, isolate, diagnose, and fix tricky software or environment issues.
Create a GitHub issue from local integration test failures.
Write behavior-focused, refactor-resistant tests that verify intent and regressions.