Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

instrument-integration

БесплатноБез исполняемых скриптовНе проверен

Add PostHog SDK integration to your application. Use when setting up PostHog for the first time or reviewing PRs that need PostHog initialization. Covers SDK…

PostHogот PostHog★ 81 звезда на GitHub

Об этом скилле

Add PostHog SDK integration

Use this skill to add the PostHog SDK to an application. Use it when setting up PostHog for the first time, or reviewing PRs that need PostHog initialization. Covers SDK installation, provider setup, and basic configuration. Supports any framework or language.

Supported frameworks and languages: Next.js, React, React Router, Remix, Vue, Nuxt, TanStack Start, SvelteKit, Astro, Angular, Gatsby, Docusaurus, Django, Flask, FastAPI, Laravel, PHP, WordPress, Ruby on Rails, Elixir (Phoenix), Go, Java (Spring Boot), Rust, .NET, Android, iOS, Swift, Flutter, Kotlin Multiplatform, React Native, Expo, Capacitor, Node.js, NestJS, Fastify, Hono, Cloudflare Workers, Convex, Unity, Godot, Roblox, and vanilla JavaScript.

Instructions

Before you edit anything, read references/COMMANDMENTS.md. It lists the rules every PostHog install follows: how to install the SDK, where to create the client, how to identify users, Content Security Policy and multi-platform apps, plus the rules for this framework.

Follow these steps IN ORDER:

STEP 1: Analyze the codebase and detect the platform.

Look for dependency files (package.json, pubspec.yaml, Podfile, Package.swift, requirements.txt, Gemfile, composer.json, go.mod, mix.exs, etc.) to determine the framework and language.

Look for lockfiles (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lockb, go.sum, pubspec.lock, Podfile.lock, Package.resolved, mix.lock) to determine the package manager.

  • Check for existing PostHog setup. If PostHog is already installed and initialized, do not modify its code. Inform the user and skip to verification.

STEP 2: Research integration. 2.1. Find the reference file below that matches the detected framework — it is the source of truth for SDK initialization, provider setup, and configuration patterns. Read it now. 2.2. If no reference matches, fall back to your general knowledge and web search. Use posthog.com/docs as the primary search source.

STEP 3: Install the PostHog SDK.

  • Add the PostHog SDK package for the detected platform. Do not manually edit package.json — use the package manager's install command.
  • If the project keeps more than one lockfile for the same manifest, such as a second Gemfile lock for another bundle, update each one.

STEP 4: Initialize PostHog.

  • Follow the framework reference for where and how to initialize. This varies significantly by framework (e.g., instrumentation-client.ts for Next.js 15.3+, AppConfig.ready() for Django, create_app() for Flask).
  • Set up the PostHog provider/wrapper component if the framework requires one.
  • For posthog-js, set defaults to the preset the framework docs reference shows. The example projects can show an older preset.
  • For posthog-js, if the framework reference documents a reverse proxy for this framework, set it up as part of this change. Otherwise, suggest one in your final message: a reverse proxy keeps ad blockers from dropping events, and the instrument-reverse-proxy skill sets one up (https://posthog.com/docs/advanced/proxy.md).

STEP 5: Identify users.

  • Add PostHog identify() calls on the client side during login and signup events.
  • If both frontend and backend exist, pass the client-side session and distinct ID using X-POSTHOG-DISTINCT-ID and X-POSTHOG-SESSION-ID headers to the server-side code.

STEP 6: Set up environment variables.

  • Check if the project already has PostHog environment variables configured (e.g. in .env, .env.local, or framework-specific env files). If valid values already exist, skip this step.
  • If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions).
  • If it gave you none, call the PostHog MCP server's projects-get tool to list the projects. If more than one comes back, ask the user which project to use. Then call project-get with that project's id and read its api_token. Before you write the token, tell the user the project's name and confirm it is the one this app should send to. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead.
  • For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the api_host field of the project-get response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud.
  • Write these values to the appropriate env file (e.g. .env.local for Next.js, .env for others) using the framework's naming convention.
  • Reference these environment variables in code instead of hardcoding them.
  • List the key names in .env.example, or the env template the project already uses, with placeholder values, so the next developer knows what to set. Create .env.example
Полный SKILL.md на GitHub

Установить instrument-integration в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/COMMANDMENTS.mdreferences/EXAMPLE-android.mdreferences/EXAMPLE-angular.mdreferences/EXAMPLE-astro-hybrid.mdreferences/EXAMPLE-astro-ssr.mdreferences/EXAMPLE-astro-static.mdreferences/EXAMPLE-astro-view-transitions.mdreferences/EXAMPLE-cloudflare-workers.mdreferences/EXAMPLE-convex.mdreferences/EXAMPLE-django.mdreferences/EXAMPLE-docusaurus.mdreferences/EXAMPLE-dotnet.mdreferences/EXAMPLE-elixir.mdreferences/EXAMPLE-expo.mdreferences/EXAMPLE-fastapi.mdreferences/EXAMPLE-fastify.mdreferences/EXAMPLE-flask.mdreferences/EXAMPLE-flutter.mdreferences/EXAMPLE-gatsby.mdreferences/EXAMPLE-go.mdreferences/EXAMPLE-hono.mdreferences/EXAMPLE-java-spring-boot.mdreferences/EXAMPLE-javascript-node.mdreferences/EXAMPLE-javascript-web.mdreferences/EXAMPLE-laravel.mdreferences/EXAMPLE-nestjs.mdreferences/EXAMPLE-next-app-router.mdreferences/EXAMPLE-next-pages-router.mdreferences/EXAMPLE-nuxt-3-6.mdreferences/EXAMPLE-nuxt-4.mdreferences/EXAMPLE-php.mdreferences/EXAMPLE-python.mdreferences/EXAMPLE-react-native.mdreferences/EXAMPLE-react-react-router-6.mdreferences/EXAMPLE-react-react-router-7-data.mdreferences/EXAMPLE-react-react-router-7-declarative.mdreferences/EXAMPLE-react-react-router-7-framework.mdreferences/EXAMPLE-react-tanstack-router-code-based.mdreferences/EXAMPLE-react-tanstack-router-file-based.mdreferences/EXAMPLE-react-vite.md

FAQ

Что делает скилл instrument-integration?

Add PostHog SDK integration to your application. Use when setting up PostHog for the first time or reviewing PRs that need PostHog initialization. Covers SDK installation, provider setup, and basic configuration for any framework.

Как установить скилл instrument-integration?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл instrument-integration запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить instrument-integration с