posthog-instrumentation
posthog/posthog-for-claude
Automatically add PostHog analytics, event tracking, and feature flags to your codebase.
What is posthog-instrumentation?
This skill helps you instrument your code with PostHog analytics. Use it when you need to add event tracking, implement feature flags, or set up user identification in JavaScript, TypeScript, Python, React, Next.js, or Node.js applications.
- Add event tracking to capture user actions and behaviors
- Implement feature flags for gradual feature rollouts
- Set up user identification to track individual users
- Detect existing PostHog setup and avoid duplication
- Provide framework-specific instrumentation patterns for React, Next.js, Python, and Node.js
How to install posthog-instrumentation
npx skills add https://github.com/posthog/posthog-for-claude --skill posthog-instrumentationHow to use posthog-instrumentation
- 1.Describe what analytics or feature flags you want to add to your code
- 2.Specify your framework (React, Next.js, Python, Node.js, etc.)
- 3.The skill will identify existing PostHog setup and suggest appropriate instrumentation
- 4.Review and apply the generated code patterns to your codebase
Use cases
- Adding analytics to a React component to track button clicks and user interactions
- Implementing feature flags in a Next.js app to gradually roll out new features
- Instrumenting a Python backend to capture purchase or signup events
- Setting up user identification to correlate events with specific users
- Adding PostHog to an existing codebase that currently has no analytics
- Full-stack developers building analytics into new or existing applications
- Product teams implementing feature flags for gradual rollouts
- Backend engineers instrumenting Python or Node.js services
- Frontend developers adding event tracking to React or Next.js applications
posthog-instrumentation FAQ
JavaScript/TypeScript, React, Next.js, Python, and Node.js. The skill detects your framework and provides appropriate code patterns.
No, the skill checks for existing PostHog configuration and avoids duplication.
Snake_case is recommended for consistent event naming across your analytics.
The skill provides patterns for checking feature flags using posthog.isFeatureEnabled() in JavaScript or posthog.feature_enabled() in Python.
Yes, you need a PostHog project and API key. The skill helps you instrument your code to use PostHog, but doesn't create the PostHog account or project.
Full instructions (SKILL.md)
Source of truth, from posthog/posthog-for-claude.
name: posthog-instrumentation description: 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.
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
Related skills
More from posthog/posthog-for-claude and the wider catalog.

implementing-agent-modes
Create and manage PostHog AI agent modes to control tools, prompts, and behavior for specific use cases.

instagram-account-research
Research Instagram accounts for creator discovery, competitor profiling, and account health snapshots using hosted profile and post collection.

adversarial-review
>-

powersync
Guided onboarding and best practices for building applications with PowerSync — Cloud and self-hosted setup, sync configuration, client SDK usage, backend integration (Supabase, custom Postgres, MongoDB, MySQL, MSSQL), and debugging. Use this skill whenever the user mentions PowerSync, offline-first sync, local-first architecture, sync rules, sync streams, uploadData, fetchCredentials, real-time data replication, or wants to add offline-capable sync to a mobile or web app — even if they don't explicitly name PowerSync.

chrome-extension
Chrome Extensions (Manifest V3) performance and code quality guidelines. Use when writing, reviewing, or refactoring Chrome extension code including service workers, content scripts, message passing, storage APIs, TypeScript patterns, and testing.

clean-architecture
Clean Architecture principles and best practices for designing maintainable, testable software systems.