feat(utils): add fix-pr command for automated PR/MR remediation#614
feat(utils): add fix-pr command for automated PR/MR remediation#614cardil wants to merge 5 commits into
Conversation
WalkthroughAdds a new ChangesUtils plugin
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant User
participant FixPr as utils:fix-pr
participant ReviewGet as review get
participant ReviewReply as review reply
participant CI as CI checks
User->>FixPr: run with PR/MR number and flags
FixPr->>ReviewGet: fetch PR/MR state for the iteration
FixPr->>ReviewReply: post replies for unresolved review threads
FixPr->>CI: inspect failed checks and logs
FixPr->>User: continue loop until mergeable or blocked
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (2 errors)
✅ Passed checks (8 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: cardil The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/data.json`:
- Around line 450-455: The generated docs artifacts are out of sync with the
current fix-pr metadata. Regenerate the docs from the source command definition
in fix-pr.md so the updated argument_hint, description, and synopsis are
reflected consistently in both docs/data.json and PLUGINS.md.
In `@PLUGINS.md`:
- Line 295: The `/utils:fix-pr` command hint in the generated docs is out of
sync with the command’s frontmatter. Regenerate the entry sourced from
docs/data.json so the bullet matches the actual argument_hint for fix-pr.md,
including the PR/MR reference and the --auto-approve option. Locate the
generated command text for /utils:fix-pr and update it from the underlying
metadata rather than editing the displayed string manually.
In `@plugins/utils/commands/fix-pr.md`:
- Around line 10-12: The fenced example in fix-pr.md is unlabeled and triggers
markdownlint MD040; update the markdown fences in this document to use an
appropriate language tag such as bash, text, or diff so the example is properly
labeled. Keep the existing command example intact and ensure any other fenced
blocks in the file follow the same pattern.
- Around line 120-137: The rebase workflow in the command guide still instructs
`git push --force-with-lease`, which must be removed from this `fix-pr` flow.
Update the rebase handling section to use a non-destructive push path or require
an explicit user confirmation gate before any push, and make sure the steps
around rebase resolution in this document no longer mention any force-push
variant. Keep the guidance aligned with the existing `Handle rebase outcome` and
`git rebase --continue` flow while replacing the final push instruction with a
safe alternative.
- Around line 79-89: Clarify the polling contract around review get so it does
not read like a one-time fetch for all phases. Update the documentation around
review get <PR_NUMBER> to state that the full PR/MR snapshot should be fetched
at the start of each iteration, and re-run after rebases and while waiting for
CI. Keep the existing snapshot/phase explanation, but make the repeated-use
behavior explicit in the same section.
- Around line 241-244: The failed CI log collection step in the PR fix guide is
GitHub-only and needs a GitLab fallback. Update the instructions around the
“Fetch failure details” step to either add a `glab ci view`/`glab ci trace` path
for GitLab or clearly label the existing `gh run view` flow as GitHub-specific;
keep the wording aligned with the surrounding `review get` guidance in the
fix-pr workflow.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 89f47fc5-7636-4d6c-b4e4-1e0656341b5b
📒 Files selected for processing (3)
PLUGINS.mddocs/data.jsonplugins/utils/commands/fix-pr.md
Add new /utils:fix-pr command that automates the complete PR remediation workflow by iteratively resolving merge conflicts, addressing review comments, and fixing failing CI checks. Key features: - Three-phase loop: conflicts → reviews → CI checks - Intelligent conflict resolution via rebase - Integrates with existing /utils:address-reviews logic - Automated CI failure analysis and fixes - --skip-reviews flag for CI-only workflow - Configurable max iterations (default: 5) This command helps developers get PRs ready to merge with minimal manual intervention, handling complex scenarios where review fixes might break CI or create new conflicts. Assisted-By: 🤖 Claude Sonnet 4.5 <noreply@anthropic.com>
- Single 'review get' call per iteration for threads, mergeability, CI status - Use 'review reply' for all review thread replies - Install review from cardil/review if missing, detect PATH bin dir - Document GitLab MR support alongside GitHub PRs Assisted-by: 🤖 claude-sonnet-4-6
- Add --auto-approve=no|ai|human|all flag (default: ai) - Human reviewer replies require confirmation by default - Bot replies auto-posted by default - Draft shown in normal message, question tool used only for yes/no - Examples: ask_followup_question (Roo/Zoo), question (Opencode) - Remove AI footer from replies Assisted-by: 🤖 claude-sonnet-4-6
Assisted-by: 🤖 claude-sonnet-4-6
a0325a2 to
5d037d0
Compare
- Add language tags to all fenced code blocks (MD040) - Clarify review get polling contract (re-run after rebase and while waiting for CI) - Add GitLab fallback for failed CI log fetching (glab ci view / glab ci trace) - Replace 'gracefully' with specific error handling description - Bump utils plugin version to 0.0.13 - Regenerate docs/index.html and marketplace.json Assisted-by: 🤖 claude-sonnet-4-6
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
plugins/utils/commands/fix-pr.md (1)
355-356: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winUse the resolved base branch here instead of hardcoding
main.These instructions should mirror the earlier
BASE_BRANCHlookup. Hardcodingorigin/main/mainmakes the guide wrong for repos whose target branch is notmain, including GitLab MRs.♻️ Proposed fix
- Resolve conflicts with: git rebase origin/main + Resolve conflicts with: git rebase origin/${BASE_BRANCH} ... - 🔄 Rebasing on main... + 🔄 Rebasing on ${BASE_BRANCH}...Also applies to: 417-418
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@plugins/utils/commands/fix-pr.md` around lines 355 - 356, The conflict-resolution instruction is hardcoded to use origin/main, which breaks repos whose base branch is not main. Update the rebase guidance in the fix-pr markdown to use the resolved base branch value, matching the earlier BASE_BRANCH lookup logic, and make the same replacement in the other referenced location so both instructions stay consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@plugins/utils/commands/fix-pr.md`:
- Around line 355-356: The conflict-resolution instruction is hardcoded to use
origin/main, which breaks repos whose base branch is not main. Update the rebase
guidance in the fix-pr markdown to use the resolved base branch value, matching
the earlier BASE_BRANCH lookup logic, and make the same replacement in the other
referenced location so both instructions stay consistent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 3622c5e7-1081-4b91-97ae-9cf1e210d2ec
📒 Files selected for processing (4)
.claude-plugin/marketplace.jsondocs/index.htmlplugins/utils/.claude-plugin/plugin.jsonplugins/utils/commands/fix-pr.md
✅ Files skipped from review due to trivial changes (1)
- plugins/utils/.claude-plugin/plugin.json
Adds
/utils:fix-prcommand that iteratively resolves merge conflicts, addresses review comments, and fixes CI failures until the PR/MR is mergeable.Key features:
reviewtool)review getcall per iteration for all state (threads, mergeability, CI)review replyfor posting replies to review threadsreviewfrom cardil/review if missing, detects PATH bin dir--auto-approve=no|ai|human|allcontrols reply confirmation (default:ai-- bots auto-posted, humans require confirmation)--skip-reviews,--skip-rebase,-n NflagsSupersedes #240.
Assisted-by: 🤖 claude-sonnet-4-6
Summary by CodeRabbit
/utils:fix-prcommand.