Find feature flags that were soft-deleted in the active project within a recent time window. Use when the user asks "what flags were deleted in the last N days", "show me recently deleted feature flags", "who deleted flag X", "audit recent flag deletions", or anything similar. Handles the non-obvious gotcha that system.feature_flags exposes the deleted boolean but does not expose a deletion timestamp — the actual deleted-at time lives in the per-flag activity log and must be cross-referenced.
Add this skill
npx mdskills install PostHog/finding-deleted-feature-flags@PostHog? Sign in with GitHub to claim this listing.Solves a non-obvious two-stage API limitation with clear workflow and excellent gotcha documentation
1---2name: finding-deleted-feature-flags3description: 'Find feature flags that were soft-deleted in the active project within a recent time window. Use when the user asks "what flags were deleted in the last N days", "show me recently deleted feature flags", "who deleted flag X", "audit recent flag deletions", or anything similar. Handles the non-obvious gotcha that system.feature_flags exposes the deleted boolean but does not expose a deletion timestamp — the actual deleted-at time lives in the per-flag activity log and must be cross-referenced.'4---56# Finding recently deleted feature flags78This skill produces a list of feature flags that were soft-deleted in the active project within a user-specified time window, along with who deleted each one and when.910## When to use this skill1112- The user asks "what flags got deleted last week / in the last N days?"13- The user wants an audit of recent flag deletions (who, when, what was removed)14- The user wants to find when a specific flag was deleted, or by whom15- Any "recently deleted feature flags" framing1617Don't use this for **active** stale-flag cleanup — that's `cleaning-up-stale-feature-flags`. This skill is for flags that have already been removed.1819## The gotcha that makes this non-trivial2021`system.feature_flags` exposes `deleted` as a boolean but does **not** expose `deleted_at`, `updated_at`, or `last_modified_at`. There's no way to filter soft-deleted flags by deletion time in a single SQL query — trying to use those columns will return `Unable to resolve field`.2223The actual deletion timestamp lives in the per-flag activity log, reachable only via `posthog:feature-flags-activity-retrieve` (one call per flag id). There is no bulk activity endpoint.2425So the workflow is two-stage: SQL to enumerate candidates, then parallel activity-log lookups to find each deletion event.2627## Workflow2829### 1. Clarify the window if ambiguous3031"Last week" is ambiguous — it can mean rolling 7 days from now, or the previous calendar week (Mon–Sun). If the user wasn't explicit, ask, or surface both interpretations in the final report.3233Always compute the cutoff in UTC and keep the user's local interpretation in your head separately.3435### 2. Enumerate soft-deleted flags via SQL3637Query `system.feature_flags` for `deleted = true` in the active project, ordered by `created_at DESC`:3839```sql40SELECT id, key, created_at41FROM system.feature_flags42WHERE team_id = <team_id> AND deleted = true43ORDER BY created_at DESC44LIMIT 10045```4647Order by `created_at DESC` because deletions empirically cluster near creation — most flags get deleted within a few days of being created — so walking the most-recently-created candidates first finds recent deletions fastest. **But** this is a heuristic, not a guarantee: an older flag deleted recently won't be at the top of this list. Be explicit about that limitation when you report.4849`team_id` defaults to the active project, but include it explicitly for clarity.5051### 3. Fan out activity-log lookups in parallel5253For each candidate id, call `posthog:feature-flags-activity-retrieve` with `limit: 5, page: 1`. **Issue all calls in one message so they run concurrently** — sequential calls are dramatically slower.5455```text56call feature-flags-activity-retrieve {"id": <flag_id>, "limit": 5, "page": 1}57```5859Reasonable batch sizes:6061- "last 7 days" → top 20–25 candidates62- "last 30 days" → top 5063- "last 90 days" → walk the full ~1006465If you sample fewer than the full set, say so in the report and offer to walk the rest as a follow-up.6667### 4. Extract the deletion event from each response6869In each response, find the entry where `activity == "deleted"`. That entry's `created_at` is the actual deletion time, and `user.email` / `user.first_name` identify the deleter.7071The deletion event's `detail.changes` array typically contains:7273- `{field: "deleted", before: false, after: true}` — the actual delete74- `{field: "key", before: "<original>", after: "<original>:deleted:<id>"}` — Django renames the key on delete to free up the unique constraint75- `{field: "name", ...}` — the name sometimes gets reset7677For most flags there's exactly one delete event. If a flag has been deleted-and-restored multiple times, take the most recent `activity: deleted` event within the window.7879### 5. Filter and report8081Filter the collected deletion events to those whose `created_at` falls inside the requested window. Present as a table:8283| Flag ID | Key | Deleted at (UTC) | Deleted by |8485State your methodology in the report (how many candidates you walked vs. how many soft-deleted flags exist total), so the user knows what was and wasn't checked.8687## Watch-outs8889- **Borderline cases**: if a deletion is within ~1 hour of the window cutoff, surface it as borderline rather than silently dropping it.90- **Don't trust `created_at` as a proxy for deletion time**: a flag created in 2024 can still have been deleted last week. The activity log is the only authority.91- **Renamed keys are normal**: a flag with key `foo:deleted:12345` was the flag originally keyed `foo`. The original key/name appears in the delete event's `detail.changes` array — surface that to the user, not the renamed form.92- **Walking all candidates is possible but slow**: ~100 parallel activity-log calls is doable. Offer it as a follow-up rather than the default for short windows.9394## Example interaction9596User: "what flags got deleted in the last week?"97981. Clarify if needed, or note both interpretations: "rolling 7 days ending now (UTC), in the active project"992. Run the SQL enumeration to get up to 100 soft-deleted candidates ordered by `created_at DESC`1003. Fan out activity-log lookups in parallel across the top ~25 candidates1014. Extract `activity: deleted` entries; filter to those whose `created_at >= now - 7 days`1025. Report:103104 ```text105 Found 2 feature flags deleted in the last 7 days (rolling, ending 2026-05-22 19:04 UTC):106107 | Flag ID | Key | Deleted at (UTC) | Deleted by |108 |---------|-------------------------------------------|----------------------|-------------|109 | 687432 | high_frequency_alerts | 2026-05-22 17:23 | Matt P. |110 | 676665 | tasks-sendblue-prewarmed-sandbox-pool | 2026-05-15 13:45 | Alessandro |111112 Methodology: walked the activity log for the 25 most-recently-created soft-deleted113 flags. Team 2 has ~100 soft-deleted flags total; the remaining ~75 were created114 before mid-March 2026 and were not checked. Want me to walk the rest?115 ```116117## Related tools118119- `posthog:execute-sql`: Used in step 2 to enumerate soft-deleted candidates against `system.feature_flags`120- `posthog:feature-flags-activity-retrieve`: Used in step 3 to find the actual deletion event for each candidate121- `posthog:feature-flag-get-definition`: Useful if the user then wants to inspect what the deleted flag looked like122
Full transparency — inspect the skill content before installing.