Terminal
Terminal/Skill
Adds feature flag checks around new code, so a change can roll out gradually to some users first.
By PostHog
Works with
npx skills add posthog/ai-plugin --skill instrument-feature-flagsUse this skill to add PostHog feature flags that gate new or changed functionality. Use it after implementing features or reviewing PRs to ensure safe rollouts with feature flag controls. If PostHog is not yet installed, this skill also covers initial SDK setup. Supports any platform or language.
Supported platforms: React, Next.js, React Native, Web (JavaScript), Node.js, Python, PHP, Ruby, Go, Java, Rust, .NET, Elixir, Android, iOS, Flutter, and the REST API.
Follow these steps IN ORDER:
Look for lockfiles (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lockb, go.sum, pubspec.lock, Podfile.lock, Package.resolved, mix.lock) to determine the package manager.
STEP 2: Research instrumentation. (Skip if PostHog is already set up.) 2.1. Find the reference file below that matches the detected platform — it is the source of truth for SDK initialization, flag evaluation methods, and framework-specific patterns. Read it now. 2.2. If no reference matches, fall back to your general knowledge and web search. Use posthog.com/docs as the primary search source.
STEP 3: Create or find the feature flag.
STEP 4: Plan release conditions.
STEP 5: Instrument the feature.
STEP 6: Set up environment variables.
.env, .env.local, or framework-specific env files). If valid values already exist, skip this step.projects-get tool to retrieve the project's api_token. If multiple projects are returned, ask the user which project to use. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead.projects-get MCP response for a region field — US maps to https://us.i.posthog.com, EU maps to https://eu.i.posthog.com. If the region is not available from the MCP response or from existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud.references/react.md - React feature flags installationreferences/react-native.md - React native feature flags installationreferences/web.md - Web feature flags installationreferences/nodejs.md - Node.js feature flags installationreferences/python.md - Python feature flags installationreferences/django.md - Djangoreferences/flask.md - Flaskreferences/php.md - Php feature flags installationreferences/laravel.md - Laravelreferences/ruby.md - Ruby feature flags installationreferences/ruby-on-rails.md - Ruby on railsreferences/go.md - Go feature flags installationreferences/java.md - Java feature flags installationreferences/rust.md - Rust feature flags installationreferences/dotnet.md - .net feature flags installationreferences/dotnet.md - .netreferences/elixir.md - Elixir feature flags installationreferences/android.md - Android feature flags installationreferences/ios.md - Ios feature flags installationreferences/usage.md - Ios SDK usagereferences/flutter.md - Flutter feature flags installationreferences/api.md - API feature flags installationreferences/next-js.md - Next.jsreferences/adding-feature-flag-code.md - Adding feature flag codereferences/best-practices.md - Best practices for production-ready flagsreferences/COMMANDMENTS.md - Framework-specific rules the integration must followEach platform reference contains SDK-specific installation, flag evaluation, and code examples. Find the one matching the user's stack. If unlisted, use the API reference as a fallback.