mcpbeat

Posthog Instrumentation

posthog/posthog-instrumentation

Automatically add PostHog analytics instrumentation to code. Triggers when user asks to add tracking, instrument events, add analytics, or implement feature flags in their codebase.

420 tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
12
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/PostHog/posthog-for-claude --skill posthog-instrumentation

The instruction itself

8 sections, as written by the author

PostHog Instrumentation Skill

Help users add PostHog analytics, event tracking, and feature flags to their code.

When to Use

  • User asks to "add PostHog" or "add analytics"
  • User wants to track events or user actions
  • User needs to implement feature flags
  • User asks about instrumenting their code

Workflow

  • Identify the framework (React, Next.js, Python, Node.js, etc.)
  • Check for existing PostHog setup
  • Add appropriate instrumentation

Code Patterns

JavaScript/TypeScript

// Event tracking
posthog.capture('button_clicked', { button_name: 'signup' })

// Feature flags
if (posthog.isFeatureEnabled('new-feature')) {
  // Show new feature
}

// User identification
posthog.identify(userId, { email: user.email })

Python

from posthog import Posthog
posthog = Posthog(api_key='<ph_project_api_key>')

# Event tracking
posthog.capture(distinct_id='user_123', event='purchase_completed')

# Feature flags
if posthog.feature_enabled('new-feature', 'user_123'):
    # Show new feature

React

import { usePostHog } from 'posthog-js/react'

function MyComponent() {
  const posthog = usePostHog()

  const handleClick = () => {
    posthog.capture('button_clicked')
  }
}

Best Practices

  • Use consistent event naming (snake_case recommended)
  • Include relevant properties with events
  • Identify users early in their session
  • Use feature flags for gradual rollouts

How to use it

Copy the folder

Take posthog/posthog-instrumentation from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.