posthog-local-dev-loop
Configure PostHog local development with hot reload and testing. Use when setting up a development environment, configuring test workflows, or establishing a fast iteration cycle with PostHog. Trigger with phrases like "posthog dev setup", "posthog local development", "posthog dev environment", "develop with posthog".
- License 许可
- MIT
- 最近更新
- 2026-05-26
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- posthog-local-dev-loop
- author
- Jeremy Longshore <jeremy@intentsolutions.io>
- license
- MIT
- version
- 1.0.0
- description
- Configure PostHog local development with hot reload and testing. Use when setting up a development environment, configuring test workflows, or establishing a fast iteration cycle with PostHog. Trigger with phrases like "posthog dev setup", "posthog local development", "posthog dev environment", "develop with posthog".
- allowed-tools
- Read, Write, Edit, Bash(npm:*), Bash(pnpm:*), Grep
- compatible-with
- claude-code, codex, openclaw
03 SKILL.md 正文
PostHog Local Dev Loop
Overview
Set up a fast, reproducible local development workflow for PostHog.
Prerequisites
- Completed
posthog-install-authsetup - Node.js 18+ with npm/pnpm
- Code editor with TypeScript support
- Git for version control
Instructions
Step 1: Create Project Structure
my-posthog-project/
├── src/
│ ├── posthog/
│ │ ├── client.ts # PostHog client wrapper
│ │ ├── config.ts # Configuration management
│ │ └── utils.ts # Helper functions
│ └── index.ts
├── tests/
│ └── posthog.test.ts
├── .env.local # Local secrets (git-ignored)
├── .env.example # Template for team
└── package.json
Step 2: Configure Environment
set -euo pipefail
# Copy environment template
cp .env.example .env.local
# Install dependencies
npm install
# Start development server
npm run dev
Step 3: Setup Hot Reload
{
"scripts": {
"dev": "tsx watch src/index.ts",
"test": "vitest",
"test:watch": "vitest --watch"
}
}
Step 4: Configure Testing
import { describe, it, expect, vi } from 'vitest';
import { PostHogClient } from '../src/posthog/client';
describe('PostHog Client', () => {
it('should initialize with API key', () => {
const client = new PostHogClient({ apiKey: 'test-key' });
expect(client).toBeDefined();
});
});
Output
- Working development environment with hot reload
- Configured test suite with mocking
- Environment variable management
- Fast iteration cycle for PostHog development
Error Handling
| Error | Cause | Solution |
|---|---|---|
| Module not found | Missing dependency | Run npm install |
| Port in use | Another process | Kill process or change port |
| Env not loaded | Missing .env.local | Copy from .env.example |
| Test timeout | Slow network | Increase test timeout |
Examples
Mock PostHog Responses
vi.mock('@posthog/sdk', () => ({
PostHogClient: vi.fn().mockImplementation(() => ({
// Mock methods here
})),
}));
Debug Mode
set -euo pipefail
# Enable verbose logging
DEBUG=POSTHOG=* npm run dev
Resources
Next Steps
See posthog-sdk-patterns for production-ready code patterns.
04 同仓库更多 Skills
zustand-store-ts
Create Zustand stores with TypeScript, subscribeWithSelector middleware, and proper state/action separation. Use when building React state management, creating global stores, or implementing reactive state patterns with Zustand.
zustand-store-creator
Zustand Store Creator - Auto-activating skill for Frontend Development. Triggers on: zustand store creator, zustand store creator Part of the Frontend Development skill category.
zero-trust-config-helper
Zero Trust Config Helper - Auto-activating skill for Security Advanced. Triggers on: zero trust config helper, zero trust config helper Part of the Security Advanced skill category.
zapier-integration-helper
Zapier Integration Helper - Auto-activating skill for Business Automation. Triggers on: zapier integration helper, zapier integration helper Part of the Business Automation skill category.
zai-cli
Execute z.AI CLI providing vision, search, reader, and GitHub exploration via CLI and MCP. Use when user needs image/video analysis, OCR, UI-to-code conversion, error diagnosis, real-time web search, web page to markdown extraction, or GitHub code exploration. Trigger with phrases like "analyze this image", "search the web for", "read this page", "explore this repo", or "use zai". Requires Z_AI_API_KEY.
yt-research
Research competitor YouTube channels, niches, and trending topics for your content strategy. Use this skill whenever the user says "research channels", "analyze competitors", "find trending topics", "niche analysis", "competitive research", "what are other creators doing", "scrape YouTube channels", or wants to understand the competitive landscape for a specific tool or topic area. Use when working with yt research. Trigger with 'yt', 'research'.