Skip to content

Commit 627d016

Browse files
committed
Add issue-fix mode for automated bug fixes
1 parent 95a169e commit 627d016

6 files changed

Lines changed: 397 additions & 19 deletions

File tree

.github/workflows/claude-code.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
echo "feedback=$FEEDBACK" >> $GITHUB_OUTPUT
3333
3434
- name: Process with Claude Code
35-
uses: fractureinc/claude-code-github-action@v0.2.2
35+
uses: fractureinc/claude-code-github-action@v0.3.0
3636
with:
3737
mode: 'review'
3838
pr-number: ${{ steps.pr.outputs.number }}
@@ -64,7 +64,7 @@ jobs:
6464
echo "feedback=$FEEDBACK" >> $GITHUB_OUTPUT
6565
6666
- name: Process with Claude Code Suggestions
67-
uses: fractureinc/claude-code-github-action@v0.2.2
67+
uses: fractureinc/claude-code-github-action@v0.3.0
6868
with:
6969
mode: 'suggest'
7070
pr-number: ${{ steps.pr.outputs.number }}
@@ -104,7 +104,7 @@ jobs:
104104
echo "line=$LINE" >> $GITHUB_OUTPUT
105105
106106
- name: Process with Claude Code for code review comment
107-
uses: fractureinc/claude-code-github-action@v0.2.2
107+
uses: fractureinc/claude-code-github-action@v0.3.0
108108
with:
109109
mode: 'review'
110110
pr-number: ${{ steps.details.outputs.number }}
@@ -143,7 +143,7 @@ jobs:
143143
echo "line=$LINE" >> $GITHUB_OUTPUT
144144
145145
- name: Process with Claude Code Suggestions for code review
146-
uses: fractureinc/claude-code-github-action@v0.2.2
146+
uses: fractureinc/claude-code-github-action@v0.3.0
147147
with:
148148
mode: 'suggest-review'
149149
pr-number: ${{ steps.details.outputs.number }}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Claude Code Issue Fix
2+
3+
on:
4+
issues:
5+
types: [labeled]
6+
7+
jobs:
8+
process-issue-fix:
9+
runs-on: ubuntu-latest
10+
# Only run on issues with the 'claude-fix' label
11+
if: ${{ github.event.label.name == 'claude-fix' }}
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
issues: write
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Setup GitHub CLI
23+
run: |
24+
gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
25+
26+
- name: Setup git user
27+
run: |
28+
git config --global user.name "Claude Code Bot"
29+
git config --global user.email "claude-bot@example.com"
30+
31+
- name: Process issue with Claude Code
32+
uses: fractureinc/claude-code-github-action@v0.3.0
33+
with:
34+
mode: 'issue-fix'
35+
issue-number: ${{ github.event.issue.number }}
36+
repo-owner: ${{ github.repository_owner }}
37+
repo-name: ${{ github.repository }}
38+
branch-prefix: 'fix'
39+
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
40+
github-token: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 76 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This GitHub Action integrates Claude Code in your GitHub workflows, enabling AI-
77
- Process PR comments prefixed with "claude:" for general analysis
88
- Process PR comments prefixed with "claude-suggest:" for code suggestions
99
- Process code review comments to provide in-line analysis and suggestions
10+
- Automatically analyze issues and create fix PRs based on issue labels
1011
- Provide rich context about the PR to Claude, including file diffs
1112
- Get AI-powered code analysis and suggestions
1213
- Create GitHub-compatible suggested changes that can be applied with one click
@@ -49,7 +50,7 @@ jobs:
4950
echo "feedback=$FEEDBACK" >> $GITHUB_OUTPUT
5051
5152
- name: Process with Claude Code
52-
uses: fractureinc/claude-code-github-action@v0.2.2
53+
uses: fractureinc/claude-code-github-action@v0.3.0
5354
with:
5455
mode: 'review'
5556
pr-number: ${{ steps.pr.outputs.number }}
@@ -81,7 +82,7 @@ jobs:
8182
echo "feedback=$FEEDBACK" >> $GITHUB_OUTPUT
8283
8384
- name: Process with Claude Code Suggestions
84-
uses: fractureinc/claude-code-github-action@v0.2.2
85+
uses: fractureinc/claude-code-github-action@v0.3.0
8586
with:
8687
mode: 'suggest'
8788
pr-number: ${{ steps.pr.outputs.number }}
@@ -94,29 +95,35 @@ jobs:
9495
9596
| Input | Description | Required | Default |
9697
|-------|-------------|----------|---------|
97-
| `mode` | Operation mode (review, suggest, suggest-review, direct) | Yes | `review` |
98+
| `mode` | Operation mode (review, suggest, suggest-review, issue-fix, direct) | Yes | `review` |
9899
| `pr-number` | Pull request number | Yes* | |
99-
| `feedback` | User query text | Yes | |
100+
| `feedback` | User query text | Yes* | |
100101
| `file-path` | Path to the file being reviewed (for suggest-review mode) | No** | |
101102
| `line-number` | Line number in the file (for suggest-review mode) | No** | |
102103
| `comment-id` | GitHub comment ID to reply to (for suggest-review mode) | No** | |
104+
| `issue-number` | Issue number (for issue-fix mode) | Yes*** | |
105+
| `repo-owner` | Owner of the repository (for issue-fix mode) | Yes*** | |
106+
| `repo-name` | Name of the repository (for issue-fix mode) | Yes*** | |
107+
| `branch-prefix` | Prefix for the feature branch created for issue fixes | No | `fix` |
103108
| `strict-mode` | Whether to strictly follow user requests without adding unrelated improvements | No | `true` |
104109
| `anthropic-api-key` | Anthropic API key | Yes | |
105110
| `github-token` | GitHub token | Yes | |
106111
| `output-file` | Output file path (for direct mode) | No | `claude-code-output` |
107112

108113
\* Required when mode is 'review' or 'suggest'
109-
\** Required when mode is 'suggest-review'
114+
\** Required when mode is 'suggest-review'
115+
\*** Required when mode is 'issue-fix'
110116

111117
## Enhanced Context for Claude
112118

113-
With version 0.2.2, Claude now receives complete context for your PRs, including:
119+
With version 0.3.0, Claude now receives complete context for your PRs and issues, including:
114120

115121
- PR metadata (title, description, branch info)
116-
- List of all files changed
117-
- Complete diff of all changes in the PR
118-
- Repository information
119-
- Full repository checkout for improved code understanding
122+
- Issue details (title, description, labels)
123+
- List of all files changed in PRs
124+
- Complete diff of all changes in PRs
125+
- Repository information (name, description, languages)
126+
- Full repository checkout for improved code understanding and analysis
120127

121128
## Available Modes
122129

@@ -134,6 +141,16 @@ Creates true GitHub-compatible suggestions that can be applied with one click di
134141

135142
By default, this mode uses "strict mode" which ensures Claude only makes changes specifically related to what was requested, without adding unrelated improvements. You can disable strict mode by setting `strict-mode: 'false'` to allow Claude to suggest additional improvements.
136143
144+
### Issue Fix Mode (`mode: 'issue-fix'`)
145+
146+
Analyzes GitHub issues labeled with "claude-fix" and automatically creates a PR with proposed fixes. This mode:
147+
- Analyzes the issue description to understand the problem
148+
- Identifies affected files in the codebase
149+
- Implements code changes to fix the issue
150+
- Creates a branch with the changes
151+
- Opens a PR with detailed explanation
152+
- Comments on the original issue with a link to the PR
153+
137154
### Direct Mode (`mode: 'direct'`)
138155

139156
Sends a query directly to Claude and saves the response to a file without PR context.
@@ -183,6 +200,55 @@ permissions:
183200
issues: write
184201
```
185202

203+
## Issue Fix Workflow
204+
205+
Create a workflow file (`.github/workflows/claude-issue-fix.yml`) that responds to issues labeled with "claude-fix":
206+
207+
```yaml
208+
name: Claude Code Issue Fix
209+
210+
on:
211+
issues:
212+
types: [labeled]
213+
214+
jobs:
215+
process-issue-fix:
216+
runs-on: ubuntu-latest
217+
# Only run on issues with the 'claude-fix' label
218+
if: ${{ github.event.label.name == 'claude-fix' }}
219+
permissions:
220+
contents: write # Needed to create branches
221+
pull-requests: write # Needed to create PRs
222+
issues: write # Needed to comment on issues
223+
steps:
224+
- name: Checkout repository
225+
uses: actions/checkout@v4
226+
with:
227+
fetch-depth: 0
228+
229+
- name: Setup GitHub CLI
230+
run: |
231+
gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
232+
233+
- name: Setup git user
234+
run: |
235+
git config --global user.name "Claude Code Bot"
236+
git config --global user.email "claude-bot@example.com"
237+
238+
- name: Process issue with Claude Code
239+
uses: fractureinc/claude-code-github-action@v0.3.0
240+
with:
241+
mode: 'issue-fix'
242+
issue-number: ${{ github.event.issue.number }}
243+
repo-owner: ${{ github.repository_owner }}
244+
repo-name: ${{ github.repository }}
245+
branch-prefix: 'fix'
246+
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
247+
github-token: ${{ secrets.GITHUB_TOKEN }}
248+
```
249+
250+
This workflow is triggered when an issue is labeled with "claude-fix". Only repo maintainers with write access can add this label, providing security control.
251+
186252
## License
187253

188254
MIT

action.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,25 @@ branding:
66

77
inputs:
88
mode:
9-
description: 'The mode to run the action in (review, suggest, suggest-review, direct)'
9+
description: 'The mode to run the action in (review, suggest, suggest-review, issue-fix, direct)'
1010
required: true
1111
default: 'review'
1212
pr-number:
13-
description: 'Pull request number'
13+
description: 'Pull request number (for PR-related modes)'
1414
required: false
15+
issue-number:
16+
description: 'Issue number (for issue-fix mode)'
17+
required: false
18+
repo-owner:
19+
description: 'Owner of the repository (for issue-fix mode)'
20+
required: false
21+
repo-name:
22+
description: 'Name of the repository (for issue-fix mode)'
23+
required: false
24+
branch-prefix:
25+
description: 'Prefix for the feature branch created for issue fixes'
26+
required: false
27+
default: 'fix'
1528
feedback:
1629
description: 'The feedback text from the comment'
1730
required: false
@@ -83,4 +96,11 @@ runs:
8396
shell: bash
8497
run: |
8598
chmod +x ${{ github.action_path }}/scripts/suggest-review-mode.sh
86-
${{ github.action_path }}/scripts/suggest-review-mode.sh "${{ inputs.pr-number }}" "${{ inputs.feedback }}" "${{ inputs.file-path }}" "${{ inputs.line-number }}" "${{ inputs.comment-id }}" "${{ inputs.anthropic-api-key }}" "${{ inputs.github-token }}" "${{ inputs.strict-mode }}"
99+
${{ github.action_path }}/scripts/suggest-review-mode.sh "${{ inputs.pr-number }}" "${{ inputs.feedback }}" "${{ inputs.file-path }}" "${{ inputs.line-number }}" "${{ inputs.comment-id }}" "${{ inputs.anthropic-api-key }}" "${{ inputs.github-token }}" "${{ inputs.strict-mode }}"
100+
101+
- name: Process Issue Fix
102+
if: inputs.mode == 'issue-fix'
103+
shell: bash
104+
run: |
105+
chmod +x ${{ github.action_path }}/scripts/issue-fix-mode.sh
106+
${{ github.action_path }}/scripts/issue-fix-mode.sh "${{ inputs.issue-number }}" "${{ inputs.repo-owner }}" "${{ inputs.repo-name }}" "${{ inputs.branch-prefix }}" "${{ inputs.anthropic-api-key }}" "${{ inputs.github-token }}"

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "claude-code-github-action",
3-
"version": "0.2.2",
4-
"description": "GitHub action for Claude Code Integration in PR comments, reviews and inline code suggestions",
3+
"version": "0.3.0",
4+
"description": "GitHub action for Claude Code Integration in PR comments, reviews, inline code suggestions, and issue-based fixes",
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1"

0 commit comments

Comments
 (0)