pr-guardian
Skill0 starsChanged 11 days agoApache-2.0View on GitHub
Watch one pushed branch in the background until its pull request is green, merged or blocked: a guardian agent rebases on the default branch, fixes what CI and the reviewers report, commits and pushes per the repo's configured policy, and reports with proof. One guardian per branch, a write lock so a human and the agent never race on the same push, and re-adoption of the branches whose guardian died with its session. Use when someone says "watch my PR", "babysit this branch until green", "is my branch mergeable", "keep this PR mergeable", or right after a push. `--dry-run` prints the diagnosis and the action plan without pushing anything. Also checks the prerequisites and offers to install or configure what is missing: "set up pr-guardian", "check my setup", "is my machine ready". Needs git, gh (authenticated, repo scope), jq, coreutils timeout and bash 3.2 or newer — Git Bash on Windows.
- Commits and pushes
3 other projects use a version of this.
Adopted by
Most recently taken up by
- stoa-platform/stoatheir own version, first seen Nov 1, 2026
- subhansh-dev/pr-guardiantheir own version, first seen Jul 13, 2026
- s-hiraoku/synapse-a2atheir own version, first seen May 6, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- s-hiraoku/synapse-a2a★ 17same name
- stoa-platform/stoa★ 9same name
- subhansh-dev/pr-guardian★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository6 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- dead-code-auditSkill
- front-reviewSkill
- intakeSkill
- pr-todoSkill
- sentry-triageSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 0 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 42
After a fix, run doctor again and relay it.
- Very specific: line 58
If the same script's get --repo <repo> --branch <branch> already shows a live entry with an agent, do not dispatch a second one: …
- Very specific: line 67
When the agent reports, relay its first line (GREEN, MERGED, BLOCKED, UNREVIEWED or DRY-RUN) and the PR URL, then what needs a human.
- Very specific: line 78
Read from <repo>/.pr-guardian.json, else ~/.config/pr-guardian.json, else the default.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
PR guardian
Three entry points, one script and one agent. <skill-dir> is the directory holding this
file; the script is scripts/pr-guardian.sh (--help lists every command), the agent is
agents/pr-guardian.md, dispatched as subagent_type: "pr-guardian".
| Caller says | Do |
"set up pr-guardian", "check my setup", "is my machine ready", doctor | the setup procedure below: doctor, then doctor --fix and config init as proposals. |
"watch my PR", "babysit this branch", "keep it mergeable", watch [<branch>] [--dry-run] | the watch procedure below. No branch named: the current one. |
"is my branch mergeable", "what would the guardian do", watch --dry-run | watch with --dry-run: the agent runs doctor and plan, prints the action list, pushes nothing, and ends with DRY-RUN. |
"which guardians are running", status | bash <skill-dir>/scripts/pr-guardian.sh list, then one plan --repo <repo> --branch <branch> per live entry; relay both. |
setup
bash <skill-dir>/scripts/pr-guardian.sh doctor. Relay its lines verbatim, oneok/FAIL/skipper check; every check runs, the exit code is 1 when any failed.- No
FAIL: say in one line that the machine is ready, then go to step 5. - Any
FAIL:bash <skill-dir>/scripts/pr-guardian.sh doctor --fix. It runs nothing; it prints onefix: <command>per failed check whose hint is a command. Present each one as a proposal and run only what the user approves, never an install command of your own.gh auth loginis interactive: the user runs it in their own terminal. On Windows say the command may need an elevated terminal. AFAILwith nofix:line (shell,state) is fixed by hand as its hint says. - After a fix, run
doctoragain and relay it. Stop while aFAILremains. - Propose
bash <skill-dir>/scripts/pr-guardian.sh config init --dir <repo>in one line (exists: <path>means the repo already has one;--dry-runshows the file) and ask two things: does a bot open the PRs (thenpr.createisfalse) and does the team squash-merge (thencommitsis"amend"). Explain a key with its row in the table below, one line each, when the user asks or answers.
watch
bash <skill-dir>/scripts/pr-guardian.sh doctor. On aFAILline, relay it and stop — nothing is dispatched until it passes; the setup procedure is the way to fix it.- Resolve the target:
repoasowner/namefromgit remote get-url origin,branch(the argument, elsegit rev-parse --abbrev-ref HEAD),worktreefromgit rev-parse --show-toplevel, HEAD fromgit rev-parse --short HEAD. - Register the entry and keep the id it prints:
bash <skill-dir>/scripts/pr-guardian.sh register --repo <repo> --branch <branch> --worktree <worktree> --sha <head>. If the same script'sget --repo <repo> --branch <branch>already shows aliveentry with an agent, do not dispatch a second one:SendMessagethat agent instead. - Dispatch the agent, in the background, with a brief that carries verbatim:
repo,branch,worktree,guardian id,script: <skill-dir>/scripts/pr-guardian.sh, HEAD and its subject, your own agent handle,--dry-runwhen asked, and the acceptance: PR mergeable, every required check green, no unresolved review thread. - Right after the Agent tool returns, record the handle — an unregistered guardian is
unreachable:
bash <skill-dir>/scripts/pr-guardian.sh set --id <id> --agent "<handle>". Tell the user in one line that the guardian is running and how to reach it. - When the agent reports, relay its first line (
GREEN,MERGED,BLOCKED,UNREVIEWEDorDRY-RUN) and the PR URL, then what needs a human. Subagent output never reaches the user on its own.
The plugin's hooks do steps 2 to 5 for you after every successful git push on a
feat/, fix/, chore/, refactor/, perf/, docs/, ci/ or test/ branch, and
list the orphaned guardians at session start. This procedure is for a branch pushed
before the plugin was installed, a guardian someone stopped, or a dry run.
Configuration
Read from <repo>/.pr-guardian.json, else ~/.config/pr-guardian.json, else the default.
bash <skill-dir>/scripts/pr-guardian.sh config <key> --dir <repo> prints the value in force;
config init --dir <repo> writes the file with the defaults when the repo has none.
| Key | Default | Effect |
orgs | [] (any owner) | The hooks act only on repositories whose owner is listed; a manual watch ignores it. |
pr.create | true | The guardian opens the PR when none exists. false: it never runs gh pr create and waits for one. |
commits | "stack" | Fixes are new commits; --force-with-lease only after a rebase. "amend": every fix is amended into the branch's single commit. |
pr.sync_body | false | true: after an amend that rewrote the message, the PR body (and title) are rewritten from the head commit. |
review_bots | [] | Logins whose conversation comments count as review findings and must cover HEAD before the PR is GREEN. |
A team whose bot opens the PR from the pushed commit, squash-merges, and builds the description from the commit body:
{ "orgs": ["my-org"], "pr": { "create": false, "sync_body": true }, "commits": "amend", "review_bots": ["review-bot[bot]"] }Prerequisites
bash <skill-dir>/scripts/pr-guardian.sh doctor — bash 3.2+, git, gh authenticated with the
repo scope, jq, coreutils timeout, Git Bash on Windows, a writable state directory
($PR_GUARDIAN_HOME, default ~/.pr-guardian). One line per check, every check runs, exit
1 when any FAIL, each with the install command for the OS; doctor --fix lists those
commands as fix: lines and runs none of them.
State file, lock semantics, hook events, plan lines, report vocabulary and every failure
line: reference.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

