# instrument-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.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 154 installs · ★ 101 repo stars
- Author: PostHog
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/PostHog/ai-plugin/tree/HEAD/skills/instrument-metrics/SKILL.md
- Updated: 2026-10-24
- Security check: automated, 2026-11-17 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/instrument-metrics

## What it 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.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add PostHog/ai-plugin --skill instrument-metrics -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/instrument-metrics/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/instrument-metrics/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add PostHog/ai-plugin --skill instrument-metrics -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/instrument-metrics/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add PostHog/ai-plugin --skill instrument-metrics -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/instrument-metrics/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install PostHog/ai-plugin skills/instrument-metrics
```

2. **Manually: put the files in place**
- File: `.github/skills/instrument-metrics/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add PostHog/ai-plugin --skill instrument-metrics -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/PostHog/ai-plugin --path skills/instrument-metrics
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/instrument-metrics/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add PostHog/ai-plugin --skill instrument-metrics -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/PostHog/ai-plugin/tree/HEAD/skills/instrument-metrics/SKILL.md

## When to use it
- 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
- Add PostHog metrics to the new API handlers.
- After reviewing this PR, track failures and request durations.
- Send the existing OpenTelemetry metrics to PostHog.

## Similar
- [instrument-logs](https://affpapa.org/en/nevibecode/skills/instrument-logs.md) — skill · 490 installs
- [otel-declarative-config](https://affpapa.org/en/nevibecode/skills/otel-declarative-config.md) — skill · ★ 126 repo stars
- [iii-observability](https://affpapa.org/en/nevibecode/skills/iii-observability.md) — skill · 195 installs
- [otel-instrumentation](https://affpapa.org/en/nevibecode/skills/otel-instrumentation.md) — skill · 3600 installs
- [instrument-feature-flags](https://affpapa.org/en/nevibecode/skills/instrument-feature-flags.md) — skill · 630 installs
- [otel-telemetrygen](https://affpapa.org/en/nevibecode/skills/otel-telemetrygen.md) — skill · ★ 126 repo stars

From the same set: [posthog/ai-plugin](https://affpapa.org/en/nevibecode/by/posthog/ai-plugin.md) — 82 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
