cleaning-up-stale-feature-flags
できること
このスキルは、古い、または完全にロールアウトされたフィーチャーフラグを見つけ、それらをまだ確認しているコードを削除します。古いフラグの乱雑さを減らしたい開発者やチーム向けです。
使う場面
- ✓どのフィーチャーフラグを安全に削除できるか知りたいとき。
- ✓フラグが長期間完全にロールアウトされているのに、コードがまだそれを確認しているとき。
- ✓フィーチャーフラグの乱雑さを減らすため、定期的に見直しているとき。
スキルのリンク
https://github.com/PostHog/posthog/blob/master/products/feature_flags/skills/cleaning-up-stale-feature-flags/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“どのフィーチャーフラグを削除できますか?それらをチェックしているコードも整理してくれますか?”
毎週5つの新しいスキル。1分で読めます。
仕組み
未使用または完全にロールアウトされたフラグを見つけ、まずコードを整理します。フラグ自体はPostHogで、コードの変更がデプロイされた後に変更されます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Cleaning up stale feature flags
This skill guides you through finding feature flags that no longer serve a purpose and removing them safely. The ordering is fixed: clean up the code, wait for that cleanup to deploy, and only then change the flag in PostHog.
When to use this skill
- The user asks to clean up, audit, review, or remove their feature flags
- The user wants to find flags that are stale, unused, or fully rolled out
- The user asks "which feature flags can I remove?" or similar
- The user wants to reduce tech debt from old feature flags
- The user asks for a feature flag hygiene review
- The user runs a weekly or recurring flag cleanup
Do not activate for an unrelated coding task that merely mentions a feature flag. Cleaning up a flag is its own job, requested by the user.
What makes a flag stale
A feature flag is considered stale when it's no longer doing useful work. PostHog tracks this with two signals:
- Usage-based staleness: The flag has
last_called_atdata, but hasn't been evaluated in 30+ days. This means PostHog has not received recent calls. Local evaluation or disabled event capture can hide continued use. - Configuration-based staleness: The flag has no usage data (
last_called_atis 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.
Treat configuration-based staleness more cautiously than old evaluation evidence:
$feature_flag_called events can be missing when local evaluation is used or event capture is disabled,
and a config-only signal says nothing about whether code still checks the flag.
Stale means cleanup candidate, never proof that removal is safe.
Establish what you can do
First separate assessment from cleanup. A request to review or assess a flag authorizes reads and recommendations, not code edits. Only an explicit cleanup request authorizes repository changes, subject to the checks below. Then work out which path you can complete in this session:
- PostHog read access only (no repository): assess candidates, then produce the tailored handoff prompt (see "Hand off when you cannot edit the repository").
- Repository read access: additionally inspect the exact call sites and turn the handoff into a repository-specific plan.
- Repository write access: make the code changes yourself and test them locally.
- Authorized publishing: also open one draft PR per flag, following the host's branch, commit, and PR policy.
Filesystem access is not permission to publish. The agent host's review, commit, and PR policy always wins over this skill.
Whichever path applies, never change the flag in PostHog during this workflow. Archiving the flag belongs to a later continuation, after the user confirms the code cleanup deployed (see "After the cleanup is deployed").
When the user's request clearly authorizes cleanup and you can edit the repository, execute: pick the safest deterministic candidate and clean it up directly. Do not stop to generate a copy-paste prompt, and do not add confirmation steps for local, uncommitted code changes. One action still needs approval in the user's own words: pushing a branch or opening a PR. The availability of a git or GitHub tool is not that approval, and a push to a repository cannot be taken back. The flag itself is never changed in this workflow, with or without approval.
Workflow
1. Establish scope
- Confirm which PostHog project you are assessing flags in.
- Confirm the current repository is a plausible owner of the flag (the key appears in it, or the user says it does).
- Ask about other repositories, services, mobile apps, or workers when the flag may span independently deployed code. One repository cleanup is not proof that every deployed consumer is gone.
- Default to cleaning one high-confidence flag first, unless the user explicitly asked for a known set. For a set, finish one flag (through validation and its PR) before starting the next.
2. Find and assess candidates
When the user names a specific flag, start from posthog:feature-flag-get-definition-by-key,
which returns the numeric id and the full definition in
よくある質問
フラグが古いとはどういう意味ですか?
30日以上呼び出されていないフラグ、または完全にオンになっているフラグで、使用データがないものが古いとみなされます。
エージェントが自分でコードを削除しますか?
エージェントがリポジトリを読み書きできる場合は、コードの整理を自分で行います。
なぜフラグを最後に変更するのですか?
フラグを先に削除すると、まだそれを確認しているコードが壊れるかもしれないため、コードを整理してデプロイしてからフラグを変更します。
詳細
作者による元の説明
Identify stale feature flags in a PostHog project and clean up the code that checks them. Use when the user wants to find, audit, or remove unused, fully rolled out, or abandoned feature flags, run a feature flag hygiene review or a weekly cleanup, reduce feature flag tech debt, or asks "which flags can I remove?". When the agent can read and edit a repository it performs the code cleanup itself: tested local changes, and one draft PR per flag when the user authorizes publishing. Agents without repository access generate a tailored cleanup prompt instead. Covers staleness detection, dependency
repo: PostHog/posthog
人気
- GitHubのスター
- 41k
- ランキング
- #6883
- ライセンス
- —
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
depot-ci
41kエージェントが、GitHub Actionsの代替であるDepot CIのワークフローを設定し実行できるよう支援します。既存のワークフローの移行や、実行ログの確認も含みます。
depot-container-builds
41kエージェントが、Depotのリモート・ビルダーでDockerイメージを作れるよう支援します。マルチプラットフォームのイメージ、レジストリへのプッシュ、ビルド失敗の修正を含みます。
depot-github-runners
41kエージェントが、GitHub Actionsのジョブを Depot が管理するランナーに移し、ランナーのサイズとラベルを選び、ランナー設定の問題を解決できるよう支援します。
editing-agents-md
41kエージェントが、AGENTS.mdとCLAUDE.mdのどちらにルールを書くべきかを判断し、ファイルを膨らませずに守られやすい形で書けるよう支援します。
似ているスキル
openclaw-update
394k既存のOpenClaw Gatewayを更新するようエージェントを支援します。インストール方法に合った更新方法を選び、セッションを動かし続けます。
diagnose-gateway
394k設定、チャンネル、ポートを確認して、OpenClaw Gatewayが失敗している理由を、何も変更せずに突き止めるようエージェントを支援します。
crabbox-apps
394k一時的なクラウドマシン上でアプリを開いて実行し、そのビューをチャットのサイドパネルに表示するようエージェントを支援します。