set-up-feature-flags
Skill7 starsChanged 16 days agoMITView on GitHub
Use when adding feature flags to a frontend — vendor-agnostic OpenFeature SDK (useFlag hook/composable) with fail-closed defaults, user-targeting context, a dev override, and flag-gated routes. Provider swap (PostHog, GrowthBook, LaunchDarkly) is one line.
- Reads credentials
- Installs packages
1 other project uses a version of this.
Adopted by
Most recently taken up by
- VelimirMueller/claude-skillsword for word, first seen Oct 11, 2026
Other versions1 project uses a version of this.
Word for word · 1
- VelimirMueller/claude-skills★ 7100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
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.
In this repository156 other files it gives its agents.
- skills/swift/swiftui-design-principles/AGENTS.mdAGENTS.md
- skills/swift/ios-code-audit/CLAUDE.mdCLAUDE.md
- skills/swift/swift-focusengine-pro/llms.txtllms.txt
- build-llm-seamSkill
- build-mcp-serverSkill
- build-rag-pipelineSkill
- secure-llm-featuresSkill
- set-up-llm-evalsSkill
- build-nextjs-backendSkill
- build-supabase-edge-functionSkill
- configure-backend-testsSkill
- design-http-apiSkill
- harden-backendSkill
- scaffold-fastapi-serviceSkill
- scaffold-go-serviceSkill
- scaffold-hono-serviceSkill
- secure-supabase-rlsSkill
- set-up-backend-authSkill
- set-up-background-jobsSkill
- set-up-databaseSkill
- set-up-nextjs-supabase-authSkill
- set-up-observabilitySkill
- set-up-supabaseSkill
- build-cliSkill
- release-cliSkill
- set-up-dev-toolchainSkill
- audit-securitySkill
- audit-toolchainSkill
- extend-skillsetSkill
- promote-releaseSkill
- set-up-stack-profileSkill
- write-commit-messagesSkill
- write-pull-requestsSkill
- analyze-complexitySkill
- apply-algorithmsSkill
- apply-design-patternsSkill
- apply-design-principlesSkill
- apply-solidSkill
- choose-data-structureSkill
- debug-systematicallySkill
- enforce-dependency-ruleSkill
- refactor-safelySkill
- slice-and-estimateSkill
- write-clean-testsSkill
- write-readable-codeSkill
- clean-frontend-scaffoldingSkill
- configure-accessibilitySkill
- configure-analyticsSkill
- configure-ciSkill
- configure-error-trackingSkill
- configure-lintingSkill
- configure-test-stackSkill
- configure-typescriptSkill
- create-moduleSkill
- optimize-performanceSkill
- scaffold-frontend-projectSkill
- set-up-authSkill
- set-up-design-systemSkill
- set-up-document-headSkill
- set-up-error-boundariesSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
Look for ad-hoc env-var flags (VITE_FEATURE_X) — those are build-time toggles, not runtime flags.
- Distinctive: line 19
No flags → full setup.
- Very specific: line 24
Read frontend.framework from the profile (commands use pnpm.
- Very specific: line 116
Never hand-code if (user.id === 'me') — that's what targeting is for.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Set Up Feature Flags
1. Audit current state
cat .claude/stack-profile.md 2>/dev/null || cat ~/.claude/stack-profile.md 2>/dev/null # frontend.framework, package_manager
grep -E '"(@openfeature/web-sdk|@openfeature/react-sdk)"' package.json 2>/dev/null
grep -rn "import.meta.env.VITE_FEATURE_\|featureFlag\|useFlag" src/ 2>/dev/null | headLook for ad-hoc env-var flags (VITE_FEATURE_X) — those are build-time toggles, not runtime flags; this skill replaces them where you need runtime control. Pairs with set-up-auth (targeting context = the logged-in user) and set-up-routing (flag-gated routes).
2. Decide what to do
- No flags → full setup.
- Env-var toggles only → migrate the ones that need runtime/gradual rollout to OpenFeature; leave pure build-time switches as env.
- Vendor SDK used directly in components → put it behind the OpenFeature seam (step 5).
3. Detect framework
Read frontend.framework from the profile (commands use pnpm; translate for package_manager).
React → @openfeature/react-sdk (provider + useFlag). Vue → @openfeature/web-sdk + a small composable.
4. Install
pnpm add @openfeature/web-sdk @openfeature/core @openfeature/react-sdk # Vue: drop react-sdk@openfeature/core is a peer of the web SDK; list it explicitly so the version is yours, not whatever the resolver picks. Why OpenFeature at all: feature-flags-patterns.md.
5. Set the provider (vendor-agnostic seam)
// src/libs/featureFlags.ts
import { OpenFeature, InMemoryProvider } from '@openfeature/web-sdk';
// Dev/test: in-memory flags. Prod: your vendor's OpenFeature provider
// (PostHog / GrowthBook / LaunchDarkly / ConfigCat / Flagsmith) — a one-line swap.
const provider = new InMemoryProvider({
'new-dashboard': { variants: { on: true, off: false }, defaultVariant: 'off', disabled: false },
});
export async function initFeatureFlags(): Promise<void> {
try {
await OpenFeature.setProviderAndWait(provider);
} catch {
// Provider failed to start: every read now returns its safe default (fail closed).
}
}Await it before the first render (below). A flag read before the provider is ready returns the default, so a route guard on a cold deep link would 404 a user who has the flag.
6. React — OpenFeatureProvider + useFlag
// main.tsx
import { OpenFeatureProvider } from '@openfeature/react-sdk';
import { initFeatureFlags } from '@/libs/featureFlags';
await initFeatureFlags(); // top-level await: Vite builds ES modules; keep it before createRoot
createRoot(document.getElementById('root')!).render(
<OpenFeatureProvider>
<App />
</OpenFeatureProvider>,
);// usage — query-style hook with a mandatory safe default
import { useFlag } from '@openfeature/react-sdk';
function Dashboard() {
const { value: showNew } = useFlag('new-dashboard', false); // default = control
return showNew ? <NewDashboard /> : <ClassicDashboard />;
}The React SDK re-renders on flag/context change and supports Suspense while the provider initializes.
7. Vue — a composable
// src/composables/useFlag.ts
import { OpenFeature, ProviderEvents } from '@openfeature/web-sdk';
import { onScopeDispose, ref } from 'vue';
export function useFlag(key: string, defaultValue: boolean) {
const client = OpenFeature.getClient();
const value = ref(client.getBooleanValue(key, defaultValue));
const refresh = () => {
value.value = client.getBooleanValue(key, defaultValue);
};
// Re-read when the provider becomes ready, its rules change, or the context changes.
client.addHandler(ProviderEvents.Ready, refresh);
client.addHandler(ProviderEvents.ConfigurationChanged, refresh);
client.addHandler(ProviderEvents.ContextChanged, refresh);
onScopeDispose(() => {
client.removeHandler(ProviderEvents.Ready, refresh);
client.removeHandler(ProviderEvents.ConfigurationChanged, refresh);
client.removeHandler(ProviderEvents.ContextChanged, refresh);
});
return value;
}Handler event names are the ProviderEvents enum: the string literal 'PROVIDER_CONFIGURATION_CHANGED' does not type-check. Call await initFeatureFlags() before app.mount() in main.ts.
8. Targeting context (who gets the flag)
Set the evaluation context from the current user — the provider targets on it (plan, % rollout, allow-list). Update it on login (set-up-auth):
import { OpenFeature } from '@openfeature/web-sdk';
await OpenFeature.setContext({ targetingKey: user.id, plan: user.plan, country: user.country });
await OpenFeature.setContext({}); // on logout: drop the previous user's targetingNever hand-code if (user.id === 'me') — that's what targeting is for. The context is sent to the flag vendor: use a pseudonymous id as targetingKey, never an email or name (GDPR: the vendor becomes a processor of whatever you put here).
9. Gate a route behind a flag
// React (TanStack Router): src/routes/new-dashboard.tsx
import { createFileRoute, notFound } from '@tanstack/react-router';
import { OpenFeature } from '@openfeature/web-sdk';
export const Route = createFileRoute('/new-dashboard')({
beforeLoad: () => {
if (!OpenFeature.getClient().getBooleanValue('new-dashboard', false)) throw notFound();
},
});Dev override: seed the InMemoryProvider from a local panel / localStorage so you can flip flags without the backend; To layer overrides over the real provider, OpenFeature's web multi-provider (@openfeature/multi-provider-web, pre-1.0 at 0.0.x) is an option; a plain wrapper provider is the safer choice until it stabilizes.
10. Verify
pnpm typecheck
pnpm devFlip defaultVariant (or the dev override) → the gated UI/route appears; the safe default (control) renders when the provider is unreachable. Open the gated route as a cold deep link: it must load, not 404. A flag hides UI only — the API must enforce who may use the feature.
References
- ./feature-flags-patterns.md — vendor-agnostic seam, fail-closed defaults, targeting-not-hardcoding, flags-are-debt cleanup, build-time-env vs runtime-flag.
- ../set-up-auth/SKILL.md — the user that feeds the targeting context.
- ../set-up-routing/SKILL.md — the route guard hook.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

