installing-posthog-in-a-codebase
できること
このスキルは、エージェントが読み取りと編集を行えるコードベースに、PostHogの分析ライブラリを導入します。アプリにプロダクト分析やセッションリプレイを追加したい開発者向けです。
使う場面
- ✓アプリにPostHog、プロダクト分析、セッションリプレイを追加したいとき。
- ✓ReactやNext.jsなど、フレームワーク用のPostHogライブラリを導入したいとき。
- ✓エージェントに、プロジェクトトークンとホストの設定を正しい場所に置いてほしいとき。
スキルのリンク
https://github.com/PostHog/posthog/blob/master/products/wizard/skills/installing-posthog-in-a-codebase/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“Next.jsアプリにPostHog分析を追加してください。ドキュメントにある最新の設定方法を使ってください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、プロジェクトのファイルからフレームワークを検出し、それに対応するPostHogのドキュメントページを読みます。次に最新のパッケージをインストールし、プロジェクトトークンとホストの設定を追加して、セットアップのコードを書きます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Installing PostHog in a codebase
Use this skill when you can read and edit the user's code.
If you can't access their code, as is common in ChatGPT on the web or Claude on the web, use installing-posthog-from-chat.
PostHog's docs are the source of truth for each SDK's setup. Init options, file locations and recommended settings change between SDK releases, so read the docs page for the framework before you write code, and follow it rather than what you remember.
1. Find the framework and read its docs
Detect the framework from the manifest files (package.json, pyproject.toml, requirements.txt, Gemfile, composer.json, go.mod, and so on) and the app's entry points.
A web app with its own backend usually needs a client SDK and a server SDK, so read both pages.
For a framework that isn't listed, call docs-search with the framework name.
2. Install the latest SDK
Add each package with the project's own package manager and no version, for example npm install posthog-js, pnpm add posthog-node, uv add posthog or bundle add posthog-ruby.
That resolves the newest release.
Don't type a version into the manifest from memory, because that pins an old release.
In a monorepo, install into the package that runs the app, not the workspace root.
3. Get the token and host
Call project-get without an ID.
Use api_token as the project token and api_host as the SDK's host option.
- Read both from environment variables in code, using the names the docs page uses (for example
NEXT_PUBLIC_POSTHOG_PROJECT_TOKENandNEXT_PUBLIC_POSTHOG_HOST). - Write the real values to the env file the framework loads, such as
.env.localor.env. If the project has an example env file, add the variable names there with empty values. - Never hard-code the
よくある質問
PostHogのセットアップについて、エージェントは記憶に頼りますか?
いいえ。リリースごとに設定の詳細が変わるため、まず使っているフレームワークの最新のドキュメントを読みます。
コードへのアクセスを与えられない場合はどうなりますか?
その場合は別のスキルを使います。そのスキルは、チャットでセットアップを案内し、プルリクエストとして届けます。
どのフレームワークに対応していますか?
React、Next.js、VueやNuxtなどの一般的なWebフレームワークと、いくつかのサーバー側の言語に対応しており、それぞれに専用のドキュメントページがあります。
詳細
作者による元の説明
Install and configure a PostHog SDK in a repository you can read and edit, following PostHog's docs for the framework. Use when a user working in their codebase asks to add, install, or set up PostHog, product analytics, session replay, or a PostHog SDK. Covers finding the right docs page, installing the latest package, getting the project token and ingestion host from project-get, keeping them in the env file, server-side setup, identifying users, and verifying the change. If you can't access the user's code, as is common in ChatGPT on the web or Claude on the web, use installing-posthog-from
repo: PostHog/posthog
人気
- GitHubのスター
- 41k
- ランキング
- #6979
- ライセンス
- —
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
depot-ci
41kエージェントが、GitHub Actionsの代替であるDepot CIのワークフローを設定し実行できるよう支援します。既存のワークフローの移行や、実行ログの確認も含みます。
depot-container-builds
41kエージェントが、Depotのリモート・ビルダーでDockerイメージを作れるよう支援します。マルチプラットフォームのイメージ、レジストリへのプッシュ、ビルド失敗の修正を含みます。
depot-github-runners
41kエージェントが、GitHub Actionsのジョブを Depot が管理するランナーに移し、ランナーのサイズとラベルを選び、ランナー設定の問題を解決できるよう支援します。
editing-agents-md
41kエージェントが、AGENTS.mdとCLAUDE.mdのどちらにルールを書くべきかを判断し、ファイルを膨らませずに守られやすい形で書けるよう支援します。
似ているスキル
diffs
394k編集内容の実際の共有可能な差分を、手書きの要約ではなく、ビューアーのリンクや画像ファイルとして作成するようエージェントを支援します。
coding-agent
394kCodex、Claude Code、OpenCodeに大きめのコーディング作業をバックグラウンドのワーカーとして渡し、その進捗を確認するようエージェントを支援します。
gh-issues
394kGitHubのイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。