GitHub

title AI wizard

import WizardInstall from 'getting-started/_snippets/wizard.mdx'

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:

<ProductList className="grid gap-4 grid-cols-2 not-prose" urlPrefix="/docs/" sourceField="wizardSupport" sourceValues={[true, { value: "In development", color: "red" }, { value: "Coming soon", color: "yellow" }]} />

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 for your AI agent
The AI wizard integrating both the JS Web SDK and Node SDK into a Next.js application

AI wizard installation

Self-driving

Self-driving is currently in open beta.

The wizard is also how you turn on self-driving. 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:

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.

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 – enable signal sources, set up scouts, and get your inbox link
wizard audit <subcommand> Audit an existing integration – see Audit subcommands
wizard revenue-analytics Wire up Stripe + PostHog revenue analytics
wizard mcp-analytics Instrument your own MCP server with MCP Analytics
wizard ai-observability Instrument your LLM calls with AI Observability
wizard replay-vision Turn on Session Replay and create Replay Vision 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 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.

Read the original on github.com ↗