kata-review-pull-requests
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseComprehensive PR Review
全面PR审查
Run a comprehensive pull request review using multiple specialized agents, each focusing on a different aspect of code quality.
Review Aspects (optional): "$ARGUMENTS"
使用多个专业Agent执行全面的拉取请求(PR)审查,每个Agent专注于代码质量的不同方面。
审查维度(可选): "$ARGUMENTS"
Review Workflow:
审查工作流:
-
Determine Review Scope
- Check git status to identify changed files
- Parse arguments to see if user requested specific review aspects
- Default: Run all applicable reviews
-
Available Review Aspects:
- comments - Analyze code comment accuracy and maintainability
- tests - Review test coverage quality and completeness
- errors - Check error handling for silent failures
- types - Analyze type design and invariants (if new types added)
- code - General code review for project guidelines
- simplify - Simplify code for clarity and maintainability
- all - Run all applicable reviews (default)
-
Identify Changed Files
- Run to see modified files
git diff --name-only - Check if PR already exists:
gh pr view - Identify file types and what reviews apply
Error handling:- If fails (not a git repo): Report error clearly and stop
git diff - If fails with "no PR found": Expected for pre-PR reviews, continue with git diff
gh pr view - If fails with auth error: Note that GitHub CLI authentication is needed
gh pr view - If no changed files found: Report "No changes detected" and stop
- Run
-
Determine Applicable ReviewsBased on changes:
- Always applicable: kata-code-reviewer (general quality)
- If test files changed: kata-pr-test-analyzer
- If comments/docs added: kata-comment-analyzer
- If error handling changed: kata-failure-finder
- If types added/modified: kata-type-design-analyzer
- After passing review: kata-code-simplifier (polish and refine)
-
Launch Review AgentsSequential approach (one at a time):
- Easier to understand and act on
- Each report is complete before next
- Good for interactive review
Parallel approach (user can request):- Launch all agents simultaneously
- Faster for comprehensive review
- Results come back together
Agent failure handling:- If agent completes: Include results in aggregation
- If agent times out: Report "[agent-name] timed out - consider running independently"
- If agent fails: Report "[agent-name] failed: [error reason]"
- If one agent fails, STILL proceed with remaining agents
- Never silently skip a failed agent - always report its status
-
Aggregate ResultsAfter agents complete, summarize:
- Critical Issues (must fix before merge)
- Important Issues (should fix)
- Suggestions (nice to have)
- Positive Observations (what's good)
Edge cases:- If no issues found: Celebrate with "All Checks Passed" summary
- If agents conflict: Note the disagreement and let user decide
- If agent output malformed: Note "[agent] output could not be parsed"
- Always include count of agents completed vs failed
-
Provide Action PlanOrganize findings:markdown
# PR Review Summary ## Critical Issues (X found) - [agent-name]: Issue description [file:line] ## Important Issues (X found) - [agent-name]: Issue description [file:line] ## Suggestions (X found) - [agent-name]: Suggestion [file:line] ## Strengths - What's well-done in this PR ## Recommended Action 1. Fix critical issues first 2. Address important issues 3. Consider suggestions 4. Re-run review after fixes
-
确定审查范围
- 执行命令识别变更文件
git status - 解析参数,查看用户是否指定了特定审查维度
- 默认:运行所有适用的审查
- 执行
-
可用审查维度:
- comments - 分析代码注释的准确性与可维护性
- tests - 审查测试覆盖率的质量与完整性
- errors - 检查错误处理是否存在静默故障
- types - 分析类型设计与不变量(如果新增了类型)
- code - 基于项目规范的通用代码审查
- simplify - 简化代码以提升清晰度与可维护性
- all - 运行所有适用的审查(默认选项)
-
识别变更文件
- 执行查看修改的文件
git diff --name-only - 检查PR是否已存在:
gh pr view - 识别文件类型及适用的审查维度
错误处理:- 若执行失败(当前目录不是git仓库):清晰报告错误并终止流程
git diff - 若执行失败并提示"no PR found":属于PR创建前的审查场景,继续基于git diff结果执行
gh pr view - 若因认证错误失败:提示需要完成GitHub CLI认证
gh pr view - 若未发现变更文件:报告"未检测到任何变更"并终止流程
- 执行
-
确定适用的审查根据变更内容:
- 始终适用:kata-code-reviewer(通用质量审查)
- 若测试文件变更:kata-pr-test-analyzer
- 若添加了注释/文档:kata-comment-analyzer
- 若错误处理逻辑变更:kata-failure-finder
- 若类型新增/修改:kata-type-design-analyzer
- 审查通过后:kata-code-simplifier(代码优化与精炼)
-
启动审查Agent串行模式(依次执行):
- 结果更易理解与跟进
- 每个Agent完成审查后再启动下一个
- 适合交互式审查场景
并行模式(用户可主动请求):- 同时启动所有Agent
- 全面审查速度更快
- 所有结果同时返回
Agent故障处理:- 若Agent执行完成:将结果纳入汇总
- 若Agent超时:报告"[agent-name] 超时 - 建议单独运行该Agent"
- 若Agent执行失败:报告"[agent-name] 执行失败:[错误原因]"
- 即使某个Agent失败,仍继续执行剩余Agent
- 绝不静默跳过失败的Agent - 必须始终报告其状态
-
汇总审查结果所有Agent完成后,汇总内容包括:
- 关键问题(合并前必须修复)
- 重要问题(建议修复)
- 优化建议(可选修复)
- 正面评价(代码亮点)
边缘场景处理:- 若未发现任何问题:显示"所有检查通过"的总结
- 若Agent结果存在冲突:标注分歧并由用户决定
- 若Agent输出格式异常:标注"[agent] 输出内容无法解析"
- 始终统计已完成与失败的Agent数量
-
提供改进行动计划整理审查结果为以下格式:markdown
# PR审查总结 ## 关键问题(共X个) - [agent-name]: 问题描述 [文件:行号] ## 重要问题(共X个) - [agent-name]: 问题描述 [文件:行号] ## 优化建议(共X个) - [agent-name]: 建议内容 [文件:行号] ## 代码亮点 - 本次PR中的优秀实践 ## 推荐行动步骤 1. 优先修复关键问题 2. 处理重要问题 3. 考虑采纳优化建议 4. 修复后重新运行审查
Usage Examples:
使用示例:
Full review (default):
/kata-review-pull-requestsSpecific aspects:
/kata-review-pull-requests tests errors全面审查(默认):
/kata-review-pull-requests指定审查维度:
/kata-review-pull-requests tests errorsReviews only test coverage and error handling
仅审查测试覆盖率与错误处理
/kata-review-pull-requests comments
/kata-review-pull-requests comments
Reviews only code comments
仅审查代码注释
/kata-review-pull-requests simplify
/kata-review-pull-requests simplify
Simplifies code after passing review
审查通过后简化代码
**Parallel review:**/kata-review-pull-requests all parallel
**并行审查:**/kata-review-pull-requests all parallel
Launches all agents in parallel
并行启动所有Agent
undefinedundefinedAgent Descriptions:
Agent说明:
kata-comment-analyzer:
- Verifies comment accuracy vs code
- Identifies comment rot
- Checks documentation completeness
kata-pr-test-analyzer:
- Reviews behavioral test coverage
- Identifies critical gaps
- Evaluates test quality
kata-failure-finder:
- Finds silent failures
- Reviews catch blocks
- Checks error logging
kata-type-design-analyzer:
- Analyzes type encapsulation
- Reviews invariant expression
- Rates type design quality
kata-code-reviewer:
- Checks CLAUDE.md compliance
- Detects bugs and issues
- Reviews general code quality
kata-code-simplifier:
- Simplifies complex code
- Improves clarity and readability
- Applies project standards
- Preserves functionality
kata-comment-analyzer:
- 验证注释与代码的一致性
- 识别过时注释
- 检查文档完整性
kata-pr-test-analyzer:
- 审查行为测试覆盖率
- 识别关键测试缺口
- 评估测试质量
kata-failure-finder:
- 发现静默故障
- 审查catch块逻辑
- 检查错误日志实现
kata-type-design-analyzer:
- 分析类型封装性
- 审查不变量表达式
- 评估类型设计质量
kata-code-reviewer:
- 检查是否符合CLAUDE.md规范
- 检测潜在bug与问题
- 审查通用代码质量
kata-code-simplifier:
- 简化复杂代码逻辑
- 提升代码清晰度与可读性
- 遵循项目规范
- 保留原有功能
Tips:
使用提示:
- Run early: Before creating PR, not after
- Focus on changes: Agents analyze git diff by default
- Address critical first: Fix high-priority issues before lower priority
- Re-run after fixes: Verify issues are resolved
- Use specific reviews: Target specific aspects when you know the concern
- 尽早运行:在创建PR前运行,而非之后
- 聚焦变更:Agent默认仅分析git diff中的变更内容
- 优先处理关键问题:先修复高优先级问题,再处理低优先级问题
- 修复后重新运行:验证问题是否已解决
- 使用指定维度审查:当明确关注点时,针对性选择审查维度
Workflow Integration:
工作流集成:
Before committing:
1. Write code
2. Run: /kata-review-pull-requests code errors
3. Fix any critical issues
4. CommitBefore creating PR:
1. Stage all changes
2. Run: /kata-review-pull-requests all
3. Address all critical and important issues
4. Run specific reviews again to verify
5. Create PRAfter PR feedback:
1. Make requested changes
2. Run targeted reviews based on feedback
3. Verify issues are resolved
4. Push updates提交代码前:
1. 编写代码
2. 运行:/kata-review-pull-requests code errors
3. 修复所有关键问题
4. 提交代码创建PR前:
1. 暂存所有变更
2. 运行:/kata-review-pull-requests all
3. 处理所有关键与重要问题
4. 再次运行指定维度审查以验证
5. 创建PR收到PR反馈后:
1. 根据反馈修改代码
2. 针对反馈内容运行指定维度审查
3. 验证问题是否已解决
4. 推送更新