> ## Documentation Index
> Fetch the complete documentation index at: https://confidence.spotify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrate from PostHog to Confidence

> Learn how to migrate feature flags and multivariate flags from PostHog to Confidence with the AI-powered migration kit.

export const HowToSchema = ({name, description, steps = []}) => {
  const schema = {
    "@context": "https://schema.org",
    "@type": "HowTo",
    name,
    description
  };
  if (steps.length > 0) {
    schema.step = steps.map((s, i) => ({
      "@type": "HowToStep",
      position: i + 1,
      name: typeof s === "string" ? s : s.name,
      text: typeof s === "string" ? s : s.text || s.name
    }));
  }
  return <script type="application/ld+json" dangerouslySetInnerHTML={{
    __html: JSON.stringify(schema)
  }} />;
};

<HowToSchema
  name="Migrate from PostHog to Confidence"
  description="Migrate feature flags and multivariate flags from PostHog to Confidence with the AI-powered migration kit."
  steps={[
{
  name: "Plan the flag migration",
  text: "Run /confidence:migrate-posthog plan flag. The kit scans your PostHog feature flags, asks you to choose a Confidence client and entity, and writes a migration plan file.",
},
{
  name: "Review the plan",
  text: "The plan lists every flag with its targeting conditions and rollout percentages, and marks anything that can't migrate automatically.",
},
{
  name: "Execute the flag migration",
  text: "Run /confidence:migrate-posthog execute with the plan file. The kit recreates each flag in Confidence with its targeting rules intact.",
},
{
  name: "Plan and execute the code migration",
  text: "Run /confidence:migrate-posthog plan code, review the plan, then execute it. The kit rewrites each PostHog SDK call to the Confidence SDK, creating one pull request per flag.",
},
]}
/>

Run this skill to migrate from PostHog to Confidence:

```bash theme={null}
npx skills add spotify/confidence-ai-plugins --skill migrate-posthog
```

The installer works with Claude Code, Cursor, Codex, Gemini CLI, and other AI assistants, and asks which one to install to. You can also install the full [Confidence plugin](/docs/migrations/overview#install-the-confidence-plugin) with your assistant's own plugin manager.

The kit moves your feature flags and multivariate flags to Confidence, then rewrites your application code from the PostHog SDK to the Confidence SDK. See the [migrations overview](/docs/migrations/overview) for how migration kits work.

## Before You Begin

To run this migration kit, you need:

* The [Confidence plugin](/docs/migrations/overview#install-the-confidence-plugin) installed in your AI assistant

* The PostHog MCP server, authenticated with your PostHog account. For example, in Claude Code:

  ```bash theme={null}
  claude mcp add posthog --transport http --url "https://mcp-eu.posthog.com/mcp"
  ```

* The Confidence Flags MCP server, authenticated with your account

* The Confidence Documentation MCP server, used during code transformation

## Run the Migration

Invoke the kit with the `/confidence:migrate-posthog` command in your AI assistant.

<Steps>
  <Step title="Plan the flag migration">
    Run `/confidence:migrate-posthog plan flag`. The kit scans your PostHog feature flags, asks you to choose a Confidence client and entity, and writes a migration plan file.
  </Step>

  <Step title="Review the plan">
    The plan lists every flag with its targeting conditions and rollout percentages, and marks anything that can't migrate automatically. Plan files are resumable, so you can pause and continue later.
  </Step>

  <Step title="Execute the flag migration">
    Run `/confidence:migrate-posthog execute <plan-file>`. The kit recreates each flag in Confidence with its targeting rules intact.
  </Step>

  <Step title="Plan and execute the code migration">
    Run `/confidence:migrate-posthog plan code`, review the plan, then execute it. If your app already uses OpenFeature, the kit swaps the registered provider and leaves call sites unchanged. Otherwise it rewrites each PostHog SDK call to the Confidence SDK, creating one pull request per flag.
  </Step>
</Steps>

## What Gets Migrated

| PostHog                 | Confidence                                                       |
| ----------------------- | ---------------------------------------------------------------- |
| Feature flag            | Flag with matching targeting rules                               |
| Multivariate flag       | Variant assignments within a single rule, with percentage splits |
| `distinct_id` bucketing | Entity field of your choice, such as `user_id`                   |
| Group-based bucketing   | Group entity reference                                           |
| Targeting conditions    | Criteria and expression rules                                    |
| Rollout percentage      | Rollout percentage on the targeting rule                         |

## Known Limitations

The kit flags these PostHog features for manual review because Confidence doesn't support them:

* The `icontains` substring operator
* The `is_not_set` condition
* Cohort targeting

## Analyze Historical Experiments

The migration kit moves your flags and code, not your historical experiment results. To re-analyze experiments that ran on PostHog, import their assignment data into your data warehouse and follow the [Analyze a Past Experiment](/docs/quickstarts/analyze-past-experiment) quickstart.

## Related Resources

<CardGroup cols={2}>
  <Card title="Migrations Overview" href="/docs/migrations/overview">
    How migration kits work and how to install the plugin
  </Card>

  <Card title="Use AI with Confidence" href="/docs/quickstarts/use-mcp">
    Set up the Confidence MCP servers for your AI assistant
  </Card>

  <Card title="Analyze a Past Experiment" href="/docs/quickstarts/analyze-past-experiment">
    Re-analyze experiments that ran on another platform
  </Card>

  <Card title="SDK Integration" href="/docs/sdks/introduction">
    Integrate Confidence SDKs into your application
  </Card>
</CardGroup>
