Skip to content

Commit 117d932

Browse files
committed
Merge upstream/main into fork
2 parents f70aaf0 + f6e5597 commit 117d932

26 files changed

Lines changed: 1051 additions & 284 deletions

.DS_Store

-8 KB
Binary file not shown.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ""
5+
labels: bug
6+
assignees: ""
7+
---
8+
9+
**Describe the bug**
10+
A clear and concise description of what the bug is.
11+
12+
**To Reproduce**
13+
Steps to reproduce the behavior:
14+
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Workflow yml file**
27+
If it's not sensitive, consider including a paste of your full Claude workflow.yml file.
28+
29+
**API Provider**
30+
31+
[ ] Anthropic First-Party API (default)
32+
[ ] AWS Bedrock
33+
[ ] GCP Vertex
34+
35+
**Additional context**
36+
Add any other context about the problem here.

.github/workflows/claude.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ jobs:
3434
uses: anthropics/claude-code-action@beta
3535
with:
3636
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
37+
allowed_tools: "Bash(bun install),Bash(bun test:*),Bash(bun run format),Bash(bun typecheck)"
38+
custom_instructions: "You have also been granted tools for editing files and running bun commands (install, run, test, typecheck) for testing your changes: bun install, bun test, bun run format, bun typecheck."
39+
model: "claude-opus-4-20250514"

.github/workflows/issue-triage.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Claude Issue Triage
2+
description: Run Claude Code for issue triage in GitHub Actions
3+
on:
4+
issues:
5+
types: [opened]
6+
7+
jobs:
8+
triage-issue:
9+
runs-on: ubuntu-latest
10+
timeout-minutes: 10
11+
permissions:
12+
contents: read
13+
issues: write
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Setup GitHub MCP Server
22+
run: |
23+
mkdir -p /tmp/mcp-config
24+
cat > /tmp/mcp-config/mcp-servers.json << 'EOF'
25+
{
26+
"github": {
27+
"command": "docker",
28+
"args": [
29+
"run",
30+
"-i",
31+
"--rm",
32+
"-e",
33+
"GITHUB_PERSONAL_ACCESS_TOKEN",
34+
"ghcr.io/github/github-mcp-server:sha-7aced2b"
35+
],
36+
"env": {
37+
"GITHUB_PERSONAL_ACCESS_TOKEN": "${{ secrets.GITHUB_TOKEN }}"
38+
}
39+
}
40+
}
41+
EOF
42+
43+
- name: Create triage prompt
44+
run: |
45+
mkdir -p /tmp/claude-prompts
46+
cat > /tmp/claude-prompts/triage-prompt.txt << 'EOF'
47+
You're an issue triage assistant for GitHub issues. Your task is to analyze the issue and select appropriate labels from the provided list.
48+
49+
IMPORTANT: Don't post any comments or messages to the issue. Your only action should be to apply labels.
50+
51+
Issue Information:
52+
- REPO: ${{ github.repository }}
53+
- ISSUE_NUMBER: ${{ github.event.issue.number }}
54+
55+
TASK OVERVIEW:
56+
57+
1. First, fetch the list of labels available in this repository by running: `gh label list`. Run exactly this command with nothing else.
58+
59+
2. Next, use the GitHub tools to get context about the issue:
60+
- You have access to these tools:
61+
- mcp__github__get_issue: Use this to retrieve the current issue's details including title, description, and existing labels
62+
- mcp__github__get_issue_comments: Use this to read any discussion or additional context provided in the comments
63+
- mcp__github__update_issue: Use this to apply labels to the issue (do not use this for commenting)
64+
- mcp__github__search_issues: Use this to find similar issues that might provide context for proper categorization and to identify potential duplicate issues
65+
- mcp__github__list_issues: Use this to understand patterns in how other issues are labeled
66+
- Start by using mcp__github__get_issue to get the issue details
67+
68+
3. Analyze the issue content, considering:
69+
- The issue title and description
70+
- The type of issue (bug report, feature request, question, etc.)
71+
- Technical areas mentioned
72+
- Severity or priority indicators
73+
- User impact
74+
- Components affected
75+
76+
4. Select appropriate labels from the available labels list provided above:
77+
- Choose labels that accurately reflect the issue's nature
78+
- Be specific but comprehensive
79+
- Select priority labels if you can determine urgency (high-priority, med-priority, or low-priority)
80+
- Consider platform labels (android, ios) if applicable
81+
- If you find similar issues using mcp__github__search_issues, consider using a "duplicate" label if appropriate. Only do so if the issue is a duplicate of another OPEN issue.
82+
83+
5. Apply the selected labels:
84+
- Use mcp__github__update_issue to apply your selected labels
85+
- DO NOT post any comments explaining your decision
86+
- DO NOT communicate directly with users
87+
- If no labels are clearly applicable, do not apply any labels
88+
89+
IMPORTANT GUIDELINES:
90+
- Be thorough in your analysis
91+
- Only select labels from the provided list above
92+
- DO NOT post any comments to the issue
93+
- Your ONLY action should be to apply labels using mcp__github__update_issue
94+
- It's okay to not add any labels if none are clearly applicable
95+
EOF
96+
97+
- name: Run Claude Code for Issue Triage
98+
uses: anthropics/claude-code-base-action@beta
99+
with:
100+
prompt_file: /tmp/claude-prompts/triage-prompt.txt
101+
allowed_tools: "Bash(gh label list),mcp__github__get_issue,mcp__github__get_issue_comments,mcp__github__update_issue,mcp__github__search_issues,mcp__github__list_issues"
102+
mcp_config: /tmp/mcp-config/mcp-servers.json
103+
timeout_minutes: "5"
104+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.DS_Store
12
node_modules
23

34
**/.claude/settings.local.json

FAQ.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Frequently Asked Questions (FAQ)
2+
3+
This FAQ addresses common questions and gotchas when using the Claude Code GitHub Action.
4+
5+
## Triggering and Authentication
6+
7+
### Why doesn't tagging @claude from my automated workflow work?
8+
9+
The `github-actions` user cannot trigger subsequent GitHub Actions workflows. This is a GitHub security feature to prevent infinite loops. To make this work, you need to use a Personal Access Token (PAT) instead, which will act as a regular user, or use a separate app token of your own. When posting a comment on an issue or PR from your workflow, use your PAT instead of the `GITHUB_TOKEN` generated in your workflow.
10+
11+
### Why does Claude say I don't have permission to trigger it?
12+
13+
Only users with **write permissions** to the repository can trigger Claude. This is a security feature to prevent unauthorized use. Make sure the user commenting has at least write access to the repository.
14+
15+
### Why am I getting OIDC authentication errors?
16+
17+
If you're using the default GitHub App authentication, you must add the `id-token: write` permission to your workflow:
18+
19+
```yaml
20+
permissions:
21+
contents: read
22+
id-token: write # Required for OIDC authentication
23+
```
24+
25+
The OIDC token is required in order for the Claude GitHub app to function. If you wish to not use the GitHub app, you can instead provide a `github_token` input to the action for Claude to operate with. See the [Claude Code permissions documentation][perms] for more.
26+
27+
## Claude's Capabilities and Limitations
28+
29+
### Why won't Claude update workflow files when I ask it to?
30+
31+
The GitHub App for Claude doesn't have workflow write access for security reasons. This prevents Claude from modifying CI/CD configurations that could potentially create unintended consequences. This is something we may reconsider in the future.
32+
33+
### Why won't Claude rebase my branch?
34+
35+
By default, Claude only uses commit tools for non-destructive changes to the branch. Claude is configured to:
36+
37+
- Never push to branches other than where it was invoked (either its own branch or the PR branch)
38+
- Never force push or perform destructive operations
39+
40+
You can grant additional tools via the `allowed_tools` input if needed:
41+
42+
```yaml
43+
allowed_tools: "Bash(git rebase:*)" # Use with caution
44+
```
45+
46+
### Why won't Claude create a pull request?
47+
48+
Claude doesn't create PRs by default. Instead, it pushes commits to a branch and provides a link to a pre-filled PR submission page. This approach ensures your repository's branch protection rules are still adhered to and gives you final control over PR creation.
49+
50+
### Why can't Claude run my tests or see CI results?
51+
52+
Claude cannot access GitHub Actions logs, test results, or other CI/CD outputs by default. It only has access to the repository files. If you need Claude to see test results, you can either:
53+
54+
1. Instruct Claude to run tests before making commits
55+
2. Copy and paste CI results into a comment for Claude to analyze
56+
57+
This limitation exists for security reasons but may be reconsidered in the future based on user feedback.
58+
59+
### Why does Claude only update one comment instead of creating new ones?
60+
61+
Claude is configured to update a single comment to avoid cluttering PR/issue discussions. All of Claude's responses, including progress updates and final results, will appear in the same comment with checkboxes showing task progress.
62+
63+
## Branch and Commit Behavior
64+
65+
### Why did Claude create a new branch when commenting on a closed PR?
66+
67+
Claude's branch behavior depends on the context:
68+
69+
- **Open PRs**: Pushes directly to the existing PR branch
70+
- **Closed/Merged PRs**: Creates a new branch (cannot push to closed PR branches)
71+
- **Issues**: Always creates a new branch with a timestamp
72+
73+
### Why are my commits shallow/missing history?
74+
75+
For performance, Claude uses shallow clones:
76+
77+
- PRs: `--depth=20` (last 20 commits)
78+
- New branches: `--depth=1` (single commit)
79+
80+
If you need full history, you can configure this in your workflow before calling Claude in the `actions/checkout` step.
81+
82+
```
83+
- uses: actions/checkout@v4
84+
depth: 0 # will fetch full repo history
85+
```
86+
87+
## Configuration and Tools
88+
89+
### What's the difference between `direct_prompt` and `custom_instructions`?
90+
91+
These inputs serve different purposes in how Claude responds:
92+
93+
- **`direct_prompt`**: Bypasses trigger detection entirely. When provided, Claude executes this exact instruction regardless of comments or mentions. Perfect for automated workflows where you want Claude to perform a specific task on every run (e.g., "Update the API documentation based on changes in this PR").
94+
95+
- **`custom_instructions`**: Additional context added to Claude's system prompt while still respecting normal triggers. These instructions modify Claude's behavior but don't replace the triggering comment. Use this to give Claude standing instructions like "You have been granted additional tools for ...".
96+
97+
Example:
98+
99+
```yaml
100+
# Using direct_prompt - runs automatically without @claude mention
101+
direct_prompt: "Review this PR for security vulnerabilities"
102+
103+
# Using custom_instructions - still requires @claude trigger
104+
custom_instructions: "Focus on performance implications and suggest optimizations"
105+
```
106+
107+
### Why doesn't Claude execute my bash commands?
108+
109+
The Bash tool is **disabled by default** for security. To enable individual bash commands:
110+
111+
```yaml
112+
allowed_tools: "Bash(npm:*),Bash(git:*)" # Allows only npm and git commands
113+
```
114+
115+
### Can Claude work across multiple repositories?
116+
117+
No, Claude's GitHub app token is sandboxed to the current repository only. It cannot push to any other repositories. It can, however, read public repositories, but to get access to this, you must configure it with tools to do so.
118+
119+
## MCP Servers and Extended Functionality
120+
121+
### What MCP servers are available by default?
122+
123+
Claude Code Action automatically configures two MCP servers:
124+
125+
1. **GitHub MCP server**: For GitHub API operations
126+
2. **File operations server**: For advanced file manipulation
127+
128+
However, tools from these servers still need to be explicitly allowed via `allowed_tools`.
129+
130+
## Troubleshooting
131+
132+
### How can I debug what Claude is doing?
133+
134+
Check the GitHub Action log for Claude's run for the full execution trace.
135+
136+
### Why can't I trigger Claude with `@claude-mention` or `claude!`?
137+
138+
The trigger uses word boundaries, so `@claude` must be a complete word. Variations like `@claude-bot`, `@claude!`, or `claude@mention` won't work unless you customize the `trigger_phrase`.
139+
140+
## Best Practices
141+
142+
1. **Always specify permissions explicitly** in your workflow file
143+
2. **Use GitHub Secrets** for API keys - never hardcode them
144+
3. **Be specific with `allowed_tools`** - only enable what's necessary
145+
4. **Test in a separate branch** before using on important PRs
146+
5. **Monitor Claude's token usage** to avoid hitting API limits
147+
6. **Review Claude's changes** carefully before merging
148+
149+
## Getting Help
150+
151+
If you encounter issues not covered here:
152+
153+
1. Check the [GitHub Issues](https://github.com/anthropics/claude-code-action/issues)
154+
2. Review the [example workflows](https://github.com/anthropics/claude-code-action#examples)
155+
156+
[perms]: https://docs.anthropic.com/en/docs/claude-code/settings#permissions

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ This fork allows Claude Max subscribers to use their subscription in GitHub Acti
5555
- `CLAUDE_EXPIRES_AT`: The token expiration timestamp
5656
4. Use the OAuth configuration in your workflow (see examples below)
5757

58+
## 📚 FAQ
59+
60+
Having issues or questions? Check out our [Frequently Asked Questions](./FAQ.md) for solutions to common problems and detailed explanations of Claude's capabilities and limitations.
61+
5862
## Usage
5963

6064
Add a workflow file to your repository (e.g., `.github/workflows/claude.yml`):
@@ -499,7 +503,7 @@ anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
499503
```
500504

501505
This applies to all sensitive values including API keys, access tokens, and credentials.
502-
We also reccomend that you always use short-lived tokens when possible
506+
We also recommend that you always use short-lived tokens when possible
503507

504508
## License
505509

action.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ inputs:
1212
assignee_trigger:
1313
description: "The assignee username that triggers the action (e.g. @claude)"
1414
required: false
15+
base_branch:
16+
description: "The branch to use as the base/source when creating new branches (defaults to repository default branch)"
17+
required: false
1518

1619
# Claude Code configuration
1720
model:
@@ -83,7 +86,7 @@ runs:
8386
using: "composite"
8487
steps:
8588
- name: Install Bun
86-
uses: oven-sh/setup-bun@v2
89+
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # https://github.com/oven-sh/setup-bun/releases/tag/v2.0.2
8790
with:
8891
bun-version: 1.2.11
8992

@@ -101,6 +104,7 @@ runs:
101104
env:
102105
TRIGGER_PHRASE: ${{ inputs.trigger_phrase }}
103106
ASSIGNEE_TRIGGER: ${{ inputs.assignee_trigger }}
107+
BASE_BRANCH: ${{ inputs.base_branch }}
104108
ALLOWED_TOOLS: ${{ inputs.allowed_tools }}
105109
CUSTOM_INSTRUCTIONS: ${{ inputs.custom_instructions }}
106110
DIRECT_PROMPT: ${{ inputs.direct_prompt }}
@@ -130,6 +134,9 @@ runs:
130134
ANTHROPIC_MODEL: ${{ inputs.model || inputs.anthropic_model }}
131135
GITHUB_TOKEN: ${{ steps.prepare.outputs.GITHUB_TOKEN }}
132136

137+
# Provider configuration
138+
ANTHROPIC_BASE_URL: ${{ env.ANTHROPIC_BASE_URL }}
139+
133140
# AWS configuration
134141
AWS_REGION: ${{ env.AWS_REGION }}
135142
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
@@ -163,10 +170,12 @@ runs:
163170
TRIGGER_COMMENT_ID: ${{ github.event.comment.id }}
164171
CLAUDE_BRANCH: ${{ steps.prepare.outputs.CLAUDE_BRANCH }}
165172
IS_PR: ${{ github.event.issue.pull_request != null || github.event_name == 'pull_request_review_comment' }}
166-
DEFAULT_BRANCH: ${{ steps.prepare.outputs.DEFAULT_BRANCH }}
173+
BASE_BRANCH: ${{ steps.prepare.outputs.BASE_BRANCH }}
167174
CLAUDE_SUCCESS: ${{ steps.claude-code.outputs.conclusion == 'success' }}
168175
OUTPUT_FILE: ${{ steps.claude-code.outputs.execution_file || '' }}
169176
TRIGGER_USERNAME: ${{ github.event.comment.user.login || github.event.issue.user.login || github.event.pull_request.user.login || github.event.sender.login || github.triggering_actor || github.actor || '' }}
177+
PREPARE_SUCCESS: ${{ steps.prepare.outcome == 'success' }}
178+
PREPARE_ERROR: ${{ steps.prepare.outputs.prepare_error || '' }}
170179

171180
- name: Display Claude Code Report
172181
if: steps.prepare.outputs.contains_trigger == 'true' && steps.claude-code.outputs.execution_file != ''

src/.DS_Store

-6 KB
Binary file not shown.

0 commit comments

Comments
 (0)