adding-warehouse-perso…
Sync columns from a synced data warehouse table onto PostHog person or group properties, so warehouse data becomes usable anywhere person and group properties…
Identify and clean up stale feature flags in a PostHog project. Use when the user wants to find unused, fully rolled out, or abandoned feature flags, review them for safety, and then disable or delete them. Covers staleness detection, dependency checking, and safe removal
$ npx -y skills add PostHog/ai-plugin --skill cleaning-up-stale-feature-flags --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/cleaning-up-stale-feature-flagsContext preview
The summary Claude sees to decide when to auto-load this skill.
Identify and clean up stale feature flags in a PostHog project. Use when the user wants to find unused, fully rolled out, or abandoned feature flags, review them for safety, and then disable or delete them. Covers staleness detection, dependency checking, and safe removal
name: cleaning-up-stale-feature-flags description: 'Identify and clean up stale feature flags in a PostHog project. Use when the user wants to find unused, fully rolled out, or abandoned feature flags, review them for safety, and then disable or delete them. Covers staleness detection, dependency checking, and safe removal workflows.'
This skill guides you through finding feature flags that are no longer serving a purpose and safely removing them.
A feature flag is considered stale when it's no longer doing useful work. PostHog tracks this with two signals:
1. **Usage-based staleness**: The flag has `last_called_at` data, but hasn't been evaluated in 30+ days. This is the strongest signal — the SDKs are no longer checking this flag. 2. **Configuration-based staleness**: The flag has no usage data (`last_called_at` is null), is 30+ days old, and is 100% rolled out (boolean at 100% with no property filters, or a multivariate flag with one variant at 100%). A fully rolled out flag with no conditions is equivalent to a hardcoded value — it can be replaced by removing the flag check from code.
Disabled flags (`active: false`) are not considered stale — they were intentionally turned off and may be kept for reactivation.
Call `posthog:feature-flag-get-all` with `active: "STALE"`. This returns all stale flags in a single request — PostHog handles the staleness detection server-side using the criteria described above.
For each stale flag, gather context before recommending action:
**Check if it's tied to an experiment:**
The `posthog:feature-flag-get-definition` tool returns an `experiment_set` field. If non-empty, the flag is used by an experiment — check the experiment status before touching it.
**Check if other flags depend on it:**
Feature flags can have dependencies (flag B only evaluates when flag A is true). The flag definition includes dependency information in its `filters`. Look for `flag_key` references in other flags' filter groups.
**Check when it was last modified:**
A flag last updated years ago with no recent calls is a stronger removal candidate than one updated last month with no calls (it might be newly deployed and waiting for a release).
**Summarize for the user:**
For each stale flag, present:
Generate a cleanup prompt the user can run in their code editor or coding agent. The cleanup instructions must be tailored to each flag's rollout state, because the rollout state determines which code path to keep. This list also serves as the approval checklist — if the user says their code is already cleaned up, they review it and confirm which flags to disable.
Classify each flag into one of three rollout states based on its definition:
Then generate instructions following this structure:
**For fully rolled out boolean flags** — remove the flag check but keep the enabled code path:
Search for: isFeatureEnabled, useFeatureFlag, getFeatureFlag, posthog.isFeatureEnabled, posthog.getFeatureFlag For flag "example-flag": - Remove the if-check, keep the body - If there is an else branch, remove the else branch entirely
**For fully rolled out multivariate flags** — keep only the winning variant's code:
For flag "example-flag" (keep variant: "winning-variant"): - For if/else chains: keep only the branch matching "winning-variant", remove the flag check - For switch statements: keep only the winning variant's case, remove the switch
**For not-rolled-out flags** — remove the entire flag check AND the enabled code path:
For flag "example-flag": - Remove the if-check AND its body (the feature was never active) - If there is an else branch, keep only the else body
**For partial rollout flags** — flag these for manual review:
For flag "example-flag": - This flag had a partial rollout — check the flag's intent to determine which code path to keep - Then remove the flag check
End the instructions with: "After cleanup, remove any dead code branches and unused imports."
Present the full cleanup prompt in a copyable format so the user can paste it directly into Claude Code, Cursor, Copilot, or any other AI code editor.
**Never disable flags before the code changes are deployed.** Disabling a fully rolled out flag while code still checks it will cause that code path to stop working — a production regression.
**Never disable flags without explicit user approval.** Always present the list and recommendations first, then ask which flags to act on.
Present the user with both options and their tradeoffs:
Official PostHog plugin for AI clients. Access PostHog products directly from your AI coding tool.
Repo: PostHog/ai-plugin
Sync columns from a synced data warehouse table onto PostHog person or group properties, so warehouse data becomes usable anywhere person and group properties…
Analyze the most expensive users in AI observability and explain why they cost so much. Use when the user asks about top spenders, expensive users, per-user…
Analyze session replay patterns across experiment variants to understand user behavior differences. Use when the user wants to see how users interact with…
Split a completed PostHog task run into activity records — what the agent tried, whether it worked, what blocked it — and record each one through the…
Assesses what a page's heatmap is telling you and recommends concrete changes. Pulls click / rageclick / scroll-depth data for a URL, names the hot elements by…
Audit every endpoint in a PostHog project for staleness, failed materialisations, and unused materialised versions. Use when the user asks "what endpoints can…