# Merge On Green

> merge, ci, github, forgejo, exact-head, polling, safety

- Skill: `lost-rob0t/merge-on-green` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx get-skill add lost-rob0t/merge-on-green`
- Raw SKILL.md: https://api.skillmd.com/api/skills/lost-rob0t/merge-on-green/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: lost-rob0t (https://skillmd.com/u/lost-rob0t)
- Updated: 2026-11-18
- Page: https://skillmd.com/skills/lost-rob0t/merge-on-green

---


# Merge On Green

## Goal

Merge only the exact pull-request head whose required gates and reviews
were verified.

## Workflow

Run `scripts/merge-on-green <pr-number>` from a checkout of the
repository. The provider is detected from the origin remote:
GitHub uses the `gh` CLI; Forgejo uses its REST API with `FORGEJO_TOKEN`.
Override detection with `--provider
github|forgejo` and pass `--repo owner/name` when the remote is
ambiguous.

The helper records the PR head SHA, polls gate state with bounded
exponential backoff, and honors `Retry-After`. Pending, cancelled,
failed, conflicting, draft, closed, missing-review, and rate-limited
states are reported and bounded; it never busy-loops.

## Exact-head invariant

Immediately before merging it re-probes the head. If the head differs
from the validated head, all green evidence is invalidated and
validation restarts for the new SHA. The merged commit is always the
verified commit.

## Rules

- Never equate an old-SHA green result with current green.
- Never duplicate a PR across providers.
- Forgejo review policies requiring team or stale-review evaluation fail closed.
- Exit codes: 0 merged, 2 configuration, 3 provider failure,
  4 blocked/timeout/head churn, 5 rate-limited beyond budget.
- Use `--dry-run` to verify eligibility without merging.
- On timeout or ambiguity, stop without merging and report the blocker.

