{"name":"posthog-instrumentation","url":"https://skills.sh/posthog/posthog-for-claude/posthog-instrumentation","install":"npx skills add posthog/posthog-for-claude --skill posthog-instrumentation","sdk":"posthog","key":"posthog/posthog-instrumentation","description":"Automatically add PostHog analytics instrumentation to code. Triggers when user asks to add tracking, instrument events, add analytics, or implement feature flags in their codebase.","hasContent":true,"content":"---\nname: posthog-instrumentation\ndescription: Automatically add PostHog analytics instrumentation to code. Triggers when user asks to add tracking, instrument events, add analytics, or implement feature flags in their codebase.\n---\n\n# PostHog Instrumentation Skill\n\nHelp users add PostHog analytics, event tracking, and feature flags to their code.\n\n## When to Use\n\n- User asks to \"add PostHog\" or \"add analytics\"\n- User wants to track events or user actions\n- User needs to implement feature flags\n- User asks about instrumenting their code\n\n## Workflow\n\n1. Identify the framework (React, Next.js, Python, Node.js, etc.)\n2. Check for existing PostHog setup\n3. Add appropriate instrumentation\n\n## Code Patterns\n\n### JavaScript/TypeScript\n```javascript\n// Event tracking\nposthog.capture('button_clicked', { button_name: 'signup' })\n\n// Feature flags\nif (posthog.isFeatureEnabled('new-feature')) {\n  // Show new feature\n}\n\n// User identification\nposthog.identify(userId, { email: user.email })\n```\n\n### Python\n```python\nfrom posthog import Posthog\nposthog = Posthog(api_key='<ph_project_api_key>')\n\n# Event tracking\nposthog.capture(distinct_id='user_123', event='purchase_completed')\n\n# Feature flags\nif posthog.feature_enabled('new-feature', 'user_123'):\n    # Show new feature\n```\n\n### React\n```jsx\nimport { usePostHog } from 'posthog-js/react'\n\nfunction MyComponent() {\n  const posthog = usePostHog()\n\n  const handleClick = () => {\n    posthog.capture('button_clicked')\n  }\n}\n```\n\n## Best Practices\n\n- Use consistent event naming (snake_case recommended)\n- Include relevant properties with events\n- Identify users early in their session\n- Use feature flags for gradual rollouts\n","contentSource":"skills.sh/api/download/posthog/posthog-for-claude/posthog-instrumentation","contentFetchedAt":"2026-07-27T08:59:27.572Z"}