Skip to content
Back to search

posthog

MarketplaceWorks with Claude CodeGitHub

Official PostHog plugin for AI clients. Access PostHog products directly from your AI coding tool.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/posthog--ai-plugin/badge.svg)](/listings/posthog--ai-plugin)

HTML

<a href="/listings/posthog--ai-plugin"><img src="/api/listings/posthog--ai-plugin/badge.svg" alt="findsafeskills safety rating" /></a>

Install

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Claude Code

1. Install the plugin: ```bash claude plugin install posthog ```

Or install from this repo as a marketplace: ```bash claude plugin marketplace add PostHog/ai-plugin claude plugin install posthog@posthog ```

2. Authenticate via OAuth: ```bash # Just enter Claude Code anywhere claude # Then, use the /mcp command within Claude, select plugin:posthog:posthog, and press Enter /mcp ``` Then follow the browser prompts to log into PostHog.

3. (Optional) Send Claude Code sessions to PostHog LLM Analytics.

Add to `~/.claude/settings.json` (global) or `.claude/settings.local.json` (per-project): ```json { "env": { "POSTHOG_LLMA_CC_ENABLED": "true", "POSTHOG_API_KEY": "phc_...", "POSTHOG_HOST": "https://eu.i.posthog.com" } } ```

Both `POSTHOG_LLMA_CC_ENABLED=true` and `POSTHOG_API_KEY` are required. Sessions are sent when Claude Code exits. Set `POSTHOG_LLMA_PRIVACY_MODE=true` to redact prompt/output content. Add custom properties to all events with `POSTHOG_LLMA_CUSTOM_PROPERTIES` (JSON string, e.g. `'{"ai_product": "my-app"}'`). Set `POSTHOG_AI_PURPOSE` to declare what the session is doing relative to the repo — documented values are `authoring` and `review`, 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 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](https://cursor.com/marketplace) or add manually in Cursor Settings > Plugins.

The plugin installs the PostHog MCP server. Claude Code's session capture and the write-command gate don't run in Cursor.

In Cursor IDE, the MCP connection runs through Cursor's hosted service, so Cursor holds your PostHog sign-in and you may need to sign in again after updating the plugin.

Grok Bot (desktop and mobile) lists the same plugin from the Cursor Marketplace. Open **Plugins**, search for **PostHog**, install it, and log into PostHog when prompted.

Codex

1. Add the marketplace: ```bash codex plugin marketplace add PostHog/ai-plugin ```

2. Install the plugin from inside Codex: ``` codex # Then run /plugins, select PostHog, and install /plugins ```

3. Trust the plugin's hook when Codex asks you to review it at startup, or later from `/hooks`. The hook approves known PostHog reads (`tools`, `search`, `info` and the other read-only `exec` commands, and calls to tools on `hooks/read-tools.txt`) so they run without a prompt. Every other call, including every write, gets Codex's own approval prompt. The `POSTHOG_MCP_EXEC_GATE_*` variables don't apply on Codex. Codex asks before every PostHog call until you trust the hook, and again after each plugin update until you re-trust it. The one exception is `render-ui`, which shows a PostHog chart or view in the conversation and never changes data, so it always runs without a prompt.

A few Codex settings change this:

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 57 lines
  1. {
  2. "name": "posthog",
  3. "owner": {
  4. "name": "PostHog",
  5. "email": "hey@posthog.com",
  6. "url": "https://posthog.com"
  7. },
  8. "description": "Official PostHog plugin for AI clients. Access PostHog products directly from your AI coding tool.",
  9. "plugins": [
  10. {
  11. "name": "posthog",
  12. "source": "./",
  13. "description": "Access PostHog analytics, feature flags, experiments, error tracking, and insights directly from your AI coding tool. Optionally capture Claude Code sessions to PostHog LLM Analytics.",
  14. "version": "1.2.1",
  15. "author": {
  16. "name": "PostHog",
  17. "email": "hey@posthog.com",
  18. "url": "https://posthog.com"
  19. },
  20. "homepage": "https://posthog.com/docs/model-context-protocol",
  21. "repository": "https://github.com/PostHog/ai-plugin",
  22. "license": "MIT",
  23. "category": "productivity",
  24. "keywords": [
  25. "analytics",
  26. "feature-flags",
  27. "experiments",
  28. "error-tracking",
  29. "a/b-testing",
  30. "surveys",
  31. "dashboards",
  32. "llm-analytics"
  33. ]
  34. },
  35. {
  36. "name": "posthog-telemetry",
  37. "source": "./telemetry",
  38. "description": "Send Claude Code sessions to PostHog LLM analytics. Hooks only: no skills, no commands, no MCP server. Install this instead of the PostHog plugin, not alongside it.",
  39. "version": "1.0.37",
  40. "author": {
  41. "name": "PostHog",
  42. "email": "hey@posthog.com",
  43. "url": "https://posthog.com"
  44. },
  45. "homepage": "https://posthog.com/docs/ai-observability/installation/claude-code",
  46. "repository": "https://github.com/PostHog/ai-plugin",
  47. "license": "MIT",
  48. "category": "productivity",
  49. "keywords": [
  50. "llm-analytics",
  51. "ai-observability",
  52. "claude-code",
  53. "telemetry"
  54. ]
  55. }
  56. ]
  57. }
README.md · README · 194 lines
  1. # PostHog AI plugin
  2. Official PostHog plugin for AI clients. Access PostHog products directly from your AI coding tool.
  3. ## Installation
  4. ### Claude Code
  5. 1. Install the plugin:
  6. ```bash
  7. claude plugin install posthog
  8. ```
  9. Or install from this repo as a marketplace:
  10. ```bash
  11. claude plugin marketplace add PostHog/ai-plugin
  12. claude plugin install posthog@posthog
  13. ```
  14. 2. Authenticate via OAuth:
  15. ```bash
  16. # Just enter Claude Code anywhere
  17. claude
  18. # Then, use the /mcp command within Claude, select plugin:posthog:posthog, and press Enter
  19. /mcp
  20. ```
  21. Then follow the browser prompts to log into PostHog.
  22. 3. (Optional) Send Claude Code sessions to PostHog LLM Analytics.
  23. Add to `~/.claude/settings.json` (global) or `.claude/settings.local.json` (per-project):
  24. ```json
  25. {
  26. "env": {
  27. "POSTHOG_LLMA_CC_ENABLED": "true",
  28. "POSTHOG_API_KEY": "phc_...",
  29. "POSTHOG_HOST": "https://eu.i.posthog.com"
  30. }
  31. }
  32. ```
  33. Both `POSTHOG_LLMA_CC_ENABLED=true` and `POSTHOG_API_KEY` are required. Sessions are sent when Claude Code exits. Set `POSTHOG_LLMA_PRIVACY_MODE=true` to redact prompt/output content. Add custom properties to all events with `POSTHOG_LLMA_CUSTOM_PROPERTIES` (JSON string, e.g. `'{"ai_product": "my-app"}'`). Set `POSTHOG_AI_PURPOSE` to declare what the session is doing relative to the repo — documented values are `authoring` and `review`, 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.
  34. #### Session capture without the rest of the plugin
  35. To send Claude Code sessions to PostHog LLM analytics without the slash commands or the MCP server, install the capture plugin on its own:
  36. ```bash
  37. claude plugin marketplace add PostHog/ai-plugin
  38. claude plugin install posthog-telemetry@posthog
  39. ```
  40. 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.
  41. 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.
  42. ### Cursor
  43. Install from the [Cursor Marketplace](https://cursor.com/marketplace) or add manually in Cursor Settings > Plugins.
  44. The plugin installs the PostHog MCP server. Claude Code's session capture and the write-command gate don't run in Cursor.
  45. In Cursor IDE, the MCP connection runs through Cursor's hosted service, so Cursor holds your PostHog sign-in and you may need to sign in again after updating the plugin.
  46. Grok Bot (desktop and mobile) lists the same plugin from the Cursor Marketplace. Open **Plugins**, search for **PostHog**, install it, and log into PostHog when prompted.
  47. ### Codex
  48. 1. Add the marketplace:
  49. ```bash
  50. codex plugin marketplace add PostHog/ai-plugin
  51. ```
  52. 2. Install the plugin from inside Codex:
  53. ```
  54. codex
  55. # Then run /plugins, select PostHog, and install
  56. /plugins
  57. ```
  58. 3. Trust the plugin's hook when Codex asks you to review it at startup, or later from `/hooks`. The hook approves known PostHog reads (`tools`, `search`, `info` and the other read-only `exec` commands, and calls to tools on `hooks/read-tools.txt`) so they run without a prompt. Every other call, including every write, gets Codex's own approval prompt. The `POSTHOG_MCP_EXEC_GATE_*` variables don't apply on Codex. Codex asks before every PostHog call until you trust the hook, and again after each plugin update until you re-trust it. The one exception is `render-ui`, which shows a PostHog chart or view in the conversation and never changes data, so it always runs without a prompt.
  59. A few Codex settings change this:
  60. - A `[mcp_servers.posthog]` entry in your own `~/.codex/config.toml` replaces the plugin's server config entirely, including the prompt mode the gate relies on. Remove it, or add `default_tools_approval_mode = "prompt"` and a `[mcp_servers.posthog.tools.render-ui]` table with `approval_mode = "approve"` to it.
  61. - With approval policy `never` and full access (`--dangerously-bypass-approvals-and-sandbox`), Codex approves MCP calls before the hook runs, so nothing is gated.
  62. - With approval policy `never` and a restricted sandbox, calls the hook doesn't approve are denied instead of prompted.
  63. ### Antigravity
  64. 1. Install the plugin:
  65. ```bash
  66. agy plugin install https://github.com/PostHog/ai-plugin
  67. ```
  68. 2. Authenticate via OAuth: run `/mcp`, select `posthog_posthog`, and choose **Authenticate**. Open the link it shows, log into PostHog, and paste the authorization code back into Antigravity.
  69. The plugin installs the PostHog MCP server. Claude Code's session capture and the write-command gate don't run in Antigravity.
  70. ### Gemini CLI
  71. ```bash
  72. gemini extensions install https://github.com/PostHog/ai-plugin
  73. ```
  74. ### Grok
  75. 1. Install the plugin:
  76. ```bash
  77. grok plugin install PostHog/ai-plugin --trust
  78. ```
  79. 2. Authenticate via OAuth:
  80. On first use of a PostHog tool, Grok prompts you to authorize in your browser. Log into PostHog to connect.
  81. ### Claude Cowork
  82. 1. Add the marketplace: open **Settings** > **Plugins**, click **Add** > **Add marketplace**, enter `PostHog/ai-plugin`, and click **Sync**.
  83. 2. Install the plugin: click **Browse**, select **PostHog**, and install. The plugin stays in sync with this repo automatically.
  84. 3. Authenticate via OAuth: on first use of a PostHog tool, follow the browser prompts to log into PostHog.
  85. ## How to develop
  86. 1. Clone and install the plugin:
  87. ```bash
  88. git clone https://github.com/PostHog/ai-plugin
  89. claude --plugin-dir ./ai-plugin
  90. ```
  91. 2. Authenticate via OAuth:
  92. ```
  93. /mcp
  94. ```
  95. Then follow the browser prompts to log into PostHog.
  96. ## Features
  97. This plugin connects your AI client to the PostHog MCP server, which covers:
  98. - **Feature flags** - Create, update, and manage feature flags
  99. - **Experiments** - Run and analyze A/B tests
  100. - **Insights** - Query analytics and create visualizations
  101. - **Dashboards** - Manage dashboards and add insights
  102. - **Error tracking** - View and debug errors
  103. - **LLM analytics** - Track AI/LLM costs and usage
  104. - **Documentation** - Search PostHog docs
  105. - And more
  106. The plugin bundles no skills. The PostHog MCP server provides them, and your agent loads one when it needs it through the server's `learn` command.
  107. ## Example usage
  108. ```
  109. > What feature flags do I have?
  110. > Create a feature flag called new-onboarding for 50% of users
  111. > Show me errors from the last 24 hours
  112. > Which errors are affecting the most users?
  113. > How many users signed up this week?
  114. > What's the conversion rate for the checkout funnel?
  115. > Show me all my experiments
  116. > What are the results of the checkout-flow experiment?
  117. > Create a new dashboard called Product Metrics
  118. > Add the signup funnel insight to the Growth dashboard
  119. > What are the responses to the NPS survey?
  120. > Create a feedback survey for the checkout page
  121. > What's my most triggered event?
  122. > Show me the top 10 pages by pageviews
  123. ```
  124. ## Self-hosted
  125. For self-hosted PostHog instances, set the `POSTHOG_MCP_URL` environment variable to point to your instance:
  126. ```bash
  127. export POSTHOG_MCP_URL="https://mcp.your-posthog-instance.com/mcp"
  128. ```
  129. ## Documentation
  130. - [PostHog MCP documentation](https://posthog.com/docs/model-context-protocol)
  131. - [PostHog API documentation](https://posthog.com/docs/api)
  132. ## License
  133. MIT

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.