> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # AI wizard Canonical URL: https://posthog.com/docs/ai-engineering/ai-wizard ## On this page - [How it works](#how-it-works) - [AI wizard installation](#ai-wizard-installation) - [Frameworks and languages](#frameworks-and-languages) - [Self-driving](#self-driving) - [Commands](#commands) - [Feedback](#feedback) The PostHog wizard is an agentic CLI tool that uses AI to set up and manage PostHog in your codebase. By default, it installs and instruments PostHog for you with a single command: `npx -y @posthog/wizard@latest`. It does more than installation, though. The wizard can also audit an existing integration, migrate you from another vendor, upload source maps, set up Revenue Analytics, and diagnose configuration issues – so it's just as useful after you're up and running as it is on day one. `npx @posthog/wizard` When it's done, your project is onboarded with: - [MCP Analytics](https://posthog.com/docs/mcp-analytics.md) - [Product Analytics](https://posthog.com/docs/product-analytics.md) - [Session Replay](https://posthog.com/docs/session-replay.md) - [Error Tracking](https://posthog.com/docs/error-tracking.md) - [Web Analytics](https://posthog.com/docs/web-analytics.md) - [AI Observability](https://posthog.com/docs/ai-observability.md) - [Replay Vision](https://posthog.com/docs/replay-vision.md) - [Feature Flags](https://posthog.com/docs/feature-flags.md) - [Experiments](https://posthog.com/docs/experiments.md) - [Logs](https://posthog.com/docs/logs.md) ## How it works Running the wizard automatically: 1. Authenticates your PostHog account 2. Installs the relevant **PostHog SDKs** 3. Scans your codebase and app architecture 4. Creates **custom events** based on real product flows 5. Configures `.env` file with your project credentials 6. Writes code and instruments the PostHog SDKs **client-side** and **server-side** 7. Generates **insights** and **dashboards** in the PostHog app 8. Optionally installs the [PostHog MCP server](https://posthog.com/docs/model-context-protocol.md) for your AI agent The AI wizard integrating both the JS Web SDK and Node SDK into a Next.js application ## AI wizard installation Install PostHog in minutes with our wizard by running this command in your project directory: `npx @posthog/wizard` Wait for it to finish and test the setup once the wizard is complete. ## Frameworks and languages The wizard supports the following frameworks and languages: - [![](https://res.cloudinary.com/dmukukwp6/image/upload/Android_robot_bec2fb7318.svg)Android (Kotlin)](https://posthog.com/docs/libraries/android.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/docs/integrate/frameworks/angular.svg)Angular](https://posthog.com/docs/libraries/angular.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/astro_icon_dark_23a13977ad.svg)Astro](https://posthog.com/docs/libraries/astro.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/docs/integrate/frameworks/django.svg)Django](https://posthog.com/docs/libraries/django.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/docs/integrate/python.svg)FastAPI](https://github.com/PostHog/wizard) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/docs/integrate/frameworks/flask.svg)Flask](https://posthog.com/docs/libraries/flask.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/docs/integrate/frameworks/laravel.svg)Laravel](https://posthog.com/docs/libraries/laravel.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/docs/integrate/frameworks/nextjs.svg)Next.js](https://posthog.com/docs/libraries/next-js.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/docs/integrate/frameworks/nuxt.svg)Nuxt](https://posthog.com/docs/libraries/nuxt-js.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/docs/integrate/python.svg)Python](https://posthog.com/docs/libraries/python.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/docs/integrate/react.svg)React Native](https://posthog.com/docs/libraries/react-native.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/docs/integrate/react.svg)React](https://posthog.com/docs/libraries/react.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/docs/integrate/ruby.svg)Ruby](https://posthog.com/docs/libraries/ruby.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/rails_581d31c82d.svg)Ruby on Rails](https://posthog.com/docs/libraries/ruby-on-rails.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/rr_logo_light_970950178e.svg)React Router](https://posthog.com/docs/libraries/react-router.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/docs/integrate/frameworks/svelte.svg)SvelteKit](https://posthog.com/docs/libraries/svelte.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/docs/integrate/ios.svg)Swift (iOS/macOS)](https://posthog.com/docs/libraries/ios.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/q_auto,f_auto/logo_color_600_391d28faae.png)TanStack Start](https://github.com/PostHog/wizard) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/docs/integrate/frameworks/vue.svg)Vue](https://posthog.com/docs/libraries/vue-js.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/docs/integrate/elixir.svg)Elixir](https://posthog.com/docs/libraries/elixir.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/docs/integrate/flutter.svg)Flutter](https://posthog.com/docs/libraries/flutter.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/docs/integrate/go.svg)Go](https://posthog.com/docs/libraries/go.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/docs/integrate/java.svg)Java](https://posthog.com/docs/libraries/java.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/docs/integrate/rust.svg)Rust](https://posthog.com/docs/libraries/rust.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/docs/integrate/kmp.svg)Kotlin Multiplatform](https://posthog.com/docs/libraries/kmp.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/docs/integrate/nodejs.svg)Node.js](https://posthog.com/docs/libraries/node.md) - [![](https://res.cloudinary.com/dmukukwp6/image/upload/q_auto,f_auto/logo_color_600_391d28faae.png)TanStack Router](https://github.com/PostHog/wizard) We've got more on the way. Check out the wizard's [GitHub repo](https://github.com/PostHog/wizard) for more details. **Set up a reverse proxy (recommended)** We recommend [setting up a reverse proxy](https://posthog.com/docs/advanced/proxy.md), so that events are less likely to be intercepted by tracking blockers. We have our [own managed reverse proxy service](https://posthog.com/docs/advanced/proxy/managed-reverse-proxy.md), which is free for all PostHog Cloud users, routes through our infrastructure, and makes setting up your proxy easy. If you don't want to use our managed service then there are several other options for creating a reverse proxy, including using [Cloudflare](https://posthog.com/docs/advanced/proxy/cloudflare.md), [AWS Cloudfront](https://posthog.com/docs/advanced/proxy/cloudfront.md), and [Vercel](https://posthog.com/docs/advanced/proxy/vercel.md). **Grouping products in one project (recommended)** If you have multiple customer-facing products (e.g. a marketing website + mobile app + web app), it's best to install PostHog on them all and [group them in one project](https://posthog.com/docs/settings/projects.md). This makes it possible to track users across their entire journey (e.g. from visiting your marketing website to signing up for your product), or how they use your product across multiple platforms. **Add IPs to Firewall/WAF allowlists (recommended)** For certain features like [heatmaps](https://posthog.com/docs/toolbar/heatmaps.md), your Web Application Firewall (WAF) may be blocking PostHog's requests to your site. Add these IP addresses to your WAF allowlist or rules to let PostHog access your site. **EU**: `3.75.65.221`, `18.197.246.42`, `3.120.223.253`, `3.40.9.80/28` **US**: `44.205.89.55`, `52.4.194.122`, `44.208.188.173`, `3.41.215.48/28` These are public, stable IPs used by PostHog services. PostHog captures heatmap screenshots using [Browserless](https://www.browserless.io), which has its own IP addresses. Browserless [publishes the current list here](https://docs.browserless.io/baas/troubleshooting/whitelisting-ips). An allowlist does not help when your app has a private address. For apps on an internal network, see [internal and intranet applications](https://posthog.com/docs/session-replay/troubleshooting.md#internal-and-intranet-applications). > **Using an AI assistant?** If your AI client is connected to the [PostHog MCP server](https://posthog.com/docs/model-context-protocol.md), you can ask it to install PostHog in your GitHub repository – no terminal required. The wizard runs in the cloud and opens a pull request for you to review. ## Self-driving The wizard is also how you turn on [self-driving](https://posthog.com/docs/self-driving.md). A self-driving product can prompt itself: PostHog turns your product data into signals, and agents act on those signals to ship improvements – all inside the guardrails you set. Once PostHog is installed and capturing events, run the self-driving setup. It enables your signal sources, sets up your scouts, and hands you a link to your inbox: `npx @posthog/wizard self-driving` From there, scouts run on a schedule and emit signals, related signals group into reports, and those reports land in your inbox ranked by priority – with a pull request ready to review whenever a report is actionable. For the full walkthrough, see the [self-driving setup guide](https://posthog.com/docs/self-driving/setup.md). ## Commands Running `npx @posthog/wizard` starts the default integration flow. The wizard also supports the following commands: | Command | What it does | | --- | --- | | `wizard` | Default flow – installs and instruments PostHog | | `wizard self-driving` | Turn on [self-driving](https://posthog.com/docs/self-driving.md) – enable signal sources, set up scouts, and get your inbox link | | `wizard audit ` | Audit an existing integration – see [Audit subcommands](#audit-subcommands) | | `wizard revenue-analytics` | Wire up Stripe + PostHog revenue analytics | | `wizard mcp-analytics` | Instrument your own MCP server with [MCP Analytics](https://posthog.com/docs/mcp-analytics.md) | | `wizard ai-observability` | Instrument your LLM calls with [AI Observability](https://posthog.com/docs/ai-observability.md) | | `wizard replay-vision` | Turn on Session Replay and create [Replay Vision](https://posthog.com/docs/replay-vision.md) scanners written for your product | | `wizard migrate` | Migrate from another analytics or feature-flag vendor | | `wizard upload-source-maps` | Upload source maps to PostHog Error Tracking | | `wizard error-tracking` | Set up [Error Tracking](https://posthog.com/docs/error-tracking.md), with source map upload and release linking | | `wizard warehouse` | Detect and connect [data warehouse sources](https://posthog.com/docs/data-warehouse/sources.md) | | `wizard feature-flags` | Set up example [feature flags](https://posthog.com/docs/feature-flags.md) | | `wizard metrics` | Add PostHog application metrics to your project | | `wizard mcp add` / `wizard mcp remove` / `wizard mcp tutorial` | Manage the PostHog MCP server for your AI agent, or explore the MCP tutorial | | `wizard slack add` | Connect PostHog to your Slack | | `wizard skill ` | Run a single skill by name – browse the available skills in the [context-mill releases](https://github.com/PostHog/context-mill/releases/latest) | ### Audit subcommands `@npx @posthog/wizard audit` on its own runs the `events` audit. Pass a subcommand to run a specific one. | Command | What it does | | --- | --- | | `wizard audit events` | Audit event capture quality and cost (default) | | `wizard audit all` | Comprehensive audit across every area | | `wizard audit autocapture` | Audit autocapture setup and cost | | `wizard audit feature-flags` | Audit feature flag usage and cost | | `wizard audit identify` | Audit your `$identify` implementation | | `wizard audit session-replay` | Audit session replay setup | | `wizard audit web-analytics` | Audit web analytics setup | ### Legacy commands The CLI was overhauled to consolidate commands into a smaller, more consistent surface. If you used an older command name, here's where it went: | Old command | New command | What changed | | --- | --- | --- | | `wizard integrate` | `wizard` | The default flow now runs the integration | | `wizard events-audit` | `wizard audit events` | Now an `audit` subcommand | | `wizard audit` | `wizard audit ` | Now takes a subcommand; `wizard audit all` runs a full audit | | `wizard revenue` | `wizard revenue-analytics` | Renamed – update any scripts using `revenue` | | `wizard upload-sourcemaps` | `wizard upload-source-maps` | Renamed (the old `upload-sourcemaps` still works) | ## Feedback We think flows like the AI wizard are pretty cool and the future of developer experience. The AI wizard is our recommended and default method for [installing PostHog](https://posthog.com/docs/getting-started/install?tab=wizard.md) and getting started. If you have any feedback or requests, we would love to hear from you. Feel free to comment on this page or open an issue on [GitHub](https://github.com/PostHog/wizard/issues).