From 52677844c6a8540bb9b4fcb236bd96c10c13edb0 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 7 Oct 2026 23:09:29 +0000 Subject: [PATCH 1/2] merge-green-prs: only merge PRs with auto-merge switched on The 'Auto merge when complete' checkbox in Claude Code's CI button (GitHub auto-merge, a non-null auto_merge on the PR) now enables the skill per PR. If the flag is off or not visible, the PR is reported and left alone. The skill never toggles it. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_014k4kywyN5dAo39izUPvxbw --- .claude/skills/merge-green-prs/SKILL.md | 12 ++++++++---- CLAUDE.md | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.claude/skills/merge-green-prs/SKILL.md b/.claude/skills/merge-green-prs/SKILL.md index 10b86f2..3eda4b0 100644 --- a/.claude/skills/merge-green-prs/SKILL.md +++ b/.claude/skills/merge-green-prs/SKILL.md @@ -1,6 +1,6 @@ --- name: merge-green-prs -description: Check this repo's open pull requests and merge the ones from claude/* branches whose tests have passed. Use when asked to merge green PRs, watch PRs, or clear the PR queue. Never merges a PR from any other branch. +description: Check this repo's open pull requests and merge the ones from claude/* branches whose tests have passed AND that have auto-merge switched on (the "Auto merge when complete" checkbox in Claude Code's CI button). Use when asked to merge green PRs, watch PRs, or clear the PR queue. Never merges a PR from any other branch, or one with auto-merge off. --- # Merge green PRs @@ -15,19 +15,23 @@ A PR is merged only if ALL of these hold; otherwise report it and leave it alone 4. `mergeable_state` is `clean` (not `blocked`, `behind`, `dirty`, `unstable`, `draft`, `unknown`). 5. Its check runs (`get_check_runs`) exist, are all `completed`, and every one has conclusion `success`. 6. No review with `CHANGES_REQUESTED` (`get_reviews`) and no unresolved review thread (`get_review_comments`). +7. Auto-merge is ON for the PR. That is the "Auto merge when complete" checkbox in Claude Code's CI button, which sets + GitHub's auto-merge: `pull_request_read` `get` shows a non-null `auto_merge` object. Unticked means do not merge. If the + field is absent you cannot tell, so treat it as off and say so. The checkbox is the user's switch: never enable or + disable auto-merge yourself. ## Steps 1. `list_pull_requests` (state `open`). Skip, with the reason, everything that fails 1-3. 2. For each remaining PR, read it fresh from GitHub: `pull_request_read` `get`, `get_check_runs`, `get_reviews`, `get_review_comments`. Never rely on earlier results or memory for a PR's state. -3. Checks still `queued` or `in_progress` -> "waiting", do nothing. Any failure -> "red", say which check, do not merge. +3. Auto-merge off -> "auto-merge off", do nothing (green or not). Checks still `queued` or `in_progress` -> "waiting", do nothing. Any failure -> "red", say which check, do not merge. `behind` or conflicted -> report; do not update the branch or merge without being asked. 4. Eligible -> `merge_pull_request` with `merge_method: merge` and `expectedHeadSha` set to the head SHA you just read (so a push that lands in between aborts the merge). 5. Read the PR back from GitHub and confirm `merged: true`. If the session was subscribed to it, unsubscribe. -6. Finish with one table: PR number and title, outcome (merged / waiting / red / blocked / skipped), and the reason. +6. Finish with one table: PR number and title, outcome (merged / waiting / red / blocked / auto-merge off / skipped), and the reason. ## Never -- Merge a PR from a branch that doesn't start with `claude/`, a fork, a draft, or one with a failing, missing or pending check. +- Merge a PR from a branch that doesn't start with `claude/`, a fork, a draft, one with auto-merge off, or one with a failing, missing or pending check. - Skip, disable or re-run tests to get green; push to a PR's branch; force-push; approve reviews; close PRs; delete branches. - State a PR's status without reading it from GitHub in this run. diff --git a/CLAUDE.md b/CLAUDE.md index 82b0369..71d3a2c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -7,7 +7,7 @@ MCP data tools and web search. User-facing docs are in `README.md`; this file is - `make check`: ruff + pytest (no network, a few seconds). Run it before every commit, on Python 3.13.5 (production; `uv venv --python 3.13.5`). GitHub CI runs the latest stable Python and Node.js instead, to catch breakage from the next upgrade early. - `make prompt-report`: token breakdown of a sample request. `python bot.py [label]` runs the bot. -- `/merge-green-prs` (`.claude/skills/merge-green-prs/SKILL.md`): check open PRs and merge the green ones from `claude/*` branches. +- `/merge-green-prs` (`.claude/skills/merge-green-prs/SKILL.md`): check open PRs and merge the green `claude/*` ones that have the CI button's "Auto merge when complete" ticked. - Tests use fakes (`tests/conftest.py`: FakeBot, user_msg; `tests/fakes.py`: ScriptedBackend, FakeMcp, fake SDK clients; `tests/fixtures/` real anonymised MCP output). Add a test next to the module you change; don't write scratch scripts. From db67e4e91495726f2de32057ed1826491676e553 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 7 Oct 2026 23:13:25 +0000 Subject: [PATCH 2/2] Retire the merge-green-prs skill: GitHub auto-merge does the merging The CI button's 'Auto-merge when ready' checkbox is GitHub's native auto-merge, so the skill only duplicated it. CLAUDE.md now says how merging works and what it needs. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_014k4kywyN5dAo39izUPvxbw --- .claude/skills/merge-green-prs/SKILL.md | 37 ------------------------- CLAUDE.md | 3 +- 2 files changed, 2 insertions(+), 38 deletions(-) delete mode 100644 .claude/skills/merge-green-prs/SKILL.md diff --git a/.claude/skills/merge-green-prs/SKILL.md b/.claude/skills/merge-green-prs/SKILL.md deleted file mode 100644 index 3eda4b0..0000000 --- a/.claude/skills/merge-green-prs/SKILL.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -name: merge-green-prs -description: Check this repo's open pull requests and merge the ones from claude/* branches whose tests have passed AND that have auto-merge switched on (the "Auto merge when complete" checkbox in Claude Code's CI button). Use when asked to merge green PRs, watch PRs, or clear the PR queue. Never merges a PR from any other branch, or one with auto-merge off. ---- - -# Merge green PRs - -Repo: the current repository (`owner/repo` from the git remote). Use the GitHub MCP tools (`mcp__github__*`), never `gh`. - -## Which PRs are eligible -A PR is merged only if ALL of these hold; otherwise report it and leave it alone: -1. Open and not a draft. -2. Head branch starts with `claude/` and lives in this same repo (not a fork). -3. Base branch is the default branch. -4. `mergeable_state` is `clean` (not `blocked`, `behind`, `dirty`, `unstable`, `draft`, `unknown`). -5. Its check runs (`get_check_runs`) exist, are all `completed`, and every one has conclusion `success`. -6. No review with `CHANGES_REQUESTED` (`get_reviews`) and no unresolved review thread (`get_review_comments`). -7. Auto-merge is ON for the PR. That is the "Auto merge when complete" checkbox in Claude Code's CI button, which sets - GitHub's auto-merge: `pull_request_read` `get` shows a non-null `auto_merge` object. Unticked means do not merge. If the - field is absent you cannot tell, so treat it as off and say so. The checkbox is the user's switch: never enable or - disable auto-merge yourself. - -## Steps -1. `list_pull_requests` (state `open`). Skip, with the reason, everything that fails 1-3. -2. For each remaining PR, read it fresh from GitHub: `pull_request_read` `get`, `get_check_runs`, `get_reviews`, - `get_review_comments`. Never rely on earlier results or memory for a PR's state. -3. Auto-merge off -> "auto-merge off", do nothing (green or not). Checks still `queued` or `in_progress` -> "waiting", do nothing. Any failure -> "red", say which check, do not merge. - `behind` or conflicted -> report; do not update the branch or merge without being asked. -4. Eligible -> `merge_pull_request` with `merge_method: merge` and `expectedHeadSha` set to the head SHA you just read - (so a push that lands in between aborts the merge). -5. Read the PR back from GitHub and confirm `merged: true`. If the session was subscribed to it, unsubscribe. -6. Finish with one table: PR number and title, outcome (merged / waiting / red / blocked / auto-merge off / skipped), and the reason. - -## Never -- Merge a PR from a branch that doesn't start with `claude/`, a fork, a draft, one with auto-merge off, or one with a failing, missing or pending check. -- Skip, disable or re-run tests to get green; push to a PR's branch; force-push; approve reviews; close PRs; delete branches. -- State a PR's status without reading it from GitHub in this run. diff --git a/CLAUDE.md b/CLAUDE.md index 71d3a2c..f1b0a66 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -7,7 +7,8 @@ MCP data tools and web search. User-facing docs are in `README.md`; this file is - `make check`: ruff + pytest (no network, a few seconds). Run it before every commit, on Python 3.13.5 (production; `uv venv --python 3.13.5`). GitHub CI runs the latest stable Python and Node.js instead, to catch breakage from the next upgrade early. - `make prompt-report`: token breakdown of a sample request. `python bot.py [label]` runs the bot. -- `/merge-green-prs` (`.claude/skills/merge-green-prs/SKILL.md`): check open PRs and merge the green `claude/*` ones that have the CI button's "Auto merge when complete" ticked. +- Merging: tick "Auto-merge when ready" in the PR's CI button; GitHub merges once the required `check` passes (needs "Allow auto-merge" in + the repo settings and `check` as a required status on `main`). - Tests use fakes (`tests/conftest.py`: FakeBot, user_msg; `tests/fakes.py`: ScriptedBackend, FakeMcp, fake SDK clients; `tests/fixtures/` real anonymised MCP output). Add a test next to the module you change; don't write scratch scripts.