Skip to main content Inicio Creadores jeremylongshore tons-of-skills-marketplace posthog-core-workflow-b
posthog-core-workflow-b 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".
Ir a la instalación Skills Marketplace Descubre y explora habilidades de IA creadas por la comunidad.
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Copiar promptMostrar detalles del prompt Un comando directo omite el prompt de revisión. Revisa el origen antes de ejecutarlo.
npx skills add https://github.com/jeremylongshore/tons-of-skills-marketplace --skill posthog-core-workflow-bEl comando permanece en una sola línea. Desplázate horizontalmente para revisarlo antes de copiarlo.
¿Prefieres una copia local? Descarga los archivos que SkillsMP tiene disponibles ahora.
Descargar Zip Descargando... Más de este repositorio langchain-deploy-integration Deploy a LangChain 1.0 / LangGraph 1.0 app to Cloud Run, Vercel, or LangServe correctly — with timeouts sized for chain length, cold-start mitigation, SSE anti-buffering headers, and Secret Manager over .env. Use when prepping a first production deploy, debugging a stream that hangs behind a proxy, or diagnosing p99 latency spikes. Trigger with "langchain deploy", "langchain cloud run", "langchain vercel python", "langchain langserve", or "langchain docker".
langchain-langgraph-agents Build a correct LangGraph 1.0 ReAct agent with create_react_agent — typed tools, error propagation, recursion caps, and stop conditions that actually stop. Use when writing a first tool-calling agent, migrating from AgentExecutor or initialize_agent, or diagnosing an agent that loops on vague prompts. Trigger with "langgraph agent", "create_react_agent", "langgraph tool calling", "AgentExecutor migration", or "agent loop cost".
langchain-langgraph-human-in-loop Build LangGraph 1.0 human-in-the-loop approval flows with interrupt_before /
interrupt_after and Command(resume=...) — JSON-serializable state, clean
resume semantics, and UI wiring for approval decisions. Use when adding an
approval gate before an expensive tool call, wiring a Slack/web UI for agent
approvals, or debugging a graph that crashes on interrupt.
Trigger with "langgraph human in loop", "langgraph interrupt_before",
"langgraph approval flow", "Command resume", "langgraph HITL".
name posthog-core-workflow-b description 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".
allowed-tools Read, Write, Edit, Bash(npm:*), Grep version 1.12.0 license MIT author Jeremy Longshore <jeremy@intentsolutions.io> tags ["saas","posthog","workflow","feature-flags","experiments"] compatibility Designed for Claude Code
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' ;
if (posthog.isFeatureEnabled ('new-checkout-flow' )) {
renderNewCheckout ();
} else {
renderLegacyCheckout ();
}
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 ();
}
const payload = posthog.getFeatureFlagPayload ( );
posthog. ( {
enabled = posthog. ( );
(enabled ?? );
});
'banner-config'
onFeatureFlags
() =>
const
isFeatureEnabled
'new-feature'
setFeatureEnabled
false
Step 2: Evaluate Feature Flags (Server — posthog-node) import { PostHog } from 'posthog-node' ;
const posthog = new PostHog (process.env .NEXT_PUBLIC_POSTHOG_KEY !, {
host : 'https://us.i.posthog.com' ,
personalApiKey : process.env .POSTHOG_PERSONAL_API_KEY ,
});
async function checkFlag (userId : string ): Promise <boolean > {
const enabled = await posthog.isFeatureEnabled ('new-api-version' , userId);
return enabled ?? false ;
}
async function getVariant (userId : string ): Promise <string > {
const variant = await posthog.getFeatureFlag ('onboarding-experiment' , userId, {
personProperties : { plan : 'pro' , country : 'US' },
});
return (variant as string ) || 'control' ;
}
async function getUserFlags (userId : string ) {
const flags = await posthog.getAllFlags (userId, {
personProperties : { plan : 'enterprise' },
groupProperties : { company : { name : 'Acme' } },
});
return flags;
}
async function getFlagsAndPayloads (userId : string ) {
const result = await posthog.getAllFlagsAndPayloads (userId);
return result;
}
Step 3: Create Feature Flags via API set -euo pipefail
curl -X POST "https://app.posthog.com/api/projects/$POSTHOG_PROJECT_ID /feature_flags/" \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY " \
-H "Content-Type: application/json" \
-d '{
"key": "new-dashboard-v2",
"name": "New Dashboard V2",
"active": true,
"filters": {
"groups": [{
"rollout_percentage": 25,
"properties": []
}]
}
}'
curl -X POST "https://app.posthog.com/api/projects/$POSTHOG_PROJECT_ID /feature_flags/" \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY " \
-H "Content-Type: application/json" \
-d '{
"key": "checkout-experiment",
"name": "Checkout Flow Experiment",
"active": true,
"filters": {
"multivariate": {
"variants": [
{"key": "control", "rollout_percentage": 50},
{"key": "streamlined", "rollout_percentage": 50}
]
},
"groups": [{"rollout_percentage": 100, "properties": []}]
}
}'
Step 4: Set Up an Experiment
async function runExperiment (userId : string ) {
const posthog = new PostHog (process.env .NEXT_PUBLIC_POSTHOG_KEY !);
const variant = await posthog.getFeatureFlag ('checkout-experiment' , userId);
posthog.capture ({
distinctId : userId,
event : 'purchase_completed' ,
properties : {
variant,
order_value : 49.99 ,
},
});
await posthog.flush ();
return variant;
}
Step 5: Query Experiment Results via API set -euo pipefail
curl "https://app.posthog.com/api/projects/$POSTHOG_PROJECT_ID /experiments/" \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY " | \
jq '.results[] | {id, name, start_date, end_date, feature_flag_key}'
curl "https://app.posthog.com/api/projects/$POSTHOG_PROJECT_ID /experiments/EXPERIMENT_ID/results/" \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY " | \
jq '{
variants: [.result.variants[] | {key, count, conversion_rate: .absolute_exposure}],
significance: .result.significance_code,
probability: .result.probability
}'
Step 6: Manage Cohorts via API set -euo pipefail
curl -X POST "https://app.posthog.com/api/projects/$POSTHOG_PROJECT_ID /cohorts/" \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY " \
-H "Content-Type: application/json" \
-d '{
"name": "Recent Signups (30d)",
"is_calculating": true,
"filters": {
"properties": {
"type": "AND",
"values": [{
"type": "AND",
"values": [{
"key": "user_signed_up",
"type": "behavioral",
"value": "performed_event",
"time_value": 30,
"time_interval": "day"
}]
}]
}
}
}'
curl "https://app.posthog.com/api/projects/$POSTHOG_PROJECT_ID /cohorts/" \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY " | \
jq '.results[] | {id, name, count, is_calculating}'
Error Handling Error Cause Solution Flag always returns undefined Flags not loaded yet Use posthog.onFeatureFlags() callback Flag returns default on server No personalApiKey set Add personal API key for local evaluation Experiment not tracking Goal event name mismatch Verify event name matches experiment config Cohort stuck is_calculating Large dataset Wait for calculation; check PostHog status getAllFlags slowNo local evaluation Set personalApiKey in PostHog constructor
Output
Feature flag evaluation (boolean and multivariate)
Server-side local evaluation for low-latency flag checks
A/B experiment setup with goal metric tracking
Cohort creation and management via API
Experiment results with statistical significance
Resources
Next Steps For common errors, see posthog-common-errors.