Add a workflow file to your repository (e.g., .github/workflows/claude.yml):
name: Claude Assistant
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned, labeled]
pull_request_review:
types: [submitted]
jobs:
claude-response:
runs-on: ubuntu-latest
steps:
- uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
# Or use OAuth token instead:
# claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
# Optional: provide a prompt for automation workflows
# prompt: "Review this PR for security issues"
# Optional: pass advanced arguments to Claude CLI
# claude_args: |
# --max-turns 10
# --model claude-4-0-sonnet-20250805
# Optional: add custom plugin marketplaces
# plugin_marketplaces: "https://github.com/anthropics/claude-plugins-official.git\nhttps://github.com/user/marketplace.git"
# Optional: install Claude Code plugins
# plugins: "code-review@claude-plugins-official\nfeature-dev@claude-plugins-official"
# Optional: add custom trigger phrase (default: @claude)
# trigger_phrase: "/claude"
# Optional: add assignee trigger for issues
# assignee_trigger: "claude"
# Optional: add label trigger for issues
# label_trigger: "claude"
# Optional: grant additional permissions (requires corresponding GitHub token permissions)
# additional_permissions: |
# actions: read
# Optional: allow bot users to trigger the action
# allowed_bots: "dependabot[bot],renovate[bot]"| Input | Description | Required | Default |
|---|---|---|---|
anthropic_api_key |
Anthropic API key (required for direct API, not needed for Bedrock/Vertex) | No* | - |
claude_code_oauth_token |
Claude Code OAuth token (alternative to anthropic_api_key) | No* | - |
anthropic_federation_rule_id |
Workload identity federation rule ID (fdrl_...). With anthropic_organization_id, authenticates via the workflow's GitHub OIDC token instead of a static API key. See Setup Guide |
No* | - |
anthropic_organization_id |
Anthropic organization UUID for workload identity federation | No* | - |
anthropic_service_account_id |
Service account ID (svac_...) the federated token acts as (optional) |
No | - |
anthropic_workspace_id |
Workspace ID (wrkspc_...) for workload identity federation. Optional when the federation rule targets a single workspace |
No | - |
anthropic_oidc_audience |
Audience requested on the GitHub OIDC token used for workload identity federation | No | https://api.anthropic.com |
prompt |
Instructions for Claude. Can be a direct prompt or custom template for automation workflows | No | - |
track_progress |
Force tag mode with tracking comments. Only works with specific PR/issue events. Preserves GitHub context | No | false |
include_fix_links |
Include 'Fix this' links in PR code review feedback that open Claude Code with context to fix the identified issue | No | true |
claude_args |
Additional arguments to pass directly to Claude CLI (e.g., --max-turns 10 --model claude-4-0-sonnet-20250805) |
No | "" |
base_branch |
The base branch to use for creating new branches (e.g., 'main', 'develop'). See also Security | No | - |
use_sticky_comment |
Use just one comment to deliver PR comments (only applies for pull_request event workflows) | No | false |
classify_inline_comments |
Buffer inline comments without confirmed: true and classify them (real review vs test/probe) via Haiku before posting after the session ends. Prevents subagent test comments. Set 'false' to post all inline comments immediately |
No | true |
github_token |
GitHub token for Claude to operate with. Only include this if you're connecting a custom GitHub app of your own! | No | - |
use_bedrock |
Use Amazon Bedrock with OIDC authentication instead of direct Anthropic API | No | false |
use_vertex |
Use Google Vertex AI with OIDC authentication instead of direct Anthropic API | No | false |
assignee_trigger |
The assignee username that triggers the action (e.g. @claude). Only used for issue assignment | No | - |
label_trigger |
The label name that triggers the action when applied to an issue (e.g. "claude"). With prompt and track_progress, an empty value accepts any label |
No | - |
trigger_phrase |
The trigger phrase to look for in comments, issue/PR bodies, and issue titles | No | @claude |
branch_prefix |
The prefix to use for Claude branches (defaults to 'claude/', use 'claude-' for dash format) | No | claude/ |
settings |
Claude Code settings as JSON string or path to settings JSON file | No | "" |
additional_permissions |
Additional permissions to enable. Currently supports 'actions: read' for viewing workflow results | No | "" |
use_commit_signing |
Enable commit signing using GitHub's API. Simple but cannot perform complex git operations like rebasing. See Security | No | false |
ssh_signing_key |
SSH private key for signing commits. Enables signed commits with full git CLI support (rebasing, etc.). See Security | No | "" |
bot_id |
GitHub user ID to use for git operations (defaults to Claude's bot ID). Required with ssh_signing_key for verified commits |
No | 41898282 |
bot_name |
GitHub username to use for git operations (defaults to Claude's bot name). Required with ssh_signing_key for verified commits |
No | claude[bot] |
include_comments_by_actor |
Comma-separated list of actor usernames to INCLUDE in comments. Supports the *[bot] wildcard to match all bot accounts. Empty (default) includes all actors |
No | "" |
exclude_comments_by_actor |
Comma-separated list of actor usernames to EXCLUDE from comments. Supports the *[bot] wildcard to match all bot accounts. If an actor matches both lists, exclusion takes priority |
No | "" |
allowed_bots |
Comma-separated list of allowed bot usernames, or '*' to allow all bots. Empty string (default) allows no bots. '*', external Apps may be able to invoke this action. See Security |
No | "" |
allow_fork_prs |
Set to true to run on pull requests from forks, and on workflow_run events for a fork's run. By default, and with any other value, the action skips them. See Security. |
No | false |
restrict_untrusted_prs |
On pull requests whose author does not have write access, deny commands that commonly run code from the checkout, even if claude_args allows them. See Security. |
No | true |
allowed_non_write_users |
github_token input. See Security |
No | "" |
path_to_claude_code_executable |
Optional path to a custom Claude Code executable. Skips automatic installation. Useful for Nix, custom containers, or specialized environments | No | "" |
path_to_bun_executable |
Optional path to a custom Bun executable. Skips automatic Bun installation. Useful for Nix, custom containers, or specialized environments | No | "" |
plugin_marketplaces |
Newline-separated list of Claude Code plugin marketplace Git URLs to install from (e.g., see example in workflow above). Marketplaces are added before plugin installation | No | "" |
plugins |
Newline-separated list of Claude Code plugin names to install (e.g., see example in workflow above). Plugins are installed before Claude Code execution | No | "" |
These inputs are deprecated and will be removed in a future version:
| Input | Description | Migration Path |
|---|---|---|
mode |
DEPRECATED: Mode is now automatically detected based on workflow context | Remove this input; the action auto-detects the correct mode |
direct_prompt |
DEPRECATED: Use prompt instead |
Replace with prompt |
override_prompt |
DEPRECATED: Use prompt with template variables or claude_args with --system-prompt |
Use prompt for templates or claude_args for system prompts |
custom_instructions |
DEPRECATED: Use claude_args with --append-system-prompt or include in prompt |
Move instructions to prompt or use claude_args |
max_turns |
DEPRECATED: Use claude_args with --max-turns instead |
Use claude_args: "--max-turns 5" |
model |
DEPRECATED: Use claude_args with --model instead |
Use claude_args: "--model claude-4-0-sonnet-20250805" |
fallback_model |
DEPRECATED: Use claude_args with fallback configuration |
Configure fallback in claude_args or settings |
allowed_tools |
DEPRECATED: Use claude_args with --allowedTools instead |
Use claude_args: "--allowedTools Edit,Read,Write" |
disallowed_tools |
DEPRECATED: Use claude_args with --disallowedTools instead |
Use claude_args: "--disallowedTools WebSearch" |
mcp_config |
DEPRECATED: Use claude_args with --mcp-config instead |
Use claude_args: "--mcp-config '{...}'" |
claude_env |
DEPRECATED: Use settings with env configuration |
Configure environment in settings JSON |
*Required when using direct Anthropic API (default and when not using Bedrock or Vertex)
Note: This action is currently in beta. Features and APIs may change as we continue to improve the integration.
The action runs Claude in auto mode by default. Reads and file edits in the workspace run without asking, and a safety review decides any other tool call that your allow rules don't cover. Narrow allow rules like Bash(npm test) skip the review, and broad ones like Bash(*) or package-manager run commands are ignored in this mode.
Set another mode in claude_args. These are the earlier defaults:
- uses: anthropics/claude-code-action@v1
with:
# For @claude mentions: allow file edits in the workspace, and deny what no rule covers
claude_args: --permission-mode acceptEdits
# For workflows with a prompt: deny what no rule covers
# claude_args: --permission-mode defaultOpt out if your workflow relies on --allowedTools as a strict list, because auto mode can run other tool calls when the review passes.
- Unsupported model or organization setting: auto mode needs a supported model, and an administrator can turn it off. The session then starts in Manual. For
@claudementions, the action logs a warning and switches toacceptEdits. With aprompt, it stays in Manual and denies what no rule covers. allowed_non_write_usersorallowed_botsis set: sessions keep the earlier defaults, because other people's text reaches these runs without a write-access check, so the review can't pass a call those defaults deny. Add--permission-mode autoto opt in.ANTHROPIC_BASE_URLis set: sessions keep the earlier defaults, because the safety check depends on what a gateway passes through. Add--permission-mode autoonce your gateway supports it.path_to_claude_code_executableis set: sessions keep the earlier defaults, because a Claude Code version that predates auto mode exits on the flag. Add--permission-mode autoif your version supports it.- The
settingsinput setsenv.ANTHROPIC_BASE_URL, sets apermissions.defaultModeother thanauto, or is a file path: sessions keep the earlier defaults, including for a file that sets neither, because a pull request can change the file. Workflows with a prompt then use the mode in your settings. For@claudementions,acceptEditsstill overrides it, so pass yours inclaude_args. --dangerously-skip-permissions: this still takes priority over any mode.
- Where the server's check doesn't reach a session, Claude Code makes its own classifier requests, which count toward token usage.
- On Amazon Bedrock, your account may need access to the classifier's model, or actions that need the review are blocked. See the error reference.
- Tool calls that used to be denied can now run if the review passes.
- Allow rules that auto mode ignores no longer approve those commands on their own.
- The action checks only JSON in the
settingsinput, not settings files such as.claude/settings.jsonin your repository. If one of those pointsANTHROPIC_BASE_URLto a gateway or setspermissions.defaultMode, auto mode still applies, so set the mode you want inclaude_args.
For a comprehensive guide on migrating from v0.x to v1.0, including step-by-step instructions and examples, see our Migration Guide.
Before (v0.x):
- uses: anthropics/claude-code-action@beta
with:
mode: "tag"
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
custom_instructions: "Focus on security"
max_turns: "10"After (v1.0):
- uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
claude_args: |
--max-turns 10
--append-system-prompt "Focus on security"Before (v0.x):
- uses: anthropics/claude-code-action@beta
with:
mode: "agent"
direct_prompt: "Update the API documentation"
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
model: "claude-4-0-sonnet-20250805"
allowed_tools: "Edit,Read,Write"After (v1.0):
- uses: anthropics/claude-code-action@v1
with:
prompt: |
REPO: ${{ github.repository }}
PR NUMBER: ${{ github.event.pull_request.number }}
Update the API documentation to reflect changes in this PR
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
claude_args: |
--model claude-4-0-sonnet-20250805
--allowedTools Edit,Read,WriteBefore (v0.x):
- uses: anthropics/claude-code-action@beta
with:
override_prompt: |
Analyze PR #$PR_NUMBER for security issues.
Focus on: $CHANGED_FILESAfter (v1.0):
- uses: anthropics/claude-code-action@v1
with:
prompt: |
Analyze PR #${{ github.event.pull_request.number }} for security issues.
Focus on the changed files in this PR.Get validated JSON results from Claude that automatically become GitHub Action outputs. This enables building complex automation workflows where Claude analyzes data and subsequent steps use the results.
- name: Detect flaky tests
id: analyze
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
prompt: |
Check the CI logs and determine if this is a flaky test.
Return: is_flaky (boolean), confidence (0-1), summary (string)
claude_args: |
--json-schema '{"type":"object","properties":{"is_flaky":{"type":"boolean"},"confidence":{"type":"number"},"summary":{"type":"string"}},"required":["is_flaky"]}'
- name: Retry if flaky
if: fromJSON(steps.analyze.outputs.structured_output || '{}').is_flaky == true
run: gh workflow run CI- Define Schema: Provide a JSON schema via
--json-schemaflag inclaude_args - Claude Executes: Claude uses tools to complete your task
- Validated Output: Result is validated against your schema
- JSON Output: All fields are returned in a single
structured_outputJSON string
All structured output fields are available in the structured_output output as a JSON string. It is empty when the action skips the run, which is why these expressions fall back to '{}'. Test fields against true, because a missing field also equals false:
In GitHub Actions expressions:
if: |
fromJSON(steps.analyze.outputs.structured_output || '{}').is_flaky == true &&
fromJSON(steps.analyze.outputs.structured_output || '{}').confidence >= 0.7
run: ./retry-tests.shIn bash with jq:
- name: Process results
env:
OUTPUT: ${{ steps.analyze.outputs.structured_output }}
run: |
IS_FLAKY=$(echo "$OUTPUT" | jq -r '.is_flaky')
SUMMARY=$(echo "$OUTPUT" | jq -r '.summary')Always pass these values to a script through env:, as above. GitHub puts a ${{ }} expression's value into the script before the shell reads it, so a quote or other shell syntax in Claude's answer can break the script or run as a command.
Note: Due to GitHub Actions limitations, composite actions cannot expose dynamic outputs. All fields are bundled in the single structured_output JSON string.
See examples/test-failure-analysis.yml for a working example that:
- Detects flaky test failures
- Uses confidence thresholds in conditionals
- Auto-retries workflows
- Comments on PRs
For complete details on JSON Schema syntax and Agent SDK structured outputs: https://docs.claude.com/en/docs/agent-sdk/structured-outputs
These examples show how to interact with Claude using comments in PRs and issues. By default, Claude will be triggered anytime you mention @claude, but you can customize the exact trigger phrase using the trigger_phrase input in the workflow.
Claude will see the full PR context, including any comments.
Add a comment to a PR or issue:
@claude What does this function do and how could we improve it?
Claude will analyze the code and provide a detailed explanation with suggestions.
Ask Claude to implement specific changes:
@claude Can you add error handling to this function?
Get a thorough review:
@claude Please review this PR and suggest improvements
Claude will analyze the changes and provide feedback.
Upload a screenshot of a bug and ask Claude to fix it:
@claude Here's a screenshot of a bug I'm seeing [upload screenshot]. Can you fix it?
Claude can see and analyze images, making it easy to fix visual bugs or UI issues.
If a description is edited after the event that triggered the run, Claude gets the text from that event without its images. A comment or review edited after that event is left out, or loses its images. Ticking a checkbox counts as an edit, and re-running the job does not help. If the images are still in the description, mentioning Claude in a new comment includes them.