Agent skill · software engineering · jeremylongshore

posthog-local-dev-loop

Build a deterministic local PostHog development loop with dependency injection, mocks, test identities, and optional isolated-project verification. Use when developing analytics without polluting production data. Trigger with "mock PostHog", "PostHog local development", or "test PostHog".

Why this skill is useful

Provides specific mocking patterns and configuration for PostHog that enhance testing workflows not commonly found in public documentation.

What it needs

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

What this skill does

PostHog Local Dev Loop Overview Set up a fast local development workflow for PostHog integrations. Covers debug mode for event inspection, mocking posthog-node for unit tests, and a dev/test PostHog project to avoid polluting production data. Prerequisites Completed posthog-install-auth setup Node.js 20+ with npm/pnpm Vitest or Jest for testing Separate PostHog project for development (recommended) Instructions Tool discipline Use Read to inspect the relevant configuration and implementation before proposing changes. Use Grep to locate initialization, capture, flag, and credential boundaries. 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: Project Structure Step 2: PostHog Client with Dev Mode Step 3: Browser Debug Mode Step 4: Mock PostHog for Unit Tests Step 5: Integration Test with Real Dev Project Step 6: Package Scripts Error Handling Error Cause Solution ------- ------- ---------- Events not in dev dashboard Wrong project key Verify .env.local has dev project phc key Mock not intercepting Wrong import path Ensure vi.mock path matches actual import Integration test timeout PostHog unreachable Check network, increase vitest timeout Debug mode too noisy ph.debug() in prod Guard with NODEENV === 'development' Output Development PostHog client with instant flush Browser debug mode for event inspection Mocked posthog-node for unit tests Integration test suite for real PostHog connectivity Examples For a feature-flagged component, inject a small analytics interface, use an in-memory fake for unit tests, and reserve network verification for an isolated PostHog project. Test enabled, disabled, undefined, and capture-failure paths without putting real keys in fixtures. 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-local-dev-loop

View the source on GitHub

Browse the @skills marketplace