Skip to content

Conversation

@Disdjj
Copy link
Member

@Disdjj Disdjj commented Dec 4, 2025

No description provided.

@gemini-code-assist

This comment was marked as spam.

gemini-code-assist[bot]

This comment was marked as spam.

3. 对好的实践也要给予肯定
4. 保持客观、专业
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"]}'
Copy link
Member Author

Choose a reason for hiding this comment

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

代码可读性问题:

这一行的 claude_args 参数格式非常难以阅读和维护:

  • JSON schema 直接写在一行中,无法辨识结构
  • 工具列表混在一起,不易理解

建议改进:

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"]
  }'

或者考虑使用 YAML 的多行格式提高可读性。

3. 使用简体中文
claude_args: |
--allowedTools "Bash(gh *)" "Bash(git *)" "Read" "Glob" "Grep"
--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":["PASS","WARN","FAIL"]},"summary":{"type":"string","maxLength":50}},"required":["conclusion","summary"]}'
Copy link
Member Author

Choose a reason for hiding this comment

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

相同的可读性问题:

pr-review.yml:76 相同的问题,建议采用相同的格式优化方案。

3. 使用简体中文
claude_args: |
--allowedTools "Bash(gh *)" "Bash(git *)" "Read" "Glob" "Grep"
--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":["PASS","WARN","FAIL"]},"summary":{"type":"string","maxLength":50}},"required":["conclusion","summary"]}'
Copy link
Member Author

Choose a reason for hiding this comment

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

配置不一致问题:

Commit Review 的 allowedTools 配置与 PR Review 完全相同,但 Commit Review 不需要创建 PR 评论。

当前工具包括:

  • mcp__github_inline_comment__create_inline_comment - 用于 PR inline 评论
  • Bash(gh pr comment:*), Bash(gh pr diff:*), Bash(gh pr view:*) - 都是 PR 相关命令

建议: Commit Review 应该使用不同的工具集,移除 PR 相关工具,可能需要添加 Bash(git *) 等 git 命令支持。

3. 使用简体中文
claude_args: |
--allowedTools "Bash(gh *)" "Bash(git *)" "Read" "Glob" "Grep"
--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":["PASS","WARN","FAIL"]},"summary":{"type":"string","maxLength":50}},"required":["conclusion","summary"]}'
Copy link
Member Author

Choose a reason for hiding this comment

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

❌ 工具权限配置错误

Commit Review 不涉及 PR 操作,但配置中包含了 PR 相关的工具:

  • mcp__github_inline_comment__create_inline_comment - 用于 PR inline comment
  • Bash(gh pr comment:*) - PR 评论命令
  • Bash(gh pr diff:*) - PR diff 命令
  • Bash(gh pr view:*) - PR 查看命令

建议修改为:

--allowedTools "Bash(git show:*),Bash(git diff:*),Bash(git log:*),Read,Glob,Grep"

id: review
uses: anthropics/claude-code-action@v1
env:
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
Copy link
Member Author

Choose a reason for hiding this comment

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

⚠️ 环境变量传递方式变更

需要确认 claude-code-action@v1 是否支持通过 env.ANTHROPIC_BASE_URL 传递。

如果不确定,建议保留原有方式:

with:
  anthropic_base_url: ${{ secrets.ANTHROPIC_BASE_URL }}

你是一个专业的代码审查助手。请对当前 PR 进行全面审查.

总是使用 `gh` 命令在github上评论PR, 尽可能的使用一条评论, 不断的更新.
使用 `mcp__github_inline_comment__create_inline_comment` to highlight specific code issues.
Copy link
Member Author

Choose a reason for hiding this comment

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

⚠️ 语言不一致

建议统一使用中文:

使用 `mcp__github_inline_comment__create_inline_comment` 工具在具体代码行添加问题标注。

id: review
uses: anthropics/claude-code-action@v1
env:
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
Copy link
Member Author

Choose a reason for hiding this comment

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

⚠️ 环境变量传递方式变更

与 PR review workflow 相同的问题,需要确认 claude-code-action@v1 是否支持通过 env.ANTHROPIC_BASE_URL 传递。

3. 使用简体中文
claude_args: |
--allowedTools "Bash(gh *)" "Bash(git *)" "Read" "Glob" "Grep"
--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":["PASS","WARN","FAIL"]},"summary":{"type":"string","maxLength":50}},"required":["conclusion","summary"]}'
Copy link
Member Author

Choose a reason for hiding this comment

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

🟠 重要问题:allowedTools 配置不匹配实际需求

Commit Review 工作流使用了 mcp__github_inline_comment__create_inline_comment 工具,但这个工具主要用于 PR 的代码评论,不适用于 commit 审查场景。

建议修改为:

--allowedTools "Bash(git *)"

Commit Review 只需要 Git 操作工具即可完成审查任务。

env:
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
with:
github_token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
Copy link
Member Author

Choose a reason for hiding this comment

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

🟠 重要问题:github_token 配置缺少回退机制

如果 CUSTOM_GITHUB_TOKEN secret 未配置,workflow 将会失败。

建议添加回退机制:

github_token: ${{ secrets.CUSTOM_GITHUB_TOKEN || github.token }}

这样在没有自定义 token 时会自动使用默认的 github.token

id: review
uses: anthropics/claude-code-action@v1
env:
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
Copy link
Member Author

Choose a reason for hiding this comment

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

🟠 重要问题:环境变量配置方式需要验证

ANTHROPIC_BASE_URL 使用了 env 方式设置,需要确认 claude-code-action v1 是否支持通过环境变量读取此配置。

在之前的版本中使用的是 anthropic_base_url 参数。建议查看官方文档确认正确的配置方式。


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"]}'
Copy link
Member Author

Choose a reason for hiding this comment

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

🟢 改进建议:JSON Schema 格式可读性差

单行的 JSON Schema 难以维护和阅读。建议使用更清晰的格式:

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"]
  }'

或者将 schema 定义在单独的文件中引用。

# 自定义审查要求
```

### 修改结构化输出
Copy link
Member Author

Choose a reason for hiding this comment

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

🟢 改进建议:文档需要更详细的说明

"修改结构化输出" 一节建议补充以下内容:

  1. 字段含义说明

    • conclusion: 审查结论(APPROVE/REQUEST_CHANGES/COMMENT)
    • summary: 一句话总结(最多50字)
    • critical_count: 严重问题数量
    • important_count: 重要问题数量
    • suggestion_count: 建议数量
  2. 如何添加新字段:如添加 reviewer 字段的步骤

  3. 与飞书通知的关联:说明这些字段如何被飞书通知步骤使用

@Disdjj
Copy link
Member Author

Disdjj commented Dec 4, 2025

🔍 PR 代码审查报告

📋 概要

  • 变更文件数: 5
  • 新增/删除行数: +130 / -245

🎯 审查结论

💬 COMMENT - 这是一次重要的架构改进,将审查配置从命令文件迁移到 workflow prompt 中,整体实现合理,但存在一些需要优化的问题。

🔴 严重问题 (Critical)

🟠 重要问题 (Important)

  1. allowedTools 配置不匹配实际需求 - 详见 .github/workflows/commit-review.yml:62
  2. 环境变量配置方式需要验证 - 详见 .github/workflows/pr-review.yml:25
  3. github_token 配置缺少回退机制 - 详见 .github/workflows/pr-review.yml:27

🟢 改进建议 (Suggestions)

  1. JSON Schema 格式可读性差 - 详见 .github/workflows/pr-review.yml:79
  2. README 文档需要更详细的说明 - 详见 README.md:207
  3. Commit message 不规范 - 提交历史中存在不专业的 commit 信息(如 "fuck, use prompt"),建议使用规范的格式
  4. 工具权限说明缺失 - 建议在 README 中补充说明为什么限制 allowedTools 的安全考虑

💡 总体评价

优点:

  1. 架构改进合理 - 删除 .claude/commands 文件,将配置集中到 workflow 中,降低了配置复杂度
  2. 结构化输出实现 - 使用 --json-schema 获取结构化输出,便于飞书通知使用
  3. 文档更新及时 - README 同步更新了新的配置方式
  4. 使用 Sticky Comment - PR Review 使用 use_sticky_comment: true,避免重复评论
  5. 中文 Prompt - 使用简体中文的 prompt 提高了审查报告的可读性

需要改进的方面:

  1. ⚠️ Commit Review 的工具配置需要调整
  2. ⚠️ 环境变量配置方式需要验证
  3. ⚠️ github_token 需要添加回退机制
  4. ⚠️ Commit message 需要更加规范

总结:
本次 PR 是一次重要的架构重构,将审查逻辑从命令文件迁移到 workflow 中,使配置更加直观和易于维护。主要问题集中在工具权限配置和环境变量设置上,建议修复后合并。整体变更方向正确,代码质量良好。

@Disdjj Disdjj merged commit 7f393d8 into main Dec 4, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants