Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 0 additions & 169 deletions .github/workflows/commit-review.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:

ALWAYS Answer in 简体中文.
claude_args: |
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)" --json-schema '{"type":"object","properties":{"conclusion":{"type":"string","enum":["APPROVE","REQUEST_CHANGES","COMMENT"]},"summary":{"type":"string","maxLength":50},"critical_count":{"type":"integer"},"important_count":{"type":"integer"},"suggestion_count":{"type":"integer"}},"required":["conclusion","summary","critical_count","important_count","suggestion_count"]}'
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Read,Glob,Grep,Task" --json-schema '{"type":"object","properties":{"conclusion":{"type":"string","enum":["APPROVE","REQUEST_CHANGES","COMMENT"]},"summary":{"type":"string","maxLength":50},"critical_count":{"type":"integer"},"important_count":{"type":"integer"},"suggestion_count":{"type":"integer"}},"required":["conclusion","summary","critical_count","important_count","suggestion_count"]}'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 很好的改进

新增了 Read,Glob,Grep,Task 等工具到允许列表,这使得 Claude AI 审查时能够:

  • 读取项目文件内容
  • 搜索代码模式
  • 执行更深入的代码分析

这将显著提升代码审查的质量和准确性。

- name: Notify Feishu
if: always()
run: |
Expand Down
78 changes: 6 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# CR-template

基于 Claude AI 的自动化代码审查模板,支持 PR Review 和 Commit Review,并通过飞书 Webhook 发送通知。
基于 Claude AI 的自动化 PR 代码审查模板,通过飞书 Webhook 发送通知。

## 功能特性

| 功能 | 说明 |
|-----|------|
| PR Review | PR 创建/更新时自动审查代码质量和架构设计 |
| Commit Review | v* 分支 push 时自动审查最新 commit |
| 飞书通知 | 审查完成后发送卡片消息到飞书群 |
| 中文输出 | 所有审查报告和通知使用简体中文 |
| Sticky Comment | PR 多次审查会更新同一条评论 |
Expand All @@ -20,8 +19,7 @@

```
.github/workflows/
├── pr-review.yml # PR 审查工作流
└── commit-review.yml # Commit 审查工作流
└── pr-review.yml # PR 审查工作流
```

### 2. 配置 GitHub Secrets
Expand All @@ -47,8 +45,6 @@

## 触发条件

### PR Review

当 Pull Request 满足以下条件时触发:

| 事件 | 说明 |
Expand All @@ -60,16 +56,8 @@

> **注意**: 草稿 PR 不会触发审查

### Commit Review

当 push 到以下分支时触发:

- `v*` - 所有以 `v` 开头的分支(如 `v1.0`、`v2.0-beta`)

## 审查维度

### PR Review

**代码质量**
- 代码风格一致性
- 代码复杂度
Expand All @@ -86,16 +74,8 @@
- 模块化程度
- API 设计评估

### Commit Review

- Commit 信息是否清晰
- 代码变更是否合理
- 是否有明显问题

## 审查报告示例

### PR Review 报告

```markdown
## 🔍 PR 代码审查报告

Expand All @@ -120,28 +100,10 @@
本次 PR 实现了用户认证的核心功能,代码结构清晰...
```

### Commit Review 报告

```markdown
## 📝 Commit 审查 - v1.0

**Commit**: `abc1234`
**信息**: feat: 添加登录功能

### 变更概要
- src/login.ts (+50)
- tests/login.test.ts (+30)

### 审查结果
✅ PASS - 代码变更合理,无明显问题
```

## 飞书通知

审查完成后会发送飞书卡片消息:

### PR Review 通知

```
┌──────────────────────────────────┐
│ ✅ PR Review - APPROVE │ (绿色卡片)
Expand All @@ -154,43 +116,16 @@
└──────────────────────────────────┘
```

### Commit Review 通知

```
┌──────────────────────────────────┐
│ ✅ Commit Review - PASS │ (绿色卡片)
├──────────────────────────────────┤
│ 仓库: owner/repo 分支: v1.0 │
│ Commit: abc1234 │
│ 审查结果: 代码变更合理,无明显问题 │
│ [查看 Commit] │
└──────────────────────────────────┘
```

### 卡片颜色说明

| 审查结论 | 卡片颜色 |
|---------|---------|
| APPROVE / PASS | 🟢 绿色 |
| REQUEST_CHANGES / FAIL | 🔴 红色 |
| WARN | 🟠 橙色 |
| APPROVE | 🟢 绿色 |
| REQUEST_CHANGES | 🔴 红色 |
| COMMENT / 其他 | 🔵 蓝色 |
Comment on lines 121 to 125

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

在“卡片颜色说明”表格中,为了保持术语的一致性,建议将 COMMENT / 其他 简化为 COMMENT。这样,“审查结论”一列中的所有条目(APPROVE, REQUEST_CHANGES, COMMENT)就都是标准的 GitHub Review 事件类型了,会更加清晰明确。

Suggested change
| 审查结论 | 卡片颜色 |
|---------|---------|
| APPROVE / PASS | 🟢 绿色 |
| REQUEST_CHANGES / FAIL | 🔴 红色 |
| WARN | 🟠 橙色 |
| APPROVE | 🟢 绿色 |
| REQUEST_CHANGES | 🔴 红色 |
| COMMENT / 其他 | 🔵 蓝色 |
| 审查结论 | 卡片颜色 |
|---------|---------|
| APPROVE | 🟢 绿色 |
| REQUEST_CHANGES | 🔴 红色 |
| COMMENT | 🔵 蓝色 |


## 自定义配置

### 修改触发分支

编辑 `.github/workflows/commit-review.yml`:

```yaml
on:
push:
branches:
- 'v*' # 所有 v 开头的分支
- 'release/*' # 添加 release 分支
- 'main' # 添加 main 分支
```

### 修改审查 Prompt

编辑 workflow 文件中的 `prompt` 字段:
Expand Down Expand Up @@ -219,16 +154,15 @@ claude_args: |
.
├── .github/
│ └── workflows/
│ ├── pr-review.yml # PR 审查工作流
│ └── commit-review.yml # Commit 审查工作流
│ └── pr-review.yml # PR 审查工作流
└── README.md
```

## 技术说明

- 使用 [claude-code-action](https://github.com/anthropics/claude-code-action) v1
- 通过 `--json-schema` 获取结构化输出用于飞书通知
- PR Review 使用 `use_sticky_comment` 合并多次评论
- 使用 `use_sticky_comment` 合并多次评论

## License

Expand Down