:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(skills): sync eng analytics skills with enabled MCP tools (#85800)
Raúl Negrón-Otero92b5d4e84e1d
diff --git a/.agents/skills/debugging-ci-failures/SKILL.md b/.agents/skills/debugging-ci-failures/SKILL.mdindex e43d255e0e13..76e8b2eb0e0f 100644--- a/.agents/skills/debugging-ci-failures/SKILL.md+++ b/.agents/skills/debugging-ci-failures/SKILL.md@@ -30,7 +30,11 @@ This skill triages and classifies. Once a failure is confirmed flaky, hand offto the `fixing-flaky-tests` skill, which owns local reproduction, root-causefixing, and N-run validation. For "who broke master" — the culprit commit andthe commit that fixed it — hand off to the `investigating-ci-failures` skill,-which owns the green/red boundary analysis.+which owns the green/red boundary analysis. For aggregate pipeline health (is CI+getting slower, which workflow is the long pole, how long PRs take to merge),+read `diagnosing-ci-and-merge-bottlenecks`. Both are product skills under+`products/engineering_analytics/skills/`, not invocable here: read the+`SKILL.md` at that path.## Safety rules@@ -160,7 +164,9 @@ Given a run id, the `engineering-analytics-run-failure-logs` MCP tool returnsevery failed job's error region with original line numbers, already thinned.One call instead of a jobs listing plus a log download, and it works when thejob died before any test ran. It is bounded by Logs retention, so fall back to-`gh` for older runs.+`gh` for older runs. Given a PR number instead of a run id,+`engineering-analytics-ci-failure-logs` does the same across every run that PR+has pushed, so an earlier push's failure is still there.Extract these before classifying:@@ -221,8 +227,7 @@ Unlike the span-derived test reads, this one can give you a real rate: thewarehouse records every job attempt, greens included, so the denominator ishonest. Query 7 in`products/engineering_analytics/skills/investigating-ci-failures/references/investigation-queries.md`-is copy-ready; that skill also owns the wider investigation and is worth reading-directly, as it is a product skill and not invocable from this repo.+is copy-ready; that skill also owns the wider investigation.Read the result as:diff --git a/.agents/skills/fixing-flaky-tests/SKILL.md b/.agents/skills/fixing-flaky-tests/SKILL.mdindex e12c1bce5a25..3ea897e79c2c 100644--- a/.agents/skills/fixing-flaky-tests/SKILL.md+++ b/.agents/skills/fixing-flaky-tests/SKILL.md@@ -25,6 +25,7 @@ Before any of these: **measure, don't assume.** Flaky-vs-deterministic, and theFor triaging a red CI run (finding and classifying the failure), use the `debugging-ci-failures` skill first — this skill takes over once the failure is classified as a flaky test.For writing new Playwright tests that aren't flaky, use the `playwright-test` skill.+`investigating-ci-failures` (green/red boundary) and `diagnosing-ci-and-merge-bottlenecks` (the `engineering-analytics-flaky-tests` tool's caveats) are product skills under `products/engineering_analytics/skills/`, not invocable here: read their `SKILL.md` at that path.## 1. Measure the failure rate — from GitHub, not from a digest@@ -49,7 +50,7 @@ Read the timeline before you classify:- **Interleaved pass/fail on adjacent commits** — the same unchanged test verified passing in some runs, failing in others → genuinely **flaky**; continue here.- **A long unbroken failure streak** (say 30+ consecutive) is statistically incompatible with a flake — at any per-run rate below ~95%, `p^30 ≈ 0`. That is a **deterministic regression**: go to `debugging-ci-failures` and find the introducing commit (step 4).-- **Both at once** is common: a latent flake whose rate jumped to ~100%. Find the transition (last green → first red); that boundary, not the digest's one-line verdict, is what tells you what tipped it. The `investigating-ci-failures` skill has the boundary query if the failure reached master.+- **Both at once** is common: a latent flake whose rate jumped to ~100%. Find the transition (last green → first red); that boundary, not the digest's one-line verdict, is what tells you what tipped it. `products/engineering_analytics/skills/investigating-ci-failures/` has the boundary query if the failure reached master.If a failure is reported as (or you suspect it is) **consistent**, don't serialize — measure the rate and attempt a repro **in parallel**.@@ -65,7 +66,7 @@ hogli ci:insights search "<test name or error>" # cross-run history — corro`search` reports two surfaces; read each for what it actually claims:- **broken tests** (recent failure fingerprints, last 2 days). A `potentially_resolved` state means that job's latest default-branch run is green again — weak evidence a fix landed, not proof. Confirm _against the run data_ that it covers this failure before reporting instead of re-fixing.-- **test health** (ranked by blast radius). `confirmed_flake` is the only classification backed by proof: one commit both failed and passed the test, via a re-run attempt going green or an in-job retry. `suspected_regression` means no recovery was recorded — absence of proof, not proof of a regression, so treat it as real until your own run data says otherwise.+- **test health** (ranked by blast radius; the same spans the `engineering-analytics-flaky-tests` MCP tool reads). `confirmed_flake` is the only classification backed by proof: one commit both failed and passed the test in the same matrix job, via a re-run attempt going green or an in-job retry. A pass in a different matrix leg is not recovery. `suspected_regression` means no recovery was recorded — absence of proof, not proof of a regression, so treat it as real until your own run data says otherwise.### Corroborate with Trunk Flaky Testsdiff --git a/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.md b/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.mdindex 176e622d6916..b4759f34bdb9 100644--- a/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.md+++ b/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.md@@ -7,7 +7,9 @@ description: >flaky long-pole, how long PRs take from open to merge, how an author's merge time compares to the cohort, whichopen PRs have failing or pending CI, or where a specific pull request is stuck. Triggers on "engineeringanalytics", "is CI getting slower", "slow workflow", "flaky CI", "time to merge", "cycle time", "PR throughput",- "failing checks", "where is PR <n> stuck", "CI long pole", "what's holding up this PR".+ "failing checks", "where is PR <n> stuck", "CI long pole", "what's holding up this PR". For a verdict on one+ specific CI failure (whose fault, which commit) use investigating-ci-failures; to save these numbers as insights+ use turning-engineering-analytics-into-insights.---# Diagnosing CI and merge bottlenecks@@ -15,7 +17,8 @@ description: >Engineering analytics treats a pull request like product analytics treats a user: a PR moves through a pipeline(`opened → CI → review → merged → deployed`) and the job is to find where it slows down. The surface is **namedMCP tools** — you call them, you don't write SQL. Dogfooded on `PostHog/posthog`; the same tools serve-autonomous agents (e.g. PostHog Desktop) reasoning about their own PRs.+autonomous agents (e.g. PostHog Desktop) reasoning about their own PRs. Scope is aggregate pipeline health:+to take one failing test or red run to a verdict, switch to the `investigating-ci-failures` skill.## The tools@@ -41,8 +44,9 @@ autonomous agents (e.g. PostHog Desktop) reasoning about their own PRs.- **`engineering-analytics-flaky-tests`** — the active test-health queue from the per-test CI spans, over awindow (`date_from` default `-7d`, max 30 days). Evidence is counted per CI run, never per span or run attempt.`classification` is `confirmed_flake` only where the evidence proves nondeterminism- (`same_commit_recovery_run_count > 0`: one commit both failed and passed the test, via a "Re-run failed jobs"- attempt going green or an in-job retry); `quarantined` means a tolerated failure was recorded while masked;+ (`same_commit_recovery_run_count > 0`: one commit both failed and passed the test **in the same matrix+ job**, via a "Re-run failed jobs" attempt going green or an in-job retry; a pass in a different leg, such as FOSS+ against EE, is not recovery); `quarantined` means a tolerated failure was recorded while masked;`suspected_regression` means only failures were recorded, which is absence of proof, not proof of a real break.A test qualifies on any same-commit recovery, a quarantined failure, any master/main failure, or failures on ≥`min_failed_prs` distinct PRs (`failed_pr_count`). Answers "what is this failing test costing us" and picks@@ -51,6 +55,11 @@ autonomous agents (e.g. PostHog Desktop) reasoning about their own PRs.`@pytest.mark.flaky(reruns=N)`). Counts are absolute signal, never rates: passing runs are mostly notemitted, so there is no honest denominator.+- **`engineering-analytics-sources`**: the team's connected GitHub sources and repos. With more than one of+ either, call it first and pass the chosen entry's `source_id` **and** `repo` to `pull-requests`,+ `workflow-health`, and `pr-lifecycle`. Passing only `source_id` reads that source's default repo, not the one+ you picked. With a single source and repo the tools default to it.+There is no aggregate time-to-merge tool and no "counts" tool — derive those from `pull-requests` (the stuck/failingcounts, the merge-time percentiles).@@ -74,10 +83,10 @@ These are structural limits of today's snapshot data — state them, don't paper- **Bots and drafts are present in `pull-requests` output, excluded by convention.** Filter out `author.is_bot`(nested under `author`, not a row-level field) and `is_draft` for throughput / merge-time questions; keep them infor bot-impact questions.-- **`pull-requests` returns a capped page.** At most `limit` rows (newest first); `truncated` is `true` when more- match, and there is no repo or limit filter to narrow the call. When `truncated` is `true`, any percentile or- count you derive covers only the newest page — not the whole window — so say so and shrink `date_from` until the- real set fits under the cap.+- **`pull-requests` returns a capped page.** 1000 rows, newest first: a fixed server-side cap, echoed in the+ response as `limit`, that no parameter raises. When `truncated` is `true`, any percentile or count you derive+ covers only that newest page, not the whole window. Say so, then narrow until the real set fits: `author`+ filters to one handle, `source_id` / `repo` to one repo, and `date_from` shortens the window.## Choosing a tool@@ -88,7 +97,7 @@ These are structural limits of today's snapshot data — state them, don't paper| Which PRs are stuck open longest? | `pull-requests` | Keep `state = open`, not `is_draft`, not `author.is_bot`; sort by `created_at` ascending (oldest first). || How long are PRs taking to merge? Per author? | `pull-requests` | Over merged rows (`merged_at` set, not bot, not draft), aggregate `ready_to_merge_seconds` where non-null (fall back to `open_to_merge_seconds`, labeled as coarse) — median and p95. Group by `author.handle` for **cohort context, not a ranking** (per-developer surveillance is an explicit non-goal). Trend it by calling with two `date_from` windows. || Where is PR N stuck? | `pr-lifecycle` | Walk the sorted events: `opened → ready_for_review` (draft time, when transition events are present), the CI span (first start → last finish; one pair per workflow), `last CI finished → merged`. The largest gap is the bottleneck. A long ready→merge with quick CI points at review/idle time the `partial` data can't itemize yet — say so. |-| What is a failing test costing us? What to quarantine? | `engineering-analytics-flaky-tests` | Default window is `-7d`; rows are already ranked by blast radius (master failures, then distinct PRs hit). Report counts, never rates. For "is it flaky": only `confirmed_flake` rows are proven, and only for tests hand-marked with reruns. |+| What is a failing test costing us? What to quarantine? | `engineering-analytics-flaky-tests` | Default window is `-7d`; rows are already ranked by blast radius (master failures, then distinct PRs hit). Report counts, never rates. For "is it flaky": only `confirmed_flake` rows are proven (one commit both failed and passed **in the same matrix job**: a re-run attempt went green, or an in-job retry recovered it). |## The high-value chaindiff --git a/products/engineering_analytics/skills/investigating-ci-failures/SKILL.md b/products/engineering_analytics/skills/investigating-ci-failures/SKILL.mdindex e0b588127710..394b3c3cb0db 100644--- a/products/engineering_analytics/skills/investigating-ci-failures/SKILL.md+++ b/products/engineering_analytics/skills/investigating-ci-failures/SKILL.md@@ -104,8 +104,9 @@ threshold aren't recorded, so there is no honest denominator.fingerprint is weak evidence (the job may simply not have run). Greens come from`ci_job_history` only.- **Fingerprints are pytest-only (v1).** Jest / playwright / cargo failures appear in the raw- failure logs but are not in `ci_failures`. For those, fall back to grouped triage via the- `engineering-analytics-master-failures` / `engineering-analytics-ci-failure-logs` MCP tools.+ failure logs but are not in `ci_failures`. For those, fall back to the raw failure logs via the+ `engineering-analytics-ci-failure-logs` (PR-scoped) / `engineering-analytics-run-failure-logs`+ (run-scoped) MCP tools.- **A job that failed before its tests ran is invisible to every test-level surface.** No `FAILED`line means no fingerprint, no span, nothing for the flaky-tests tool to read — the failure is realbut the test-level answer is silence, not "fine". Setup, docker, and runner failures are only@@ -136,17 +137,17 @@ threshold aren't recorded, so there is no honest denominator.## Choosing a surface-| Question | Use |-| -------------------------------------- | ---------------------------------------------------------------------- |-| "What's broken across CI right now?" | `engineering-analytics-broken-tests` MCP tool (triaged, classified) |-| Same, but from a terminal | `hogli ci:insights` — these endpoints, scoped to the checkout's repo |-| "Why did MY PR's CI fail?" | `engineering-analytics-ci-failure-logs` MCP tool (PR-scoped, grouped) |-| "Who broke master / when did X start?" | The two views, workflow above |-| "Is X flaky?" | Shape from `ci_failures` + the flaky-tests tool |-| "Is this setup/infra failure common?" | Job conclusions, query 7 (no test rows exist for it) |-| "What's failing on master right now?" | `engineering-analytics-master-failures` MCP tool (grouped triage feed) |-| "Is CI slow / expensive / PRs stuck?" | The `diagnosing-ci-and-merge-bottlenecks` skill |-| "Save this as a dashboard/insight" | The `turning-engineering-analytics-into-insights` skill |+| Question | Use |+| -------------------------------------- | -------------------------------------------------------------------------- |+| "What's broken across CI right now?" | `engineering-analytics-broken-tests` MCP tool (triaged, classified) |+| Same, but from a terminal | `hogli ci:insights` — these endpoints, scoped to the checkout's repo |+| "Why did MY PR's CI fail?" | `engineering-analytics-ci-failure-logs` MCP tool (PR-scoped, grouped) |+| "Who broke master / when did X start?" | The two views, workflow above |+| "Is X flaky?" | Shape from `ci_failures` + the flaky-tests tool |+| "Is this setup/infra failure common?" | Job conclusions, query 7 (no test rows exist for it) |+| "What's failing on master right now?" | `breaking_master` rows + `breaking_master_jobs` from the broken-tests tool |+| "Is CI slow / expensive / PRs stuck?" | The `diagnosing-ci-and-merge-bottlenecks` skill |+| "Save this as a dashboard/insight" | The `turning-engineering-analytics-into-insights` skill |## Output expectations