---
name: github-pr-cycle-time
description: "Every Monday: median hours from pull request opened to merged last week, how many merged, time to first review, and the slowest ones. Use when the user asks for this, or when it runs on a schedule."
---

# GitHub pull request cycle time

Every Monday: median hours from pull request opened to merged last week, how many merged, time to first review, and the slowest ones.

When shipping feels slow, the first question is where pull requests wait: in review, in rework, or in a queue of approvals. GitHub records every timestamp needed to answer it but shows none of it as a trend.

Every Monday the agent takes last week's merged pull requests, works out the median time from opening (or from ready for review, for drafts) to merge, and the median wait for a first review. Engineering leads see whether review is the bottleneck, and which small PRs waited longest.

## Two ways to get the data

Use the API or MCP route when you have an MCP server, a CLI or an API token for the app. Otherwise, if you can drive a browser the user is signed in to (Claude in Chrome, a Playwright or Chrome DevTools MCP server), use the browser route. Say which one you used.

## Route A: API or MCP server

### What you need

- The `gh` CLI signed in with read access to the repositories, or a token in `GITHUB_TOKEN` with read access to pull requests.

If something is missing, say what and stop; do not invent numbers.

### Steps

1. **List last week's merged PRs** (GitHub): Run `gh pr list --repo <owner>/<repo> --state merged --search "merged:2026-10-05..2026-10-11" --limit 500 --json number,title,author,createdAt,mergedAt,additions,deletions,reviews` with last week's dates. Leave out PRs from bots such as Dependabot.
2. **Start the clock at ready for review** (GitHub): For PRs that were opened as drafts, query `timelineItems(itemTypes: READY_FOR_REVIEW_EVENT, last: 1) { nodes { ... on ReadyForReviewEvent { createdAt } } }` through `gh api graphql`, and use that time instead of `createdAt`.
3. **Work out the times**: Cycle time is `mergedAt` minus the start, in hours. Time to first review is the earliest `reviews[].submittedAt` by someone other than the author. Take the median and 90th percentile of each, and save them weekly for the trend.
4. **Post the tile**: Median cycle time is the headline with 8 weeks of history; PRs merged and median time to first review go in the glance; the five slowest PRs with their size in the opened card.

## Route B: the browser

### What you need

- Signed in to GitHub with read access to the repository; private repositories show nothing to accounts without it.

If something is missing, say what and stop; do not invent numbers.

### Steps

Start at https://github.com/pulls. The user is signed in already; never type passwords or codes, and ask if a sign-in page appears.

1. **Search last week's merged PRs**: Replace the search box contents with `is:pr is:merged repo:<owner>/<repo> merged:2026-10-05..2026-10-11 -author:app/dependabot`, using last Monday to Sunday. The count at the top is PRs merged.
2. **Read each PR's timestamps**: Open each PR. Hover the time in the **opened this pull request** line and the **merged commit** line at the bottom of the conversation to read exact times; if the timeline has a **marked this pull request as ready for review** event, start the clock there.
3. **Find the first review**: In the same timeline, the first **approved these changes**, **requested changes** or **reviewed** event by someone other than the author gives time to first review. The **Files changed** tab header shows additions and deletions.
4. **Work out the numbers**: Compute hours to merge and hours to first review per PR, take the median and 90th percentile of each, and list the five slowest PRs with author and size. Compare with last week's saved numbers.

Note: Opening every PR takes a minute or so each, so this route suits repositories merging up to about 30 PRs a week; above that, the API route is the one to use. Insights > Pulse on the repository gives the merged count alone for the last week.

## The report

- **Median cycle time** last week, with the change and an 8-week trend.
- **PRs merged**, **median time to first review** and the 90th percentile.
- **Slowest PRs**: number, author, hours and size.
- One line on where PRs waited, for example "47 of 52 hours before the first review".

## Post it to Briefkin

When `BRIEFKIN_TOKEN` is set, or `~/.config/briefkin/env` exists (the installer from https://briefkin.dev/docs writes it), also send the result to the user's Briefkin board as one card. Keep the `item_key` the same on every run so the card updates in place, use a new `event_id` per run, and put today's real numbers in place of the example ones. If the request fails, say so once and carry on.

```bash
[ -n "${BRIEFKIN_TOKEN:-}" ] || . ~/.config/briefkin/env
curl -sS -X POST "${BRIEFKIN_URL:-https://briefkin.dev}/v1/events" \
  -H "authorization: Bearer $BRIEFKIN_TOKEN" \
  -H "content-type: application/json" \
  -d @- <<'JSON'
{
  "v": 1,
  "event_id": "github-pr-cycle-time/<date of this run, e.g. 2026-10-16>",
  "item_key": "github-pr-cycle-time",
  "project": "acme-web",
  "source": "GitHub pull request cycle time skill",
  "kind": "metric",
  "title": "Median PR cycle time down to 19 hours",
  "metric": {
    "label": "Median hours to merge",
    "value": 19,
    "unit": "h",
    "better": "lower",
    "period_start": "<start of the period, ISO 8601>",
    "period_end": "<end of the period, ISO 8601>"
  },
  "glance": [
    {
      "type": "Grid",
      "props": {
        "columns": 3
      },
      "children": [
        {
          "type": "Stat",
          "props": {
            "label": "PRs merged",
            "value": 47,
            "delta": 12
          }
        },
        {
          "type": "Stat",
          "props": {
            "label": "First review (median)",
            "value": 4.5,
            "unit": "h",
            "delta": -18,
            "better": "lower"
          }
        },
        {
          "type": "Stat",
          "props": {
            "label": "90th percentile",
            "value": 71,
            "unit": "h",
            "better": "lower"
          }
        }
      ]
    }
  ],
  "widget": [
    {
      "type": "Table",
      "props": {
        "columns": [
          "Pull request",
          "Author",
          "Hours",
          "Size"
        ],
        "align": [
          "left",
          "left",
          "right",
          "right"
        ],
        "rows": [
          [
            "#1842 Move billing to the new provider",
            "dana",
            168,
            "+1,240 / -380"
          ],
          [
            "#1857 Refactor the search indexer",
            "theo",
            96,
            "+860 / -910"
          ],
          [
            "#1861 Add SSO for teams",
            "sam",
            74,
            "+520 / -40"
          ],
          [
            "#1849 Upgrade to React 19",
            "priya",
            71,
            "+310 / -295"
          ],
          [
            "#1866 Fix time zone bug in reports",
            "marco",
            52,
            "+18 / -6"
          ]
        ]
      }
    },
    {
      "type": "Callout",
      "props": {
        "text": "#1866 changed 24 lines and still took 52 hours, 47 of them waiting for a first review.",
        "tone": "warn"
      }
    }
  ],
  "size": "md"
}
JSON
```

Widgets come from the Briefkin catalog (https://briefkin.dev/v1/catalog). Without a token, just give the user the report.

Set `period_start` and `period_end` to the window the number covers: the tile names it from them ("Last 7 days", "Today", "This month"). For a count right now (open items, a balance), send `"period_label": ""` so no period shows; for another name, send it as `period_label` (at most 24 characters).

## Run it on a schedule

Suggested: Mondays at 9:00 (`0 9 * * 1`). From cron, with the agent signed in on that machine:

```bash
0 9 * * 1 claude -p "Run the github-pr-cycle-time skill"
# Codex: codex exec, Gemini CLI: gemini -p, Copilot CLI: copilot -p, OpenCode: opencode run
```

Or use the agent's own scheduler (Claude Code routines, Codex automations, Claude or ChatGPT scheduled tasks): https://briefkin.dev/skills/github-pr-cycle-time#schedule

Source: https://briefkin.dev/skills/github-pr-cycle-time
