| name | ci-error-resolution |
| description | CI/CD pipeline failure resolution with autonomous iteration loops. Local validation → branch & PR creation → CI monitoring → iteration until green. Proven patterns for GitHub Actions, includes role-specific adaptations. Use when CI pipeline failures occur, GitHub Actions errors detected, autonomous error resolution needed, PR creation for fixes required. Triggers on ci pipeline failures, github actions errors, autonomous ci resolution, ci iteration, pr creation for errors, pipeline validation, test failures in ci, build failures in ci, continuous integration debugging. |
| allowed-tools | Bash, Read, Grep |
===CI_ERROR_RESOLUTION===
PURPOSE::systematic_autonomous_CI_failure_resolution→reduce_manual_feedback_loop
ACTIVATION::[
AUTOMATIC::[ci_pipeline_errors, github_actions_failures, pr_check_failures, multiple_test_build_failures],
MANUAL::["follow CI resolution protocol", "fix these and create PR", "iterate until CI passes"]
]
PROTOCOL
PHASE_1::LOCAL_VALIDATION[
REQUIRED::ALWAYS[before_remote_operations],
COMMANDS::["npm audit --audit-level=moderate", "npm run lint:check", "npm run typecheck", "npm run test:unit", "npm run test:integration", "npm run test:security", "npm run build"],
GATE::IF[any_fail]→fix_locally_first | IF[all_pass]→PHASE_2
]
PHASE_2::BRANCH_AND_PR[
BRANCH::"fix/ci-errors-$(date +%Y%m%d-%H%M%S)",
SEQUENCE::"git checkout -b {branch} && git add -A && git commit -m 'fix: resolve CI pipeline failures\n\n- [specifics]' && git push -u origin HEAD && gh pr create --draft --title 'Fix: CI Pipeline Errors' --body '{checklist}'",
CHECKLIST::"## CI Error Resolution\n### Issues Fixed\n- [ ] Security\n- [ ] Linting\n- [ ] Types\n- [ ] Tests\n### Validation\n- [ ] Local pass\n- [ ] CI green"
]
PHASE_3::AUTONOMOUS_LOOP[
CONFIG::[MAX_ITERATIONS::10, WAIT_TIME::120s, LOG_PATTERN::"ci-errors-iter-{N}.log"],
BASH::"
MAX_ITERATIONS=10; ITERATION=0
while [ $ITERATION -lt $MAX_ITERATIONS ]; do
ITERATION=$((ITERATION + 1))
echo '🔄 Iteration '$ITERATION'/'$MAX_ITERATIONS
CI_STATUS=$(gh pr checks --json state -q '.[].state' | grep -c 'FAILURE\|ERROR' || true)
[ "$CI_STATUS" -eq 0 ] && echo '✅ CI passing!' && break
gh run list --limit 1 --json databaseId -q '.[0].databaseId' | xargs -I {} gh run view {} --log-failed > ci-errors-iter-$ITERATION.log
echo '🔍 Analyzing...'