AI Plugin
Official PostHog plugin for Claude Code, Cursor, Gemini, Codex and other AI coding tools
Install
claude plugin install posthogInstall command taken from the project's README or registry entry. Always review code before running it.
README excerpt
Read full README on GitHub →PostHog AI plugin
Official PostHog plugin for AI clients. Access PostHog products directly from your AI coding tool.
Installation
Claude Code
Install the plugin:
claude plugin install posthogOr install from this repo as a marketplace:
claude plugin marketplace add PostHog/ai-plugin claude plugin install posthog@posthogAuthenticate via OAuth:
# Just enter Claude Code anywhere claude # Then, use the /mcp command within Claude, select plugin:posthog:posthog, and press Enter /mcpThen follow the browser prompts to log into PostHog.
(Optional) Send Claude Code sessions to PostHog LLM Analytics.
Add to
~/.claude/settings.json(global) or.claude/settings.local.json(per-project):{ "env": { "POSTHOG_LLMA_CC_ENABLED": "true", "POSTHOG_API_KEY": "phc_...", "POSTHOG_HOST": "https://eu.i.posthog.com" } }Both
POSTHOG_LLMA_CC_ENABLED=trueandPOSTHOG_API_KEYare required. Sessions are sent when Claude Code exits. SetPOSTHOG_LLMA_PRIVACY_MODE=trueto redact prompt/output content. Add custom properties to all events withPOSTHOG_LLMA_CUSTOM_PROPERTIES(JSON string, e.g.'{"ai_product": "my-app"}'). SetPOSTHOG_AI_PURPOSEto declare what the session is doing relative to the repo — documented values areauthoringandreview, emitted as$ai_purpose. Useful when a harness wraps an agent it can't modify (e.g. a CI job running Claude Code as a reviewer); left unset the property is omitted.
Session capture without the rest of the plugin
To send Claude Code sessions to PostHog LLM analytics without the skills, the slash commands, or the MCP server, install the capture plugin on its own:
claude plugin marketplace add PostHog/ai-plugin
claude plugin install posthog-telemetry@posthog
It registers one SessionEnd hook and nothing else, so it adds nothing to the context of a session. It needs only the Python standard library, and it reads the same environment variables as step 3 above.
Install it instead of the posthog plugin, not alongside it. Both register the same hook, so running both parses and uploads every session twice. PostHog dedupes the events themselves, because their UUIDs are derived from the session, but the two hooks race on the status file.
Cursor
Install from the Cursor Marketplace or add manually in Cursor Settings > Plugins.
Codex
Add the marketplace:
codex plugin marketplace add PostHog/ai-pluginInstall the plugin from inside Codex:
codex # Then run /plugins, select PostHog, and install /plugins
Gemini CLI
gemini extensions install https://github.com/PostHog/ai-plugin
Grok
Install the plugin:
grok plugin install PostHog/ai-plugin --trustAuthenticate via OAuth:
On first use of a PostHog tool, Grok prompts you to authorize in your browser. Log into PostHog to connect.
Claude Cowork
Add the marketplace: open Settings > Plugins, click Add > Add marketplace, enter
PostHog/ai-plugin, and click Sync.Install the plugin: click Browse, select PostHog, and install. The plugin stays in sync with this repo automatically.
Similar plugs
CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies
Bash is all you need - A nano claude code–like 「agent harness」, built from 0 to 1
Documented system prompts from Anthropic - Claude Fable 5.1, Opus 5.5, Claude Design, Claude Code. OpenAI - ChatGPT GPT-6-Astra, Codex. Google - Gemini 3.8 Flash, 3.1 Pro,…
Wrap Antigravity, ChatGPT Codex, Claude Code, Grok Build, Muse Code, Devin as an OpenAI/Gemini/Claude/Codex compatible API service, allowing you to enjoy the free Gemini…