Posthog Instrumentation

posthog/posthog-for-claude/skills/posthog-instrumentation

by posthog412211932258No license13 starsListed Oct 8, 2026Updated Oct 8, 2026Repository updated 7 months ago

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.

ArchivedInstructions onlySoftware Development
AI-generated overview

Adds PostHog analytics, event tracking, and feature flags to application code across frameworks.

What it does
Guides an agent through instrumenting a codebase with PostHog analytics. It identifies the framework, checks for existing PostHog setup, and adds event tracking, user identification, and feature flag code. It provides JavaScript/TypeScript, Python, and React code patterns plus naming and rollout best practices.
When to use it
Use when a user asks to add PostHog or analytics to their code, track events or user actions, or implement feature flags. It suits instrumentation work in an existing application codebase.
Requirements
No scripts are included; it is instructions only. Applying it requires access to the target codebase and a PostHog project API key for the instrumented application.

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

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

Code Patterns

JavaScript/TypeScript

javascript
// Event trackingposthog.capture('button_clicked', { button_name: 'signup' })
// Feature flagsif (posthog.isFeatureEnabled('new-feature')) {  // Show new feature}
// User identificationposthog.identify(userId, { email: user.email })

Python

python
from posthog import Posthogposthog = Posthog(api_key='<ph_project_api_key>')
# Event trackingposthog.capture(distinct_id='user_123', event='purchase_completed')
# Feature flagsif posthog.feature_enabled('new-feature', 'user_123'):    # Show new feature

React

jsx
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

Source and attribution

Source:posthog/posthog-for-claudeinskills/posthog-instrumentationat commit4122119

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal

Posthog Instrumentation · skills/posthog-instrumentation Agent Skill | SourceWeft