Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(experiments): document the flag cleanup PR option in the lifecycle skill (#94007)

Juraj Majerik22385e23695e
diff --git a/products/experiments/skills/managing-experiment-lifecycle/SKILL.md b/products/experiments/skills/managing-experiment-lifecycle/SKILL.md
index 5b6dff57efc2..d349e1dcb15e 100644
--- a/products/experiments/skills/managing-experiment-lifecycle/SKILL.md
+++ b/products/experiments/skills/managing-experiment-lifecycle/SKILL.md
@@ -142,6 +142,17 @@ Required: `variant_key` (e.g. "test"). Optional: `conclusion`, `conclusion_comme
Returns 409 if an approval policy requires review before the flag change.
+### Flag cleanup PR (option on end and ship variant)
+
+Both `experiment-end` and `experiment-ship-variant` accept `open_cleanup_pr: true`.
+A background PostHog Code task then removes the experiment's feature flag code and opens a draft pull request in the team's connected GitHub repository.
+
+- Only set this when the user asks for it or confirms it.
+- The key must carry the `task:write` scope, or the whole request is rejected with a 403 and the experiment is not ended or shipped.
+- The cleanup runs only when the call actually ends the experiment and a `conclusion` is set — shipping an already-stopped experiment, or ending without a conclusion, skips it. It also requires the team to have the flag cleanup feature enabled; silently skipped when it isn't.
+- `repository` ("organization/repository") picks the target when several repositories are connected. Omit it to fall back to the experiment's saved repository, the team default, or the only connected repository. With several candidates and no default, the cleanup is skipped unless provided.
+- Track progress with `experiment-cleanup-task` — the PR URL appears there once opened; a cleanup typically takes several minutes.
+
### Archive (`experiment-archive`)
Hides a stopped experiment from the default list view.