From pr-review
Autonomous PR lifecycle agent — monitors CI, triages review comments, auto-fixes trivial issues, and loops until the PR is ready
How this skill is triggered — by the user, by Claude, or both
Slash command
/pr-review:yolo-agentThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Autonomous PR lifecycle agent. Each invocation performs exactly ONE cycle:
Autonomous PR lifecycle agent. Each invocation performs exactly ONE cycle: gather data, analyze, apply fixes, then schedule the next cycle. State is persisted to a JSON file so it survives across cycles.
Do NOT loop. Do NOT sleep. Complete one cycle, schedule the next via CronCreate (interactive) or exit for the Stop hook (headless), then stop.
The user argument is: $ARGUMENTS
$ARGUMENTS: A GitHub PR URL (https://github.com/<org>/<repo>/pull/<number>),
optionally followed by:
--infinite-loop — unlimited iterations (default: 3)--skip-users — ignore human review comments; only process bot comments
(e.g., CodeRabbit). Human comments are excluded from the comment track
entirely: they are not analyzed, not fixed, and not replied to.--yolo — auto-push ALL changes without confirmation, including non-trivial
ones. Security checks still apply: security-sensitive file patterns are never
modified, and all six security validations run before every change regardless
of this flag.**/rbac*, **/*secret*, **/*credential*, **/*token*openshift, openshift-engAuto-push WITHOUT confirmation:
All other changes (new files, logic changes, API changes, multi-package) require explicit user confirmation.
When any script or operation fails, report the error and stop immediately. Do NOT attempt to diagnose, fix, or work around the error. The user must resolve it manually.
Rules:
complete with notes describing the failure. Stop.pr-push.sh exit code 3): Display the full error
output (rejected push, auth failure, non-fast-forward, etc.). Do
NOT run git pull, git rebase, git reset, or force-push. Stop.pr-push.sh exit code 2): Display the
expected vs. staged file lists from the JSON output. Ask the user
whether to retry with the actual staged files. Do NOT unstage,
remove, or gitignore files.gh api, gh pr): Display the HTTP status code
and error body. Do NOT retry. Stop.pr-state.sh load exit code 3): Display the
error. Do NOT initialize fresh state as a fallback — a missing
state file on a continuation cycle indicates a real problem. Stop.Format for error output:
yolo-agent error — <script-or-operation>
Exit code: <N>
Output: <stderr or error JSON>
Stopping. Manual intervention required.
Save state before stopping (if state is available) so the user can
inspect it via pr-state.sh decode. Use set-notes to record the
failure reason.
Parse the PR URL, --infinite-loop flag, --skip-users flag, and --yolo
flag from $ARGUMENTS. Extract org, repo, and PR number. Store skip_users
and yolo_mode as booleans for use in later steps.
Authorship check (run once, before loading state): Get the authenticated
GitHub user (gh api user --jq '.login') and the PR author
(gh pr view <number> --repo <org>/<repo> --json author --jq '.author.login').
If they do not match (case-insensitive), refuse to proceed:
Error: PR #<number> was authored by <pr-author>, but you are authenticated
as <gh-user>. yolo-agent only operates on your own PRs.
Stop immediately — do not load state, do not enter analysis-only mode.
Load state in this order:
PR_MONITOR_STATE env var (continuation from CronCreate or Stop hook)pr-state.sh load <pr-number> (previous cycle saved it)pr-state.sh init <url> <max>If --yolo was provided (or yolo_mode is true in loaded state), set
yolo_mode to true in state via pr-state.sh set yolo_mode true.
If --skip-users was provided (or skip_users is true in loaded state),
set skip_users to true in state via pr-state.sh set skip_users true.
If continuing, set status to running and display iteration number and
previous cycle notes. If the org is not in the trusted allowlist, warn and
enter analysis-only mode.
Run pr-checks.sh <url> and pr-comments.sh <url> <addressed-ids> [--skip-users] to collect CI status and unresolved review comments. If
either script exits with code 3, follow the Error Handling rules and
stop. Pass --skip-users to pr-comments.sh when the flag was
provided — this filters out human comments at the data layer, returning
only bot comments. Extract the branch name from the checks JSON
(.pr.branch) for use in push operations. Increment the cycle counter
via pr-state.sh increment cycle. Display a compact status summary.
Check in order:
complete, clean state file, stopcomplete, clean state file, report "PR is ready", stopLaunch up to TWO parallel Agent calls:
Comment Track (if new comments exist):
The Comment Track routes comments through the team's standardized analysis skills based on author type.
Partition: Separate the inline_comments array from pr-comments.sh
output into two groups using the is_bot field:
is_bot == trueis_bot == falseWhen --skip-users was passed, pr-comments.sh has already filtered
out human comments at the data layer — the human group will be empty.
Dispatch: Launch up to TWO sub-Agent calls in parallel (one per non-empty group). Skip any group that has zero comments.
Bot comments agent:
Run the coderabbit skill in batch mode for this PR:
/pr-review:coderabbit <pr_url> --batch
Return the JSON output verbatim.
Note: The coderabbit skill currently processes only
coderabbitai[bot]comments. Other bot comments are passed through but may not receive specialized analysis. In the future, bot comments may be routed to different skills.
Human comments agent:
Run the vet-review skill in batch mode for this PR:
/pr-review:vet-review <pr_number> --batch
Return the JSON output verbatim.
Merge and classify: Collect the JSON output from each sub-agent and map findings to yolo-agent's classification:
coderabbit category | yolo-agent classification |
|---|---|
auto_apply | trivial — apply directly, batch for auto-push |
review | non-trivial — display diff, ask for confirmation |
dropped | non-actionable — reply with reason, mark addressed |
vet-review status | yolo-agent classification |
|---|---|
survived (any category) | non-trivial — display diff, ask for confirmation |
dropped | non-actionable — reply with reason, mark addressed |
Human review findings are always non-trivial — auto-pushing without confirmation would undermine the review process.
Extract comment IDs: Each finding includes a comment_id field.
Collect all IDs for state tracking via pr-state.sh add-addressed.
Findings with comment_id: null (summary/review-body sourced) should
be displayed but not added to the addressed list.
Edge cases:
| Scenario | Behavior |
|---|---|
| No bot comments | Skip coderabbit dispatch, only run vet-review |
| No human comments | Skip vet-review dispatch, only run coderabbit |
--skip-users active, no bot comments | No Comment Track work, return empty |
--skip-users active | Human group empty, only dispatch coderabbit if bots exist |
| Both groups empty | No Comment Track work, proceed to 2d/2e |
Sub-agent returns {"findings": []} | No findings from that source, merge with other |
CI Track (if failed jobs exist): Check the analyzed list in state and
skip already-analyzed jobs. Route each new failure to the appropriate skill:
| Job name pattern | Analysis method |
|---|---|
install | ci:prow-job-analyze-install-failure |
e2e, tests, conformance, serial, parallel, scenario | ci:prow-job-analyze-test-failure |
images, build, verify, unit, lint | Fetch build-log.txt, analyze directly |
| Default | ci:prow-job-analyze-test-failure |
Classify each failure as infrastructure (recommend retrigger) or code (propose fix as trivial or non-trivial).
For each proposed change, run ALL security checks before applying: file pattern check, credential scan, permission escalation check, command injection check, dependency change check, scope check. If ANY fails, refuse and report which check failed.
--yolo is active, apply directly and batch
for auto-push (same as trivial). Otherwise, display diff and ask for
confirmation/retest commentAfter applying, push via pr-push.sh <branch> <message> --expected-files <files>.
On any non-zero exit code, follow the Error Handling rules above.
On successful push, reply to each addressed comment on the PR with a brief
description of what was done (e.g., "Renamed variable to snake_case",
"Added missing import for fmt"), followed by the footer. Update state:
set last_push_cycle, add addressed comment IDs and analyzed job keys.
For non-actionable comments, reply with the reason why it was not addressed (e.g., "Already fixed in a previous commit.", "Non-trivial change — deferred to a follow-up PR."), followed by the footer.
All PR comment replies MUST use this format:
<description of what was done or why it was not addressed>
This message is AI generated by the yolo-agent of [edge-tooling](https://github.com/openshift-eng/edge-tooling).
If no changes were proposed: reply to non-actionable comments with reasons, mark all comment IDs as addressed in state.
Determine delay based on what happened:
| Condition | Delay |
|---|---|
| New comments arrived (CodeRabbit may still be posting) | 180s |
| Changes just pushed this cycle | Shortest pending job category (min 300s) |
| No push, jobs pending | 600s |
| Only slow jobs, no new comments | 900s |
Job wait time classification:
| Job name pattern | Wait |
|---|---|
unit, verify, lint, images, build | 300s |
e2e, conformance | 900s |
install, serial, scenario | 1800s |
Update state with notes, delay, and status=waiting. Save state via
pr-state.sh save <pr-number>.
Interactive mode: Schedule next cycle with CronCreate (one-shot,
recurring: false, durable: false). Prompt: /pr-review:yolo-agent <url>
(append --infinite-loop if max_iterations is 0, append --skip-users if
the flag was provided, append --yolo if yolo_mode is active). The cron
expression MUST use the machine's local
time (run date '+%H:%M' to get it), NOT UTC. Then stop.
Headless mode: Just exit. The Stop hook reads the saved state, sleeps
for next_check_delay, and spawns a new claude -p session.
Interactive (user in terminal): CronCreate one-shot schedules the next cycle within the same session. User sees output and can approve non-trivial changes.
Headless (claude -p): The Stop hook fires on exit, reads state from
the file, sleeps, and spawns a new claude -p "/pr-review:yolo-agent <url>".
Fully autonomous but cannot prompt for confirmation.
All scripts are in ${PLUGIN_DIR}/scripts/. You MUST use these scripts
for the operations they cover. Do NOT bypass them with raw gh commands,
direct jq state manipulation, manual git push, or ad-hoc replacements.
| Script | Purpose | Args | Exit codes |
|---|---|---|---|
pr-state.sh | ALL state operations | init <url> [max], save <n>, load <n>, clean <n>, get <field>, set <field> <value>, increment <field>, set-notes <text>, set-status <status>, add-addressed <id>, add-analyzed <key>, decode | 0=ok, 3=error |
pr-checks.sh | Fetch PR metadata + CI status | <pr-url> | 0=all pass, 1=failures, 2=pending only, 3=error |
pr-comments.sh | Fetch unresolved review comments | <pr-url> [addressed-ids] [--skip-users] | 0=has comments, 1=no comments, 3=error |
pr-push.sh | Validate fork remote + push | <branch> [message --expected-files f1,f2] | 0=pushed, 1=nothing to push, 2=file mismatch, 3=error |
Mandatory usage rules:
pr-state.sh (never parse or write the JSON directly)pr-checks.sh (never call gh pr checks directly)pr-comments.sh (never call gh api for comments directly)pr-push.sh (never call git push directly — the script validates the fork remote, blocks security-sensitive file patterns, and prevents pushing to upstream). When committing, --expected-files is mandatory — the script refuses to commit without itgh api is allowed only for posting replies after fixes are appliedState is a JSON string carried in PR_MONITOR_STATE env var and persisted
to /tmp/pr-review-yolo-agent-<pr-number>.json.
gh CLI authenticated with repo accessjq installedci:prow-job-analyze-test-failure, ci:prow-job-analyze-install-failurepr-review:coderabbit, pr-review:vet-reviewnpx claudepluginhub openshift-eng/edge-tooling --plugin pr-reviewProvides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.
Fetches up-to-date documentation from Context7 for libraries and frameworks like React, Next.js, Prisma. Use for setup questions, API references, and code examples.