| name | fix-ci |
| description | Diagnose and fix ALL failing CI checks on the current PR in a single pass.
Collects all failures first, then prescribes fixes. Use when CI is failing,
tests are broken, GitHub Actions report errors, or PR checks show red.
|
| disable-model-invocation | true |
| allowed-tools | ["Bash(gh *)","Bash(git *)","Bash(npm *)","Bash(mvn *)","Read","Grep","Glob"] |
| metadata | {"source":"internal","version":"2.0.0"} |
Fix CI
Diagnose and fix ALL failing CI checks in ONE pass. Never push until all
known issues are resolved.
1. Ensure All Checks Are Complete
PAGER=cat gh pr view --json number,statusCheckRollup --jq '{
pr: .number,
failed: [.statusCheckRollup[] | select(.conclusion == "FAILURE") | .name],
pending: [.statusCheckRollup[] | select(.status == "IN_PROGRESS" or .status == "QUEUED") | .name]
}'
If there are pending checks, wait for all checks to complete before diagnosing.
Fixing 2 of 5 failures wastes a push cycle.
2. Get ALL Failed Job IDs At Once
RUN_ID=$(PAGER=cat gh run list --branch $(git branch --show-current) --limit 1 --json databaseId,conclusion --jq '[.[] | select(.conclusion == "failure")][0].databaseId')
echo "Run ID: $RUN_ID"
Then get all failed jobs:
PAGER=cat gh api repos/{owner}/{repo}/actions/runs/$RUN_ID/jobs --jq '[.jobs[] | select(.conclusion == "failure" and (.name | test("CI Status|all-ci") | not)) | {id, name}]'
3. Get ALL Job Logs At Once
For EACH failed job ID from step 2, get logs in a single loop:
for JOB_ID in <SPACE_SEPARATED_JOB_IDS>; do
echo "=== JOB $JOB_ID ==="
PAGER=cat gh api repos/{owner}/{repo}/actions/jobs/$JOB_ID/logs 2>&1 | tail -80
echo ""
done
Read ALL output before making any fixes.
4. Classify ALL Failures
Before fixing anything, categorize every failure into this table.
Fix in this order (earlier fixes often resolve later issues):
| Priority | Category | Symptoms | Fix Command |
|---|
| 1 | Formatting | "Formatting failed", biome/prettier diff | pnpm run format |
| 2 | Lint | Biome lint errors | pnpm run check:fix |
| 3 | TypeScript | TS2xxx errors, type mismatch | Fix the type error in source |
| 4 | Build failure | Compilation errors, missing exports | Fix imports/exports, verify with pnpm run build:webapp |
| 5 | Webapp tests | "FAIL" in webapp test output | Fix test or source, verify with pnpm run test:webapp |
| 5 | App server tests | Maven test failures, assertion errors | Fix test or source, verify with cd server && ./mvnw test -Dsurefire.includedGroups="unit" -Dmaven.test.skip=false -T 2C --batch-mode -q |
| 6 | OpenAPI sync | "OpenAPI out of sync" | pnpm run generate:api |
| 6 | DB schema | "Schema drift detected" | pnpm run db:draft-changelog |
| 6 | DB ERD | "ERD outdated" | pnpm run db:generate-erd-docs |
5. Fix ALL Issues
Work through the entire list. Fix root causes, not symptoms.
IMPORTANT: Do NOT push after fixing only one failure if multiple exist.
Fix everything first.
6. Validate Locally Before Pushing
After ALL fixes are applied, run local validation:
pnpm run format
pnpm run check
Then run tests for ALL components that had failures:
pnpm run test:webapp
cd server && ./mvnw test -Dsurefire.includedGroups="unit" -Dmaven.test.skip=false -T 2C --batch-mode -q && cd ../..
ALL must pass locally before pushing.
7. Regenerate If Needed
If any OpenAPI or DB validation failed:
pnpm run generate:api
pnpm run db:generate-erd-docs
Run format + check again after regeneration:
pnpm run format
pnpm run check
8. Commit and Push (ONCE)
git add -A
git commit -m "fix(<scope>): resolve ci failures"
git push
9. Monitor
PAGER=cat gh pr checks $(PAGER=cat gh pr view --json number -q .number) --watch
Rules
- NEVER push after fixing only one failure if multiple failures exist
- ALWAYS run local validation (format + check + affected tests) before pushing
- If step 1 shows pending checks, wait for all checks to complete first
- If the same CI check fails twice in a row, investigate deeper - do not retry the same approach