如何在 Claude Code 用一條指令為 GitHub pull request 安裝 Anthropic 的 claude-code-action
Add Claude to your GitHub pull requests with one command in Claude Code
這篇教學示範如何在 Claude Code 執行 `/install-github-app`,為 GitHub 儲存庫安裝 Anthropic 的 `claude-code-action`,讓用戶可在 pull request 或 issue 留言中提及 @claude。
Code review is where a lot of small bugs get caught, and where a lot of teams run out of hours. claude-code-action is Anthropic's GitHub Action that lets Claude answer questions and make changes straight from pull request and issue comments. Setting a GitHub App, secrets and a workflow file by hand is fiddly. The README has a quicker route, and it starts inside Claude Code.
What you get
Once installed, you can mention @claude in a PR or issue comment. According to the README, the action can answer questions about code and architecture, review the changes in a PR and suggest improvements, and implement simple fixes, refactors and even new features. It shows progress with checkboxes that update as it works, and it runs on your own GitHub runner. Anthropic API calls go to the provider you choose.
It picks its mode automatically from your workflow context: responding to @claude mentions, issue assignments, or automation with an explicit prompt.
Before you start
- You must be a repository admin, because you will install a GitHub App and add secrets.
- The quickstart below is only for direct Anthropic API users. If you use Amazon Bedrock, Google Vertex AI or Microsoft Foundry, follow docs/cloud-providers.md in the repo instead.
- Coming from v0.x? The repo has a migration guide to v1.0 that simplifies configuration around two inputs,
promptandclaude_args.
Step 1: open Claude Code in the repo
cd your-repo
claude
Step 2: run the installer command
Inside Claude Code, run:
/install-github-app
The command walks you through installing the GitHub App and adding the required secrets. Follow the prompts.
Step 3: confirm the setup
Check the repository settings: the GitHub App should be installed, and the API key secret should exist under Actions secrets. Also look for the new workflow file the setup adds, and read it before merging. It defines when Claude is allowed to run.
Step 4: test with a harmless comment
Open a throwaway PR and comment:
@claude explain what the main function in this file does
If Claude replies with a progress checklist and then an answer, you are done. Only then try a real request such as "@claude add a unit test for this edge case".
Tips for staying safe
- Treat it like a new contributor. Review its changes before merging, every time.
- Keep the permissions in the workflow minimal. The README says additional tools can be enabled through configuration, so enable them one at a time.
- Remember that PR text goes to your chosen model provider, so check that fits your code policy.
A prompt you can hand to your agent
If you would rather not click through, give Claude Code this: "Install anthropics/claude-code-action on this repo using /install-github-app, confirm the secrets, then open a test PR comment asking Claude to explain one function."
More
The step-by-step card is on Deduped: Add Claude to your GitHub repo's pull requests and issues. For more things people do with the terminal agent, see AI use cases for Claude Code and how to explain an unfamiliar codebase with Claude Code.
Source repo: anthropics/claude-code-action.
Want the setup commands for 50 AI repos people actually ship with? Get the free AI Repos That Actually Ship pack: https://dedupedai.com/ship-pack/?utm_source=devto&utm_medium=article&utm_campaign=shippack
Get one email every Monday with the week's hottest AI repos and exactly how to use them: subscribe free at dedupedai.com
來源:DEV Community · dev.to