/ci-workflows:post-push-loopfrom ci-workflows
Use after pushing a PR to autonomously monitor CI, fetch review findings, and iterate fixes until clean. Invoke as: /post-push-loop [pr-number]
Ships in ci-workflows. 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.
None: SKILL.md is the whole skill.
Autonomously iterate through the CI/review cycle after a push. Loop exits only when external signals clear (CI green + no unresolved bot findings), or when a finding requires a human decision.
/post-push-loop [pr-number]
If pr-number is omitted, auto-detect from gh pr view --json number -q .number.
Every call to post-push-status.sh uses the OWNER/REPO#N form (for example
smartwatermelon/claude-config#716), never a bare number. PR numbers collide across
repos, so a bare number makes the script guess the repo from the current directory.
Get OWNER/REPO once, before the loop, from the checkout:
gh repo view --json nameWithOwner -q .nameWithOwner. Or take it from the PR URL
(https://github.com/OWNER/REPO/pull/N). Call it <PR_REF> below.
This skill requires ~/.claude/scripts/post-push-status.sh (from the claude-config
repo). Before starting, verify it exists and is executable. If missing, escalate
immediately — do not attempt to create or substitute it.
Additional requirements: gh (authenticated), jq, python3, and a pre-push git
hook with POSTPUSH_LOOP bypass support.
~/.claude/scripts/post-push-status.sh exists and is executablegit branch --show-current — must NOT be maingh pr view --json number -q .number, and build <PR_REF> as OWNER/REPO#NPOSTPUSH_LOOP will be set for all git push calls in this sessionRepeat until Exit: Success or Exit: Escalate:
Poll every 30 seconds:
bash ~/.claude/scripts/post-push-status.sh <PR_REF>
Check the exit code and the output before you read CI_STATE. These two cases are
terminal. Stop polling at once. Do not wait for the timeout.
PR_STATE=MERGED / PR_STATE=CLOSED line: the PR is no longer
open. Both cases also print CI_STATE=UNKNOWN; ignore it. Report the PR_STATE= line
as it is. MERGED means the work is done: report it and stop. There is no CI
verdict to check. CLOSED means someone closed the PR: Exit: Escalate.WARNING: HEAD_MISMATCH line: the PR head is not your local
HEAD. The likely cause is local commits that are not pushed yet, or the wrong PR.
Do not wait: waiting cannot fix it. Push (POSTPUSH_LOOP=1 git push), or re-check
that <PR_REF> names the PR for this branch, then return to Phase 1 for one fresh
poll. If the mismatch persists, Exit: Escalate with the WARNING line. Because
<PR_REF> names the repo, the script prints the warning and exits 0 (it keeps
going, not exit 3). Treat the WARNING: HEAD_MISMATCH line as terminal anyway.Continue polling while CI_STATE=PENDING, CI_STATE=EXPECTED, or CI_STATE=UNKNOWN.
CI_STATE=UNKNOWN with exit code 0 and no PR_STATE= or HEAD_MISMATCH line indicates a transient error (network failure or no CI checks registered yet) — treat it as pending and continue polling. It counts against the 15-minute timeout. CI_STATE=UNKNOWN with exit code 2 or 3 is NOT transient (see above).
Timeout: if CI_STATE has not resolved after 15 minutes, escalate with reason
"CI did not complete within timeout — check for stuck jobs."
Parse script output using this exact decision table — evaluate in order:
| Exit code / line | CI_STATE | FINDING lines present? | Action |
|---|---|---|---|
2 or PR_STATE=MERGED / CLOSED | UNKNOWN | Ignore | Stop. Report the PR_STATE= line (merged = done, closed = Exit: Escalate) |
3 or WARNING: HEAD_MISMATCH | UNKNOWN | Ignore | Stop polling. Push or re-check the PR, then one fresh poll; if it persists, Exit: Escalate |
0 | SUCCESS | No | Exit: Success |
0 | SUCCESS | Yes | Proceed to Phase 3 |
0 | FAILURE | Either | Proceed to Phase 3 |
0 | ERROR | Either | Proceed to Phase 3 |
0 | UNKNOWN | Either | Return to Phase 1 (transient — treat as pending) |
CI_STATE=SUCCESS alone is NOT sufficient to exit — zero FINDING lines are also required.
FINDING lines have the format:
FINDING source=<bot> file="<path>" line=<line> comment=<text>
The file= value is always double-quoted (strip the outer quotes when reading it). This handles file paths that contain spaces.
Note on issues/comments staleness: Findings from the PR conversation thread
(issues/comments) cannot be filtered by commit — that API provides no
original_commit_id field. These findings may include bot comments from previous
commits. Treat an issues/comments finding with an empty file= and line= as a
potential staleness indicator; apply extra scrutiny before classifying as CONFIDENT_FIX.
For each FINDING line, classify as CONFIDENT_FIX or ESCALATE:
CONFIDENT_FIX (all of the following must be true):
file= and line= referenceESCALATE (any of the following):
**/auth/**, **/jwt/**, **/password/**, **/session/**,
**/payment/**, **/billing/**, **/db/**, **/migrations/**,
**/crypto/**, **/secrets/**CI_STATE=ERROR (infrastructure failure, not code failure)If ANY finding is ESCALATE: stop. Do NOT apply any fixes. Go to Exit: Escalate.
If ALL findings are CONFIDENT_FIX: proceed to Phase 4.
Apply edits for each confident finding. Keep changes minimal — fix exactly what the finding describes, nothing more.
After all edits:
git diff HEAD
Review the diff briefly. If the diff is larger than expected or touches files not referenced in findings, treat as ESCALATE.
git add <only the files you changed>
git commit -m "fix: address <summary of findings>
Post-push loop iteration N: <list of findings addressed>"
Note: the pre-commit hook will run automatically. If it blocks the commit, treat as Exit: Escalate — surface both the hook finding and the remote finding.
Environment for push: set POSTPUSH_LOOP=1 to bypass the Protocol 4 interactive prompt.
POSTPUSH_LOOP=1 git push
Return to Phase 1.
✅ POST-PUSH LOOP COMPLETE
PR #NNN | N iterations
CI state: SUCCESS
Unresolved bot findings: 0
Commits pushed:
<list of commit hashes + messages>
⚠️ LOOP PAUSED — Human decision required
PR #NNN | Iteration N | CI: <state>
FINDING(S) requiring your input:
[For each finding]
Source: <bot>
File: <path>:<line>
Comment: <text>
Reason escalated: <reason>
CONTEXT:
Fixes applied this session: <list or "none">
Local review at last commit: passed / blocked
Current CI state: <state>
OPTIONS:
1. Provide direction here → I resume with your guidance
2. Take over manually → type "take over" to exit loop
3. Abandon → type "abandon" to exit, leave branch as-is
Await human response. Do not proceed autonomously.
CI_STATE=SUCCESS AND no FINDING lines from the status script.--no-verify on any git command.main.POSTPUSH_LOOP=1 on every git push call within this skill.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub smartwatermelon/smartwatermelon-marketplace --plugin ci-workflows