Skip to content

uf.fix-ci: new command to diagnose and fix failing PR checks (rebase only, never merge) #858

Closed

Description

@jflowers

Summary

New UF command .opencode/commands/uf.fix-ci.md, invoked as /uf.fix-ci [PR_NUMBER]: diagnoses failing CI checks on an open PR, runs a gated fix loop (diagnose → fix → commit → push → re-poll), rebases the head branch onto base when the PR is conflicted or behind, and verifies CI ends green.

Why

  • /uf.finale step 7 only detects failing checks after PR creation and offers "Investigate the failure" — nothing carries the fix through.
  • /uf.address-feedback fixes reviewer feedback, not red checks.
  • /uf.rebase-pr (uf.rebase-pr: port global resolve-branch-conflict command (rebase conflicted PR head onto base) #851) rebases a conflicted PR but does not address failing checks.
  • Fixing a red PR today is a manual loop: gh pr checks, log spelunking, edit, push, watch — exactly the mechanical workflow UF automates.

Command behavior

  1. Arguments: PR number optional; omitted → auto-detect the open PR for the current branch. Invalid → STOP.
  2. Prerequisites: which gh, gh auth status.
  3. Fetch PR state: gh pr view <N> --json number,state,headRefName,baseRefName,mergeable,mergeStateStatus,headRepository,baseRepository plus gh pr checks <N>. STOP if CLOSED/MERGED or all checks pass.
  4. Diagnose: for each failed check, fetch failure logs (gh run view <run-id> --log-failed); classify root cause: code failure (build/test/lint), stale branch (base moved), conflict, or flaky/infra.
  5. Rebase branch (conflicted or behind): git_fetch <BASE_REMOTE> → git_rebase <BASE_REMOTE>/<BASE_BRANCH>; resolve flagged files preserving author intent; on ambiguity STOP and offer git_rebase_abort. MUST NEVER merge base into head — rebase only. This rule is absolute.
  6. Gated fix loop: present diagnosis + proposed fix plan; human confirms via question tool. Then fix → conventional commit → push (git_push, or git_push_force_with_lease after a rebase since history was rewritten) → re-poll CI. Max-iteration cap (3); STOP on cap or unfixable failure.
  7. Flaky/infra path: when logs indicate flakiness or infra failure, offer gh run rerun --failed instead of a code change.
  8. Final verification: uf_finale_ci_poll until green or timeout; report final status. MUST NOT merge, approve, or close the PR.

Scope

  • .opencode/commands/uf.fix-ci.md following uf.review-pr.md conventions (frontmatter, <protect>, session-resume guard, progress checkpoints, TodoWrite)
  • Prefer existing plugin tools (uf_finale_ci_poll, git_fetch, git_rebase, git_rebase_abort, git_push, git_push_force_with_lease) over raw bash
  • Fix commits pass /uf.review-council before push (uf.address-feedback §4.3 precedent), once per iteration after all fixes are committed
  • Scaffold mirror internal/scaffold/assets/opencode/commands/uf.fix-ci.md (drift tests stay green)
  • AGENTS.md PR Review Commands table: /uf.fix-ci [N] — Post-PR — diagnose + fix failing checks
  • docs/usage.md command reference entry
  • make check green

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions