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 helps developers add PostHog analytics, event tracking, and feature flags to an existing codebase. It triggers when a user asks to add tracking, instrument events, add analytics, or implement feature flags, and it aims to place the right instrumentation for the framework in use rather than generic boilerplate.
Its workflow is short and practical: identify the framework (React, Next.js, Python, Node.js, and similar), check whether PostHog is already set up, and then add appropriate instrumentation. The skill supplies concrete code patterns for JavaScript/TypeScript (posthog.capture for events, posthog.isFeatureEnabled for flags, posthog.identify for user identification), Python (the Posthog client with capture and feature_enabled), and React (the usePostHog hook). It also encodes best practices such as consistent snake_case event naming, including relevant properties on events, identifying users early in the session, and using feature flags for gradual rollouts.
The target users are application developers instrumenting their products for product analytics and experimentation. This is a thin, self-contained code-pattern reference — the entire skill is a single SKILL.md with example snippets and guidance — so it is best seen as a quick, opinionated cheat sheet for wiring in PostHog rather than a deep integration tool. It references the project API key only as a placeholder in standard client setup, with no credential handling or external calls of its own, making it a benign development aid.
It guides adding PostHog event tracking, user identification, and feature flags to your code, using framework-appropriate patterns for JavaScript/TypeScript, Python, Node.js, and React.
It explicitly shows patterns for JavaScript/TypeScript, React (via the usePostHog hook), and Python, and its workflow accounts for React, Next.js, Python, and Node.js projects.
Consistent snake_case event names, attaching relevant properties to events, identifying users early in their session, and using feature flags for gradual rollouts.
The project API key appears only as a placeholder in standard client initialization; the skill does not collect, transmit, or store credentials.
It is a concise single-file cheat sheet of code patterns and best practices, not a full automated integration, so you still write and adapt the snippets into your codebase.
Quick Setup:
.claude/skills/Repository
posthog/posthog-for-claude