integration-astro-ssr — скилл для Claude Code: настройка
Скилл integration-astro-ssr встраивает аналитику PostHog в SSR-проекты на Astro с API-роутами. Помогает связать клиентские и серверные события.
MIT 109 установок ★ 80 обновлён 2026-10-24
npx skills add PostHog/skills --skill integration-astro-ssr -a claude-codeЧто делает integration-astro-ssr
Скилл ведёт агента по четырём шагам настройки: начало интеграции, правка файлов, проверка и финализация. Внутри заложены правила под Astro: скрипты инициализации обязательно помечаются директивой is:inline, чтобы компилятор не ломал сборку ошибками типов, а клиентские переменные окружения именуются с префиксом PUBLIC_.
Клиентская часть оформляется через компонент src/components/posthog.astro внутри общего лейаута. Серверный трекинг в API-роутах работает через пакет posthog-node. Для него скилл предписывает настроить синглтон в src/lib/posthog-server.ts, чтобы не плодить лишние подключения к аналитике.
Клиентские и серверные события связываются через заголовки X-POSTHOG-DISTINCT-ID и X-POSTHOG-SESSION-ID. Скилл требует выносить все ключи доступа в переменные окружения, запрещая оставлять токены прямо в исходном коде.
Какие задачи решает
- настроить аналитику PostHog в Astro с серверным рендерингом
- сохранить сквозную сессию между браузером и API-роутами через заголовки
- организовать синглтон posthog-node в серверных роутах Astro
- прописать отслеживание ошибок на границах API
Примеры запросов агенту
- Интегрируй PostHog в наш проект на Astro SSR
- Настрой сквозной трекинг пользователей для API-роутов в Astro
- Создай компонент posthog.astro и серверный синглтон для аналитики
Как установить integration-astro-ssr
1Через Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-astro-ssr -a claude-code2Вручную: положить файлы
~/.claude/skills/integration-astro-ssr/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/integration-astro-ssr/
1Через Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-astro-ssr -a codex2Вручную: положить файлы
.agents/skills/integration-astro-ssr/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-astro-ssr -a cursor2Вручную: положить файлы
.cursor/skills/integration-astro-ssr/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install PostHog/skills skills/posthog/all/skills/integration-astro-ssr2Вручную: положить файлы
.github/skills/integration-astro-ssr/SKILL.md1Через Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-astro-ssr -a gemini-cli2Командой платформы
gemini skills install https://github.com/PostHog/skills --path skills/posthog/all/skills/integration-astro-ssrВручную: положить файлы
.devin/skills/integration-astro-ssr/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-astro-ssr -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы об integration-astro-ssr
Как установить integration-astro-ssr в Claude Code?
Выполните команду npx skills add PostHog/skills --skill integration-astro-ssr -a claude-code в терминале.
Что делает этот скилл?
Он предоставляет ИИ-агенту пошаговый процесс и правила внедрения PostHog в Astro SSR, включая синглтон для posthog-node и клиентский компонент.
Как связываются события на клиенте и сервере?
Скилл предписывает передавать идентификаторы сессии и пользователя в API через HTTP-заголовки X-POSTHOG-SESSION-ID и X-POSTHOG-DISTINCT-ID.
Исходный текст
SKILL.md · MIT
--- name: integration-astro-ssr description: PostHog integration for server-rendered Astro applications with API routes metadata: author: PostHog version: 1.9.4 --- # PostHog integration for Astro (SSR) This skill helps you add PostHog analytics to Astro (SSR) applications. ## Workflow Follow these steps in order to complete the integration: 1. `basic-integration-1.0-begin.md` - PostHog Setup - Begin ← **Start here** 2. `basic-integration-1.1-edit.md` - PostHog Setup - Edit 3. `basic-integration-1.2-revise.md` - PostHog Setup - Revise 4. `basic-integration-1.3-conclude.md` - PostHog Setup - Conclusion ## Reference files - `references/EXAMPLE.md` - Astro (SSR) example project code - `references/astro.md` - Astro - docs - `references/identify-users.md` - Identify users - docs - `references/basic-integration-1.0-begin.md` - PostHog setup - begin - `references/basic-integration-1.1-edit.md` - PostHog setup - edit - `references/basic-integration-1.2-revise.md` - PostHog setup - revise - `references/basic-integration-1.3-conclude.md` - PostHog setup - conclusion The example project shows the target implementation pattern. Consult the documentation for API details. ## Key principles - **Environment variables**: Always use environment variables for PostHog keys. Never hardcode them. - **Minimal changes**: Add PostHog code alongside existing integrations. Don't replace or restructure existing code. - **Match the example**: Your implementation should follow the example project's patterns as closely as possible. ## Framework guidelines - Always use the is:inline directive on PostHog script tags to prevent Astro from processing them and causing TypeScript errors - Use PUBLIC_ prefix for client-side environment variables in Astro (e.g., PUBLIC_POSTHOG_PROJECT_TOKEN) - Create a posthog.astro component in src/components/ for reusable initialization across pages - Import the PostHog component in a Layout and wrap all pages with that layout - Use posthog-node in API routes under src/pages/api/ for server-side event tracking - Store the posthog-node client instance in a singleton pattern (src/lib/posthog-server.ts) to avoid creating multiple clients - Pass the client session ID to server via X-PostHog-Session-Id header for unified session tracking ## Identifying users Identify users during login and signup events. Refer to the example code and documentation for the correct identify pattern for this framework. If both frontend and backend code exist, pass the client-side session and distinct ID using `X-POSTHOG-DISTINCT-ID` and `X-POSTHOG-SESSION-ID` headers to maintain correlation. ## Error tracking Add PostHog error tracking to relevant files, particularly around critical user flows and API boundaries.
© PostHog · MIT · PostHog/skills