Agent skill · marketing growth · jeremylongshore

posthog-sdk-patterns

Implement typed, lifecycle-safe PostHog SDK adapters for browser, Node.js, React, Next.js, or Python. Use when application code needs a reusable analytics boundary. Trigger with "PostHog SDK pattern", "PostHog React", or "PostHog TypeScript".

Why this skill is useful

Provides specific integration patterns and type-safe event capture for PostHog that enhance the AI's ability to implement analytics in TypeScript and React applications.

What it needs

Requires posthog-js, posthog-node installed locally. Requires posthog account access. About 4k tokens when loaded. Last updated 2026-08-07. 2,604 stars on the source repository.

What this skill does

PostHog SDK Patterns Overview Production-ready patterns for PostHog integrations: singleton client, type-safe event capture, React hooks for feature flags, Next.js App Router provider, and Python integration patterns. Prerequisites posthog-js and/or posthog-node installed TypeScript project with strict mode React/Next.js (for frontend patterns) Instructions Tool discipline Use Read to inspect the relevant configuration and implementation before proposing changes. Use Write only for a new, explicitly requested artifact inside the target project. Use Edit for minimal changes to existing project files after the evidence pass. Step 1: Singleton Server Client Step 2: Type-Safe Event Capture Step 3: React Feature Flag Hook Step 4: Next.js App Router Provider Step 5: Reverse Proxy for Ad Blocker Bypass Step 6: Python Patterns Error Handling Pattern Use Case Benefit --------- ---------- --------- Singleton client All SDK usage Prevents multiple initializations Type-safe events Event capture Compile-time property validation Feature flag hooks React components Auto-updates on flag changes Reverse proxy Production Bypasses ad blockers Graceful shutdown Server processes No lost events on SIGTERM Output Singleton PostHog server client with shutdown hook Type-safe event capture with TypeScript generics React hooks for feature flags (boolean and multivariate) Next.js App Router provider with pageview tracking Reverse proxy configuration for ad blocker bypass Examples For a Next.js application, create separate client and server adapters, keep private credentials server-only, type business events, handle pageviews deliberately, and test capture plus flag fallbacks. Verify current framework guidance before copying any proxy or initialization pattern. Resources See official PostHog references for current authority and verification boundaries. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills jeremylongshore/posthog-sdk-patterns

View the source on GitHub

Browse the @skills marketplace