: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(devex): prefer trunk CLI over PR comments for queue actions (#113042)
Julian Bez3a2be6344e6c
diff --git a/.agents/skills/debugging-ci-failures/SKILL.md b/.agents/skills/debugging-ci-failures/SKILL.mdindex f7a731b28b94..c94d40adc200 100644--- a/.agents/skills/debugging-ci-failures/SKILL.md+++ b/.agents/skills/debugging-ci-failures/SKILL.md@@ -303,8 +303,8 @@ is copy-ready; that skill also owns the wider investigation.Read the result as:- **Low percentage, recent hours mostly green** — transient. Report and move on.- For a queued PR, recommend re-enqueueing rather than a code change; posting- `/trunk merge` yourself needs approval, per the Safety rules above.+ For a queued PR, recommend re-enqueueing rather than a code change; running+ `trunk merge` yourself needs approval, per the Safety rules above.- **Recent hours entirely red** — an outage, not a flake. Say so, and stoptelling people to retry. Check <https://www.githubstatus.com/> beforeattributing it to this repository; a platform incident makes every otherdiff --git a/.agents/skills/merging-prs/SKILL.md b/.agents/skills/merging-prs/SKILL.mdindex d534633ca72b..675d4bd8139f 100644--- a/.agents/skills/merging-prs/SKILL.md+++ b/.agents/skills/merging-prs/SKILL.md@@ -2,10 +2,11 @@name: merging-prsdescription: >Merge a PR into `master` through the Trunk merge queue and babysit it until it- lands. Enqueue with a `/trunk merge` comment, then watch `trunk merge status`+ lands. Enqueue with the `trunk merge` CLI (the `/trunk merge` comment is the+ fallback), then watch `trunk merge status`and the PR state until it is MERGED or the queue kicks it out, reportingTrunk's own reason for the terminal transition. Use when asked to merge a PR,- "merge when ready", "land it", "ship it", to merge a whole stack (comment on+ "merge when ready", "land it", "ship it", to merge a whole stack (enqueuethe top PR — the queue merges it and every layer below atomically), to get aPR approved by stamphog (MCP review request first, `stamphog` label as thefallback), or to babysit/watch a PR through the@@ -17,7 +18,9 @@ description: >Merges into `master` go **exclusively** through the [Trunk](https://trunk.io) 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.+To merge, you enqueue the PR with the `trunk` CLI, then watch it until Trunk lands it.+Use the `trunk` CLI for queue actions (enqueue, status, cancel). Post a `/trunk ...` comment on the PR only when the CLI is not available, or for an option the CLI does not have (see step 2).+The CLI talks to Trunk over an authenticated session and reports the result at once. A comment adds noise to the PR thread, and you only learn whether Trunk took it from the bot's reply.## Required user approval@@ -58,18 +61,26 @@ gh pr view <n> --json state,isDraft,mergeable,reviewDecision,statusCheckRollup,b- **Refusals.** A `409 not_reviewable` means stamphog does not review this PR at all (a draft, closed, bot-authored, from outside the repo, or an author without write access). The message says which. The label cannot help there, so report it.- **Label (fallback).** Use `gh pr edit <n> --add-label stamphog` when the MCP tool is not in your tool list, when the call fails on auth, or when it returns `404 not_found` (the repo is not connected in that PostHog project) or `503`. The label is sticky across ordinary pushes (non-trivial deltas re-review automatically), and it gets stripped on a `REFUSED`/`ESCALATE` verdict. Each verdict is its own review from the Stamphog app, opening with whether it approved.- **Either route:** read the reason before you retry. A retry without a change repeats the same verdict. Stamphog never approves bot-authored PRs.-- **Part of a stack** (`baseRefName != "master"`, or the PR appears in `gh api repos/$REPO/stacks`) → the queue handles stacks natively: enqueueing a PR enqueues it **and every unmerged layer below it**, tests them together, and merges them atomically. After explicit user approval, comment `/trunk merge` on the **top** PR to merge the whole stack, or on the highest layer you want landed to merge just the bottom part. Run this preflight on every layer being merged, not only the one you comment on. `/stacking-prs` covers restack mechanics and the post-merge `gh stack sync --prune`.+- **Part of a stack** (`baseRefName != "master"`, or the PR appears in `gh api repos/$REPO/stacks`) → the queue handles stacks natively: enqueueing a PR enqueues it **and every unmerged layer below it**, tests them together, and merges them atomically. After explicit user approval, enqueue the **top** PR to merge the whole stack, or the highest layer you want landed to merge just the bottom part. Run this preflight on every layer being merged, not only the one you enqueue. `/stacking-prs` covers restack mechanics and the post-merge `gh stack sync --prune`.## 2. EnqueueConfirm the required explicit user approval before running this command. If it is absent, report that the PR is ready and stop.```bash-gh pr comment <n> --body "/trunk merge"+trunk merge <n>```For a stack, `<n>` is the highest layer you want merged — it and everything below it enqueue together (see the stack preflight bullet above).-Append `--no-batch` to the comment to have the queue test the PR (or stack) alone instead of batched with other queued PRs.+`--priority <0-255>` sets the queue priority (0 is highest and skips the line); use it only when the developer asks.++Fall back to a PR comment only when the CLI is not usable: `trunk` is not installed, or `trunk merge` fails on auth (no `trunk login`).++```bash+gh pr comment <n> --body "/trunk merge"+```++The CLI has no flag for an unbatched run. When the developer wants the queue to test the PR (or stack) alone instead of batched with other queued PRs, use the comment with `--no-batch` appended.Within ~2 minutes, confirm Trunk picked it up:@@ -94,9 +105,9 @@ If nothing appears after a couple of minutes, check in this order:gh run list --branch "$(gh pr view <n> --json headRefName -q .headRefName)" --workflow "PR housekeeping" --limit 3```-2. Whether the developer has write access, or GitHub-comment commands are- disabled — report that and suggest the `trunk-merge-queue-submit` label as a- fallback.+2. Whether the developer has write access. If you enqueued with a comment, also check+ whether GitHub-comment commands are disabled — report that and suggest `trunk merge <n>`+ or the `trunk-merge-queue-submit` label as a fallback.## 3. Watch until it lands@@ -168,10 +179,11 @@ Optionally, Trunk's MCP server (`https://mcp.trunk.io/mcp`, OAuth or bearer tokeIf the developer asks to stop the merge:```bash-gh pr comment <n> --body "/trunk cancel"+trunk merge cancel <n>```-Confirm the check run reports cancelled.+Without the CLI, comment `/trunk cancel` on the PR instead.+Confirm that `trunk merge status <n>` reports `Cancelled`.## The pre-push merge queue guard@@ -182,7 +194,7 @@ When the guard blocks you, leave the branch alone and put further changes on a nTo update the queued PR on purpose, run `trunk merge cancel <n>` (or comment `/trunk cancel`), wait for it to leave the queue, then push.The check fails open — missing `gh` or `trunk`, not logged in, offline, API errors — and `TRUNK_QUEUE_PUSH_CHECK_DISABLED=1` skips it.-`trunk login` arms it, which is why the one-time interactive login is worth running even if you prefer the PR comments.+`trunk login` arms it and enables `trunk merge` and `trunk merge cancel`, so run the one-time interactive login when you can. Without it, the PR comments in steps 2 and 5 still work.## Hard rulesdiff --git a/.agents/skills/stacking-prs/SKILL.md b/.agents/skills/stacking-prs/SKILL.mdindex cb7debc5f7a7..fab2534a6932 100644--- a/.agents/skills/stacking-prs/SKILL.md+++ b/.agents/skills/stacking-prs/SKILL.md@@ -6,7 +6,7 @@ description: >restack or rebase a stack, adopt existing branches or PRs into a stack, check outsomeone else's stack, or land a stack. Covers creating and submitting stacks(draft-first), cascade rebases with `gh stack sync`, and landing one through the- Trunk merge queue via `/merging-prs` — whole-stack via `/trunk merge` on the top+ Trunk merge queue via `/merging-prs` — whole-stack via `trunk merge` on the toplayer, or bottom-first — never `gh stack merge`.---@@ -93,7 +93,7 @@ Both paths go through the Trunk merge queue via `/merging-prs`; never `gh stack**Whole stack at once (default).**The queue handles stacks natively: enqueueing a PR enqueues it and every unmerged layer below it, tests them together, and merges them atomically.-After explicit user approval, comment `/trunk merge` on the **top** PR to land the whole stack, or on the highest layer that's ready to land just the bottom part.+After explicit user approval, run `trunk merge <n>` on the **top** PR to land the whole stack, or on the highest layer that's ready to land just the bottom part. `/merging-prs` has the comment fallback for when the CLI is not available.Every layer being merged must individually pass `/merging-prs` preflight (ready, approved, no failing checks — pending ones are fine, the queue waits for them) — a mid-stack draft or missing approval blocks the layers above it.**Bottom-first, one layer at a time.**diff --git a/.agents/skills/triaging-merge-queue-failures/SKILL.md b/.agents/skills/triaging-merge-queue-failures/SKILL.mdindex fea20b41f5b4..15f0e0a64b14 100644--- a/.agents/skills/triaging-merge-queue-failures/SKILL.md+++ b/.agents/skills/triaging-merge-queue-failures/SKILL.md@@ -104,7 +104,7 @@ A person who does need to read the wording runs the helper themselves with `MQ_F- This job reads, classifies, and (when permitted) requeues. Never `gh pr merge`, approve, close, or convert PRs; never push code; never rewrite history. Fixing the PR is the author's job, and the run report says what to fix.- **Comment on a PR only when the sweep acted on it.** The one action available is a requeue, so the one comment the sweep writes on a PR is the one recording a `/trunk merge` it sent. Every other verdict — wait, hold, wider issue, escalate — goes in the run report and nowhere near the PR. Never post a comment saying what the sweep did not do or why it declined to act: its author cannot use it, and a PR that collects one of those per fire teaches everyone to ignore the comments that do carry an action.-- A requeue (`gh pr comment <n> --body "/trunk merge"`) can land code in `master`, so it is gated. Interactively it needs explicit user approval in the current conversation, exactly as `/merging-prs` prescribes. In an unattended run it additionally needs `MQ_TRIAGE_ALLOW_REQUEUE=1` in the run environment (the operator's standing approval; see references/routine-setup.md); without it, every verdict is report-only.+- A requeue can land code in `master`, so it is gated. Interactively it needs explicit user approval in the current conversation, exactly as `/merging-prs` prescribes, and it goes through `trunk merge <n>` when the CLI is installed and logged in. In an unattended run it additionally needs `MQ_TRIAGE_ALLOW_REQUEUE=1` in the run environment (the operator's standing approval; see references/routine-setup.md); without it, every verdict is report-only. The unattended sweep sends the requeue as a PR comment (`gh pr comment <n> --body "/trunk merge"`), because the sandbox has no `trunk` CLI and `submit_rejected` reads Trunk's reply to that comment.- **Never requeue when `verify` reports a marker author mismatch.** A sweep whose markers do not dedupe re-triages the same PR every fire, so an armed requeue switch would resubmit the same PR hour after hour. Report-only is the fail-closed state. An "unverified" report on a first run is not a mismatch and does not block.- **Requeue only a PR the queue has dropped.** `kicked_failed`, `removed` and `unknown` are the only requeue-eligible states. On `failed` the entry is still queued and Trunk may merge it without you; on `submitted`, `queued`, `testing`, `batched` or `passing` an attempt is in flight. Resubmitting any of those cannot help and can land on a PR that has already merged.- **Re-read the facts in the same step that acts on them.** A sweep spends minutes between classifying a PR and acting on it, and the queue moves in that window. Immediately before posting `/trunk merge`, re-run `state` and re-read the PR, and drop the requeue if anything has moved. A dropped requeue is a dropped comment too, so a classification that went stale costs nothing but the read.