instrument-metrics — Claude Code skill for PostHog metrics
The instrument-metrics Claude Code skill adds PostHog metric capture to a codebase. It runs after feature work or PR review, and when a request calls for counters or other metrics.
no license 154 installs ★ 101 updated 2026-10-24
npx skills add PostHog/ai-plugin --skill instrument-metrics -a claude-codeWhat instrument-metrics does
The skill checks the project language and its current metrics setup, then adds PostHog capture. It can instrument counters, gauges, and histograms while leaving existing metrics in place. For new measurements, it chooses a metric type and assigns units to histograms.
An installed PostHog SDK can provide the capture API; projects already exporting OpenTelemetry metrics can redirect that exporter to PostHog. The fallback uses OpenTelemetry. Setup requires a PostHog project token and host, sourced from project configuration or the PostHog MCP server's projects-get tool. The skill puts credentials in environment variables and describes how to check incoming metrics in PostHog.
What it helps with
- count successful and failed operations
- measure request and job durations
- send existing Prometheus or OpenTelemetry metrics to PostHog
- configure an OTLP metrics exporter
Example prompts for the agent
- Add PostHog metrics to the new API handlers.
- After reviewing this PR, track failures and request durations.
- Send the existing OpenTelemetry metrics to PostHog.
How to install instrument-metrics
1Skills CLI (Vercel)
npx skills add PostHog/ai-plugin --skill instrument-metrics -a claude-code2Manually: put the files in place
~/.claude/skills/instrument-metrics/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/instrument-metrics/
1Skills CLI (Vercel)
npx skills add PostHog/ai-plugin --skill instrument-metrics -a codex2Manually: put the files in place
.agents/skills/instrument-metrics/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add PostHog/ai-plugin --skill instrument-metrics -a cursor2Manually: put the files in place
.cursor/skills/instrument-metrics/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install PostHog/ai-plugin skills/instrument-metrics2Manually: put the files in place
.github/skills/instrument-metrics/SKILL.md1Skills CLI (Vercel)
npx skills add PostHog/ai-plugin --skill instrument-metrics -a gemini-cli2Platform CLI
gemini skills install https://github.com/PostHog/ai-plugin --path skills/instrument-metricsManually: put the files in place
.devin/skills/instrument-metrics/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add PostHog/ai-plugin --skill instrument-metrics -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about instrument-metrics
How do I install instrument-metrics in Claude Code?
Run npx skills add PostHog/ai-plugin --skill instrument-metrics -a claude-code. The skill file is placed at ~/.claude/skills/instrument-metrics/SKILL.md.
What does instrument-metrics do?
It adds PostHog metric capture to project code or routes existing OpenTelemetry metrics to PostHog. The skill uses counters, gauges, or histograms according to the measurement.
What does instrument-metrics need to work?
It needs a PostHog project token and host. If the token is not already configured, it can be retrieved through projects-get on a connected, authenticated PostHog MCP server; otherwise, the project token is needed.