# PR-Agent — AI PR Reviews via GitHub Action > PR-Agent is an open-source PR review agent you run as a GitHub Action or CLI to summarize changes and post review suggestions using an LLM key you control. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use 1. Add a workflow file: ```yaml name: PR Agent on: pull_request: types: [opened, synchronize] jobs: pr_agent_job: runs-on: ubuntu-latest steps: - name: PR Agent action step uses: the-pr-agent/pr-agent@main env: OPENAI_KEY: ${{ secrets.OPENAI_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` 2. Add `OPENAI_KEY` as a repo secret. 3. Open a PR and confirm the bot comments within ~30 seconds. ## Intro PR-Agent is an open-source PR review agent you run as a GitHub Action or CLI to summarize changes and post review suggestions using an LLM key you control. - **Best for:** teams that want deterministic, repeatable PR reviews (summaries, risk flags, suggestions) as a CI step - **Works with:** GitHub Actions, pull_request workflows, OPENAI_KEY/LLM key secrets, review comment permissions - **Setup time:** 10 minutes ## Practical Notes - Verified adoption signal: uses a single LLM call per tool run (~30 seconds per README claim) - Docker image namespace migration note: `0.34.2+` uses `pragent/pr-agent` (README) ## How to Run It Safely PR review bots are only useful when you can trust *when* they run and *what* they can access. Practical guardrails: - Keep the workflow limited to `pull_request` (not `pull_request_target`) unless you fully understand the security implications. - Use GitHub Action permissions narrowly; PR-Agent needs a token that can post comments, not write to the repo. - Start with one automation (for example: review summary) and add more once the team agrees on the format. If you prefer local iteration, the README also documents a CLI flow: ```bash pip install pr-agent export OPENAI_KEY=your_key_here pr-agent --pr_url https://github.com/owner/repo/pull/123 review ``` That pattern is useful for testing prompt tweaks before you bake them into CI. ### FAQ **Q: Is PR-Agent free?** A: Yes. It’s open-source under an SPDX license; your main cost is the LLM API usage. **Q: Does it work without GitHub Actions?** A: Yes. The project also supports a local CLI mode for a single PR URL. **Q: What’s the minimum permission set?** A: Typically: read repo contents + write PR comments; avoid broader scopes until needed. ## Source & Thanks > Source: https://github.com/The-PR-Agent/pr-agent > License: AGPL-3.0 > GitHub stars: 11,160 · forks: 1,501 --- ## 快速使用 1. 添加 workflow: ```yaml name: PR Agent on: pull_request: types: [opened, synchronize] jobs: pr_agent_job: runs-on: ubuntu-latest steps: - name: PR Agent action step uses: the-pr-agent/pr-agent@main env: OPENAI_KEY: ${{ secrets.OPENAI_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` 2. 在仓库 Secrets 里添加 `OPENAI_KEY`。 3. 打开一个 PR,确认机器人在约 30 秒内发出评论。 ## 简介 PR-Agent 是开源的 PR 评审 Agent:可用 GitHub Action 或 CLI 在拉取请求上自动生成摘要与建议,核心依赖你自有的 LLM key,适合把“审 PR”变成可复用的流水线。 - **适合谁:** 希望把 PR 评审变成可重复的 CI 步骤(摘要、风险点、建议)的团队 - **可搭配:** GitHub Actions、pull_request 工作流、OPENAI_KEY/LLM key secrets、PR 评论权限 - **准备时间:** 10 分钟 ## 实战建议 - 按 README 描述:每个工具通常 1 次 LLM 调用,约 30 秒出结果(供你预估 CI 时延) - README 提到 Docker 镜像命名空间迁移:`0.34.2+` 使用 `pragent/pr-agent` ## 更安全的落地方式 PR 机器人只有在“可控”时才值得依赖:它什么时候运行、能看到什么、能做什么,都要清晰。 建议的安全护栏: - 优先用 `pull_request` 触发;除非你非常清楚风险,不要随便用 `pull_request_target`。 - 权限尽量最小化:能评论 PR 即可,不要默认给写仓库权限。 - 先从一种自动化开始(例如 review 摘要),团队接受格式后再逐步扩展。 如果你想先在本地试跑,README 提供了 CLI 流程: ```bash pip install pr-agent export OPENAI_KEY=your_key_here pr-agent --pr_url https://github.com/owner/repo/pull/123 review ``` 用它先验证提示词与输出风格,再上 CI 会更稳。 ### FAQ **PR-Agent 免费吗?** 答:是的,它是开源项目(见下方许可证);主要成本来自你自己配置的 LLM API 调用。 **不使用 GitHub Actions 也能用吗?** 答:可以,README 也提供了本地 CLI 对单个 PR URL 执行的方式。 **最小权限怎么配?** 答:通常只需要读取代码 + 写入 PR 评论;除非必要不要扩展到更高权限。 ## 来源与感谢 > Source: https://github.com/The-PR-Agent/pr-agent > License: AGPL-3.0 > GitHub stars: 11,160 · forks: 1,501 --- Source: https://tokrepo.com/en/workflows/pr-agent-ai-pr-reviews-via-github-action Author: Agent Toolkit