Fix PR issues (review comments, test failures, missing docs) using Claude Code. Works as both a local CLI plugin and a reusable GitHub Action.
claude plugin install deployhq/claude-fix-prThen in any repo with a PR:
/fix-pr # fixes current branch's PR
/fix-pr 123 # fixes PR #123Add .github/workflows/fix-pr.yml to your repo:
name: Fix PR
on:
check_suite:
types: [completed]
issue_comment:
types: [created]
jobs:
fix-pr:
uses: deployhq/claude-fix-pr/.github/workflows/fix-pr.yml@main
secrets:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}That's it. The action will:
- Auto-trigger when CI fails on a PR branch
- Manual trigger when someone comments
/fix-pron a PR - Skip protected branches (main, master, staging)
flowchart TD
A["/fix-pr comment on PR"] --> B["React with eyes emoji"]
C["CI fails on PR branch"] --> D{Protected branch?}
B --> D
D -- Yes --> E["Skip — refuse to modify"]
D -- No --> F["Gather PR context via gh CLI"]
F --> G["Review comments"]
F --> H["CI failure logs"]
F --> I["Documentation feedback"]
F --> J["PR diff"]
G & H & I & J --> K["Fill prompt template"]
K --> L["Run Claude Code with scoped tools"]
L --> M{Changes made?}
M -- Yes --> N["Reply to each addressed comment"]
N --> O["Commit & push fixes"]
O --> Q["Post summary comment on PR"]
M -- No --> P["Comment: no issues found"]
- Gathers context — review comments (with IDs), CI failures, documentation feedback, and PR diff using
ghCLI - Builds a prompt — fills a shared template with all gathered context
- Runs Claude — Claude reads the context, makes targeted fixes, and replies to each addressed comment via
gh api - Reports back — commits changes and posts a summary comment on the PR
- Fixes review comments — reads inline code review feedback and conversation comments, applies fixes
- Fixes CI failures — analyzes test failures, linting errors, type check issues
- Fixes documentation — typos, missing docs, outdated comments
- Replies to comments — replies to each addressed review comment with a brief description of the fix
- Only modifies files in the PR's diff
- Refuses to run on protected branches (main, master, staging)
- Tool access is scoped — Claude can only read, edit, run tests/linters, and reply to PR comments
- In local mode, asks for confirmation before committing
- In CI mode, commits are attributed to
claude-fix-pr[bot]
- GitHub CLI (
gh) — authenticated - Claude Code CLI — for local plugin use
ANTHROPIC_API_KEY— set as environment variable (local) or GitHub secret (CI)
.claude-plugin/plugin.json — Plugin metadata
commands/fix-pr.md — Local /fix-pr slash command
agents/pr-fixer.md — Subagent for complex fixes
scripts/gather-pr-context.sh — Context gathering (shared by CLI and CI)
prompt-template.md — Prompt template (shared by CLI and CI)
.github/workflows/fix-pr.yml — Reusable GitHub Action workflow
The reusable workflow responds to check_suite (auto) and issue_comment (manual). To limit triggers, override in your calling workflow:
on:
issue_comment:
types: [created] # manual only — no auto-trigger on CI failure
jobs:
fix-pr:
uses: deployhq/claude-fix-pr/.github/workflows/fix-pr.yml@main
secrets:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}The workflow allows Claude to run common test commands (bin/rspec, rubocop, go test, yarn test, npm test). To add more, fork the workflow and extend the --allowedTools list.
MIT