adding-feature-flags
Add feature flags to an application for gradual rollouts, A/B testing, and kill switches using PostHog, LaunchDarkly, or a simple local implementation.
How do I install this agent skill?
npx skills add https://github.com/spencerpauly/awesome-cursor-skills --skill adding-feature-flagsIs this agent skill safe to install?
- Gen Agent Trust Hubpass
The skill provides standard instructions and code templates for implementing feature flags using PostHog or local environment variables. No security issues were detected.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
- ZeroLeakspass
Score: 93/100 · 2 sections analyzed
What does this agent skill do?
Add Feature Flags
Use this skill when the user asks to add feature flags, feature toggles, gradual rollouts, or A/B testing.
Option A: PostHog Feature Flags (Recommended)
-
Install PostHog if not already present:
npm install posthog-js -
Use feature flags in code:
import { useFeatureFlagEnabled } from "posthog-js/react"; function MyComponent() { const showNewFeature = useFeatureFlagEnabled("new-checkout-flow"); if (showNewFeature) return <NewCheckout />; return <OldCheckout />; } -
Server-side evaluation — for server components or API routes:
import { PostHog } from "posthog-node"; const posthog = new PostHog(process.env.POSTHOG_API_KEY!); const isEnabled = await posthog.isFeatureEnabled("new-checkout-flow", userId); -
Create flags in the PostHog dashboard — set up targeting rules based on user properties, percentage rollouts, or cohorts.
Option B: Simple Local Feature Flags
For projects that don't need a third-party service:
-
Create a flags config —
lib/feature-flags.ts:export const FLAGS = { NEW_CHECKOUT: process.env.NEXT_PUBLIC_FF_NEW_CHECKOUT === "true", DARK_MODE: process.env.NEXT_PUBLIC_FF_DARK_MODE === "true", } as const; -
Use in components:
import { FLAGS } from "@/lib/feature-flags"; function App() { return FLAGS.NEW_CHECKOUT ? <NewCheckout /> : <OldCheckout />; } -
Add env vars — add flags to
.envand.env.example:NEXT_PUBLIC_FF_NEW_CHECKOUT=false NEXT_PUBLIC_FF_DARK_MODE=true
Notes
- Use feature flags for all user-facing changes during rollout, not just experiments.
- Clean up stale flags — remove the flag and the old code path once a feature is fully rolled out.
- For server-side flags, cache the evaluation result to avoid per-request API calls.
- Name flags descriptively:
new-checkout-flownotflag-1.
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/spencerpauly/awesome-cursor-skills/adding-feature-flags">View adding-feature-flags on skillZs</a>