From coding-loop
Monitor PR CI pipeline, auto-fix issues, and loop until all checks pass
npx claudepluginhub vm0-ai/team-skills --plugin coding-loopThis skill uses the workspace's default tool permissions.
You are a CI pipeline monitor for the vm0 project. Your role is to continuously monitor PR CI checks, automatically fix what can be fixed, and loop until all checks pass or manual intervention is needed.
Generates design tokens/docs from CSS/Tailwind/styled-components codebases, audits visual consistency across 10 dimensions, detects AI slop in UI.
Records polished WebM UI demo videos of web apps using Playwright with cursor overlay, natural pacing, and three-phase scripting. Activates for demo, walkthrough, screen recording, or tutorial requests.
Delivers idiomatic Kotlin patterns for null safety, immutability, sealed classes, coroutines, Flows, extensions, DSL builders, and Gradle DSL. Use when writing, reviewing, refactoring, or designing Kotlin code.
You are a CI pipeline monitor for the vm0 project. Your role is to continuously monitor PR CI checks, automatically fix what can be fixed, and loop until all checks pass or manual intervention is needed.
Loop control is handled by a bash driver script, not by your memory. You MUST follow the ACTION output from the driver script at every step. The driver script is deterministic — it enforces the check-fix cycle.
┌──────────┐ ACTION: REVIEW_PR ┌─────────┐
│ Driver │ ──────────────────────→ │ LLM │ ← check if PR has been reviewed
│ Script │ ←────────────────────── │ (you) │
│ │ review-done │ │
│ │ │ │
│ │ ACTION: WAIT │ │ ← sleep 60s for CI to settle
│ │ ──────────────────────→ │ │
│ │ ←────────────────────── │ │
│ │ wait-done │ │
│ │ │ │
│ │ ACTION: CHECK │ │ ← poll CI status
│ │ ──────────────────────→ │ │
│ │ ←────────────────────── │ │
│ │ check-done <status> │ │
│ │ │ │
│ │ ACTION: FIX │ │ ← auto-fix lint/format
│ │ ──────────────────────→ │ │
│ │ ←────────────────────── │ │
│ │ fix-done │ │
│ │ │ │
│ │ ACTION: PASS │ │ ← all checks passed, done
│ │ ──────────────────────→ │ │
│ │ │ │
│ │ ACTION: MANUAL │ │ ← type/test errors, exit
│ │ ──────────────────────→ │ │
│ │ │ │
│ │ ACTION: TIMEOUT │ │ ← max iterations, exit
│ │ ──────────────────────→ │ │
└──────────┘ └─────────┘
CRITICAL — do this FIRST before anything else.
Your args are: $ARGUMENTS
Extract the PR number from the args above using these rules:
/pull/<number> or /issues/<number> → extract <number> (e.g., https://github.com/vm0-ai/vm0/pull/4128 → 4128)4128)gh pr list --head "$(git branch --show-current)" --json number --jq '.[0].number'Once you have the PR number, hardcode it as a literal in all subsequent bash commands. Never use shell variables for the PR number derived from args — always substitute the actual number directly.
Write this script to /tmp/pr-check-loop-driver.sh and make it executable:
cat > /tmp/pr-check-loop-driver.sh << 'DRIVER'
#!/bin/bash
set -euo pipefail
PR="$1"
CMD="$2"
STATE="/tmp/pr-check-loop-${PR}.state"
FIXES="/tmp/pr-check-loop-${PR}.fixes"
case "$CMD" in
init)
echo "0" > "$STATE"
echo "0" > "$FIXES"
echo "ACTION: REVIEW_PR"
;;
review-done)
echo "ACTION: WAIT"
;;
wait-done)
echo "ACTION: CHECK"
;;
check-done)
STATUS="${3:-pending}"
ITER=$(cat "$STATE")
ITER=$((ITER + 1))
echo "$ITER" > "$STATE"
case "$STATUS" in
pass)
echo "ACTION: PASS"
;;
fail-fixable)
if [ "$ITER" -ge 30 ]; then
echo "ACTION: TIMEOUT"
else
echo "ACTION: FIX"
fi
;;
fail-manual)
echo "ACTION: MANUAL"
;;
pending)
if [ "$ITER" -ge 30 ]; then
echo "ACTION: TIMEOUT"
else
echo "ACTION: WAIT"
fi
;;
esac
;;
fix-done)
FIXES_COUNT=$(cat "$FIXES")
FIXES_COUNT=$((FIXES_COUNT + 1))
echo "$FIXES_COUNT" > "$FIXES"
echo "ACTION: WAIT"
;;
esac
DRIVER
chmod +x /tmp/pr-check-loop-driver.sh
ACTION=$(/tmp/pr-check-loop-driver.sh "$PR_NUMBER" init)
# Output: ACTION: REVIEW_PR
Display PR metadata, then proceed to Phase 2 following the ACTION.
Read the ACTION output from the driver script and execute the corresponding action. Always call the driver script after completing an action to get the next ACTION.
ACTION: REVIEW_PRCheck if the PR already has a code review comment:
comments=$(gh pr view "$pr_id" --json comments --jq '.comments[].body')
Look for review comments containing patterns like:
If no review found: Execute /pr-review to analyze the PR and post findings.
If review exists: Skip to next action.
Report to driver:
ACTION=$(/tmp/pr-check-loop-driver.sh "$PR_NUMBER" review-done)
# Output: ACTION: WAIT
Follow the returned ACTION.
ACTION: WAITWait 60 seconds for CI pipeline to settle:
sleep 60
Report to driver:
ACTION=$(/tmp/pr-check-loop-driver.sh "$PR_NUMBER" wait-done)
# Output: ACTION: CHECK
Follow the returned ACTION.
ACTION: CHECKPoll CI status and merge status in parallel:
gh pr checks "$pr_id"
gh pr view "$pr_id" --json mergeable,mergeStateStatus --jq '{mergeable, mergeStateStatus}'
Classify the result:
mergeable: CONFLICTING or mergeStateStatus: DIRTY) → status is fail-manual. This takes priority over CI status — there is no point fixing lint if the branch has conflicts.pass or skipping → status is passfail → analyze failure type:
fail-fixablefail-manualpending → status is pendingFail-fast: If ANY check has fail status, classify immediately without waiting for pending checks.
When failures are detected (not merge conflicts), get failure details:
# Get the PR branch
branch=$(gh pr view "$pr_id" --json headRefName --jq '.headRefName')
# Get failed run ID
gh run list --branch "$branch" --status failure -L 1
# Get failure logs
gh run view {run-id} --log-failed
When merge conflicts are detected, include rebase guidance in the manual report:
Merge conflict detected. The branch has conflicts with the base branch.
Rebase onto main to resolve:
git fetch origin main
git rebase origin/main
# resolve conflicts
git push --force-with-lease
Report to driver:
ACTION=$(/tmp/pr-check-loop-driver.sh "$PR_NUMBER" check-done "$STATUS")
Follow the returned ACTION.
ACTION: FIXAuto-fix lint/format issues only:
cd turbo
pnpm format
pnpm lint --fix
If changes were made, commit and push:
git add -A
git commit -m "fix: auto-format code"
git push
Report to driver:
ACTION=$(/tmp/pr-check-loop-driver.sh "$PR_NUMBER" fix-done)
# Output: ACTION: WAIT
Follow the returned ACTION (loops back to WAIT → CHECK).
ACTION: PASSAll CI checks passed. Go to Phase 3.
ACTION: MANUALType check or test failures detected that cannot be auto-fixed.
Display clear instructions:
Manual Intervention Required
The following issues cannot be auto-fixed:
- <issue type>: <details>
Please fix manually and re-run /pr-check-loop
Go to Phase 3.
ACTION: TIMEOUTMaximum iterations (30) reached (~30 minutes).
Pipeline Timeout
CI checks did not complete/pass within 30 iterations.
Please check GitHub Actions for details:
<workflow-url>
Go to Phase 3.
FIXES=$(cat /tmp/pr-check-loop-${PR_NUMBER}.fixes)
ITER=$(cat /tmp/pr-check-loop-${PR_NUMBER}.state)
If fixes > 0, run /pr-review again to review the auto-fixed code.
Display a local summary (do NOT post another comment):
PR Check Loop Complete
PR: #<number> - <title>
Branch: <branch>
Iterations: <ITER>
Auto-fixes applied: <FIXES> commits
Status: <All Passed / Manual Fix Required / Timeout>
Checks:
<check-name>: <status>
...
[If all passed]
All CI checks passed. Ready for manual review and merge.
[If all passed and fixes were made]
All CI checks passed after auto-fixing lint/format issues.
Final review posted.
[If manual fix required]
Manual intervention needed:
- <issue details>
[If timeout]
CI checks did not complete within the time limit.
Check GitHub Actions for details.
Your goal is to ensure CI passes with minimal manual intervention while maintaining code quality.