Agent skill

Posthog Multi Env Setup

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

Separate PostHog development, staging, and production data with explicit project tokens, regional hosts, secret scopes, and promotion checks.

MITAuto-check: notesDevOps & Cloud

Install Posthog Multi Env Setup

skills CLI
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill posthog-multi-env-setup -a claude-code

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

GitHub CLI
$ gh skill install jeremylongshore/tons-of-skills-marketplace posthog-multi-env-setup --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-multi-env-setup .claude/skills/posthog-multi-env-setup && 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-multi-env-setup
GitHub stars
2.8k
Token cost
~2.1k tokens
SKILL.md length
381 words
Files
2 (incl. references)
Skills in repo
3,342
Repo updated
First seen
Licence
MIT

At a glance

Separate PostHog development, staging, and production data with explicit project tokens, regional hosts, secret scopes, and promotion checks.

  • Works in 6 steps: Create Separate PostHog Projects → Environment Variables → Environment-Aware SDK Configuration → …
  • One codebase deploys to multiple environments
  • SKILL.md covers Overview, Prerequisites, Environment Strategy and Instructions, plus 5 more sections
  • Calls curl and jq; reaches us.i.posthog.com and us.posthog.com; needs NEXT_PUBLIC_POSTHOG_KEY and POSTHOG_PERSONAL_API_KEY

What it does

Posthog Multi Env Setup is an agent skill from jeremylongshore/tons-of-skills-marketplace. Separate PostHog development, staging, and production data with explicit project tokens, regional hosts, secret scopes, and promotion checks. Use when one codebase deploys to multiple environments. Trigger with "PostHog environments", "PostHog staging", or "PostHog dev prod".

Its SKILL.md is about 2.1k 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 DevOps & Cloud. It works with PostHog. 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

  • One codebase deploys to multiple environments
  • With PostHog environments
  • PostHog staging
  • PostHog dev prod

Example prompts

  • “PostHog environments”
  • “PostHog staging”
  • “PostHog dev prod”
  • “/posthog-multi-env-setup”

Requirements

  • Node.js
  • A credential in NEXT_PUBLIC_POSTHOG_KEY
  • A credential in POSTHOG_PERSONAL_API_KEY
  • Compatibility (from SKILL.md): Designed for Claude Code
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Bash(aws:*), Bash(gcloud:*), Bash(vault:*)

Workflow steps

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

  1. Create Separate PostHog Projects
  2. Environment Variables
  3. Environment-Aware SDK Configuration
  4. Browser SDK with Environment Config
  5. Server SDK with Environment Config
  6. Feature Flag Rollout Per Environment

What it can do on your machine

Read from SKILL.md and the folder at commit 80f86df. 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(aws:*)
    • Bash(gcloud:*)
    • Bash(vault:*)

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • curl
    • jq

    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
    • us.posthog.com

    Also links to:

    • posthog.com

    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_PERSONAL_API_KEY
    • POSTHOG_FEATURE_FLAGS_SECURE_API_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 Multi Env Setup loads about 2.1k tokens when it runs, and up to ~2.3k if it reads all its reference files. Until then it costs about 75 tokens; SKILL.md has 381 words of instructions outside code blocks.

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

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:53
    # .env.local (development — git-ignored)
  • NoteMentions a .env fileSKILL.md:59
    # .env.staging (CI/CD secrets or secret manager)

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 80f86df, republished under its MIT licence (© jeremylongshore). 381 words, ~2,099 tokens.

Download SKILL.mdSave it as .claude/skills/posthog-multi-env-setup/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
posthog-multi-env-setup
description
Separate PostHog development, staging, and production data with explicit project tokens, regional hosts, secret scopes, and promotion checks. Use when one codebase deploys to multiple environments. Trigger with "PostHog environments", "PostHog staging", or "PostHog dev prod".
allowed-tools
Read, Write, Edit, Bash(aws:*), Bash(gcloud:*), Bash(vault:*)
compatibility
Designed for Claude Code
argument-hint
[project-path] [environment-model]
version
1.14.0
license
MIT
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
saas, posthog, posthog-multi

PostHog Multi-Environment Setup

Overview

Use separate PostHog projects for each environment (dev, staging, production). This prevents dev/test events from polluting production analytics, allows different feature flag rollout percentages per environment, and lets you disable session recordings in non-production.

Prerequisites

  • PostHog Cloud organization that supports the required project and feature-flag environment model
  • Admin access to create multiple projects
  • Deployment platform with environment variable support

Environment Strategy

EnvironmentPostHog ProjectSession RecordingAutocaptureFeature Flags
Developmentmyapp-devDisabledEnabled100% rollout (test all)
Stagingmyapp-stagingDisabledEnabled100% rollout (QA all)
Productionmyapp-prod10% sampledTunedGradual rollout

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: Create Separate PostHog Projects

In PostHog Cloud (app.posthog.com), create three projects:

  1. myapp-development — copy the phc_... project API key
  2. myapp-staging — copy the phc_... project API key
  3. myapp-production — copy the phc_... project API key
Step 2: Environment Variables
bash
# .env.local (development — git-ignored)
NEXT_PUBLIC_POSTHOG_KEY=phc_dev_key_here
NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
POSTHOG_PERSONAL_API_KEY=phx_your_key
POSTHOG_PROJECT_ID=11111

# .env.staging (CI/CD secrets or secret manager)
NEXT_PUBLIC_POSTHOG_KEY=phc_staging_key_here
NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
POSTHOG_PERSONAL_API_KEY=phx_your_key
POSTHOG_PROJECT_ID=22222

# Production (secret manager — never in files)
# NEXT_PUBLIC_POSTHOG_KEY=phc_prod_key_here
# POSTHOG_PROJECT_ID=33333
Step 3: Environment-Aware SDK Configuration
typescript
// config/posthog.ts
type Env = 'development' | 'staging' | 'production';

interface PostHogEnvConfig {
  apiKey: string;
  host: string;
  sessionRecording: boolean;
  recordingSampleRate: number;
  autocapture: boolean | object;
  debug: boolean;
}

function getConfig(): PostHogEnvConfig {
  const env = (process.env.NODE_ENV || 'development') as Env;
  const key = process.env.NEXT_PUBLIC_POSTHOG_KEY;
  const host = process.env.NEXT_PUBLIC_POSTHOG_HOST || 'https://us.i.posthog.com';

  if (!key) {
    console.warn(`[PostHog] No API key for ${env} — analytics disabled`);
  }

  const configs: Record<Env, Omit<PostHogEnvConfig, 'apiKey' | 'host'>> = {
    development: {
      sessionRecording: false,
      recordingSampleRate: 0,
      autocapture: true,
      debug: true,
    },
    staging: {
      sessionRecording: false,
      recordingSampleRate: 0,
      autocapture: true,
      debug: false,
    },
    production: {
      sessionRecording: true,
      recordingSampleRate: 0.1,  // Record 10% of sessions
      autocapture: {
        dom_event_allowlist: ['click', 'submit'],
        element_allowlist: ['a', 'button', 'form'],
        css_selector_allowlist: ['.track-click'],
      },
      debug: false,
    },
  };

  return { apiKey: key || '', host, ...configs[env] };
}

export const posthogConfig = getConfig();
Step 4: Browser SDK with Environment Config
typescript
// app/providers.tsx
'use client';
import posthog from 'posthog-js';
import { PostHogProvider } from 'posthog-js/react';
import { useEffect } from 'react';
import { posthogConfig } from '../config/posthog';

export function PHProvider({ children }: { children: React.ReactNode }) {
  useEffect(() => {
    if (!posthogConfig.apiKey) return; // Skip if no key configured

    posthog.init(posthogConfig.apiKey, {
      api_host: posthogConfig.host,
      autocapture: posthogConfig.autocapture,
      capture_pageview: false,  // Manual in App Router
      capture_pageleave: true,
      disable_session_recording: !posthogConfig.sessionRecording,
      session_recording: posthogConfig.sessionRecording
        ? { sampleRate: posthogConfig.recordingSampleRate }
        : undefined,
      loaded: (ph) => {
        if (posthogConfig.debug) ph.debug();
      },
    });
  }, []);

  return <PostHogProvider client={posthog}>{children}</PostHogProvider>;
}
Step 5: Server SDK with Environment Config
typescript
// lib/posthog-server.ts
import { PostHog } from 'posthog-node';
import { posthogConfig } from '../config/posthog';

let client: PostHog | null = null;

export function getPostHogServer(): PostHog {
  if (client) return client;

  if (!posthogConfig.apiKey) {
    // Return no-op client when unconfigured
    return { capture: () => {}, identify: () => {}, shutdown: async () => {} } as any;
  }

  client = new PostHog(posthogConfig.apiKey, {
    host: posthogConfig.host,
    personalApiKey: process.env.POSTHOG_FEATURE_FLAGS_SECURE_API_KEY,
    flushAt: 20,
    flushInterval: 10000,
  });

  return client;
}
Step 6: Feature Flag Rollout Per Environment
typescript
// In your staging PostHog project: set all flags to 100% rollout for QA
// In your production PostHog project: gradual rollout (10% → 25% → 50% → 100%)

// Server-side flag check works the same regardless of environment
const ph = getPostHogServer();
const enabled = await ph.isFeatureEnabled('new-checkout', userId);
// Staging project: always true (100% rollout)
// Production project: depends on rollout percentage
bash
set -euo pipefail
# Set all flags to 100% in staging project (for QA)
curl "https://us.posthog.com/api/projects/$POSTHOG_STAGING_PROJECT_ID/feature_flags/" \
  -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" | \
  jq -r '.results[].id' | while read FLAG_ID; do
    curl -X PATCH "https://us.posthog.com/api/projects/$POSTHOG_STAGING_PROJECT_ID/feature_flags/$FLAG_ID/" \
      -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"filters": {"groups": [{"rollout_percentage": 100}]}}'
  done
Show full SKILL.md (177 more words)Show less

Error Handling

IssueCauseSolution
Dev events in prodSame API key across envsUse separate projects per env
No events in stagingapiKey not setCheck CI/CD secret is configured
Session recordings in devWrong configVerify sessionRecording: false in dev config
Flags different across envsSeparate projectsExpected behavior — set rollout per project
401 from server APIWrong personal keyPersonal key works across projects in same org

Output

  • Separate PostHog projects for dev, staging, production
  • Environment-aware SDK configuration
  • Session recording disabled in non-production
  • Feature flags at 100% in staging, gradual in production
  • Server SDK with no-op fallback when unconfigured

Examples

For dev, staging, and production, map each deployment to an explicit project token and host, keep server-only keys in the matching secret store, prefix synthetic identities, and test that no environment can write to another project. Promote flag definitions deliberately; do not assume projects synchronize automatically.

Resources

See official PostHog references for current authority and verification boundaries.

Next Steps

For webhook setup, see posthog-webhooks-events.

© 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-multi-env-setup of jeremylongshore/tons-of-skills-marketplace.

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

Open the folder on GitHubat commit 80f86df

Compare with similar skills

Posthog Multi Env Setup 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 Multi Env Setup compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Posthog Multi Env Setup this skilljeremylongshore/tons-of-skills-marketplace2.8k—~2.1kAutomated safety check: NotesMIT
Telemetry AnalyticsOpenHands/OpenHands90k—~305Automated safety check: PassMIT
Temps Best Practicesgotempsh/temps828—~2.9kAutomated safety check: PassApache-2.0
Exploring Apm TracesPostHog/posthog40k—~3.5kAutomated safety check: PassCustom licence
Exploring LLM TracesPostHog/posthog40k—~4.4kAutomated safety check: PassCustom licence
Configuring Experiment RolloutPostHog/posthog40k—~3.8kAutomated safety check: PassCustom licence

Similar skills

  • Telemetry Analytics

    OpenHands/OpenHands

    This skill should be used when the user asks to "add tracking", "add a PostHog event", "change telemetry consent", "instrument onboarding", "debug analytics", or changes telemetry.ts…

    90k GitHub stars~305 tokensUpdated today
    DevOps & CloudAuto-check passed
  • Temps Best Practices

    gotempsh/temps

    Best-practices reference for preparing and instrumenting applications on Temps.

    828 GitHub stars~2.9k tokensUpdated today
    DevOps & CloudAuto-check passed
  • Exploring Apm Traces

    PostHog/posthog

    Official

    Investigates distributed application performance using PostHog APM (OpenTelemetry span) data via MCP.

    40k GitHub stars~3.5k tokensUpdated today
    DevOps & CloudAuto-check passed
  • Exploring LLM Traces

    PostHog/posthog

    Official

    Debug and inspect LLM/AI agent traces using PostHog's MCP tools.

    40k GitHub stars~4.4k tokensUpdated today
    DevOps & CloudAuto-check passed
  • Official

    Configures the rollout shape of a PostHog experiment — the variant split (50/50, 80/20, A/B/C ratios), the overall rollout percentage that gates how many users enter the experiment, and the…

    40k GitHub stars~3.8k tokensUpdated today
    DevOps & CloudAuto-check passed
  • Working With Skills

    PostHog/posthog

    Official

    Best practices for agents managing PostHog skills via the MCP skill- tools — how to discover, read, create, update, and refactor skills efficiently, especially large skills with many bundled files.

    40k GitHub stars~4.4k tokensUpdated today
    DevOps & CloudAuto-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
  • Adapting Transfer Learning Models

    jeremylongshore/tons-of-skills-marketplace

    Build this skill automates the adaptation of pre-trained machine learning models using transfer learning techniques.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Agent Context Loader

    jeremylongshore/tons-of-skills-marketplace

    Execute proactive auto-loading: automatically detects and loads agents.md files.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Aggregating Performance Metrics

    jeremylongshore/tons-of-skills-marketplace

    Aggregate and centralize performance metrics from applications, systems, databases, caches, and services.

    2.8k GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Analyzing Capacity Planning

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to analyze capacity requirements and plan for future growth.

    2.8k GitHub stars~947 tokensUpdated today
    Auto-check passed
  • Analyzing Database Indexes

    jeremylongshore/tons-of-skills-marketplace

    Process use when you need to work with database indexing. An agent skill from jeremylongshore/tons-of-skills-marketplace.

    2.8k GitHub stars~2k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Posthog Multi Env Setup

What does Posthog Multi Env Setup do?

Separate PostHog development, staging, and production data with explicit project tokens, regional hosts, secret scopes, and promotion checks. Posthog Multi Env Setup is an agent skill from jeremylongshore/tons-of-skills-marketplace. Separate PostHog development, staging, and production data with explicit project tokens, regional hosts, secret scopes, and promotion checks.

When should I use Posthog Multi Env Setup?

Posthog Multi Env Setup fits situations like: one codebase deploys to multiple environments; with PostHog environments; postHog staging; postHog dev prod.

How do I install Posthog Multi Env Setup in Claude Code?

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

How do I install Posthog Multi Env Setup in Codex?

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

Can I use Posthog Multi Env Setup 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-multi-env-setup -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-multi-env-setup, .gemini/skills/posthog-multi-env-setup, .github/skills/posthog-multi-env-setup and .opencode/skills/posthog-multi-env-setup in your project.

What does Posthog Multi Env Setup need to run?

Going by SKILL.md and its folder, Posthog Multi Env Setup needs the command-line tools its instructions call (curl and jq) and credentials named NEXT_PUBLIC_POSTHOG_KEY, POSTHOG_PERSONAL_API_KEY and POSTHOG_FEATURE_FLAGS_SECURE_API_KEY. Our summary lists: Node.js; A credential in NEXT_PUBLIC_POSTHOG_KEY; A credential in POSTHOG_PERSONAL_API_KEY. Its frontmatter pre-approves these tools: Read, Write, Edit, Bash(aws:*), Bash(gcloud:*), Bash(vault:*). Compatibility (from SKILL.md): Designed for Claude Code.

Does Posthog Multi Env Setup access the network?

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

Is Posthog Multi Env Setup 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 Multi Env Setup use?

Posthog Multi Env Setup 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 Multi Env Setup use?

About 2.1k tokens (SKILL.md is roughly 8.4k 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 198 tokens, read only when the agent opens those files.

What are the alternatives to Posthog Multi Env Setup?

Skills that share tags, products or a category with Posthog Multi Env Setup: Telemetry Analytics (OpenHands/OpenHands, 90k stars), Temps Best Practices (gotempsh/temps, 828 stars), Exploring Apm Traces (PostHog/posthog, 40k stars) and Exploring LLM Traces (PostHog/posthog, 40k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Posthog Multi Env Setup?

jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,825 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 9, 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.