Skip to main content

在合并前自动修复 PR 中的 Bug

Devin 会检查每个 PR 是否存在 Bug,并自动将修复推送到对应分支。
AuthorCognition
Category代码质量
Features集成
1

为自动审查加入代码仓库和用户

Devin Review 可以自动审查你仓库中的每一个 PR —— 无需手动触发。先将你希望覆盖的仓库和用户加入自动审查。
  1. 在 Devin Web 应用中前往 Settings > Review
  2. Repositories 下,搜索并添加你希望由 Devin 自动审查的仓库(例如:acme/frontendacme/api-server
  3. Users 下,添加其 PR 应始终被审查的 GitHub 用户名 —— 或者,任何用户都可以通过点击 “Add myself (@username)” 自行加入
加入后,当 PR 被打开、推送了新的提交,或草稿被标记为准备审查时,Devin 会自动进行审查。
任何已连接 GitHub 账号的团队成员都可以自行加入自动审查 —— 无需管理员权限。前往 Settings > Review 并点击 “Add myself”
2

启用 Auto-Fix,让 Devin 不只评论还能直接推送修复

默认情况下,Devin Review 会将缺陷发现作为行内评论发布。Auto-Fix 更进一步 —— Devin 会提出代码修改方案,并可直接将修复提交推送到 PR 分支。要启用它,请前往 Settings > Customization > Pull request settings > Autofix settings - bot comments 并选择以下其中一项:
  • Respond to specific bots only —— 将 devin-ai-integration[bot] 添加到允许列表 allowlist(推荐)
  • Respond to all bot comments —— Devin 会对所有 bot 评论作出响应,而不仅是它自己的评论
你也可以在每个 PR 上单独切换 Auto-Fix:打开任意 Devin Review 页面,点击 设置图标(页眉中的三个点),然后启用 “Enable Autofix”
当其他 bot 也会对 Devin 的更改发表评论时,“Respond to all bot comments” 可能导致无限循环。请使用允许列表模式,只添加 devin-ai-integration[bot] 以确保安全。
3

查看 Devin 发现并修复了哪些问题

当在已加入的仓库上打开 PR 时,Devin Review 会自动运行并生成:
  • 在 Analysis 侧边栏中的缺陷发现,按严重程度(Severe 或 Non-severe)和置信度标记
  • Flags,用于标记值得进一步排查但不一定有误的模式
  • 当开启 Auto-Fix 时,针对 Devin 能解决的问题,直接推送到 PR 分支的修复提交
例如,在一个添加新用户设置页面的 PR 上,Devin Review 可能会发现:
Bug (Severe): Null reference in UserSettings.tsx:38

`user.preferences.theme` throws if `preferences` is undefined,
which happens for accounts created before v2.3.

Fix pushed — commit e4a1b2c:
  const theme = user.preferences?.theme ?? 'system';
你可以在 diff 视图中审查每一条发现,将缺陷标记为已解决,或使用内置的代码库感知型聊天提出后续问题 —— Devin 拥有整个仓库的上下文,而不仅仅是 diff。
4

让 Devin Review 学习你团队的标准

Devin Review 会读取仓库中的 AGENTS.mdREVIEW.md 文件来学习你团队的约定。使用这些文件来定义审查偏好、需要重点关注的常见缺陷模式,以及你希望强制执行的编码规范:
<!-- REVIEW.md -->
## Review guidelines

- All API route handlers in src/routes/* must validate request body
  with zod schemas before accessing properties. Flag any handler
  that reads req.body fields without validation.
- The useUnsafeEffect hook in src/hooks/useUnsafeEffect.ts is
  intentional — do not flag it as a missing-deps issue.
- Check for unhandled error cases in API calls.
- Ensure new database queries have appropriate indexes.
将此文件提交到你的仓库后,Devin Review 会在每个 PR 上遵循这些指南。随着团队发现新的模式,可以随时更新它 —— 例如,在一次生产故障后,将本可以捕获该问题的模式添加进去,以便 Devin 在后续审查中标记类似问题。你也可以在任意 PR 上使用 Review chat,让 Devin 在整个 diff 中检查特定模式 —— 例如,“Are there any API calls in this PR that don’t handle the error case?”。