A setup for running agents (eg: code review, triage etc.) on issues and pull requests using Anthropic’s Claude Code GitHub Action.
.claude/
agents/ # One prompt per agent
commands/ # Orchestration prompts that can call multiple agents and tools
.github/workflows/
claude-*.yml # CI workflows that run a command
- Workflow events (manual dispatch, new comment, PR opened, label changes, etc.) kick things off.
- The workflow calls
anthropics/claude-code-actionwith:prompt:/command-name REPO:… [ISSUE_NUMBER:… | PR_NUMBER:…]
- The command loads the agent(s).
There are two types of tools in this framework, controlled at different levels:
These specify which tools claude-code-action allows during command execution. Define them in .claude/commands/<command>.md:
---
allowed-tools: Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),mcp__github_inline_comment__create_inline_comment
description: Review a code contribution pull request
---This includes:
- Bash with restrictions:
Bash(gh pr comment:*)allows only specificghsubcommands - MCP tools:
mcp__<server>__<tool>from attached MCP servers - Standard Claude Code tools are available by default (see below)
For details on configuring allowed-tools, see the Claude Code GitHub Action documentation.
These are the standard Claude Code tools that individual agents can use. Specify them in .claude/agents/<agent>.md:
---
name: <agent>
description: <what it does>
tools: Read, Glob, Grep, Bash, Edit, Write, TodoWrite, BashOutput, KillBash
model: inherit
---Common standard tools:
- Read – read files
- Write – create files
- Edit / MultiEdit – change files (single/batch)
- Glob – match files by pattern
- Grep – search in files
- Bash – run shell/CLIs (unrestricted, unless limited by command
allowed-tools) - TodoWrite – manage task lists
- BashOutput / KillBash – manage long-running bash processes
- WebFetch / WebSearch – fetch/search the web (optional)
For a complete list of available Claude Code tools, see the Claude Code tools documentation.
MCP (Model Context Protocol) tools allow agents to call additional tools from attached MCP servers. Your agent prompt needs to instruct when to call a tool.
MCP tool names follow: mcp__<server>__<tool>.
MCP tools must be declared in both places:
- Command frontmatter (
allowed-tools) – so claude-code-action allows them - Agent frontmatter (
tools) – so the agent knows it can use them
Example:
Command (.claude/commands/review-pr.md):
---
allowed-tools: Bash(gh pr comment:*),mcp__github_inline_comment__create_inline_comment
---Agent (.claude/agents/code-reviewer.md):
---
tools: Read, Glob, Grep, mcp__github_inline_comment__create_inline_comment
---The claude-code-action may automatically include these built-in MCP servers depending on context (mode, available tokens, PR vs issue, enabled features):
github_commentgithub_file_opsgithub_inline_commentgithub_cigithub(Official GitHub MCP Server)
Add tools from these servers to your command's allowed-tools and agent's tools as needed (e.g., mcp__github_inline_comment__create_inline_comment).
You can also attach custom MCP servers to provide additional tools beyond the built-in ones. Create or configure custom MCP servers according to your needs and follow the same mcp__<server>__<tool> naming convention.
For details on MCP tool naming, configuration, and creating custom MCP servers, see the MCP documentation.
When configuring agents and commands, follow these security best practices:
Minimize tool access – Only grant agents the minimum set of tools they need to perform their task. Review both allowed-tools in commands and tools in agents regularly.
# ❌ Too permissive
allowed-tools: Bash
tools: Bash, Read, Write, Edit, WebFetch, WebSearch
# ✅ Properly restricted
allowed-tools: Bash(gh pr comment:*),Bash(gh pr view:*)
tools: Bash, Read, Glob, GrepAlways restrict Bash usage to specific commands in allowed-tools instead of granting unrestricted Bash access:
# ❌ Unrestricted Bash
allowed-tools: Bash
# ✅ Restricted to specific gh commands
allowed-tools: Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)When agents process untrusted input from external sources (e.g., PRs from unknown users when using allowed_non_write_users: "*" in workflows), treat the agent as potentially compromised or "jailbroken".
Key considerations:
-
Assume prompt injection – Untrusted PR content may contain prompt injection attempts to manipulate the agent.
-
Minimize tool access – Strictly limit tools and consider: What's the worst-case action a compromised agent could take? Can it modify files, commit code, or access secrets?
-
Best practices – Prefer read-only tools (
Read,Glob,Grep), restrict Bash to safe commands, avoidWrite/Edit, and use built-in MCP tools over unrestricted Bash. -
With
allowed_non_write_users: "*"– Limit to read-only operations and comments; never grantWrite,Edit, or unrestrictedBashaccess.
Always perform a security assessment: If an agent with your current tool configuration were fully compromised, what's the worst damage it could cause? If the answer is unacceptable, reduce tool access.
-
Create
.claude/agents/<agent>.md:--- name: <agent> description: <what it does> tools: Read, Glob, Grep, Bash, Edit, Write, mcp__github_inline_comment__create_inline_comment model: inherit ---
-
Create
.claude/commands/<command>.mddescribing which agent(s) to run and where to post results. Specify allowed tools in the frontmatter:--- allowed-tools: Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),mcp__github_inline_comment__create_inline_comment description: Review a code contribution pull request ---
-
Use it in a workflow:
- uses: anthropics/claude-code-action@<version-or-sha> with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} github_token: ${{ secrets.GITHUB_TOKEN }} prompt: "/<command> REPO:${{ github.repository }} PR_NUMBER:${{ github.event.pull_request.number }}"