llm-analytics-setup — скилл для Claude Code: LLM-аналитика PostHog
Скилл llm-analytics-setup подключает LLM-аналитику PostHog к приложению на одном из поддерживаемых провайдеров: токены, задержка и стоимость каждого вызова.
MIT 120 установок ★ 80 обновлён 2026-10-24
npx skills add PostHog/skills --skill llm-analytics-setup -a claude-codeЧто делает llm-analytics-setup
Скилл добавляет в приложение учёт LLM-вызовов через PostHog: сколько токенов ушло на вход и выход, какая модель отвечала, сколько это заняло времени и во сколько обошлось. Существующие вызовы провайдера остаются на месте, аналитика встаёт рядом.
Внутри папка references с отдельным файлом под каждый стек: OpenAI, Azure OpenAI, Anthropic, Google, Mistral, Groq, Ollama, OpenRouter, LangChain, LlamaIndex, DSPy, LiteLLM, Vercel AI SDK, Portkey, Helicone и другие. Агент открывает тот, что совпадает с вашим кодом, и идёт по шагам: установка SDK, настройка, примеры. Для провайдера вне списка есть manual-capture.md с общим способом отправки событий.
Нужен Python-пакет posthog (pip install posthog), ключи держите в переменных окружения: хардкод скилл запрещает. В CLI и скриптах без вызова posthog.shutdown() перед выходом события не дойдут. Письма, имена и телефоны в свойства capture() не кладут. Для них есть set(distinct_id=...), потому что в Python SDK нет identify().
Какие задачи решает
- подключить PostHog к приложению на OpenAI или Anthropic без переписывания вызовов
- посчитать стоимость каждого LLM-вызова по токенам
- привязать генерации к пользователям через distinct ID
- найти инструкцию под свой фреймворк среди LangChain, DSPy и LiteLLM
- убрать персональные данные из событий
capture()
Примеры запросов агенту
- Добавь PostHog LLM-аналитику в наш сервис на Anthropic SDK, ключи возьми из переменных окружения.
- У нас агент на LangGraph: подключи трейсинг генераций и расчёт стоимости по токенам.
- Проверь, что в
capture()не уходят email и имена пользователей.
Как установить llm-analytics-setup
1Через Skills CLI (Vercel)
npx skills add PostHog/skills --skill llm-analytics-setup -a claude-code2Вручную: положить файлы
~/.claude/skills/llm-analytics-setup/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/llm-analytics-setup/
1Через Skills CLI (Vercel)
npx skills add PostHog/skills --skill llm-analytics-setup -a codex2Вручную: положить файлы
.agents/skills/llm-analytics-setup/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add PostHog/skills --skill llm-analytics-setup -a cursor2Вручную: положить файлы
.cursor/skills/llm-analytics-setup/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install PostHog/skills skills/posthog/all/skills/llm-analytics-setup2Вручную: положить файлы
.github/skills/llm-analytics-setup/SKILL.md1Через Skills CLI (Vercel)
npx skills add PostHog/skills --skill llm-analytics-setup -a gemini-cli2Командой платформы
gemini skills install https://github.com/PostHog/skills --path skills/posthog/all/skills/llm-analytics-setupВручную: положить файлы
.devin/skills/llm-analytics-setup/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add PostHog/skills --skill llm-analytics-setup -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о llm-analytics-setup
Как установить llm-analytics-setup в Claude Code?
Выполните npx skills add PostHog/skills --skill llm-analytics-setup -a claude-code. Скилл окажется в ~/.claude/skills/llm-analytics-setup/SKILL.md.
Что делает llm-analytics-setup?
Добавляет в код учёт LLM-вызовов в PostHog: входные и выходные токены, имя модели, задержку и стоимость, с привязкой к пользователю.
Что если моего провайдера нет в списке?
Скилл переключается на references/manual-capture.md. Там общий способ отправки событий, который работает с любым провайдером.
Исходный текст
SKILL.md · MIT
---
name: llm-analytics-setup
description: PostHog LLM analytics for all supported providers
metadata:
author: PostHog
version: 1.9.4
---
# PostHog LLM analytics
This skill helps you add PostHog LLM analytics to any application using AI/LLM providers.
## Reference files
- `references/openai.md` - Openai llm analytics installation - docs
- `references/azure-openai.md` - Azure openai llm analytics installation - docs
- `references/anthropic.md` - Anthropic llm analytics installation - docs
- `references/google.md` - Google llm analytics installation - docs
- `references/cohere.md` - Cohere llm analytics installation - docs
- `references/mistral.md` - Mistral llm analytics installation - docs
- `references/perplexity.md` - Perplexity llm analytics installation - docs
- `references/deepseek.md` - Deepseek llm analytics installation - docs
- `references/groq.md` - Groq llm analytics installation - docs
- `references/together-ai.md` - Together ai llm analytics installation - docs
- `references/fireworks-ai.md` - Fireworks ai llm analytics installation - docs
- `references/xai.md` - Xai llm analytics installation - docs
- `references/cerebras.md` - Cerebras llm analytics installation - docs
- `references/hugging-face.md` - Hugging face llm analytics installation - docs
- `references/ollama.md` - Ollama llm analytics installation - docs
- `references/openrouter.md` - Openrouter llm analytics installation - docs
- `references/langchain.md` - Langchain llm analytics installation - docs
- `references/llamaindex.md` - Llamaindex llm analytics installation - docs
- `references/crewai.md` - Crewai llm analytics installation - docs
- `references/autogen.md` - Autogen llm analytics installation - docs
- `references/dspy.md` - Dspy llm analytics installation - docs
- `references/langgraph.md` - Langgraph llm analytics installation - docs
- `references/pydantic-ai.md` - Pydantic ai llm analytics installation - docs
- `references/vercel-ai.md` - Vercel ai SDK llm analytics installation - docs
- `references/litellm.md` - Litellm llm analytics installation - docs
- `references/instructor.md` - Instructor llm analytics installation - docs
- `references/semantic-kernel.md` - Semantic kernel llm analytics installation - docs
- `references/mirascope.md` - Mirascope llm analytics installation - docs
- `references/mastra.md` - Mastra llm analytics installation - docs
- `references/smolagents.md` - Smolagents llm analytics installation - docs
- `references/openai-agents.md` - Openai agents SDK llm analytics installation - docs
- `references/portkey.md` - Portkey llm analytics installation - docs
- `references/helicone.md` - Helicone llm analytics installation - docs
- `references/manual-capture.md` - Manual capture llm analytics installation - docs
- `references/basics.md` - Llm analytics basics - docs
- `references/traces.md` - Traces - docs
- `references/calculating-costs.md` - Calculating llm costs - docs
Each provider reference contains installation instructions, SDK setup, and code examples specific to that provider or framework. Find the reference that matches the user's stack and follow its instructions.
If the user's provider isn't listed, use `manual-capture.md` as a fallback — it covers the generic event capture approach that works with any provider.
## Key principles
- **Environment variables**: Always use environment variables for PostHog and LLM provider keys. Never hardcode them.
- **Minimal changes**: Add LLM analytics alongside existing LLM calls. Don't replace or restructure existing code.
- **Trace all generations**: Capture input tokens, output tokens, model name, latency, and costs for every LLM call.
- **Link to users**: Associate LLM generations with identified users via distinct IDs when possible.
- **One provider at a time**: Only instrument the provider(s) the user is actually using. Don't add instrumentation for providers not present in the codebase.
## Framework guidelines
- Remember that source code is available in the venv/site-packages directory
- posthog is the Python SDK package name
- Install dependencies with `pip install posthog` or `pip install -r requirements.txt` and do NOT use unquoted version specifiers like `>=` directly in shell commands
- In CLIs and scripts: MUST call posthog.shutdown() before exit or all events are lost
- Always use the Posthog() class constructor (instance-based API) instead of module-level posthog.api_key config
- Always include enable_exception_autocapture=True in the Posthog() constructor to automatically track exceptions
- NEVER send PII in capture() event properties — no emails, full names, phone numbers, physical addresses, IP addresses, or user-generated content
- PII belongs in identify() person properties, NOT in capture() event properties. Safe event properties are metadata like message_length, form_type, boolean flags.
- Register posthog_client.shutdown with atexit.register() to ensure all events are flushed on exit
- The Python SDK has NO identify() method — use posthog_client.set(distinct_id=user_id, properties={...}) to set person properties, or use identify_context(user_id) within a context
© PostHog · MIT · PostHog/skills