Official agent skill

Merging PRs

by PostHog in PostHog/code

Merge a PR into main through the Trunk merge queue and babysit it until it lands.

OfficialMITAuto-check passed

Install Merging PRs

skills CLI
$ npx skills add PostHog/code --skill merging-prs -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install PostHog/code merging-prs --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/PostHog/code.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/merging-prs .claude/skills/merging-prs && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
merging-prs
GitHub stars
179
Token cost
~1.3k tokens
SKILL.md length
616 words
Files
1
Skills in repo
10
Repo updated
First seen
Licence
MIT

At a glance

Merge a PR into main through the Trunk merge queue and babysit it until it lands.

  • Works in 5 steps: Preflight → Enqueue → Poll until it lands → …
  • Asked to merge a PR
  • SKILL.md covers 1. Preflight, 2. Enqueue, 3. Poll until it lands and 4. Handle failure, plus 2 more sections
  • Calls gh

What it does

Merging PRs is an agent skill from PostHog/code, published by the product's own GitHub organization. Merge a PR into main through the Trunk merge queue and babysit it until it lands. Enqueue with a "/trunk merge" comment, then poll the "Trunk Merge Queue" check run and the PR state until it is MERGED or FAILED, reporting the Trunk bot's failure reason if the PR is kicked out. Use when asked to merge a PR, "merge when ready", "land it", "ship it", or to babysit/watch a PR through the queue. Never use gh pr merge in this repo -- the queue is the only path into main.

Its SKILL.md is about 1.3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

The repository describes itself as: The era of self-driving development is here. The licence is MIT.

When your agent uses it

  • Asked to merge a PR
  • Merge when ready
  • Babysit/watch a PR through the queue

Example prompts

  • “/trunk merge”
  • “Trunk Merge Queue”
  • “merge when ready”
  • “/merging-prs”

Requirements

  • Pre-approved tools (allowed-tools): Bash(gh pr view:*), Bash(gh pr checks:*), Bash(gh pr comment:*), Bash(gh pr ready:*), Bash(gh api:*), Bash(sleep:*)

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Preflight
  2. Enqueue
  3. Poll until it lands
  4. Handle failure
  5. Cancel

What it can do on your machine

Read from SKILL.md and the folder at commit a4c32df. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Bash(gh pr view:*)
    • Bash(gh pr checks:*)
    • Bash(gh pr comment:*)
    • Bash(gh pr ready:*)
    • Bash(gh api:*)
    • Bash(sleep:*)

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • gh

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • trunk.io

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Merging PRs loads about 1.3k tokens when it runs. Until then it costs about 121 tokens; SKILL.md has 616 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~121
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from PostHog/code at commit a4c32df, republished under its MIT licence (© PostHog). 616 words, ~1,338 tokens.

Download SKILL.mdSave it as .claude/skills/merging-prs/SKILL.md (or your agent's skills folder).
name
merging-prs
description
Merge a PR into main through the Trunk merge queue and babysit it until it lands. Enqueue with a "/trunk merge" comment, then poll the "Trunk Merge Queue" check run and the PR state until it is MERGED or FAILED, reporting the Trunk bot's failure reason if the PR is kicked out. Use when asked to merge a PR, "merge when ready", "land it", "ship it", or to babysit/watch a PR through the queue. Never use `gh pr merge` in this repo -- the queue is the only path into main.
allowed-tools
Bash(gh pr view:*), Bash(gh pr checks:*), Bash(gh pr comment:*), Bash(gh pr ready:*), Bash(gh api:*), Bash(sleep:*)

Merge a PR through the Trunk merge queue

Merges into main go exclusively through the Trunk merge queue. gh pr merge and the GitHub merge button are blocked by branch ruleset. To merge, you enqueue the PR with a comment, then watch it until Trunk lands it.

When a developer says "merge this PR", "merge it when it's ready", "land it", "ship it", or "babysit this PR", do the full loop below — enqueue and watch to completion, reporting the outcome.

<n> below is the PR number. Resolve the repo slug once if you need it: REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner).

1. Preflight

bash
gh pr view <n> --json state,isDraft,mergeable,reviewDecision,statusCheckRollup
  • Not open (already merged/closed) → report and stop.
  • Draft → it can't be merged. Ask the developer to confirm, then gh pr ready <n> before continuing. Don't un-draft silently.
  • Failing required checks (statusCheckRollup) → the queue will just reject it. Report which checks are red and stop; fix them first. Pending checks are fine — the queue waits for them.
  • Not yet approved (reviewDecision empty or REVIEW_REQUIRED) → fine, enqueue anyway. See below.
  • Merge conflicts (mergeable == "CONFLICTING") → report and stop; rebase first.

Enqueueing before approval is safe, and is the closest thing this repo has to auto-merge. A submitted PR sits in Trunk's Queued state until GitHub's branch protection on main is satisfied — one approving review, code-owner review, and the required checks (build, quality, unit-test, integration-test, typecheck) — and Trunk merges it once they land. Trunk is not a bypass actor on those rules, so it cannot merge an unapproved or red PR.

The catch: pushing new commits drops the PR from the queue. If review feedback is likely, either wait for approval before enqueueing, or re-enqueue with /trunk merge after each push.

2. Enqueue

bash
gh pr comment <n> --body "/trunk merge"

Within ~2 minutes, confirm Trunk picked it up — a check run whose name starts with Trunk Merge Queue should appear on the head commit:

bash
SHA=$(gh pr view <n> --json headRefOid -q .headRefOid)
gh api repos/$REPO/commits/$SHA/check-runs \
  --jq '.check_runs[] | select(.name | startswith("Trunk Merge Queue")) | {name, status, conclusion, details_url}'

If nothing appears after a couple of minutes, the developer may lack write access or GitHub-comment commands may be disabled — report that and suggest the trunk-merge-queue-submit label as a fallback.

Show full SKILL.md (279 more words)Show less

3. Poll until it lands

Loop about every 60 seconds, up to ~45–60 minutes total. Each iteration:

bash
gh pr view <n> --json state,mergedAt          # MERGED  -> success, stop
SHA=$(gh pr view <n> --json headRefOid -q .headRefOid)
gh api repos/$REPO/commits/$SHA/check-runs \
  --jq '.check_runs[] | select(.name | startswith("Trunk Merge Queue")) | {status, conclusion, details_url}'
sleep 60
  • state == "MERGED" → done. Report success with the merge commit.
  • Check run status moves queued → in_progress → completed. Report each transition so the developer can follow along.
  • Watch the check run + PR state, not gh pr checks --watch: the queue runs CI on Trunk's own draft/trunk-merge/** branch, so this PR's own checks don't reflect the queue's testing.
  • If it's parked in Queued waiting on a human review, say so once and slow the cadence to ~5 minutes. Keep watching — the merge still has to be reported.
  • Stop at the timeout with a status summary rather than looping forever. If it was still waiting on review, say that's why and offer to keep watching.

4. Handle failure

If the check run completes with conclusion == "failure" (or the PR drops out of the queue), Trunk kicks the PR and its bot comments with the failing workflow. Read the newest comments and report the reason:

bash
gh pr view <n> --comments | tail -n 40
  • If the failure is clearly caused by this PR and the fix is obvious, fix it, push, wait for the PR's own checks to go green, and re-enqueue once with /trunk merge.
  • Otherwise stop and report the failure and the workflow link. Don't repeatedly re-enqueue a red PR.

5. Cancel

If the developer asks to stop the merge:

bash
gh pr comment <n> --body "/trunk cancel"

Confirm the check run reports cancelled.

Hard rules

  • Never run gh pr merge — it's blocked and it's not how this repo merges.
  • Never force-push a branch while it is in the queue — it removes the PR from the queue.
  • Re-enqueue a failed PR at most once automatically; beyond that, hand back to the developer.

© PostHog, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/merging-prs of PostHog/code.

Open the folder on GitHubat commit a4c32df

Compare with similar skills

Merging PRs next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Merging PRs compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Merging PRs this skillPostHog/code179—~1.3kAutomated safety check: PassMIT
Merging PRsPostHog/posthog40k—~4.1kAutomated safety check: PassCustom licence
Merge Dependabot PRsonyx-dot-app/onyx32k1 repos~2.2kAutomated safety check: PassMIT
Triaging Merge Queue FailuresPostHog/posthog40k—~9.5kAutomated safety check: PassCustom licence
Archestra Merge Queuearchestra-ai/archestra4.4k—~2.3kAutomated safety check: PassCustom licence
Mergewithastro/astro63k—~153Automated safety check: PassCustom licence

Similar skills

  • Merging PRs

    PostHog/posthog

    Official

    Merge a PR into master through the Trunk merge queue and babysit it until it lands.

    40k GitHub stars~4.1k tokensUpdated today
    Auto-check passed
  • Merge Dependabot PRs

    onyx-dot-app/onyx

    Triages and lands a batch of open Dependabot PRs in the Onyx repo, where main is gated exclusively by GitHub's merge queue: approves and enqueues green PRs, closes superseded duplicates, fixes…

    32k GitHub starsUsed in 1 repo~2.2k tokens
    DevelopmentAuto-check passed
  • Official

    Decision procedure for a PR that failed or was removed from the Trunk merge queue: classify the kick (superseded by a newer commit, not mergeable, a gate that failed on a cancelled run, real…

    40k GitHub stars~9.5k tokensUpdated today
    Auto-check passed
  • Archestra Merge Queue

    archestra-ai/archestra

    A skill your agent uses when asked to add an Archestra PR to the merge queue, monitor it through merge, or diagnose and repair merge-group CI failures.

    4.4k GitHub stars~2.3k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Merge

    withastro/astro

    Official

    Handle main-to-next merge tasks including conflict resolution, changeset cleanup, and CI fix-ups.

    63k GitHub stars~153 tokensUpdated today
    Auto-check passed
  • Merge Main To Nightly

    dotnet/dotnet-docker

    Official

    Create a PR to merge main into the nightly branch after a .NET containers release.

    4.9k GitHub stars~249 tokensUpdated today
    DevOps & CloudAuto-check passed

More from PostHog/code

All 10 skills in this repo
  • Canvas Templates

    PostHog/code

    Official

    How PostHog "canvas" dashboards work end-to-end — the two rendering tiers (json-render vs freeform React-in-iframe), the agent system prompts that steer each, and the RIGHT way to fetch PostHog data…

    179 GitHub stars~2.2k tokensUpdated 2 mo ago
    Auto-check passed
  • Dynamic Workflows

    PostHog/code

    Official

    How to write JavaScript workflow scripts for the workflow tool - fanning work out across many isolated subagents with agent(), parallel(), and pipeline(), then synthesizing one result.

    179 GitHub stars~2.3k tokensUpdated 2 mo ago
    Auto-check passed
  • MCP Servers

    PostHog/code

    Official

    Install, configure, authenticate, and troubleshoot MCP (Model Context Protocol) servers for this agent.

    179 GitHub stars~1.9k tokensUpdated 2 mo ago
    Auto-check passed
  • Onboarding Videos

    PostHog/code

    Official

    Add, replace, and optimize the looping demo videos in the onboarding "welcome" bento grid (packages/ui/src/features/onboarding).

    179 GitHub stars~1.7k tokensUpdated 2 mo ago
    Auto-check passed
  • Quill Code

    PostHog/code

    Official

    Edit the @posthog/quill design system locally and consume the change in this repo (posthog-code) before it is published to npm.

    179 GitHub stars~1.1k tokensUpdated 2 mo ago
    Auto-check passed
  • Storybook Stories

    PostHog/code

    Official

    Write Storybook stories for PostHog UI components. An agent skill from PostHog/code.

    179 GitHub stars~929 tokensUpdated 2 mo ago
    Auto-check passed

Questions about Merging PRs

What does Merging PRs do?

Merge a PR into main through the Trunk merge queue and babysit it until it lands. Merging PRs is an agent skill from PostHog/code, published by the product's own GitHub organization. Merge a PR into main through the Trunk merge queue and babysit it until it lands.

When should I use Merging PRs?

Merging PRs fits situations like: asked to merge a PR; merge when ready; babysit/watch a PR through the queue.

How do I install Merging PRs in Claude Code?

Run `npx skills add PostHog/code --skill merging-prs -a claude-code`. Or copy the skill folder (.claude/skills/merging-prs in PostHog/code) into .claude/skills/merging-prs in your project. Claude Code loads it when a task matches its description.

How do I install Merging PRs in Codex?

Run `npx skills add PostHog/code --skill merging-prs -a codex`. Or copy the skill folder (.claude/skills/merging-prs in PostHog/code) into .agents/skills/merging-prs in your project. Codex loads it when a task matches its description.

Can I use Merging PRs in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add PostHog/code --skill merging-prs -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/merging-prs, .gemini/skills/merging-prs, .github/skills/merging-prs and .opencode/skills/merging-prs in your project.

What does Merging PRs need to run?

Going by SKILL.md and its folder, Merging PRs needs the command-line tools its instructions call (gh). Its frontmatter pre-approves these tools: Bash(gh pr view:*), Bash(gh pr checks:*), Bash(gh pr comment:*), Bash(gh pr ready:*), Bash(gh api:*), Bash(sleep:*).

Does Merging PRs access the network?

SKILL.md names 1 domain. As links in the text: trunk.io. This is read from the text; nothing was executed.

Is Merging PRs safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Merging PRs use?

Merging PRs is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Merging PRs use?

About 1.3k tokens (SKILL.md is roughly 5.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Merging PRs?

Skills that share tags, products or a category with Merging PRs: Merging PRs (PostHog/posthog, 40k stars), Merge Dependabot PRs (onyx-dot-app/onyx, 32k stars), Triaging Merge Queue Failures (PostHog/posthog, 40k stars) and Archestra Merge Queue (archestra-ai/archestra, 4.4k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Merging PRs?

PostHog (a GitHub organization, an official publisher) maintains it in PostHog/code, which has 179 GitHub stars. The repository holds 10 skills in this directory. The repository was last updated on August 5, 2026.

Source: PostHog/code on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.