AI wizard
Contents
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.
When it's done, your project is onboarded with:
How it works
Running the wizard automatically:
- Authenticates your PostHog account
- Installs the relevant PostHog SDKs
- Scans your codebase and app architecture
- Creates custom events based on real product flows
- Configures
.envfile with your project credentials - Writes code and instruments the PostHog SDKs client-side and server-side
- Generates insights and dashboards in the PostHog app
- Optionally installs the PostHog MCP server for your AI agent
AI wizard installation
Install PostHog in minutes with our wizard by running this command in your project directory:
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:
We've got more on the way.
Check out the wizard's GitHub repo for more details.
We recommend setting up a reverse proxy, so that events are less likely to be intercepted by tracking blockers. We have our own managed reverse proxy service, 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, AWS Cloudfront, and Vercel.Set up a reverse proxy (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. 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.Grouping products in one project (recommended)
For certain features like heatmaps, 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: US: These are public, stable IPs used by PostHog services (e.g., Celery tasks for snapshots).Add IPs to Firewall/WAF allowlists (recommended)
3.75.65.221, 18.197.246.42, 3.120.223.25344.205.89.55, 52.4.194.122, 44.208.188.173
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 audit <subcommand> | Audit an existing integration – see Audit subcommands |
wizard revenue-analytics | Wire up Stripe + PostHog revenue analytics |
wizard migrate | Migrate from another analytics or feature-flag vendor |
wizard upload-source-maps | Upload source maps to PostHog Error Tracking |
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 <skill-name> | Run a single skill by name – browse the available skills in the context-mill releases |
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 <subcommand> | 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 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.
