Skip to content
Skill

Gh PR merge unstable state needs auto and watch branch deletes

Diagnoses stuck gh pr merge errors and restores deleted PR branches safely

Gh PR merge unstable state needs auto and watch branch deletes is an open-source agent skill for developer tools. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

Scripts
None
Platforms
Claude Code, Codex, Cursor
GitHub stars
5
Last commit
License
MIT
Listing updated

Similar skills

About Gh PR merge unstable state needs auto and watch branch deletes

This skill covers a set of gh pr merge failures that look like merge conflicts but are not. It explains how to read the mergeable and mergeStateStatus fields to tell pending checks from real file conflicts, and when to queue a merge with the --auto flag instead of retrying.

It also walks through recovery when a PR was closed because its remote branch was deleted, including restoring the branch from a local copy or from the PR's pull ref, reopening the PR, and marking a draft as ready. A further section covers a draft PR error and recommends gating branch cleanup on a non-null mergedAt value rather than on whether the branch exists.

The workflow is built from gh commands and git push and fetch commands, with no bundled scripts. It expects the GitHub CLI and git to be available and an authenticated session with rights to the repository.

When your agent uses it

Diagnose and recover from two adjacent `gh pr merge` failure modes that masquerade as merge conflicts. Use when: (1) `gh pr merge --squash` (or `--merge`) errors with "To have the pull request merged after all the requirements have been met, add the `--auto` flag" AND "Run the following to resolve the merge conflicts locally" even though you just pushed a clean resolution; (2) `gh pr view <N> --json mergeable,mergeStateStatus` returns `MERGEABLE` + `UNSTABLE` rather than `MERGEABLE` + `CLEAN`; (3) you delete the remote branch (`git push origin --delete <branch>`) immediately after `gh pr merge` returns a conflict warning thinking the merge succeeded — and discover the PR has flipped to `CLOSED` rather than `MERGED`. The actual root cause for (1)/(2) is almost always pending CI / branch-protection checks, NOT real merge conflicts; the fix is `--auto` flag so `gh` queues the merge for when checks pass. For (3) — recovery requires restoring the remote branch (`git push -u origin <branch>` from your local copy, O

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 1 file (12 KB) on GitHub on 4 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Check another skill before you install it.

Install

This skill ships in the agent-traffic-control plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

/plugin marketplace add wan-huiyan/agent-traffic-control
/plugin install agent-traffic-control@wan-huiyan-agent-traffic-control

Or copy only this skill to ~/.claude/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes &&
cp -R "$tmp/plugins/agent-traffic-control/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes" ~/.claude/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes &&
rm -rf "$tmp"

For one project only, put the folder in .claude/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes inside it instead.

Claude Code docs on skills

Copy the skill folder to ~/.agents/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes to use it in every repository:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes &&
cp -R "$tmp/plugins/agent-traffic-control/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes" ~/.agents/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes &&
rm -rf "$tmp"

For one repository only, put the folder in .agents/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes inside it instead.

Codex docs on skills

Copy the skill folder to ~/.cursor/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes to use it in every project:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes &&
cp -R "$tmp/plugins/agent-traffic-control/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes" ~/.cursor/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes &&
rm -rf "$tmp"

For one project only, put the folder in .cursor/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes inside it instead.

Cursor docs on skills

Run in a terminal (add --scope workspace to install it for the current workspace only):

gemini skills install https://github.com/wan-huiyan/agent-traffic-control.git --path plugins/agent-traffic-control/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes

Or copy the folder to ~/.gemini/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes yourself.

Gemini CLI docs on skills

For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes &&
cp -R "$tmp/plugins/agent-traffic-control/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes" ~/.copilot/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes &&
rm -rf "$tmp"

For one project only, put the folder in .github/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes inside it instead.

VS Code docs on skills

Get the folder:

git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git

Then copy agent-traffic-control/plugins/agent-traffic-control/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes into your agent's skills folder as gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes. Agents that support SKILL.md read one folder per skill.

The SKILL.md format

What it does

Merge state diagnosis
Reads mergeable and mergeStateStatus values to separate pending checks from real conflicts.
Auto-queued merges
Uses gh pr merge with --auto so GitHub merges once required checks pass.
Branch restoration
Recreates a deleted remote branch at the exact PR head commit so the PR re-links.
Draft PR handling
Marks a draft pull request as ready before attempting a merge.
Safe branch cleanup
Gates remote branch deletion on a recorded merge timestamp instead of branch existence.

Good for

  • Merge a pull request that shows UNSTABLE while CI is still running
  • Recover a PR that closed after its head branch was accidentally deleted
  • Restore a branch from a PR's pull ref when no local copy exists
  • Mark a draft pull request ready and merge it
  • Write a cleanup script that deletes branches only after a confirmed merge

Gh PR merge unstable state needs auto and watch branch deletes FAQ

Does Gh PR merge unstable state needs auto and watch branch deletes need any tools installed?

It relies on the GitHub CLI (gh) and git, using commands such as gh pr view, gh pr merge, gh pr reopen, gh pr ready and git push and fetch.

What does the --auto flag change?

It tells GitHub to wait for branch-protection requirements and merge automatically once they are met, so the merge is queued rather than attempted immediately.

What should I check before deleting a remote branch after a merge error?

Run gh pr view with the mergedAt field and delete the branch only if mergedAt is not null, because a failed merge can leave the PR open or closed without merging.

Is Gh PR merge unstable state needs auto and watch branch deletes related to other merge problems?

Yes, it points to a sibling skill for the case where gh pr merge --delete-branch fails locally because main is checked out in a worktree.

How do I install Gh PR merge unstable state needs auto and watch branch deletes in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes to use it in all your projects, or to .claude/skills/gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes in one project. Or install the agent-traffic-control plugin, which includes it: /plugin marketplace add wan-huiyan/agent-traffic-control, then /plugin install agent-traffic-control@wan-huiyan-agent-traffic-control.

Does Gh PR merge unstable state needs auto and watch branch deletes run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Gh PR merge unstable state needs auto and watch branch deletes?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

What are the best alternatives to Gh PR merge unstable state needs auto and watch branch deletes?

The closest alternatives to Gh PR merge unstable state needs auto and watch branch deletes are Gh PR merge worktree checkout trap, Merge PR, Gha PR merge ref shows upstream changes, Auto merge rearms while agent live kill then disarm verify and Gh PR pickup designated branch supersede.

Where this comes from

  • Description: from the skill's own SKILL.md.

More from wan-huiyan/agent-traffic-control