
Posthog Instrumentation
Wire PostHog event capture, identify calls, and feature flags into an existing app without guessing framework-specific patterns.
Overview
posthog-instrumentation is an agent skill most often used in Build (also Grow) that adds PostHog event tracking, user identify, and feature-flag checks to React, Next.js, Node, and Python codebases.
Install
npx skills add https://github.com/posthog/posthog-for-claude --skill posthog-instrumentationWhat is this skill?
- Framework-first workflow: detect React, Next.js, Python, Node.js, then extend or bootstrap setup
- JavaScript/TypeScript patterns for capture, isFeatureEnabled, and identify
- Python Posthog client patterns for capture and feature_enabled checks
- React usePostHog hook example for component-level event capture
- Best-practices guidance for consistent event naming and flag usage
- Documented patterns for JavaScript/TypeScript, Python, and React
- Three-step workflow: identify framework, check existing setup, add instrumentation
Adoption & trust: 1.1k installs on skills.sh; 12 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need trustworthy product analytics and feature flags in your app but do not want to hunt SDK examples for every framework or miss existing PostHog setup.
Who is it for?
Solo builders adding PostHog to an in-progress SaaS or web app when they ask the agent to instrument specific flows or flags.
Skip if: Teams that only need dashboard configuration, funnel design, or warehouse ETL with no application code changes.
When should I use this skill?
User asks to add PostHog, add analytics, track events, instrument code, or implement feature flags.
What do I get? / Deliverables
Your repo gains framework-appropriate PostHog capture, identify, and flag checks so events and experiments can run in the PostHog project you already use.
- PostHog capture, identify, and feature-flag snippets integrated into target modules
- Framework-aligned instrumentation consistent with existing project structure
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Instrumentation lands as code changes in the product, so the canonical shelf is Build even though the outcome serves measurement. PostHog is a third-party product SDK and API integration layered onto frontend, backend, or full-stack apps.
Where it fits
Add signup and checkout capture calls while wiring the billing integration.
Instrument activation and retention events before running lifecycle experiments.
Drop launch-day funnel events and flags so you can measure release impact immediately.
How it compares
Use this skill package for in-repo SDK wiring—not a PostHog MCP server or manual-only analytics consulting.
Common Questions / FAQ
Who is posthog-instrumentation for?
Solo and indie builders shipping web or API products who want their coding agent to add PostHog events, identity, and feature flags directly in source files.
When should I use posthog-instrumentation?
During Build when integrating analytics SDKs, after Ship when you discover missing telemetry, and in Grow when you need feature flags or lifecycle events instrumented before scaling traffic.
Is posthog-instrumentation safe to install?
Review the skill source and the Security Audits panel on this Prism page before granting network or secrets access, since instrumentation touches API keys and outbound analytics calls.
SKILL.md
READMESKILL.md - Posthog Instrumentation
# 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 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 ```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 ```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