claude-code-action
Applicationanthropics/claude-code-action
GitHub Action that runs Claude Code for PR reviews and issue automation.
Overview
A general-purpose GitHub Action that brings Claude Code into pull requests and issues to answer questions, review diffs, and implement code changes. It detects its execution mode from workflow context, supports Anthropic API, Amazon Bedrock, Google Vertex AI and Microsoft Foundry, and runs entirely on your own runner with structured JSON outputs.
README Preview
\n\n# Claude Code Action\n\nA general-purpose [Claude Code](https://claude.ai/code) action for GitHub PRs and issues that can answer questions and implement code changes. This action intelligently detects when to activate based on your workflow context—whether responding to @claude mentions, issue assignments, or executing automation tasks with explicit prompts. It supports multiple authentication methods including Anthropic direct API (API key or workload identity federation), Amazon Bedrock, Google Vertex AI, and Microsoft Foundry.\n\n## Features\n\n- 🎯 **Intelligent Mode Detection**: Automatically selects the appropriate execution mode based on your workflow context—no configuration needed\n- 🤖 **Interactive Code Assistant**: Claude can answer questions about code, architecture, and programming\n- 🔍 **Code Review**: Analyzes PR changes and suggests improvements\n- ✨ **Code Implementation**: Can implement simple fixes, refactoring, and even new features\n- 💬 **PR/Issue Integration**: Works seamlessly with GitHub comments and PR reviews\n- 🛠️ **Flexible Tool Access**: Access to GitHub APIs and file operations (additional tools can be enabled via configuration)\n- 📋 **Progress Tracking**: Visual progress indicators with checkboxes that dynamically update as Claude completes tasks\n- 📊 **Structured Outputs**: Get validated JSON results that automatically become GitHub Action outputs for complex automations\n- 🏃 **Runs on Your Infrastructure**: The action executes entirely on your own GitHub runner (Anthropic API calls go to your chosen provider)\n- ⚙️ **Simplified Configuration**: Unified `prompt` and `claude_args` inputs provide clean, powerful configuration aligned with Claude Code SDK\n\n## 📦 Upgrading from v0.x?\n\n**See our [Migration Guide](./docs/migration-guide.md)** for step-by-step instructions on updating your workflows to v1.0. The new version simplifies configuration while maintaining compatibility with most existing setups.\n\n## Quickstart\n\n
FAQ (5)
TroubleshootingWhy does Claude Code Action intermittently fail with "subtype: success" and "is_error: true" before running a review?
This usually means the Claude process failed during startup, not that the code review completed and failed. Inspect claude-execution-output.json and read the result field; in the reported case it contained Credit balance is too low. Fix it by checking the Anthropic API account's billing/credit balance, adding credits, and re-running the workflow. A failed startup typically shows is_error: true with no review aggregation or findings, such as spawned: 0. This is distinct from a completed review that reports findings.
TroubleshootingHow do I fix the `delete_files` schema validation error caused by the `files` vs `paths` parameter mismatch in Claude Code Action tag mode?
The mcp__github_file_ops__delete_files tool schema accepts paths, but the tag-mode prompt example incorrectly uses files. This causes Zod validation to reject the first deletion attempt when use_commit_signing: true is enabled.
Fix the prompt example in src/create-prompt/index.ts (around line 827):
- mcp__github_file_ops__delete_files: {"files": ["path/to/old.js"], "message": "chore: remove deprecated file"}
+ mcp__github_file_ops__delete_files: {"paths": ["path/to/old.js"], "message": "chore: remove deprecated file"}
Then rebuild/release the action or use a release containing that fix. In an existing run, retrying the tool call with paths works around the failed call:
{"paths": ["path/to/old.js"], "message": "chore: remove deprecated file"}
Note that commit_files still uses files; only delete_files uses paths. A regression test should import the MCP tool schemas and verify that parameter names in prompt examples match the corresponding schemas.
TroubleshootingWhy are custom Bash tools passed via claude_args ignored during Claude pull request reviews?
For pull_request events, the action auto-detects tag mode, which only merges user-provided MCP tools starting with mcp__github_ into the default allowlist. Custom rules such as Bash(npx markdownlint:*) or Bash(gh pr:*) are parsed but filtered out.
To use custom Bash tools, explicitly set mode: agent in the workflow:
- uses: anthropics/claude-code-action@v1
with:
mode: agent
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
prompt: |
Run `npx markdownlint *.md` to check markdown files.
claude_args: |
--allowedTools "Bash(npx markdownlint:*),Read,Glob"
Use the camel-case flag --allowedTools; --allowed-tools may not be recognized. This behavior was observed in claude-code-action v1.0.22.
TroubleshootingHow do I fix GitHub branch links breaking when a branch name contains `#`?
URL-encode each branch-name path segment before inserting it into a GitHub tree or compare URL, while preserving / as the path separator:
const encodedBranch = branchName
.split("/")
.map(encodeURIComponent)
.join("/");
For example, claude/fix#123 becomes claude/fix%23123, so the generated link is:
https://github.com/owner/repo/tree/claude/fix%23123nApply this encoding wherever branch URLs are created, including tracking-comment and branch-cleanup code. As a temporary workaround, avoid using
# in generated branch names or manually replace # with %23 in the link.TroubleshootingHow do I fix Claude Opus 5 or Sonnet 5 resolving to a 200k context window instead of 1M in GitHub Actions?
Append the [1m] context selector to the model IDs in your workflow configuration:
env:
ANTHROPIC_MODEL: claude-opus-5[1m]
ANTHROPIC_SMALL_FAST_MODEL: claude-sonnet-5[1m]
This is required when an ANTHROPIC_BASE_URL gateway prevents Claude Code from automatically detecting native 1M context support. The workaround was verified on action v1.0.185 with Claude Code 2.1.222: claude-opus-5[1m] resolves modelUsage.contextWindow to 1000000, while claude-opus-5 resolves to 200000 and causes premature auto-compaction.
To verify the resolved limit, enable show_full_output: true and inspect the modelUsage object in the job log:
"contextWindow": 1000000
Note: maxOutputTokens may still report 64000 even with the [1m] suffix; that value is resolved separately from the context-window selector.