Copying flags across projects

From PostHog/posthog · View interactive version

Copying flags across projects is an AI agent skill from the GitHub repository PostHog/posthog. Copy a feature flag from one PostHog project to one or more target projects in the same organization. Use when the user wants to duplicate a flag, promote a flag from staging to production, sync flags across projects, or replicate a flag configuration in a different workspace. Covers cohort remappin

How to use this skill

Skill file

Copying feature flags across projects

This skill guides you through duplicating a feature flag from a source project into one or more target projects within the same PostHog organization.

When to use this skill

What this skill does not cover

Workflow

1. Resolve the source flag

You need the flag's key and the source project's id.

2. Resolve target project ids

Targets must be in the same organization as the source. Call posthog:projects-get to list available projects and confirm membership before issuing the copy.

For a multi-target copy, the tool accepts up to 50 target project ids in a single call. Successes and failures are reported per target, so a partial failure does not block the rest.

3. Preview the source flag and its dependencies

Call posthog:feature-flag-get-definition on the source flag. Then always call posthog:feature-flags-copy-dependencies-check with feature_flag_key, from_project, and target_project_ids, rather than trying to detect dependencies first — it copies nothing, and returns an empty result with no warnings when the flag has none, so running it on every copy is cheap and never skips a real dependency.

A false can_copy_dependencies does not always mean the copy is blocked. It is also false when there is nothing to copy. Report a problem only when warnings is non-empty.

Present a concise summary to the user before copying:

4. Confirm copy options

One confirmation covers all three options. Default to the safest combination and ask the user to override only if they explicitly want different behavior:

If the user says "promote it as-is" or "turn it on in prod", switch disable_copied_flag to false. If they say "include the rollout schedule" or "with the scheduled rollout", switch copy_schedule to true.

5. Execute the copy

Call posthog:feature-flags-copy-flags-create with:

6. Report per-target outcome

The response includes a success array (one entry per copied flag) and a failed array (per-target errors). Surface both:

If any targets failed, ask the user whether to retry the failed ones, skip them, or fix the underlying issue (e.g. grant access, then retry).

Important notes

Example interaction

User: Copy the new-checkout flag from project 12345 to project 67890.

Agent: Looking at the source flag in project 12345.

_(calls posthog:feature-flag-get-definition)_

The new-checkout flag is currently a boolean at 25% rollout in project 12345, with no cohort filters and no scheduled changes. I'll copy it as disabled in project 67890 with no scheduled changes — this is the safer default. Confirm?

User: Yes, but enable it in the target.

Agent: Got it — enabling in the target.

_(calls posthog:feature-flags-copy-flags-create with disable_copied_flag: false, copy_schedule: false)_

Done. Created flag id 99887 in project 67890 (active: true). No failed targets.

Available tools

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.