copying-flags-across-projects
它能做什么
本技能将一个功能开关复制到同一组织中的一个或多个项目。适合先在测试项目中验证、再将开关转移到生产环境的团队。
适用场景
- ✓当你想将开关从测试项目转移到生产项目时。
- ✓当你希望在另一个工作区中使用同一开关,并保持其人群完整时。
- ✓当你需要在第二个项目中复制一份开关,以观察它在那里的表现时。
技能链接
https://github.com/PostHog/posthog/blob/master/products/feature_flags/skills/copying-flags-across-projects/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请将新的定价开关从我的测试项目复制到生产项目,但在那里保持关闭状态。”
每周 5 个新技能,1 分钟读完。
工作原理
它会找到开关的 key 和源项目,然后将该开关复制到目标项目。默认情况下,副本在目标项目中是关闭的,并且不会带过去已计划的改动。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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
- The user asks to "copy a flag to another project", "duplicate this flag", or "sync a flag between projects"
- The user wants to promote a flag from a staging project to a production project (or vice versa)
- The user wants to replicate a flag configuration in a different workspace and keep cohort dependencies intact
- The user is working around the absence of true environments by using projects-as-environments
What this skill does not cover
- Cross-organization copy is not supported. The endpoint requires source and target projects to belong to the same org.
- Bulk copying every flag in a project. The tool copies one flag at a time. For batch copies, loop through flag keys; each call is independent.
- Cleaning up old or stale flags — see the
cleaning-up-stale-feature-flagsskill instead.
Workflow
1. Resolve the source flag
You need the flag's key and the source project's id.
- If the user gave a flag key and a project id, use them directly.
- If the user gave a flag name (e.g. "the new pricing flag"), call
posthog:feature-flag-get-allin the source project to find the matching flag and read itskey. - If the user only gave a flag and not a project, ask which project it lives in. Don't assume the active MCP project — copying out of the wrong source is a common foot-gun.
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:
- Flag key, name, and active state in the source
- Filter groups (rollout %, property filters, variant splits)
- Any cohort references in
filters.groups[].properties[]— these will be remapped server-side, but the user should know whether the target project already has matching cohorts - Whether the flag has encrypted payloads (
has_encrypted_payloads) or is remote configuration (is_remote_configuration) - Whether scheduled changes exist (the user can opt to copy them in step 4)
- The dependency check's
copied_dependency_keys(dependencies a copy would create in a target),reused_dependency_keys(dependencies a target already satisfies), and anywarnings
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:
disable_copied_flag: true— the copied flag lands disabled in the target. Recommended by default; turning a flag on in a new project should be a deliberate, observed action.copy_schedule: false— scheduled changes do not come along. Recommended by default; schedules are usually project-specific.copy_dependencies: false— dependency flags do not come along. Set it totrueonly when the user approves copying the keys step 3's check reported.
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:
feature_flag_key: the source flag's keyfrom_project: the source project idtarget_project_ids: the resolved list of target project idsdisable_copied_flag: from step 4 (defaulttrue)copy_schedule: from step 4 (defaultfalse)- `
常见问题
我可以将开关复制到其他组织吗?
不可以。源项目和目标项目必须属于同一组织。
复制过去的开关在目标项目中会自动开启吗?
不会。默认情况下,副本在目标项目中是关闭的。
可以一次复制我所有的开关吗?
不可以。它一次只复制一个开关,因此复制多个开关需要分别复制。
详情
作者的原始描述
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 remapping, scheduled-change handling, encrypted payloads, and the safe defaults (disabled in target, no scheduled changes).
repo: PostHog/posthog
热度
- GitHub 星标
- 41k
- 排名
- #6884
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
depot-ci
41k帮你的智能体设置并运行 Depot CI 工作流(GitHub Actions 的替代方案),包括迁移现有工作流和读取运行日志。
depot-container-builds
41k帮你的智能体在 Depot 的远程构建器上构建 Docker 镜像,包括多平台镜像、推送到镜像仓库,以及修复构建失败。
depot-github-runners
41k帮你的智能体把 GitHub Actions 任务迁移到 Depot 托管的运行器上,选择运行器规格和标签,并排查运行器设置问题。
editing-agents-md
41k帮你的智能体判断某条规则应写入 AGENTS.md 还是 CLAUDE.md,并以不会让文件臃肿的方式写下,确保规则真正生效。