Agent skill

Posthog Local Dev Loop

by jeremylongshore in jeremylongshore/tons-of-skills-marketplace

Build a deterministic local PostHog development loop with dependency injection, mocks, test identities, and optional isolated-project verification.

MITAuto-check: notesTesting & QA

Install Posthog Local Dev Loop

skills CLI
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill posthog-local-dev-loop -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jeremylongshore/tons-of-skills-marketplace posthog-local-dev-loop --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.curated/posthog-local-dev-loop .claude/skills/posthog-local-dev-loop && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
posthog-local-dev-loop
GitHub stars
2.8k
Token cost
~1.8k tokens
SKILL.md length
284 words
Files
2 (incl. references)
Skills in repo
3,342
Repo updated
First seen
Licence
MIT

At a glance

Build a deterministic local PostHog development loop with dependency injection, mocks, test identities, and optional isolated-project verification.

  • Works in 6 steps: Project Structure → PostHog Client with Dev Mode → Browser Debug Mode → …
  • Developing analytics without polluting production data
  • SKILL.md covers Overview, Prerequisites, Instructions and Error Handling, plus 4 more sections
  • Reaches us.i.posthog.com; needs NEXT_PUBLIC_POSTHOG_KEY and POSTHOG_KEY

What it does

Posthog Local Dev Loop is an agent skill from jeremylongshore/tons-of-skills-marketplace. 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".

Its SKILL.md is about 1.8k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including reference files (for example `references/official-docs.md`). Compatibility notes: Designed for Claude Code

It sits in Testing & QA, covering Unit testing and Design patterns. It works with PostHog and Vitest. The repository describes itself as: Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com. The licence is MIT.

When your agent uses it

  • Developing analytics without polluting production data
  • With mock PostHog
  • PostHog local development

Example prompts

  • “mock PostHog”
  • “PostHog local development”
  • “test PostHog”
  • “/posthog-local-dev-loop”

Requirements

  • Node.js
  • A credential in NEXT_PUBLIC_POSTHOG_KEY
  • A credential in POSTHOG_KEY
  • Compatibility (from SKILL.md): Designed for Claude Code
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Bash(npm:*), Bash(pnpm:*), Grep

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. Project Structure
  2. PostHog Client with Dev Mode
  3. Browser Debug Mode
  4. Mock PostHog for Unit Tests
  5. Integration Test with Real Dev Project
  6. Package Scripts

What it can do on your machine

Read from SKILL.md and the folder at commit 23ea8d4. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Bash(npm:*)
    • Bash(pnpm:*)
    • Grep

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript and json).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • us.i.posthog.com

    Also links to:

    • posthog.com
    • vitest.dev

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • NEXT_PUBLIC_POSTHOG_KEY
    • POSTHOG_KEY
    • POSTHOG_TEST_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Designed for Claude Code

    From compatibility in the SKILL.md frontmatter.

Context cost

Posthog Local Dev Loop loads about 1.8k tokens when it runs, and up to ~2k if it reads all its reference files. Until then it costs about 78 tokens; SKILL.md has 284 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~78
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NoteMentions a .env fileSKILL.md:49
    ├── .env.local                 # Dev keys (git-ignored)
  • NoteMentions a .env fileSKILL.md:216
    dashboard | Wrong project key | Verify `.env.local` has dev project `phc_` key |

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from jeremylongshore/tons-of-skills-marketplace at commit 23ea8d4, republished under its MIT licence (© jeremylongshore). 284 words, ~1,821 tokens.

Download SKILL.mdSave it as .claude/skills/posthog-local-dev-loop/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
posthog-local-dev-loop
description
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".
allowed-tools
Read, Write, Edit, Bash(npm:*), Bash(pnpm:*), Grep
compatibility
Designed for Claude Code
argument-hint
[project-path] [test-command]
version
1.14.0
license
MIT
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
saas, posthog, testing, workflow

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
my-posthog-app/
├── src/
│   ├── analytics/
│   │   ├── posthog.ts         # Singleton client
│   │   ├── events.ts          # Event taxonomy (typed constants)
│   │   └── flags.ts           # Feature flag keys
│   └── index.ts
├── tests/
│   ├── analytics.test.ts      # Unit tests with mocked PostHog
│   └── integration.test.ts    # Integration tests (real PostHog dev project)
├── .env.local                 # Dev keys (git-ignored)
├── .env.example               # Template: NEXT_PUBLIC_POSTHOG_KEY=phc_...
└── package.json
Step 2: PostHog Client with Dev Mode
typescript
// src/analytics/posthog.ts
import { PostHog } from 'posthog-node';

let client: PostHog | null = null;

export function getPostHog(): PostHog {
  if (!client) {
    client = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
      host: process.env.POSTHOG_HOST || 'https://us.i.posthog.com',
      flushAt: process.env.NODE_ENV === 'development' ? 1 : 20,
      flushInterval: process.env.NODE_ENV === 'development' ? 0 : 10000,
      // In dev, flush immediately so events appear instantly in dashboard
    });
  }
  return client;
}

export async function shutdown() {
  if (client) {
    await client.shutdown();
    client = null;
  }
}
Step 3: Browser Debug Mode
typescript
// Enable PostHog debug mode in development
import posthog from 'posthog-js';

posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
  api_host: 'https://us.i.posthog.com',
  loaded: (ph) => {
    if (process.env.NODE_ENV === 'development') {
      ph.debug();
      // All events logged to browser console:
      // [PostHog.js] Sending event: {"event":"$pageview","properties":{...}}
    }
  },
});

// Disable capture entirely in test environments
if (process.env.NODE_ENV === 'test') {
  posthog.opt_out_capturing();
}
Step 4: Mock PostHog for Unit Tests
typescript
// tests/analytics.test.ts
import { describe, it, expect, vi, beforeEach } from 'vitest';

// Mock posthog-node
vi.mock('posthog-node', () => {
  const mockCapture = vi.fn();
  const mockIdentify = vi.fn();
  const mockGetFeatureFlag = vi.fn().mockResolvedValue(true);
  const mockShutdown = vi.fn().mockResolvedValue(undefined);
  const mockFlush = vi.fn().mockResolvedValue(undefined);

  return {
    PostHog: vi.fn().mockImplementation(() => ({
      capture: mockCapture,
      identify: mockIdentify,
      getFeatureFlag: mockGetFeatureFlag,
      getAllFlags: vi.fn().mockResolvedValue({ 'new-feature': true }),
      shutdown: mockShutdown,
      flush: mockFlush,
    })),
  };
});

import { PostHog } from 'posthog-node';

describe('Analytics', () => {
  let ph: InstanceType<typeof PostHog>;

  beforeEach(() => {
    vi.clearAllMocks();
    ph = new PostHog('phc_test_key');
  });

  it('captures events with correct properties', () => {
    ph.capture({
      distinctId: 'user-1',
      event: 'button_clicked',
      properties: { button: 'signup' },
    });

    expect(ph.capture).toHaveBeenCalledWith({
      distinctId: 'user-1',
      event: 'button_clicked',
      properties: { button: 'signup' },
    });
  });

  it('evaluates feature flags', async () => {
    const result = await ph.getFeatureFlag('new-feature', 'user-1');
    expect(result).toBe(true);
  });
});
Step 5: Integration Test with Real Dev Project
typescript
// tests/integration.test.ts
import { describe, it, expect, afterAll } from 'vitest';
import { PostHog } from 'posthog-node';

const POSTHOG_KEY = process.env.POSTHOG_TEST_KEY;

describe.skipIf(!POSTHOG_KEY)('PostHog Integration', () => {
  const ph = new PostHog(POSTHOG_KEY!, {
    host: 'https://us.i.posthog.com',
    flushAt: 1,
    flushInterval: 0,
  });

  afterAll(async () => {
    await ph.shutdown();
  });

  it('should capture and flush an event', async () => {
    ph.capture({
      distinctId: `test-${Date.now()}`,
      event: 'integration_test',
      properties: { test: true },
    });
    // Flush returns successfully if network is reachable
    await expect(ph.flush()).resolves.not.toThrow();
  });

  it('should evaluate feature flags', async () => {
    const flags = await ph.getAllFlags(`test-${Date.now()}`);
    expect(typeof flags).toBe('object');
  });
});
Step 6: Package Scripts
json
{
  "scripts": {
    "dev": "tsx watch src/index.ts",
    "test": "vitest run",
    "test:watch": "vitest --watch",
    "test:integration": "POSTHOG_TEST_KEY=$NEXT_PUBLIC_POSTHOG_KEY vitest run tests/integration"
  }
}

Error Handling

ErrorCauseSolution
Events not in dev dashboardWrong project keyVerify .env.local has dev project phc_ key
Mock not interceptingWrong import pathEnsure vi.mock path matches actual import
Integration test timeoutPostHog unreachableCheck network, increase vitest timeout
Debug mode too noisyph.debug() in prodGuard with NODE_ENV === '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.

Next Steps

See posthog-sdk-patterns for production-ready code patterns.

© jeremylongshore, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (references) in skills/.curated/posthog-local-dev-loop of jeremylongshore/tons-of-skills-marketplace.

  • SKILL.md
  • references/official-docs.md

Open the folder on GitHubat commit 23ea8d4

Compare with similar skills

Posthog Local Dev Loop next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Posthog Local Dev Loop compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Posthog Local Dev Loop this skilljeremylongshore/tons-of-skills-marketplace2.8k—~1.8kAutomated safety check: NotesMIT
Console Testingsynnaxlabs/synnax128—~5.4kAutomated safety check: PassCustom licence
Effect TSmattiacerutti/supernova187—~2.8kAutomated safety check: PassMIT
Angular Developerradix-ng/primitives274—~1.2kAutomated safety check: PassMIT
Test Writing WorkflowiOfficeAI/AionUi33k1 repos~1.2kAutomated safety check: PassApache-2.0
Vitestsupabase/supabase111k12 repos~1.1kAutomated safety check: PassApache-2.0

Similar skills

  • Console Testing

    synnaxlabs/synnax

    Rules for writing and editing unit tests in the Console (console/src//.spec.ts[x]).

    128 GitHub stars~5.4k tokensUpdated today
    Testing & QAAuto-check passed
  • Effect TS

    mattiacerutti/supernova

    Write idiomatic Effect v4 TypeScript following official best practices from effect-solutions and the Effect source.

    187 GitHub stars~2.8k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Angular Developer

    radix-ng/primitives

    Angular framework reference for building this signals-first, headless directive library.

    274 GitHub stars~1.2k tokensUpdated 10 days ago
    DevelopmentAuto-check passed
  • Test Writing Workflow

    iOfficeAI/AionUi

    Sets the test-writing workflow for the repository: risk-first scenario lists, behavior-focused Vitest tests, a full run before each commit and a coverage target.

    33k GitHub starsUsed in 1 repo~1.2k tokens
    Testing & QAAuto-check passed
  • Vitest

    supabase/supabase

    Official

    Vitest API and config reference (Jest-compatible) — mocking with vi., spies, fake timers, coverage configuration, fixtures, snapshots, and test filtering.

    111k GitHub starsUsed in 12 repos~1.1k tokens
    Testing & QAAuto-check passed
  • Test Guard

    amElnagdy/guard-skills

    Reviews newly written or edited tests against nine rules that cut test bloat, such as mock-heavy checks and near-duplicate cases, before they are committed.

    1.3k GitHub starsUsed in 2 repos~2.1k tokens
    Testing & QAAuto-check passed

More from jeremylongshore/tons-of-skills-marketplace

All 3,342 skills in this repo
  • Performing Security Code Review

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to conduct a security-focused code review using the security-agent plugin.

    2.8k GitHub starsUsed in 2 repos~1.3k tokens
    Auto-check: notes
  • Analyzing Text With NLP

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to perform natural language processing and text analysis using the nlp-text-analyzer plugin.

    2.8k GitHub starsUsed in 1 repo~819 tokens
    Auto-check passed
  • Building Neural Networks

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill allows AI assistant to construct and configure neural network architectures using the neural-network-builder plugin.

    2.8k GitHub starsUsed in 1 repo~1k tokens
    Auto-check passed
  • Detecting Data Anomalies

    jeremylongshore/tons-of-skills-marketplace

    Process identify anomalies and outliers in datasets using machine learning algorithms.

    2.8k GitHub starsUsed in 1 repo~1.4k tokens
    Auto-check passed
  • Explaining Machine Learning Models

    jeremylongshore/tons-of-skills-marketplace

    Build this skill enables AI assistant to provide interpretability and explainability for machine learning models.

    2.8k GitHub starsUsed in 1 repo~1k tokens
    Auto-check passed
  • Optimizing Prompts

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill optimizes prompts for large language models (llms) to reduce token usage, lower costs, and improve performance.

    2.8k GitHub starsUsed in 1 repo~1k tokens
    Auto-check passed

Works with

Categories

Questions about Posthog Local Dev Loop

What does Posthog Local Dev Loop do?

Build a deterministic local PostHog development loop with dependency injection, mocks, test identities, and optional isolated-project verification. Posthog Local Dev Loop is an agent skill from jeremylongshore/tons-of-skills-marketplace. Build a deterministic local PostHog development loop with dependency injection, mocks, test identities, and optional isolated-project verification.

When should I use Posthog Local Dev Loop?

Posthog Local Dev Loop fits situations like: developing analytics without polluting production data; with mock PostHog; postHog local development.

How do I install Posthog Local Dev Loop in Claude Code?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill posthog-local-dev-loop -a claude-code`. Or copy the skill folder (skills/.curated/posthog-local-dev-loop in jeremylongshore/tons-of-skills-marketplace) into .claude/skills/posthog-local-dev-loop in your project. Claude Code loads it when a task matches its description.

How do I install Posthog Local Dev Loop in Codex?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill posthog-local-dev-loop -a codex`. Or copy the skill folder (skills/.curated/posthog-local-dev-loop in jeremylongshore/tons-of-skills-marketplace) into .agents/skills/posthog-local-dev-loop in your project. Codex loads it when a task matches its description.

Can I use Posthog Local Dev Loop in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill posthog-local-dev-loop -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/posthog-local-dev-loop, .gemini/skills/posthog-local-dev-loop, .github/skills/posthog-local-dev-loop and .opencode/skills/posthog-local-dev-loop in your project.

What does Posthog Local Dev Loop need to run?

Going by SKILL.md and its folder, Posthog Local Dev Loop needs credentials named NEXT_PUBLIC_POSTHOG_KEY, POSTHOG_KEY and POSTHOG_TEST_KEY. Our summary lists: Node.js; A credential in NEXT_PUBLIC_POSTHOG_KEY; A credential in POSTHOG_KEY. Its frontmatter pre-approves these tools: Read, Write, Edit, Bash(npm:*), Bash(pnpm:*), Grep. Compatibility (from SKILL.md): Designed for Claude Code.

Does Posthog Local Dev Loop access the network?

SKILL.md names 3 domains. In commands or code: us.i.posthog.com; the agent is likely to contact it when it follows the instructions. As links in the text: posthog.com and vitest.dev. This is read from the text; nothing was executed.

Is Posthog Local Dev Loop safe to install?

Our automated static check of SKILL.md found notes only (mentions a .env file), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Posthog Local Dev Loop use?

Posthog Local Dev Loop is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Posthog Local Dev Loop use?

About 1.8k tokens (SKILL.md is roughly 7.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 201 tokens, read only when the agent opens those files.

What are the alternatives to Posthog Local Dev Loop?

Skills that share tags, products or a category with Posthog Local Dev Loop: Console Testing (synnaxlabs/synnax, 128 stars), Effect TS (mattiacerutti/supernova, 187 stars), Angular Developer (radix-ng/primitives, 274 stars) and Test Writing Workflow (iOfficeAI/AionUi, 33k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Posthog Local Dev Loop?

jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,821 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 8, 2026.

Source: jeremylongshore/tons-of-skills-marketplace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.