Implement PostHog feature flags, A/B experiments, and cohort management.
Use when rolling out features with flags, running A/B tests, creating cohorts,
or evaluating multivariate experiments with PostHog.
Trigger: "posthog feature flag", "posthog experiment", "posthog A/B test",
"posthog cohort", "feature rollout posthog", "posthog multivariate".
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
Implement PostHog feature flags, A/B experiments, and cohort management.
Use when rolling out features with flags, running A/B tests, creating cohorts,
or evaluating multivariate experiments with PostHog.
Trigger: "posthog feature flag", "posthog experiment", "posthog A/B test",
"posthog cohort", "feature rollout posthog", "posthog multivariate".
Designed for Claude Code, also compatible with Codex and OpenClaw
PostHog Core Workflow B — Feature Flags & Experiments
Overview
Feature flag management, A/B experiment evaluation, and cohort analysis with PostHog. Covers boolean and multivariate flags, local evaluation for performance, experiment setup and statistical significance, and cohort creation via the API.
Prerequisites
Completed posthog-install-auth setup
Familiarity with posthog-core-workflow-a (event capture)
Personal API key (phx_...) for flag management API
Instructions
Step 1: Evaluate Feature Flags (Browser)
import posthog from'posthog-js';
// Boolean flagif (posthog.isFeatureEnabled('new-checkout-flow')) {
renderNewCheckout();
} else {
renderLegacyCheckout();
}
// Multivariate flag (returns string variant name)const variant = posthog.getFeatureFlag('pricing-page-experiment');
switch (variant) {
case'control':
renderOriginalPricing();
break;
case'annual-first':
renderAnnualFirstPricing();
break;
case'social-proof':
renderSocialProofPricing();
break;
default:
renderOriginalPricing(); // Fallback if flag not loaded yet
}
// Get flag payload (JSON data attached to a flag variant)const payload = posthog.getFeatureFlagPayload();
posthog.( {
enabled = posthog.();
(enabled ?? );
});