AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The investigate-metric skill provides a structured, step-by-step procedure for root-cause analysis of product metric anomalies. It guides the user through classifying the metric, confirming the anomaly, checking for variance, identifying known changes, and running specific playbooks based on the query type. The skill leverages various PostHog tools to isolate segments, compare periods, and generate clear explanations for stakeholders.
What it does
- Classifies metric anomalies based on query type (Trends, Funnels, Retention, etc.).
- Performs variance checks to distinguish between real anomalies and expected seasonality.
- Correlates anomalies with recent feature flags, experiments, and annotations.
- Executes specialized playbooks for deep-dive analysis into specific metric behaviors.
- Generates interactive chart explanations to walk users through findings.
- Produces structured written reports when chart explanations are not applicable.
When to use it
- When a user asks why a specific product metric has dropped, spiked, or plateaued.
- When investigating anomalies in dashboards, saved insights, or custom queries.
- When a user requests an explanation or a walkthrough of a specific chart.
- When performing root-cause analysis for trends, funnels, retention, or lifecycle metrics.
Advantages
- Standardizes the investigation process to ensure consistent and thorough analysis.
- Reduces manual effort by automating comparisons to prior periods and breakdown attribution.
- Provides a clear taxonomy of common causes to speed up hypothesis generation.
- Integrates directly with PostHog tools for seamless data retrieval and visualization.
Usage examples
- “Why did our signup conversion rate drop last Tuesday?”
- The agent will classify the metric, run a funnel analysis, compare the date range to prior periods, and identify if the drop correlates with a specific release or traffic source.
- “Can you walk me through this retention chart?”
- The agent will analyze the retention cohort data, identify key trends or shifts, and generate an interactive chart explanation highlighting the most significant moments.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/posthog/investigate-metric/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip investigate-metric.zip -d .agents/skills
Documentation by PostHog
Investigating a metric change
For "why did X change?" questions about a saved insight, dashboard tile, or pasted query, and for "explain this chart" or "walk me through this" when the user names no change. Don't load this skill for plain "what is X?" questions — only when there's a chart or an observed change to explain.
Tools
Targets PostHog MCP v2. Typed query tools accept the query body directly — pass
kind, series, dateRange as top-level fields, do not wrap in InsightVizNode.
| Tool | Purpose |
|---|---|
posthog:query-trends | Trends (count over time) |
posthog:query-funnel | Funnels (multi-step conversion) |
posthog:query-retention | Retention (cohort return rates) |
posthog:query-stickiness | Stickiness (active days per user) |
posthog:query-lifecycle | Lifecycle (new/returning/resurrecting/dormant) |
posthog:query-paths | Paths (navigation flow) |
posthog:query-trends-actors | Users behind a trend bucket (trends source only) |
posthog:execute-sql | Existing SQL insights and custom analysis |
posthog:read-data-schema | Discover events, properties, sample values |
posthog:insight-get / -query | Fetch a saved insight's metadata / data |
posthog:explain-chart | Walk the user through a trends chart (Step 5) |
Plus the standard PostHog tools the playbooks reference by name (feature-flag-get-all,
experiment-list, annotations-list, query-error-tracking-issues-list, query-logs,
query-session-recordings-list, cohorts-list/-create, annotation-create,
insight-create).
Helper scripts
compare_to_prior_periods.py— auto-detects interval and compares recent values to the natural cycle (day-of-week, hour-of-week, or sequential). Use to resolve step 2.2 cheaply.breakdown_attribution.py— ranks breakdown segments by absolute delta and flags offsetting moves.
python3 scripts/compare_to_prior_periods.py < query_result.json
WINDOW=7 python3 scripts/breakdown_attribution.py < breakdown_result.jsonStep 1 — Classify the metric
Read query.kind from the source the user pointed at:
Saved insight (URL,
short_id):posthog:insight-get→query.kind. Useposthog:insight-queryif you also need the numbers.A query you already ran or the user pasted: read
kinddirectly.A metric the user only names, such as "signups", or shows in a screenshot: find its event with
posthog:read-data-schemaand run it as one series over time withposthog:query-trends. That query is yourTrendsQuery. Whenquery-trendscannot express the metric, such as a warehouse-only metric or a custom SQL join, run it withposthog:execute-sqland treat it as aHogQLQuery.Nothing pointed at, or several events could be the metric: ask which one. Don't guess.
| kind | Playbook |
|---|---|
TrendsQuery | trend-playbook.md |
FunnelsQuery | funnel-playbook.md |
RetentionQuery | retention-playbook.md |
StickinessQuery | stickiness-playbook.md |
LifecycleQuery | lifecycle-playbook.md |
PathsQuery | paths-playbook.md |
HogQLQuery | route by what the SQL aggregates (see below) |
If kind === "TrendsQuery" and trendsFilter.display === "BoxPlot", use
box-plot-playbook.md — distribution metric, no
breakdowns.
For HogQLQuery insights, classify by the SQL's shape: count over time → trend
playbook, multi-step conversion → funnel playbook, cohort return → retention playbook.
Run the SQL through posthog:execute-sql to get the data, then follow the closest
playbook's steps. See HogQL insights in shared-patterns.md.
If the user's question spans multiple kinds, run the playbooks in sequence.
Choose how you will show the findings
Decide this now, before the investigation, because it changes which queries you keep.
When the user gave you a saved insight or a query that is a TrendsQuery over time (not a box plot, 2D heatmap or scatter plot), or named a metric you ran as one, the investigation ends with a chart explanation from posthog:explain-chart.
posthog:explain-chart exists only where chart explanations are enabled, so check for it now and read its schema.
Where PostHog tools run through exec, it is not in your own tool list: run info explain-chart before you decide it is missing.
When it does not exist, the findings go in a written report.
The chart explanation is the answer, in place of a notebook or a long reply. Write a notebook as well only when the user asks for one.
For anything else, such as a metric that only SQL can express, the findings go in a written report.
When it is a chart explanation:
Add "Show the chart explanation (Step 5)" as the last item of your plan or to-do list.
Keep the query behind each finding. The chart explanation runs it again and draws the result beside the finding. Prefer an insight query, such as a
TrendsQuerywith a breakdown or a property filter, and use SQL only for what an insight query cannot express.
Step 2 — Common opening moves
2.1 Confirm the anomaly
Run the primary tool. Record baseline, current, delta (absolute and %), and the start of the anomaly window.
When the user asked you to explain a trends chart over time and named no change, find what stands out first with what-stands-out.md. Each moment it finds becomes its own anomaly to run through the rest of the steps, most striking first. For funnels, retention, paths and other kinds, use that kind's playbook to choose what to look into.
2.2 Variance check
Widen to 3–4× the user's interval (or use compareFilter: {"compare": true} on
TrendsQuery / StickinessQuery; for other kinds run two date ranges).
Pipe the widened result through
compare_to_prior_periods.py — it flags
seasonality, partial right-edge buckets, and real anomalies. If the movement is
normal variance, report that and stop.
2.3 Known changes in the window
In rough order of signal:
posthog:feature-flag-get-all→ flags withupdated_atnear the anomaly start.posthog:experiment-list→start_date/end_datenear the start.posthog:annotations-list→date_markernear the start.git logfor the window if the repo is reachable (highest signal when available).
Any match is a hypothesis to confirm in the playbook (usually via breakdown on
$feature/<flag_key>, app_version, or utm_source).
Step 3 — Run the playbook
Open the playbook for the kind from Step 1 and follow its numbered steps. Carry the record from 2.1 and any candidates from 2.3 into it.
Step 4 — Cross-check
Pick a segment the suspected cause should not have affected and rerun there. Stable in the control = strong hypothesis; moved too = expand the investigation. Skip when 2.2 already explained the movement.
Step 5 — Write findings
Before you write your answer, call posthog:explain-chart when the investigation has a TrendsQuery over time.
Do this after a long investigation too, and when most of your evidence is SQL.
For anything else, use the written report.
The chart explanation
It draws the chart with each moment highlighted and lets the user step through them. Map the investigation onto it:
Anomaly → one chapter per moment, with
startandendcopied exactly from the chart'sdays. The app works out each chapter's numbers from the chart, so leave them out ofsummary.Likely cause and Confidence →
cause,confidenceandconfidence_reason.Evidence →
evidence, each finding with thequerythat produced it, theinsightShortIdof a saved insight, or aurlto a GitHub pull request or commit. No other links are accepted. The chart explanation runs each query and draws it: an insight query with its insight chart, and aHogQLQueryfrom its rows. Shape the SQL for the chart, with the x-axis column first, then optionally one text column to break down by, then the numbers. Prefer a series over time to a before-and-after comparison, so the user sees when the change happened.Zoomed-in evidence → when the metric moved suddenly, add one finding that zooms in on the change. Use the insight's own query with a
dateRangearound the change, at the interval that shows it best, fromminutetoday. Filter it to the segment the cause points at, such as the affected browser or region.A headline of one sentence with no numbers sums up the whole chart. Wrap each name behind a moment, such as the referrer of a spike or the country behind a rise, in
**double asterisks**so the chart explanation highlights it. Do the same in eachcause.
Call posthog:explain-chart first. It reports any chapter whose dates match no point on the
chart, so fix those dates and call it again.
When its response says the user already sees the result, the chart explanation is on screen, and you are done.
Otherwise call posthog:render-ui with tool_name explain-chart and the same input as tool_input.
When render-ui does not exist, call posthog:explain-chart-save with the same arguments and give the user the link it returns, which opens the chart explanation in PostHog.
When the call fails because the tool does not exist, or neither render-ui nor a link is available, the user sees nothing, so write the written report instead.
Then reply briefly. Say which chapter to look at first, then add only what the chart explanation cannot hold, such as a caveat about the data, a linked fix or a decision that is still open. End with one offer from below. The chart explanation already holds the chart, the chapters, their causes and their evidence, so do not describe the chart or list the moments again.
The written report
Without the chart explanation, use the format below. Offer to save key charts via posthog:insight-create.
If a cause is found and no annotation marks it, offer posthog:annotation-create.
See common-causes.md for the cause taxonomy.
# Investigation: <metric>
**Anomaly**: <baseline> → <current> (<delta>) starting <date>
## Likely cause
<one sentence>
**Confidence**: low | medium | high — <one-line reason>
**Evidence**
- <query result>
- <flag / experiment / annotation / commit if applicable>
## Possible causes (ruled out)
- <hypothesis>: <why>
## Affected segment
- <shared properties of affected users/events>
## Data gaps
- <checks skipped and why>
## Suggested follow-ups
- <concrete next action>
- <offer to save chart / create annotation>Confidence rule of thumb:
high — multiple independent signals corroborate (e.g. a segment isolates the delta and a flag/version aligns and an error or annotation matches).
medium — one corroborating signal, or strong pattern-match without a cross-check.
low — pattern matches a known cause but no corroboration, or the data only rules things out.
Link insights and dashboards inline: [Name](/insights/short_id).
Reference files
Playbooks: trend, box-plot, funnel, retention, stickiness, lifecycle, paths
shared-patterns.md — recipes used across playbooks
common-causes.md — cause taxonomy with confirming queries
Files
- ATTRIBUTION.mdAdded by AutoGineer855 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md12.7 KiB
- references/box-plot-playbook.md4.0 KiB
- references/common-causes.md2.4 KiB
- references/funnel-playbook.md2.0 KiB
- references/lifecycle-playbook.md1.5 KiB
- references/paths-playbook.md1.7 KiB
- references/retention-playbook.md1.5 KiB
- references/shared-patterns.md6.1 KiB
- references/stickiness-playbook.md1.2 KiB
- references/trend-playbook.md1.6 KiB
- references/what-stands-out.md2.7 KiB
- scripts/breakdown_attribution.pyScript5.8 KiB
- scripts/compare_to_prior_periods.pyScript14.3 KiB
references/shared-patterns.md
Shared patterns
Recipes used across playbooks.
Contents
When to reach for HogQL
HogQL insights
HogQL quantile template
Property discovery
Related-metrics sweep
Breakdown dimensions
Interpreting breakdown results
Interval zoom
Actor drilldown
Session recordings
Error / logs cross-check
When to reach for HogQL
Use the typed query tools by default. Use posthog:execute-sql only when the question
can't be expressed structurally:
Ratios across different events.
Joins with data-warehouse tables.
Custom aggregations like
quantile,arrayJoin, regex extraction.
HogQL insights
For saved insights with query.kind === "HogQLQuery", the playbook routing is shape-based
rather than kind-based. Read the SQL and pick the closest playbook:
count(...) GROUP BY toStartOfDay(...)or similar count-over-time → trend playbook.Multi-step
windowFunnelor sequential filtering → funnel playbook.Cohort-keyed return aggregates → retention playbook.
Run the insight's SQL through posthog:execute-sql to get the data, then follow the
chosen playbook's steps using the typed tools where they fit. Drop back to
execute-sql for the breakdown / drilldown variants when the original SQL has shape
the typed schema can't express.
HogQL quantile template
For per-bucket distribution stats with a segment dimension (box plots can't take
breakdownFilter).
SELECT
toStartOfDay(timestamp) AS day,
properties.plan AS segment,
quantiles(0.25, 0.5, 0.75, 0.9)(toFloat(properties.order_value)) AS q,
count() AS n
FROM events
WHERE event = 'checkout_completed'
AND timestamp >= now() - INTERVAL 30 DAY
GROUP BY day, segmentCast
toFloat(properties.X)— properties are loose-typed.Report
nalongside quantiles; a p75 swing on small cells is usually noise.
Property discovery
Use posthog:read-data-schema to discover events and properties before filtering or
breaking down. The query.kind field selects:
events— list events for fuzzy-matching by name.event_propertieswithevent_name— properties on a specific event.entity_propertieswithentity: "person"— person properties.event_property_valueswithevent_name+property_name— sample values.
Related-metrics sweep
Before going deep on one metric, run the same anomaly-window query on 2–3 adjacent metrics — upstream funnel steps, sibling events, total event volume, parent-event counts. If they all moved together, the cause is broader than the specific metric (ingestion gap, cohort shift, tracking regression). If only the target metric moved, the investigation is correctly scoped.
Use when the metric sits inside a larger pipeline (a funnel step, a retention activity event, a derived rate) and you want to rule out an upstream cause cheaply.
posthog:query-trends
{
"kind": "TrendsQuery",
"dateRange": { "date_from": "-30d" },
"interval": "day",
"series": [
{ "kind": "EventsNode", "event": "$pageview", "math": "total" },
{ "kind": "EventsNode", "event": "user signed up", "math": "total" },
{ "kind": "EventsNode", "event": "first team event ingested", "math": "total" }
]
}A single multi-series query is cheaper than three breakdowns and the visual alignment (or lack of it) answers the question immediately.
Breakdown dimensions
A few candidate dimensions, roughly in order of signal:
$feature/<flag_key>— highest signal post-release.$browser,$os,$device_type,$geoip_country_code— for platform / regional issues.app_version,$lib_version— for SDK regressions.is_identified,$is_first_session, plan / tier — for user-state issues.Custom event properties from
read-data-schema— usually most diagnostic.
Interpreting breakdown results
Rank by absolute delta, not %. Pipe through
breakdown_attribution.py — it ranks by
contribution and detects offsetting cases (aggregate flat, segments moved oppositely).
If no breakdown isolates the delta the cause is system-wide (deploy, tracking, infra), not segment-specific. Try a compound breakdown of up to 3 properties for interaction effects (e.g. one browser × one country).
If event volume per interval < ~100, percentages are unreliable — report absolutes too.
When a segment looks guilty, check its pre-anomaly baseline before concluding: the segment may have always behaved that way, with its share of volume just growing at the anomaly start (cohort composition change, not a real regression).
Interval zoom
When a daily point looks anomalous, rerun the query at interval: "hour" scoped to that
day. A one-hour cliff is an incident; a sustained shift is something broader. Use
interval: "minute" for tight incident windows.
Actor drilldown
posthog:query-trends-actors only accepts a trends source. The selector fields are day,
series, and (if breakdown) breakdown:
posthog:query-trends-actors
{
"kind": "InsightActorsQuery",
"source": {
"kind": "TrendsQuery",
"dateRange": { "date_from": "2026-03-10", "date_to": "2026-03-10" },
"series": [{ "kind": "EventsNode", "event": "$pageview", "math": "dau" }],
"breakdownFilter": { "breakdowns": [{ "property": "plan", "type": "event" }] }
},
"day": "2026-03-10",
"breakdown": "free"
}Session recordings
For UI-shaped drops, pull recordings matching the affected segment via
posthog:query-session-recordings-list. Watching three or four is often faster than
running more queries. Fetch individual ones with posthog:session-recording-get.
Error / logs cross-check
Run posthog:query-error-tracking-issues-list and posthog:query-logs for the anomaly window.
A correlated error is a candidate, not a conclusion — confirm three things:
Timing — error volume aligns with the metric movement.
Plausible mechanism — the error actually affects the metric's surface (a 500 on a submit endpoint can; a console warning usually can't).
User overlap — affected users overlap with users hitting the error.
If any check fails, note the error as coincidental and move on.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Python
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- PostHog
- Publisher
- PostHog (Official)
- Source
- PostHog/skills · skills/omnibus/investigate-metric · commit a5d30e7
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by PostHog or PostHog.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download investigate-metric.zip