11# Claude Code GitHub Action
22
3- This GitHub Action integrates Claude Code in your GitHub workflows, enabling AI-assisted code reviews and responses to PR comments.
3+ This GitHub Action integrates Claude Code in your GitHub workflows, enabling AI-assisted code reviews, suggestions, and responses to PR comments.
44
55## Features
66
7- - Process PR comments prefixed with "claude:"
7+ - Process PR comments prefixed with "claude:" for general analysis
8+ - Process PR comments prefixed with "claude-suggest:" for clickable code suggestions
89- Provide rich context about the PR to Claude, including file diffs
910- Get AI-powered code analysis and suggestions
11+ - Create GitHub-compatible suggested changes that can be applied with one click
1012- Simple setup with minimal configuration
1113- Uses GitHub CLI and Claude Code CLI for reliability
1214
1315## Usage
1416
15- Create a workflow file that responds to comments containing the "claude:" prefix :
17+ Create a workflow file ( ` .github/workflows/claude-code.yml ` ) that responds to comments with the appropriate prefixes :
1618
1719``` yaml
1820name : Claude Code Integration
1921
2022on :
2123 issue_comment :
2224 types : [created]
23- pull_request_review_comment :
24- types : [created]
2525
2626jobs :
27- process-pr-comment :
27+ process-pr-review :
2828 runs-on : ubuntu-latest
2929 if : ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, 'claude:') }}
3030 permissions :
3131 contents : read
3232 pull-requests : write
3333 issues : write
3434 steps :
35+ - name : Checkout code
36+ uses : actions/checkout@v4
37+ with :
38+ fetch-depth : 0
39+
3540 - name : Get PR details
3641 id : pr
3742 run : |
@@ -43,60 +48,114 @@ jobs:
4348 echo "feedback=$FEEDBACK" >> $GITHUB_OUTPUT
4449
4550 - name : Process with Claude Code
46- uses : fractureinc/claude-code-github-action@v0.1.7
51+ uses : fractureinc/claude-code-github-action@v0.2.0
4752 with :
4853 mode : ' review'
4954 pr-number : ${{ steps.pr.outputs.number }}
5055 feedback : ${{ steps.pr.outputs.feedback }}
5156 anthropic-api-key : ${{ secrets.ANTHROPIC_API_KEY }}
5257 github-token : ${{ secrets.GITHUB_TOKEN }}
58+
59+ process-pr-suggestions :
60+ runs-on : ubuntu-latest
61+ if : ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, 'claude-suggest:') }}
62+ permissions :
63+ contents : read
64+ pull-requests : write
65+ issues : write
66+ steps :
67+ - name : Checkout code
68+ uses : actions/checkout@v4
69+ with :
70+ fetch-depth : 0
71+
72+ - name : Get PR details
73+ id : pr
74+ run : |
75+ PR_NUMBER="${{ github.event.issue.number }}"
76+ FEEDBACK="${{ github.event.comment.body }}"
77+ # Remove the "claude-suggest:" prefix
78+ FEEDBACK="${FEEDBACK#claude-suggest:}"
79+ echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT
80+ echo "feedback=$FEEDBACK" >> $GITHUB_OUTPUT
81+
82+ - name : Process with Claude Code Suggestions
83+ uses : fractureinc/claude-code-github-action@v0.2.0
84+ with :
85+ mode : ' suggest'
86+ pr-number : ${{ steps.pr.outputs.number }}
87+ feedback : ${{ steps.pr.outputs.feedback }}
88+ anthropic-api-key : ${{ secrets.ANTHROPIC_API_KEY }}
89+ github-token : ${{ secrets.GITHUB_TOKEN }}
5390` ` `
5491
5592## Configuration
5693
5794| Input | Description | Required | Default |
5895|-------|-------------|----------|---------|
59- | ` mode` | Operation mode (review or direct) | Yes | `review` |
96+ | ` mode` | Operation mode (review, suggest, direct) | Yes | `review` |
6097| `pr-number` | Pull request number | Yes* | |
6198| `feedback` | User query text | Yes | |
6299| `anthropic-api-key` | Anthropic API key | Yes | |
63100| `github-token` | GitHub token | Yes | |
64101| `output-file` | Output file path (for direct mode) | No | `claude-code-output` |
65102
66- \* Required when mode is 'review'
103+ \* Required when mode is 'review' or 'suggest'
67104
68105# # Enhanced Context for Claude
69106
70- With version 0.1.7 , Claude now receives complete context for your PRs, including :
107+ With version 0.2.0 , Claude now receives complete context for your PRs, including :
71108
72109- PR metadata (title, description, branch info)
73110- List of all files changed
74111- Complete diff of all changes in the PR
75112- Repository information
113+ - Full repository checkout for improved code understanding
76114
77- This allows Claude to provide much more accurate and helpful responses about your code changes.
115+ # # Available Modes
116+
117+ # ## Review Mode (`mode: 'review'`)
118+
119+ Standard mode that provides Claude's analysis and feedback about your PR changes as a comment.
120+
121+ # ## Suggest Mode (`mode: 'suggest'`)
122+
123+ Creates GitHub-compatible suggested changes that can be applied with one click directly from the PR interface.
124+
125+ # ## Direct Mode (`mode: 'direct'`)
126+
127+ Sends a query directly to Claude and saves the response to a file without PR context.
78128
79129# # Example Queries
80130
81- Here are some example queries you can use with the claude : prefix:
131+ # ## Review Mode Examples (prefix: ` claude:`)
82132
83133- `claude : Explain the changes in this PR`
84134- `claude : Can you suggest improvements to the code?`
85135- `claude : Are there any security issues in these changes?`
86136- `claude : How would you refactor this to be more maintainable?`
87137- `claude : What tests should be added for this code?`
88138
139+ # ## Suggest Mode Examples (prefix: `claude-suggest:`)
140+
141+ - `claude-suggest : Improve error handling in the API client`
142+ - `claude-suggest : Fix any potential memory leaks`
143+ - `claude-suggest : Optimize the database query on line 25`
144+ - `claude-suggest : Make this code more readable`
145+
89146# # How It Works
90147
91- 1. The action is triggered when a comment starting with "claude:" is detected on a PR
148+ 1. The action is triggered when a comment with the appropriate prefix is detected on a PR
921492. The action extracts the PR number and the user's query
93- 3. Using GitHub CLI, the action fetches comprehensive information about the PR including :
150+ 3. The repository is checked out to provide full code context
151+ 4. Using GitHub CLI, the action fetches comprehensive information about the PR including :
94152 - PR metadata
95153 - List of files changed
96154 - Complete diff of all changes
97- 4. This rich context is provided to Claude along with the user's query
98- 5. Claude processes the information and provides a helpful response
99- 6. The response is posted as a comment on the PR
155+ 5. This rich context is provided to Claude along with the user's query
156+ 6. Claude processes the information and provides a helpful response
157+ 7. For review mode : The response is posted as a comment on the PR
158+ 8. For suggest mode : Claude formats responses as GitHub suggested changes that can be applied with one click
100159
101160# # Permissions
102161
0 commit comments