Skip to content

Add Claude PR reviewer command and CI workflow#2379

Merged
MarceloRGonc merged 7 commits into
mainfrom
feature/claude-pr-reviewer
Jun 25, 2026
Merged

Add Claude PR reviewer command and CI workflow#2379
MarceloRGonc merged 7 commits into
mainfrom
feature/claude-pr-reviewer

Conversation

@MarceloRGonc

@MarceloRGonc MarceloRGonc commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an automated PR review system using Claude Code Action:

  • .claude/commands/review-code.md — Multi-phase review command that:

    • Gathers PR context (diff, metadata, existing comments)
    • Analyzes through 14 OpenOps-specific lenses (design, workflow execution, security, migrations, etc.)
    • Validates findings with confidence scoring via subagents (drops false positives below 75%)
    • Previews findings before posting (interactive locally, auto-posts in CI)
    • Posts inline GitHub review comments + upsertable summary comment
  • .github/workflows/pr-reviewer.yml — CI workflow that:

    • Accepts PR number and optional model input
    • Uses GitHub App token for auth
    • Renders the review prompt and runs Claude Code Action
    • Posts a failure comment on the PR if the workflow errors

Testing

  • Verified workflow YAML syntax
  • Reviewed command structure against Claude Code Action docs
  • Confirmed lint-staged/prettier ran cleanly on commit

Part of CI-202

- Add .claude/commands/review-code.md with multi-phase review process
  (gather context, analyze through OpenOps-specific lenses, validate
  with confidence scoring, preview, and post inline comments)
- Update .github/workflows/pr-reviewer.yml to run Claude Code Action
  with the review prompt, GitHub App auth, and failure notifications

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 24, 2026 16:48
@linear

linear Bot commented Jun 24, 2026

Copy link
Copy Markdown

CI-202

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Claude Code–driven PR review command plus a manually triggered GitHub Actions workflow to run it and post results back to the PR.

Changes:

  • Extends .github/workflows/pr-reviewer.yml to accept a model input, obtain a GitHub App token, render the review prompt, run anthropics/claude-code-action, and comment on failures.
  • Adds .claude/commands/review-code.md, a multi-phase review procedure/prompt tailored to the OpenOps repo and review conventions.

Blocking

  • actions/create-github-app-token is configured with client-id instead of the repo’s established app-id input key, which will break token generation and the workflow run.
  • Prompt rendering only substitutes $ARGUMENTS, leaving {PR_NUMBER} placeholders literal in CI (likely degrading or breaking the command instructions).
  • PR number validation claims “positive integer” but currently permits 0.

Non-blocking

  • Security hardening: CI grants the agent Bash + Write tools while secrets are present, increasing prompt-injection blast radius; consider tightening allowed tools and/or gating with an environment approval.

Merge recommendation

Do not merge

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
.github/workflows/pr-reviewer.yml Implements the dispatchable CI workflow to run Claude Code Action against a PR and post results.
.claude/commands/review-code.md Adds the structured multi-phase review “command” content used as the action prompt.

Comment thread .github/workflows/pr-reviewer.yml
Comment thread .github/workflows/pr-reviewer.yml Outdated
Comment thread .github/workflows/pr-reviewer.yml
Comment thread .github/workflows/pr-reviewer.yml
MarceloRGonc and others added 3 commits June 24, 2026 18:09
The CI workflow could not produce a valid review as written: the shallow
checkout left the merge base out of history (empty/wrong diffs) and the
review step had no GH_TOKEN, so the gh-based checkout and summary upsert
would fail auth silently. Add fetch-depth: 0 and GH_TOKEN, and expose
Glob/Grep for cross-file validation in CI.

Also harden the command: validation subagents now read referenced files
instead of dropping cross-file findings, large diffs analyze per-file with
an explicit coverage note, inline comments skip unaddable lines and fall
back to the summary, lockfiles are excluded from the most-changed read,
and the LOCAL merge base is resolved once against origin/main.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@MarceloRGonc MarceloRGonc requested a review from ravikiranvm June 25, 2026 08:11
Inline comments never posted in CI: the workflow_dispatch trigger gates
out claude-code-action's inline-comment MCP server (context.isPR is false,
upstream issue #635), so pull_request_review_write calls were denied and the
buffer drained empty. Switch all posting — inline review, summary comment,
and UPDATE-mode replies — to gh api over Bash, which is authenticated in
both CI and local, needs no MCP server, and sidesteps the buffering and
isPR gate entirely. Keep the 422-on-unaddable-line guard and summary
fallback. Drop the now-unused github write tools from both tool lists;
pull_request_read stays as the only GitHub MCP tool (PR data fetch).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@MarceloRGonc MarceloRGonc enabled auto-merge (squash) June 25, 2026 09:05
Replace the Phase 2 pull_request_read MCP call with gh pr view (metadata),
git diff against origin/<base> (the PR is already checked out), and gh api
for existing comments/reviews. The command now uses no GitHub MCP tools at
all, so PR mode works identically in CI and locally without an MCP server.
Drop the last MCP entry from both tool lists.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@MarceloRGonc MarceloRGonc merged commit 01813cd into main Jun 25, 2026
21 checks passed
@MarceloRGonc MarceloRGonc deleted the feature/claude-pr-reviewer branch June 25, 2026 09:43
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants