setting-feature-flags-in-storybook
Skill by PostHog
Explains how to set feature flags in Storybook stories for components gated on a flag. Covers the featureFlags story parameter for boolean and multivariate flags. Aimed at developers writing stories for visual-regression snapshots.
Install setting-feature-flags-in-storybook
Built from the published package, never by AI.
git clone --depth 1 https://github.com/PostHog/posthog /tmp/posthog && mkdir -p ~/.claude/skills && cp -r /tmp/posthog/.agents/skills/setting-feature-flags-in-storybook ~/.claude/skills/setting-feature-flags-in-storybookRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
Step-by-step: install setting-feature-flags-in-storybook in Claude Code
git clone --depth 1 https://github.com/PostHog/posthog /tmp/posthog && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/posthog/.agents/skills/setting-feature-flags-in-storybook ~/.gemini/antigravity-cli/skills/setting-feature-flags-in-storybookAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install setting-feature-flags-in-storybook in Antigravity CLI
Skills can run scripts on your machine. Some need an API key: check the README.
About
This skill is a guide for writing Storybook stories for components that depend on a feature flag. It describes the featureFlags story parameter. Boolean flags are passed as an array of flag names that evaluate to true. Multivariate flags, such as experiment arms, are pinned with a record that maps each flag to a variant value.
The skill warns against calling featureFlagLogic.actions.setFeatureFlags from a story. According to the source, that call passes in jest but renders the flag-off branch in the visual-regression Storybook. It also notes that a per-story featureFlags parameter replaces the meta-level one, so meta flags must be listed again. The skill is for frontend developers working on PostHog's Storybook setup who write stories for gated components.
Written from the project's SKILL.md and checked against it.
What it can do
- Boolean flag parameterSets flags that evaluate to true through the featureFlags story parameter as an array.
- Multivariate flag recordPins a specific variant value for a flag using a record form of featureFlags.
- Per-story arm variantsRenders different experiment arms in separate stories using per-story featureFlags records.
- Override warningExplains that per-story featureFlags replaces meta flags, so meta flags must be re-listed.
Try asking
- Write a Storybook story for my component gated on the MY_FLAG feature flag.
- Create control and treatment stories for an experiment flag with variant values.
- Show how to keep meta-level feature flags when adding a per-story featureFlags override.
Good to know
- Calling featureFlagLogic.actions.setFeatureFlags from a story renders the flag-off branch in visual-regression snapshots.
- Per-story featureFlags replaces meta-level flags rather than merging with them.
- Disabling posthog-js flags is not recommended because it stalls app-level stories.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: .agents/skills/setting-feature-flags-in-storybook/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Alternatives to setting-feature-flags-in-storybook
All alternatives →Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.
Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.
Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.
Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.
Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.
Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.
Compare with openclaw-github-repo-commander, gradio or hig-components-menus
setting-feature-flags-in-storybook: common questions
Why does my story show the flag-off version in visual regression tests?
The source says imperatively calling featureFlagLogic.actions.setFeatureFlags is wiped by the empty onFeatureFlags callback in the built Storybook. Using the featureFlags story parameter avoids this.
How do I set a multivariate flag in a Storybook story?
Use the record form of the featureFlags parameter, mapping the flag key to a variant string such as 'control' or 'test_b'. The array form only supports true values.
Why do my other flags disappear when I add a story-level featureFlags?
A story's parameters replace the meta parameters via a shallow merge, so any meta-level flags must be listed again in the story's featureFlags.
How do I install setting-feature-flags-in-storybook?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is setting-feature-flags-in-storybook free?
The code is published under the NOASSERTION licence. The service it connects to may have its own pricing.
Is setting-feature-flags-in-storybook safe to use?
It scores 81 of 100. Grades: maintenance A, licence F, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to setting-feature-flags-in-storybook?
Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.
