Skip to main content
skill CX Codex

feature-flags-api — Claude Code skill for PostHog flags

The feature-flags-api skill guides agents through adding PostHog feature flag checks to API applications. Use it when you want to introduce flags without restructuring existing code.

MIT 111 installs ★ 80 updated 2026-10-24

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add PostHog/skills --skill feature-flags-api -a claude-code
Open on GitHub

What feature-flags-api does

The skill guides changes to API code that add feature flag checks alongside the current logic. It favors boolean checks unless you ask for multivariate flags, and recommends server-side evaluation when possible to avoid UI flicker. Keep PostHog keys in environment variables; the skill says not to hardcode them.

Reference files cover API flag setup, adding flag checks, and feature flag practices. There are no framework-specific patterns in the skill, so the guidance stays general. When a PostHog MCP server is connected, the agent can use its tools to create, list, update, or delete flags in PostHog.

What it helps with

  • add a PostHog flag check to API code
  • preserve existing logic while introducing flags
  • choose a boolean check for a feature flag
  • manage flags through PostHog MCP tools

Example prompts for the agent

  • Add a boolean PostHog feature flag check to this API without restructuring its existing logic.
  • Show how to add PostHog feature flags to this API and keep the keys in environment variables.
  • Check for a connected PostHog MCP server and create a flag for this API with its tools.

How to install feature-flags-api

1Skills CLI (Vercel)

npx skills add PostHog/skills --skill feature-flags-api -a claude-code

2Manually: put the files in place

~/.claude/skills/feature-flags-api/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/feature-flags-api/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about feature-flags-api

How do I install feature-flags-api in Claude Code?

Run npx skills add PostHog/skills --skill feature-flags-api -a claude-code. The skill file is at ~/.claude/skills/feature-flags-api/SKILL.md.

What does feature-flags-api do?

It guides agents adding PostHog feature flag checks to API applications while keeping existing logic in place. It favors boolean checks and server-side evaluation when possible.

Where should I keep PostHog keys, and can the skill manage flags?

Store PostHog keys in environment variables rather than in code. If a PostHog MCP server is connected, the agent can use its tools to manage flags.

Source text

SKILL.md · MIT
---
name: feature-flags-api
description: PostHog feature flags for API applications
metadata:
  author: PostHog
  version: 1.9.4
---

# PostHog feature flags for API

This skill helps you add PostHog feature flags to API applications.

## Reference files

- `references/api.md` - API feature flags installation - docs
- `references/adding-feature-flag-code.md` - Adding feature flag code - docs
- `references/best-practices.md` - Feature flag best practices - docs

Consult the documentation for API details and framework-specific patterns.

## Key principles

- **Environment variables**: Always use environment variables for PostHog keys. Never hardcode them.
- **Minimal changes**: Add feature flag code alongside existing logic. Don't replace or restructure existing code.
- **Boolean flags first**: Default to boolean flag checks unless the user specifically asks for multivariate flags.
- **Server-side when possible**: Prefer server-side flag evaluation to avoid UI flicker.

## PostHog MCP tools

Check if a PostHog MCP server is connected. If available, look for tools related to feature flag management (creating, listing, updating, deleting flags). Use these tools to manage flags directly in PostHog rather than requiring the user to do it manually in the dashboard.

## Framework guidelines

_No specific framework guidelines._

© PostHog · MIT · PostHog/skills

Similar skills

All skills for Backend and APIs →

From the same set112

The whole set →
feature-flags-nodejs The feature-flags-nodejs skill helps add PostHog feature flags to Node.js applications. Use it when new behavior needs controlled server-side rollout. CX Codex +1 113installs integration-expo The integration-expo skill adds PostHog analytics to Expo apps and guides the setup in stages. Use it for events, user identification, screens, and errors. CX Codex +1 112installs feature-flags-ios feature-flags-ios adds PostHog feature flags to iOS apps, manages SPM dependencies cleanly, and enforces environment variable handling in Xcode. CX Codex +1 112installs feature-flags-react feature-flags-react adds PostHog feature flag checks to a React app and keeps them clear of the code that already works. CX Codex +1 112installs integration-react-native The integration-react-native skill guides an agent through adding PostHog analytics to a React Native app, including user identification and error tracking. CX Codex +1 109installs feature-flags-react-native feature-flags-react-native integrates PostHog feature flags into React Native apps following best practices for hooks, environment variables, and navigation. CX Codex +1 109installs integration-astro-ssr integration-astro-ssr adds PostHog analytics to server-rendered Astro setups with API endpoints. Connects frontend tracking with backend routes. CX Codex +1 109installs integration-swift integration-swift guides PostHog analytics integration into Swift applications across iOS and macOS targets. CX Codex +1 108installs

Project sponsors

Companies that keep this analytics open