一键导入
babysit-pr
PR health monitor that checks CI, reviews, comments, and merge status, then autonomously fixes issues. Designed for periodic use with /loop.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
PR health monitor that checks CI, reviews, comments, and merge status, then autonomously fixes issues. Designed for periodic use with /loop.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Style rules for git commit messages. Use when writing or editing a commit message.
Style rules for PR review comments and replies. Use when drafting or posting a PR review comment, inline comment, or thread reply.
Manage tasks in Notion. List, create, update tasks. Use for any Notion task-related operations.
Test-Driven Development guidance. Use during feature-dev Phase 5 (Implementation) or any code implementation. Ensures tests are written BEFORE implementation code, following Red-Green-Refactor cycle.
Execute GitHub CLI commands using the correct Homebrew path. Use when interacting with GitHub PRs, issues, repos, or any gh command.
Create stacked pull requests for GitHub repositories. Use when breaking large features into sequential, dependent PRs with conventional commit titles. Triggers on requests to create stacked PRs, split work into multiple PRs, or organize changes into a PR series.
基于 SOC 职业分类
| name | babysit-pr |
| description | PR health monitor that checks CI, reviews, comments, and merge status, then autonomously fixes issues. Designed for periodic use with /loop. |
You are an autonomous PR health monitor. Check the PR state, fix what you can, report what you cannot.
Run the data collection script from the scripts/ folder:
scripts/collect-pr-state.sh $ARGUMENTS
$ARGUMENTS is the PR number (optional — defaults to current branch's PR).
The script outputs a JSON object. Key fields: health.healthy (early exit), checks.failedChecks (CI failures), mergeable (conflicts), reviewThreads.unresolved (inline review feedback), prComments.human (PR-level comments from humans, excluding bots), reviewers (assigned reviewers). See script source for full schema.
Exit conditions:
health.healthy is true → output PR #<number> — healthy, no action needed. and STOP.checks.failedChecks is empty AND checks.pendingChecks is non-empty AND any check's startedAt is within the last 15 minutes → report "Waiting for CI — N checks pending (started at )" and STOP. This prevents re-analyzing a PR where a previous fix is still being verified by CI.Process blockers in this exact order: 2a → 2b → 2c → 2d. Skip a section if its trigger condition is not met.
Trigger: checks.failedChecks is non-empty.
For each failed check, classify by name and handle accordingly:
| Check name pattern (case-insensitive substring) | Classification | Action |
|---|---|---|
jenkins or continuous-integration | Jenkins umbrella | → Diagnose via Jenkins scripts (see below) |
sonarqube or sonar | Code quality gate | → Fetch findings via script (see below), then skip |
lint or eslint or stylelint | Lint | → Run project lint command |
type or typecheck or tsc | Type check | → Run project type-check command |
test or jest or unit | Test | → Run project test command (see below for how to scope) |
build or compile | Build | → Run project build command |
| (no match) | Unknown | → Report as "cannot auto-fix" with link URL, skip |
Check the project's package.json scripts or CLAUDE.md for the exact lint/type-check/test/build commands. Common patterns: yarn lint, yarn type-check, yarn test, yarn build.
Diagnosing Jenkins umbrella checks:
All Jenkins scripts use JENKINS_USERNAME and JENKINS_API_TOKEN from the shell environment and the Blue Ocean REST API.
scripts/fetch-build-info.sh "<jenkins-build-url>"
Output includes build status, all pipeline stages with [PASS]/[FAIL]/[SKIP], and the last 150 lines of the console log.scripts/fetch-failed-tests.sh "<jenkins-build-url>"
Output format: one block per failed test with FAILED: <name>, File: <path>, Error: <message>.
b. Parse the console log (from step 1 output) for test failure patterns (e.g., ● <test suite> › <test name>, FAIL <file>).
Note: CI runs tests with --silent, so test names are often absent from the console log.scripts/fetch-stage-log.sh "<jenkins-build-url>" "<stage-name>"
This automatically follows downstream jobs, finds the failing stage/step, and outputs the actual error log. If <stage-name> is omitted, it finds the first failing stage.<test name> — not related to PR changes. Replayed build."Replaying a build via Blue Ocean API (preferred over empty commits):
source scripts/jenkins-url-helper.sh
validate_jenkins_env
BLUE_BASE=$(jenkins_to_blue_ocean "<jenkins-build-url>")
jenkins_post "$BLUE_BASE/replay"
On script failure: 404/not-found → replay the build. 401/403 auth error → fall back to local commands (lint → type-check → test). Other errors → report and skip.
Diagnosing SonarQube quality gate failures:
When the failing Jenkins stage is "Code Coverage and Static Analysis" (or similar SonarQube stage), run:
scripts/fetch-sonar-results.sh "<jenkins-build-url>"
This script:
SONAR_TOKEN is set → queries the SonarQube API for the quality gate status and lists all unresolved issues with severity, type, message, and file location.SONAR_TOKEN is not set → outputs the dashboard URL and instructions to generate a token.After running, always skip (do not auto-fix SonarQube findings). Report the dashboard URL and any findings to the user so they can decide what to address. Suggest setting SONAR_TOKEN in ~/.zshrc if it's missing (generate at <sonar-server>/account/security).
Fixing a classified check (lint/type/test/build):
--testNamePattern for Jest).--testPathPattern for Jest).<check> failure locally — possible environment difference. See CI logs: <link>". Skip this check.<check> after 3 attempts" with the latest error output. Skip this check.fix(<scope>): <description>), and push.After pushing a fix, STOP. Do not process remaining failed checks — let CI re-run and re-invoke the skill on the next /loop cycle.
Trigger: mergeable equals CONFLICTING.
git fetch origin <baseRefName> && git rebase origin/<baseRefName>
git add <resolved files> && git rebase --continue.git push --force-with-lease. If rejected → run git rebase --abort and report "Merge conflicts require manual resolution."Trigger: reviewThreads.unresolvedCount > 0.
Important: Always present the analysis and wait for explicit user approval before making changes. Do not auto-fix review feedback.
reviewThreads.unresolved — each thread has path, line, and comments[] (each with body, user, createdAt). Focus on the first comment in each thread (the reviewer's original feedback).?, or contains "why", "how", "could you explain", "what about", "thoughts on".gh pr comment <number> --body "Addressed review feedback: <summary>"
Trigger: prComments.humanCount > 0.
PR-level comments (also called "issue comments") are general comments on the PR, not attached to specific code lines. These often contain questions, feedback, or screenshots from reviewers.
Important: Always present the analysis and wait for explicit user approval before responding. Do not auto-reply.
prComments.human — each entry has body, user, and createdAt.gh pr comment <number> --body "<response>".After processing all blockers, report each applicable warning. Do not auto-fix these.
| Condition | Output |
|---|---|
isDraft is true | "PR is in draft mode" |
checks.pendingChecks is non-empty | "N checks pending — waiting for CI" |
reviewDecision is REVIEW_REQUIRED or "null" | "Awaiting code review" |
reviewers array is empty | "No reviewers assigned — consider adding reviewers" |
reviewThreads.unresolvedCount > 0 | "N unresolved review threads (presented in Step 2c)" |
reviewThreads.outdatedCount > 0 | "N outdated review threads (code has changed since comment)" |
behindCount > 0 | "Branch is N commits behind <baseRefName>" |
prComments.humanCount > 0 | "N PR-level comments from humans (presented in Step 2d)" |
Always output this format:
PR #<number> Status
===================
Branch: <headRefName> -> <baseRefName>
Actions Taken:
- <7-char SHA> <scope>: <description> (from fixes made in this run)
- (or "None")
Remaining Issues:
- <issue and why it needs attention>
- (or "None")