| name | pr-iteration |
| description | Guide the agent through iterative PR/MR refinement to ensure all CI checks, tests, linting, and validation passes before considering the work complete. Never declare success until all automated checks pass. |
| license | MIT |
| compatibility | opencode |
| metadata | {"category":"workflow","tool":"git"} |
What I Do
I ensure that all Pull Requests (PRs) or Merge Requests (MRs) pass every automated check before being declared
complete. I guide the agent through iterative refinement until CI is green.
Core Principles
- Iterate until all checks pass - Never declare "done" while any check is failing
- Run checks locally first - Fix issues locally before pushing to avoid CI noise
- Address cascading failures systematically - Fix one category at a time (lint → typecheck → test → build)
- Commit incremental fixes - Save progress as you fix issues, don't batch all fixes into one commit
- Verify after each fix - Re-run the failed check to confirm it's resolved
When to Use Me
- Creating a new PR/MR from scratch
- Addressing CI failures on an existing PR/MR
- Refactoring code that affects multiple packages
- Adding features that require cross-package changes
- Merging dependent PRs in sequence
Iteration Workflow
Phase 1: Pre-Flight Checks (Before Creating PR)
bun install
bun run lint
bun run typecheck
bun run test
bun run build
If any check fails → FIX IT before proceeding
Phase 2: PR Creation & Initial Validation
After creating PR/MR:
bun run lint && bun run typecheck && bun run test && bun run build
Phase 3: Iterative Fix Loop
While any check is failing:
CHECK → FAIL → FIX → COMMIT → PUSH → RE-CHECK → (REPEAT UNTIL PASS)
Priority order for fixing failures:
- Linting errors (formatting, style) - Usually quickest to fix
- Type errors - May require interface changes
- Test failures - Logic bugs or test updates needed
- Build failures - Often the most complex
Phase 4: Final Verification
bun run lint
bun run typecheck
bun run test
bun run build
Only declare PR ready when ALL checks pass.
Common Failure Patterns & Fixes
Pattern 1: Linting Failures
Symptom: CI fails on bun run lint or biome/eslint errors
Fix Process:
bun run lint --fix
biome check --write .
bun run lint
Iterate until: bun run lint exits 0
Pattern 2: Type Errors
Symptom: bun run typecheck or tsc fails
Fix Process:
bun run typecheck
bun run typecheck
Iterate until: bun run typecheck exits 0
Pattern 3: Test Failures
Symptom: Tests fail locally or in CI
Fix Process:
bun test path/to/failing-test.ts
bun test path/to/failing-test.ts
bun run test
Iterate until: All tests pass
Pattern 4: Build Failures
Symptom: bun run build or nx build fails
Fix Process:
bunx nx run-many --target=build --all --verbose
bun run build
Iterate until: Build succeeds
Pattern 5: Cross-Package Failures
Symptom: Changes in one package break another
Fix Process:
bunx nx affected:graph
bunx nx run-many --target=build --projects=dependency-package
bunx nx run-many --target=build --projects=dependent-package
bunx nx affected:test
Iterate until: All affected packages build and test successfully
CI/CD Integration
GitHub Actions Workflow
name: Validate PR
on: [pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- name: Install
run: bun install
- name: Lint
run: bun run lint
- name: Type Check
run: bun run typecheck
- name: Test
run: bun run test
- name: Build
run: bun run build
Required Status Checks
Configure branch protection to require:
- ✅ Lint passing
- ✅ Type check passing
- ✅ Tests passing
- ✅ Build passing
No PR should be mergeable until all checks pass.
Debugging CI Failures
Step 1: Replicate Locally
biome ci --reporter=github --diagnostic-level=error . --verbose
Step 2: Check Environment Differences
Common differences:
- Node/Bun version - Match CI version exactly
- Operating system - CI runs Linux; develop on Linux/macOS/WSL
- Clean state - CI starts fresh; you may have cached files
rm -rf node_modules bun.lockb
bun install
Step 3: Fix and Verify
bun run lint && bun run typecheck && bun run test && bun run build
git add .
git commit -m "fix: resolve CI failures"
git push
Step 4: Monitor CI
- Watch CI logs for new failures
- Repeat fix loop if needed
Multi-PR Dependency Management
When merging PRs with dependencies (e.g., PR B depends on PR A):
Step 1: Merge Base PR First
git checkout main
git merge feat/pr-a
Step 2: Rebase Dependent PR
git checkout feat/pr-b
git rebase main
bun run lint && bun run typecheck && bun run test && bun run build
git push --force-with-lease
Step 3: Iterate Until Green
If checks fail after rebase:
FAIL → ANALYZE (conflicts? dependency changes?) → FIX → PUSH → RE-CHECK
Dependencies may introduce breaking changes requiring fixes in dependent PR.
Commit Strategy During Iteration
Incremental Commits
Save progress as you fix issues:
git add .
git commit -m "style: fix linting errors"
git add .
git commit -m "fix: resolve type errors"
git add .
git commit -m "test: update failing tests"
Squash Before Merge (Optional)
If you prefer clean history:
git rebase -i main
Emergency Recovery
CI is completely broken
cat package.json | grep -A 5 '"scripts"'
bunx biome --version
bunx tsc --version
echo $NODE_VERSION
echo $BUN_VERSION
rm -rf node_modules bun.lockb
bun install
Infinite fix loop
If you keep fixing and CI keeps failing:
- Take a break - Step away, review with fresh eyes
- Check CI logs carefully - Read the full error message
- Run exact CI command locally - Don't assume your command is equivalent
- Ask for help - Sometimes a second pair of eyes helps
Success Criteria
A PR is ONLY ready when:
- ✅
bun run lint passes (0 errors, 0 warnings)
- ✅
bun run typecheck passes (0 type errors)
- ✅
bun run test passes (all tests green)
- ✅
bun run build passes (all packages build)
- ✅ CI pipeline is green
- ✅ No merge conflicts with target branch
If any check fails → CONTINUE ITERATING
Remember
✅ DO:
- Run checks locally before pushing
- Fix one category at a time
- Commit incremental fixes
- Verify after each fix
- Monitor CI after every push
- Rebase dependent PRs after base PR merges
❌ NEVER:
- Declare PR ready with failing checks
- Ignore CI failures
- Batch all fixes into one giant commit
- Skip local verification and rely on CI
- Merge with "will fix later" mentality
Quick Reference
bun run lint && bun run typecheck && bun run test && bun run build
bun run lint --fix
bun run typecheck
bun test path/to/test.ts
bunx nx run package-name:build