/synapse-a2a:pr-guardianfrom synapse-a2a
Monitors a GitHub PR for merge conflicts, CI failures, and CodeRabbit review comments, then automatically fixes issues until all checks pass. Polls every 5 minutes.
Ships in synapse-a2a. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Watch a PR, detect problems, fix them, repeat — until everything is green.
After pushing a PR you typically wait for CI, check for merge conflicts,
and respond to CodeRabbit review comments. Each issue requires a separate
manual step. PR Guardian automates the entire feedback loop: it uses
gh run watch to efficiently wait for CI completion (consuming zero
session cycles while waiting), then polls the PR status, dispatches the
appropriate fix skill when a problem is found, and exits only when all
checks pass (or the iteration limit is reached).
/pr-guardian # Default: 5 min interval, 20 max iterations
/pr-guardian --interval 3 # Poll every 3 minutes
/pr-guardian --max-iterations 10 # Give up after 10 cycles
Before starting the loop, verify:
gh CLI is installed and authenticatedgh pr view)If any check fails, report the error and stop.
gh run watchBefore polling, wait for all GitHub Actions workflow runs to complete
using gh run watch. This blocks at the shell level until CI finishes,
consuming zero Claude Code session cycles while waiting.
# Get the latest workflow run for the current branch
RUN_ID=$(gh run list --branch "$(git rev-parse --abbrev-ref HEAD)" \
--limit 1 --json databaseId --jq '.[0].databaseId' 2>/dev/null || echo "")
if [[ -n "$RUN_ID" ]]; then
# Block until this run completes (exit code reflects pass/fail)
gh run watch "$RUN_ID" --exit-status 2>/dev/null || true
fi
Fallback: If gh run watch is unavailable or fails (e.g., no
workflow runs found yet on the first cycle after push), skip straight
to Step 2 and let the polling script detect checks_running > 0.
Run the bundled status script:
bash <skill-path>/scripts/poll_pr_status.sh
This returns a JSON object with these fields:
| Field | Type | Meaning |
|---|---|---|
branch | string | Current branch name |
pr_number | int | PR number |
checks_total | int | Total CI checks (excludes CodeRabbit) |
checks_passed | int | CI checks that passed |
checks_failed | int | CI checks that failed |
checks_running | int | CI checks still in progress |
has_conflict | bool | Merge conflicts detected |
coderabbit_check | string | CodeRabbit check status: none/pending/pass/fail |
coderabbit_comments | int | Number of CodeRabbit inline comments |
all_green | bool | True when everything passes (including CodeRabbit) |
Important: all_green is only true when ALL of these hold:
pending AND NOT none (review must have completed at least once)✅ Addressed are excluded)Print a concise status line each cycle:
[PR Guardian] Cycle 3/20 — PR #42
CI: 4 passed, 1 failed, 0 running
Conflicts: none
CodeRabbit: review completed, 2 inline comments
→ Action: fixing CodeRabbit comments
When issues are found, fix them one category at a time in this order.
Only fix one category per cycle — after fixing, go back to Step 1 to
re-poll, because a fix may have changed the state (e.g., a push
triggers new CI runs and gh run watch will wait for them).
Priority 1 — Merge conflicts
Merge conflicts block everything else. When has_conflict is true:
/fix-conflictPriority 2 — CI failures
When checks_failed > 0 and checks_running == 0 (Step 1's
gh run watch already waited, so running should normally be 0):
/fix-ciPriority 3 — CodeRabbit review comments
When coderabbit_check == "pass" and coderabbit_comments > 0 and CI
is passing:
/fix-review/fix-review will verify each finding against current code before fixingIMPORTANT: Only dispatch /fix-review when coderabbit_check is
"pass" (review completed). If it is "pending", wait — the review is
still in progress and comments may not be final yet.
The correct action is to wait (not fix) when:
checks_running > 0: CI is still running — this should be rare
since Step 1 already waited via gh run watch, but can happen if
new runs were triggered between watch and pollcoderabbit_check == "pending": CodeRabbit review is in progress —
wait with a short sleep (60-120 seconds) and re-run Step 2 only.
Do NOT go back to Step 1 (gh run watch) — CodeRabbit is not a
GitHub Actions run. Retry up to 5 times before moving to the next
full cyclecoderabbit_check == "none": CodeRabbit hasn't started yet (common
right after a push) — same short-sleep retry as pendingchecks_total == 0 and it's the first cycle: checks haven't started
yet — go back to Step 1 where gh run watch will block until they appearDo not invoke any fix skill while checks are still running or reviews are pending — you would be fixing based on incomplete information.
After each cycle, check:
all_green == true): Print success message and exitIf none of these conditions are met, go back to Step 1. There is no
fixed sleep between cycles — gh run watch in Step 1 provides the
natural wait for CI to complete after a fix push.
| Flag | Default | Description |
|---|---|---|
--interval | 2 | Minutes between CodeRabbit pending retries |
--max-iterations | 20 | Max cycles before giving up |
Success:
[PR Guardian] All checks green! PR #42 is ready.
CI: 6/6 passed | Conflicts: none | CodeRabbit: pass, 0 comments
Completed in 3 cycles over 15 minutes.
Max iterations:
[PR Guardian] Reached 20 cycles without all-green.
Remaining issues:
- CI: tests failing (pytest assertion error in test_auth.py)
- CodeRabbit: 2 unresolved inline comments
Manual intervention needed.
Repeated failure:
[PR Guardian] Same CI failure persisted after 3 fix attempts.
Failing check: tests
Last error: AssertionError in test_auth.py:42
Automatic repair is not resolving this — please fix manually.
/fix-conflict, /fix-ci, and /fix-review.
It does not reimplement their logic — it orchestrates them.gh run watch replaces the old fixed-interval sleep loop for CI
waiting. This eliminates wasted polling cycles and reduces session
consumption from 5-10 cycles to 1-3 for a typical PR.gh run watch handles CI, and a short-sleep retry loop (60-120s, max 5
retries) handles CodeRabbit pending states.gh CLI and
standard git commands. It works outside Synapse environments.gh run watch is unavailable (no runs found, older gh version),
the skill falls back to the polling script detecting
checks_running > 0 and retrying on the next cycle.pending/pass/fail) is tracked
separately from inline comment count. A pending check means
the review is still running — do NOT dispatch /fix-review yet./fix-review verifies each CodeRabbit finding against the current
code before applying fixes — it does not blindly apply suggestions.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
pr-monitoring, ci-automation, merge-conflict, codereview, github-actions
npx claudepluginhub s-hiraoku/synapse-a2a --plugin synapse-a2a24 skills in this plugin
/anthropic-skill-creatorDesign, review, and improve Claude/Codex skills based on Anthropic's "The Complete Guide to Building Skills for Claude". Use when creating a new skill, rewriting SKILL.md frontmatter and workflows, fixing under-triggering or over-triggering, designing scripts/references/assets, building test cases, or preparing a skill for upload/distribution./api-designGuide API design for REST, GraphQL, gRPC, and CLI interfaces. Use this skill when designing new APIs, reviewing existing API contracts, or establishing API conventions for a project. Produces consistent, well-documented API specifications./code-reviewPerform structured code reviews focusing on correctness, readability, security, and maintainability. Use this skill when reviewing pull requests, evaluating code changes, or establishing review standards for a team./code-simplifierSimplifies and refines code for clarity, consistency, and maintainability while preserving all functionality. Focuses on recently modified code unless instructed otherwise. This skill should be used when code-quality checks pass but the code would benefit from structural cleanup — deduplication, branching simplification, naming improvements, or dead-code removal. Invoked as a subagent from /code-quality or directly via the Task tool./dev-issueBootstrap a new GitHub issue implementation in one command: fetch the issue body, gather cross-references and code hotspots, infer a branch prefix and slug, generate a structured task brief, create a fresh branch from latest main, and (by default) spawn a codex agent to implement it. Triggered by /dev-issue <number>. Use this skill when starting work on a new issue that follows the standard issue → codex spawn → review → PR pipeline./doc-organizerAudit, restructure, and consolidate project documentation for clarity and maintainability. Use this skill when docs have grown organically and need reorganization, when duplicate content exists across files, or when documentation structure needs standardization.Other plugins' skills for the same job