feature-flags
Skill3.9k starsChanged 3 days agoMITView on GitHub
Use when: implementing, creating, testing, or debugging feature flags in Primer React. Covers useFeatureFlag hook, FeatureFlags provider, DefaultFeatureFlags, FeatureFlagScope, Storybook integration, and the feature flag lifecycle at GitHub.
- Reads credentials
We split this skill into the rules it gives an agent
2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 17 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 64
Use snake_case: primer_react_my_feature_name
- Very specific: line 203
Check packages/react/src/FeatureFlags/DefaultFeatureFlags.ts for the current list of all registered feature flags and their default values.
“Common” is measured: kept by at least 6 in 10 of the 17 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Feature Flags in Primer React
Feature flags provide a way to incrementally build and deliver changes in Primer alongside the feature flag system at GitHub. They help build confidence in changes and improve the reliability of releases.
Architecture
Feature flags are implemented in packages/react/src/FeatureFlags/ with these core pieces:
| File | Purpose |
FeatureFlags.tsx | React context provider component |
useFeatureFlag.ts | Hook to check if a flag is enabled |
FeatureFlagScope.ts | Class that manages flag collections and merging |
DefaultFeatureFlags.ts | Default flag values (all flags listed here) |
FeatureFlagContext.ts | React context definition |
index.ts | Public exports |
Exports
Feature flags are exported from @primer/react/experimental:
import {FeatureFlags, useFeatureFlag, DefaultFeatureFlags} from '@primer/react/experimental'They are NOT exported from the main @primer/react entry point.
How to Use a Feature Flag in a Component
1. Add the flag to DefaultFeatureFlags
Register your flag in packages/react/src/FeatureFlags/DefaultFeatureFlags.ts with a default value of false:
export const DefaultFeatureFlags = FeatureFlagScope.create({
// ...existing flags...
primer_react_my_new_feature: false,
})2. Use useFeatureFlag in your component
import {useFeatureFlag} from '../FeatureFlags'
function MyComponent() {
const enabled = useFeatureFlag('primer_react_my_new_feature')
if (enabled) {
return <NewBehavior />
}
return <CurrentBehavior />
}3. Naming conventions
- Prefix with
primer_react_for flags in the@primer/reactpackage - Use snake_case:
primer_react_my_feature_name
Patterns
Change behavior conditionally
function ExampleComponent({children}) {
const enabled = useFeatureFlag('primer_react_my_feature')
return (
<button
onClick={() => {
if (enabled) {
// new behavior
} else {
// current behavior
}
}}
>
{children}
</button>
)
}Toggle between two component versions
function ExampleComponent(props) {
const enabled = useFeatureFlag('primer_react_my_feature')
if (enabled) {
return <ExampleComponentNext {...props} />
}
return <ExampleComponentClassic {...props} />
}Data attributes on DOM elements
function MyOverlay() {
const enabled = useFeatureFlag('primer_react_my_feature')
return <div data-my-feature={enabled ? '' : undefined} />
}Real Codebase Examples
CSS anchor positioning (packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx)
const cssAnchorPositioning = useFeatureFlag('primer_react_css_anchor_positioning')
useEffect(() => {
if (cssAnchorPositioning && !hasLoadedAnchorPositioningPolyfill.current) {
applyAnchorPositioningPolyfill()
hasLoadedAnchorPositioningPolyfill.current = true
}
}, [open, overlayRef, updateOverlayRef, cssAnchorPositioning])Breadcrumbs overflow (packages/react/src/Breadcrumbs/Breadcrumbs.tsx)
const overflowMenuEnabled = useFeatureFlag('primer_react_breadcrumbs_overflow_menu')Testing with Feature Flags
Wrap your component with the FeatureFlags provider to set flag values in tests:
import {FeatureFlags} from '../../FeatureFlags'
// Test with flag enabled
render(
<FeatureFlags flags={{primer_react_my_feature: true}}>
<MyComponent />
</FeatureFlags>,
)
// Test with flag disabled (or omit the wrapper to use default values from DefaultFeatureFlags)
render(
<FeatureFlags flags={{primer_react_my_feature: false}}>
<MyComponent />
</FeatureFlags>,
)Key testing behaviors
- Unknown flags default to
false - Nested
FeatureFlagsproviders merge flags — inner values override outer values - You should test both enabled and disabled states
Storybook Integration
Enable flag in a specific story
import {FeatureFlags} from '../../FeatureFlags'
export const WithFeatureEnabled = () => (
<FeatureFlags flags={{primer_react_my_feature: true}}>
<MyComponent />
</FeatureFlags>
)
export const WithFeatureDisabled = () => <MyComponent />Enable flag in all stories
Storybook's global preview (packages/react/.storybook/preview.jsx) already wraps all stories in a FeatureFlags provider, using DefaultFeatureFlags as the source of default values and toolbar options. In most cases you only need to register your flag in DefaultFeatureFlags.ts; you do not need to manually add it to the FeatureFlags wrapper.
To enable a flag globally via environment, add its exact flag name (for example, primer_react_my_feature) to the featureFlagEnvList set in preview.jsx, and set the corresponding env var to 1 (for example, VITE_primer_react_my_feature=1). The preview code reads import.meta.env[\VITE*${flag}`], so the part after VITE*` must match the flag string exactly.
Feature Flag Lifecycle
- Create — Register the flag in
DefaultFeatureFlags.tswith valuefalse - Implement — Use
useFeatureFlag()in components, write tests for both states - Test in Storybook — Create stories with the flag enabled/disabled
- Ship — Merge to main; the flag remains off by default
- Enable at GitHub — Use DevPortal to enable for specific actors, then staffship, then GA
- Remove — Once fully rolled out, remove the flag from code and
DefaultFeatureFlags.ts
Temporarily testing in Dotcom CI
Set your flag to true in DefaultFeatureFlags.ts to enable it by default for CI testing. Set it back to false before merging.
FeatureFlags Provider Internals
FeatureFlagScope.create(flags)— Creates a scope from a plain object{[key: string]: boolean}FeatureFlagScope.merge(a, b)— Merges two scopes;bvalues overridea- The
FeatureFlagscomponent merges parent context flags with the providedflagsprop DefaultFeatureFlagsis the initial context value — it defines all known flags
Current Feature Flags
Check packages/react/src/FeatureFlags/DefaultFeatureFlags.ts for the current list of all registered feature flags and their default values.
Trending
Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data
Who's talking about primer/react
- vercel/next.js“Turbopack Sass loader does not resolve imports correctly”GitHub · Jan 1, 2024 · 7 reactions
- mui/mui-design-kits“[figma] Support Figma Code Connect ”GitHub · Jun 28, 2024 · 5 reactions
- filipedeschamps/tabnews.com.br“feat(primer/react): update version”GitHub · Dec 20, 2023 · 2 reactions
- github/docs“Fix theme mismatch”GitHub · May 18, 2023 · 2 reactions
- primer/view_components“Component status page”GitHub · Nov 29, 2021 · 2 reactions
The biggest 5 of 36 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 36
Talked about on GitHub (36 times).
On GitHub · 36
- Jan 1, 2024Turbopack Sass loader does not resolve imports correctly — vercel/next.js7 reactions · 11 comments
- Jun 28, 2024[figma] Support Figma Code Connect — mui/mui-design-kits5 reactions · 5 comments
- Dec 20, 2023feat(primer/react): update version — filipedeschamps/tabnews.com.br2 reactions · 10 comments
- May 18, 2023Fix theme mismatch — github/docs2 reactions · 13 comments
- Nov 29, 2021Component status page — primer/view_components2 reactions · 7 comments
31 more on GitHub
- Mar 9, 2026Bump the app group with 8 updates — CRRU-UK/photo-id-app1 reaction · 2 comments
- Feb 12, 2026Add `AGENTS.md` — carbon-design-system/carbon1 reaction · 1 comment
- Feb 2, 2026Bump the app group with 13 updates — CRRU-UK/photo-id-app1 reaction · 2 comments
- Nov 10, 2025deps: bump @primer/react from 37.31.0 to 38.1.0 — npm/documentation1 reaction · 4 comments
- Mar 3, 2025Update release_conductor.yml — primer/.github1 reaction
- Oct 17, 2024Docs: add a11y guidance regarding required fields — primer/design1 reaction · 2 comments
- Oct 15, 2024Fix bug where checkboxes were broken with prefers-reduced-motion — primer/view_components1 reaction · 1 comment
- Aug 30, 2024Atualiza as propriedades do componente `Tooltip` para serem compatíveis com a nova versão (`Tooltip v2`) — filipedeschamps/tabnews.com.br1 reaction · 1 comment
- Mar 28, 2024Tooltip: Update the threshold value to match with the offset — primer/view_components1 reaction · 1 comment
- Feb 28, 2023Show source code in React component examples — primer/design1 reaction
- Dec 13, 2022Add a treatment for consistent appearance of content on focus — primer/design1 reaction · 1 comment
- Nov 9, 2022Using playwright to generate snapshots — primer/view_components1 reaction · 2 comments
- Oct 19, 2022Focus zone calls error in vitest + jsdom — primer/behaviors1 reaction · 2 comments
- Oct 11, 2022Atualiza todas as dependências possíveis — filipedeschamps/tabnews.com.br1 reaction · 2 comments
- Aug 19, 2022Add a CommonJS build to the package — github/combobox-nav1 reaction · 6 comments
- Feb 16, 2022ModuleNotFoundError: Could not find module in path "" relative to "" — codesandbox/codesandbox-client1 reaction · 9 comments
- Oct 29, 2026Create: Timeline in Figma — deboramoratalla-lab/ds-lab0 reactions
- Oct 26, 2026🐛 cheatcode_install registers an MCP server with its repo URL as the command and reports success — trustmybot/plugin0 reactions
- Oct 19, 2026Add named capture modes with mode-keyed baselines (bet) — ravidsrk/frontguard0 reactions
- Oct 15, 2026Rule proposal: Enforce consistency between documented jsDoc default and actual default values — typescript-eslint/typescript-eslint0 reactions · 2 comments
- Sep 26, 2026Refatorações e ajustes finais da Milestone 3 — jeancarlier/clone-tabnews0 reactions
- Jun 24, 2026This project is not maintained anymore 😢 — github/command0 reactions · 1 comment
- Jun 11, 2026WS2 · Regenerate primer-react through the corrected registry-scoped meta-skill (HITL) — vercel-labs/ds-skill-extraction-workshop0 reactions · 3 comments
- Feb 6, 2026Upgrade React to 19, additional major dependency updates (Primer, TanStack, tRPC) — github-community-projects/private-mirrors0 reactions · 3 comments
- Nov 21, 2025User interface — panodata/suraya0 reactions · 4 comments
- Apr 11, 2025✨ 이슈 상세 페이지 UI 개선 — Seono-Na/demo-issue-api-playground0 reactions
- Mar 21, 2025IconButton should include Tooltip by default — benbalter/alt-text-generator-action0 reactions
- Mar 21, 2024Improve SSR by removing Webpack dependency — github-community-projects/org-metrics-dashboard0 reactions
- Jan 11, 2024Other relevant component libraries/frameworks — crate/crate-ui-components0 reactions
- Jan 5, 2024Add a pull request template — deven-org/boiler0 reactions
- Sep 23, 2022Element should not auto-register itself unless a browser context is found — github/markdown-toolbar-element0 reactions · 8 comments
Other versions20 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 20
- react/react★ 252ksame name
- facebook/react★ 252ksame name
- getsentry/sentry★ 46ksame name
- redis/RedisInsight★ 8.9ksame name
- BuilderIO/agent-native★ 7.6ksame name
- macro-inc/macro★ 6ksame name
- marcus/sidecar★ 1.1ksame name
- kid-sid/claude-spellbook★ 190same name
- irahardianto/awesome-agv★ 157same name
- shepherdjerred/monorepo★ 111same name
10 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use background-jobs, caching and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
YepAPISkillbackground-jobs
Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.
Also in 3 projects that use this
zebbernSkillcaching
Caching strategies — invalidation, TTL guidelines, cache keys, cache layers, and when not to cache. Use when implementing or reviewing caching logic.
Also in 3 projects that use this
harperaaSkillrate-limiting
Implement rate limiting to prevent brute force attacks, spam, and resource abuse. Use this skill when you need to protect endpoints from automated attacks, prevent API abuse, limit request frequency, or control infrastructure costs. Triggers include "rate limiting", "rate limit", "brute force", "prevent spam", "API abuse", "resource exhaustion", "DoS", "withRateLimit", "too many requests", "429 error".
Also in 3 projects that use this
AnthropicSkillincident-response
Run an incident response workflow — triage, communicate, and write postmortem. Trigger with "we have an incident", "production is down", an alert that needs severity assessment, a status update mid-incident, or when writing a blameless postmortem after resolution.
Also in 5 projects that use this
OpenAISkillobservability
Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.
Also in 5 projects that use this
JohnJBorenSkillci-cd
CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies
Also in 3 projects that use this
In this repository17 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- agentic-workflowsSkill
- changesetsSkill
- component-testingSkill
- create-adr-migratorSkill
- deprecationsSkill
- modular-ds-accessibility-contractSkill
- modular-ds-base-componentsSkill
- modular-ds-config-componentsSkill
- modular-ds-presentational-componentsSkill
- modular-ds-spectrum-modelSkill
- modular-ds-utilitiesSkill
- slotsSkill
- storybookSkill
- style-guideSkill
- turborepoSkill
- write-skillSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

