ci: fix Claude Code Review workflow to post PR comments - #726
Merged
Conversation
The Claude Code Review workflow was not posting comments on PRs due to: 1. Insufficient permissions: pull-requests: read (needs write to post) 2. Max turns exhaustion: Claude ran out of 5 turns before posting 3. No guidance for fork PR behavior Changes: - Update permissions from pull-requests: read to pull-requests: write to allow posting PR review comments - Increase max-turns from 5 to 10 to ensure Claude completes review and successfully posts the comment - Add comprehensive documentation about fork PR approval requirements and setup instructions for maintainers - Add inline comment explaining the permission change This fixes the issue where Claude would analyze PRs but never post the review comments. With write permissions and more turns, Claude can now complete the review cycle and post feedback. Fork PRs will require manual approval by maintainers (security best practice to prevent secret exfiltration). Related: #722 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as resolved.
This comment was marked as resolved.
Additional fixes to Claude Code Review workflow: 1. Remove paths-ignore filter for workflow file itself - Previously prevented testing workflow changes - PR #726 was skipped because it only modified the workflow - Now workflow changes will trigger the review for testing 2. Add explicit fork PR skip condition - if: github.event.pull_request.head.repo.full_name == github.repository - Fork PRs cannot access secrets or OIDC tokens (GitHub security) - Gracefully skip instead of failing with authentication errors - Clear documentation explaining why and what alternatives exist 3. Update documentation - Explain GitHub's security model for fork PRs - Provide alternatives for fork PR reviews: * Use on-demand @claude workflow * Manual review * Merge first, review next PR - Remove misleading manual approval instructions (doesn't help) This ensures: - Fork PRs skip cleanly without errors - Workflow changes can be tested immediately - Clear guidance for maintainers handling fork PRs Related: PR #725 (fork) failed with OIDC token error Related: PR #726 was skipped due to path filter 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Reverts the removal of paths-ignore that was causing OIDC token validation failures on PR #726. Root Cause: - GitHub's security model requires workflow files using id-token: write to be byte-for-byte identical to the version on the master branch - When a PR modifies a workflow file, OIDC token exchange fails with: "401 Unauthorized - Workflow validation failed" - This is intentional security to prevent malicious workflow modifications from stealing tokens or secrets What Happened: 1. Commit 3934b75 (Oct 22) correctly added paths-ignore to prevent this error 2. Commit 76b6d1e (Nov 2) removed it to "allow testing workflow changes" 3. PR #726 now fails with the exact OIDC error that 3934b75 prevented The Paradox: - Removing paths-ignore doesn't enable testing - GitHub's security prevents it - Workflow modifications CANNOT be tested in PRs before merging (by design) - You cannot bypass OIDC validation for modified workflows Solution: - Restore paths-ignore for the workflow file itself - Add comprehensive documentation explaining GitHub's security restriction - Accept that workflow changes must be manually reviewed - Once merged to master, the updated workflow applies to all future PRs Changes: - Restored: paths-ignore: '.github/workflows/claude-code-review.yml' - Added: Detailed comments explaining OIDC validation and security model - Kept: pull-requests: write permission (needed for posting) - Kept: --max-turns 10 (prevents exhaustion) - Kept: Fork PR skip condition (prevents fork failures) After merging this PR: - Future workflow modifications will skip auto-review (expected) - Future PRs with code changes will get Claude reviews (working) - No more false-positive OIDC validation errors Related: Commit 3934b75 (original fix) Related: https://github.com/openvanilla/McBopomofo/actions/runs/19004088783 (OIDC error) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Fixes issue where Claude bot posted reviews to workflow output instead of PR comments, and encountered MCP permission denials. Root Cause (from run #19002226499): - Workflow used gh CLI (Bash tools) but execution used MCP tools - MCP tool allowlist was incomplete - missing mcp__github__get_pull_request - Permission denial prevented Claude from getting PR context - Reviews posted to workflow summary instead of PR Changes: 1. Replace Bash/gh CLI tools with MCP GitHub review tools - More reliable than CLI wrapper - Native GitHub API integration - Matches claude.yml workflow pattern 2. Complete MCP tool allowlist: - mcp__github__get_pull_request (ADDED - was missing, caused denials) - mcp__github__create_pending_pull_request_review - mcp__github__get_pull_request_diff - mcp__github__add_comment_to_pending_review - mcp__github__submit_pending_pull_request_review 3. Update prompt to use GitHub review system: - Clear step-by-step instructions for MCP tools - Request inline comments with suggestion blocks - Submit as "COMMENT" event type (non-blocking) Benefits: - Reviews post as proper GitHub PR reviews (not workflow logs) - Inline comments with one-click apply suggestions - No permission denial errors - Consistent with claude.yml on-demand workflow Related: https://github.com/openvanilla/McBopomofo/actions/runs/19002226499 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
tianjianjiang
requested review from
a team,
Copilot,
lukhnos,
mjhsieh and
zonble
November 1, 2025 20:43
Adds missing MCP tool to claude.yml to match claude-code-review.yml
configuration and eliminate permission denials.
Root Cause:
- Run #19002226499 (claude.yml) shows permission denial for
mcp__github__get_pull_request
- Claude tried to call this tool but it wasn't in the allowlist
- claude-code-review.yml has it, but claude.yml doesn't (inconsistency)
Evidence:
```json
"permission_denials": [{
"tool_name": "mcp__github__get_pull_request",
"tool_use_id": "toolu_016hAvM8afGTCeBQjMh5hyrk"
}]
```
What the Tool Provides:
- PR metadata: title, description, status, author, labels, branches
- Context about the PR's purpose and intent
- Complements get_pull_request_diff (which only shows code changes)
Why It's Needed:
- Diff alone doesn't explain the "why" behind changes
- Claude needs PR description to understand author's intent
- Leads to more contextual and relevant reviews
Changes:
1. Added mcp__github__get_pull_request to allowedTools list
2. Updated prompt to document the tool (step 1: "Get PR context")
3. Added inline comment explaining the addition
4. Now consistent with claude-code-review.yml (commit cf370da)
Benefits:
- Eliminates permission denials in @claude mentions
- Both workflows now have identical MCP tool capabilities
- Better review quality with full PR context
- Follows same fix pattern from claude-code-review.yml
Related: https://github.com/openvanilla/McBopomofo/actions/runs/19002226499
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This comment was marked as outdated.
This comment was marked as outdated.
tianjianjiang
marked this pull request as draft
November 1, 2025 21:04
Major refactoring to eliminate duplication and ensure MCP tool consistency across all Claude Code workflows. Changes: 1. Created new reusable workflow (claude-review-reusable.yml): - Single source of truth for MCP tool configuration - Standardized permissions and action setup - Parameterized prompt via workflow_call inputs - Complete MCP tool list including mcp__github__get_me 2. Refactored claude.yml to use reusable workflow: - Removed duplicated action configuration - Kept trigger logic (issue_comment, PR review comments) - Passes custom prompt as input - Much shorter and cleaner 3. Refactored claude-code-review.yml to use reusable workflow: - Removed duplicated action configuration - Kept fork PR skip condition - Kept paths-ignore for OIDC security - Passes custom prompt as input 4. Added mcp__github__get_me to standard tool list: - Fixes permission denials in run #19002499746 - Provides authenticated user context - Prevents wasted API calls - Now included automatically in both workflows Standard MCP Tool List (now centralized): - mcp__github__get_me (NEW - user context) - mcp__github__get_pull_request (PR metadata) - mcp__github__create_pending_pull_request_review (start review) - mcp__github__get_pull_request_diff (code changes) - mcp__github__add_comment_to_pending_review (inline comments) - mcp__github__submit_pending_pull_request_review (publish) Benefits: - Eliminates duplication (70+ lines reduced to ~30 per workflow) - Impossible for workflows to drift (single source of truth) - Easier maintenance (update once, applies everywhere) - Consistent MCP tools across all Claude workflows - No more permission denials for get_me or get_pull_request Evidence: - Run #19002499746 had permission denial for mcp__github__get_me - Run #19002226499 had permission denial for mcp__github__get_pull_request - Both now resolved by centralized tool list Related: https://github.com/openvanilla/McBopomofo/actions/runs/19002499746 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This comment was marked as outdated.
This comment was marked as outdated.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
tianjianjiang
marked this pull request as ready for review
November 2, 2025 04:56
- Move misaligned comment block from concurrency section to top level - Comments were incorrectly nested under concurrency key - Proper YAML structure with comments at appropriate indentation level - Maintains documentation about OIDC token validation behavior
- Remove github.event_name == 'pull_request' condition that never matches - Reusable workflows receive 'workflow_call' as event_name, not caller's event - Step will now execute properly when Claude review fails - Simplifies condition to just failure() check for better reliability
- Add explicit claude_args input parameter with clear default value - Extract complex multi-line conditional logic to simple parameter reference - Maintain backward compatibility with claude_args_override parameter - Improves maintainability and reduces risk of syntax errors - Makes default Claude arguments visible in workflow interface
- Extract error message body to environment variable with YAML pipe syntax - Replace single-line string with embedded newlines for better maintainability - Use multi-line YAML format for easier reading and modification - Preserve exact formatting and spacing for GitHub comment display - Improves code readability and reduces maintenance burden
- Add explicit bot exclusions to prevent unnecessary workflow runs - Enhance repository branch check with additional safety conditions - Reduce manual approval prompts for automated contributors - Maintain security while improving workflow automation efficiency
- Add copilot-autofix[bot] and copilot[bot] to exclusion list - Include github-actions[bot] for comprehensive bot coverage - Consolidate bot exclusions into single JSON array for better maintainability - Addresses the main source of manual approval requirements from Copilot PRs
- Change copilot-autofix[bot] to app/copilot-autofix (correct format) - Change copilot[bot] to github-copilot[bot] (official name) - Add copilot-for-business[bot] for GitHub Copilot Business accounts - Use accurate bot identifiers based on GitHub's actual bot naming conventions
- Remove unused claude_args_override input parameter entirely - Simplify claude_args logic to use direct parameter reference - No calling workflows use the deprecated parameter - Reduces maintenance burden and eliminates confusion - Cleaner API with single claude_args parameter
tianjianjiang
force-pushed
the
ci/fix_claude_code_review_posting
branch
from
November 2, 2025 07:20
310ee5c to
a51d166
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This comment was marked as off-topic.
This comment was marked as off-topic.
- Remove 'issues' trigger that lacks PR context for review tools - Add github.event.issue.pull_request check for issue_comment events - Prevent failures when @claude is mentioned on plain issues - Ensure all triggered events have necessary PR context for MCP tools - Add documentation about PR context requirement
- Change to copilot-pull-request-reviewer[bot] based on GitHub Apps URL pattern - Remove incorrect app/copilot-autofix and copilot-for-business[bot] names - Add standard copilot-autofix[bot] for autofix feature - Should resolve manual approval issues for Copilot-generated PRs
- Remove permissions block from claude-review-reusable.yml - Caller permissions take precedence and override reusable workflow permissions - Both calling workflows already declare identical permissions explicitly - Eliminates redundancy and potential confusion about permission inheritance - Add documentation about permission inheritance behavior
- Add repository owner check for additional security validation - Expand bot exclusion list with app/ prefixed variants - Add comprehensive documentation about repository settings requirement - Clarify that manual approvals are primarily a repository-level setting issue
tianjianjiang
marked this pull request as ready for review
November 2, 2025 07:45
|
Persistent review updated to latest commit f66bc92 |
zonble
approved these changes
Nov 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Fix Claude Code Review Workflow Issues
Comprehensive overhaul of Claude workflows to resolve reliability, permissions, and automation issues.
Files Changed
.github/workflows/claude-code-review.yml- Automatic PR reviews.github/workflows/claude.yml- Manual @claude trigger workflow.github/workflows/claude-review-reusable.yml- Shared workflow configurationProblems Solved
Manual Approval Requirements
Permission and Authentication Issues
Reliability and Error Handling
Code Quality and Maintainability
Technical Improvements
Workflow Architecture
Event Handling
Error Recovery
Result
Claude reviews now execute automatically without manual intervention, with robust error handling and clear user feedback when issues occur. All workflows validated with actionlint and follow conventional commit standards.
PR Type
Enhancement, Bug fix
Description
Centralize Claude review via reusable workflow
Grant PR write permissions for comments
Skip fork/bot PRs with clear guidance
Add concurrency, timeouts, and error reporting
Diagram Walkthrough
File Walkthrough
claude-code-review.yml
Use reusable workflow and correct permissions.github/workflows/claude-code-review.yml
pull-requests: write, addactions: readclaude-review-reusable.yml
New reusable Claude review workflow.github/workflows/claude-review-reusable.yml
claude_argswith MCP GitHub tools and max-turns 10claude.yml
Streamline manual @claude workflow via reusable job.github/workflows/claude.yml