当前位置: 首页 > Skill >

advanced-code-review

advanced-code-review

1.0.0 2026.11.24 浏览:231
获取Skill文件查看使用说明
作者:苏川许可证:
本文目录展开

Code Review v2

Intelligent Review Workflow

Phase 1: Context Analysis

Before reviewing code, understand the context:

  1. Identify change scope: What files/modules are affected?
  2. Understand intent: Read PR description, linked issues, commit messages
  3. Assess risk level: -🔴High**: Core logic, auth, payment, data handling, public APIs -Medium**: Business logic, internal APIs, utilities -Low**: Tests, docs, config, minor refactoring
  4. Determine review depth based on risk level

Phase 2: Automated Analysis

Run these checks mentally before manual review:

□ Static analysis patterns (type mismatches, unused imports, dead code)
□ Security patterns (injection, unsafe deserialization, hardcoded secrets)
□ Performance patterns (N+1 queries, unbounded loops, missing indexes)
□ Concurrency patterns (race conditions, deadlocks, missing synchronization)

Phase 3: Manual Review

Follow the CHECKLIST.md for systematic review.

Phase 4: Feedback Generation

Use templates from TEMPLATES.md for structured feedback.

Quick Reference: Review Dimensions

Dimension Focus Area Key Questions
Correctness Logic, edge cases Does it work correctly in all scenarios?
Security Vulnerabilities, data protection Are there security risks or data leaks?
Performance Efficiency, resource usage Will this scale? Any bottlenecks?
Maintainability Readability, structure Can others understand and modify this?
Observability Logging, monitoring, debugging Can we detect and diagnose issues?
Testing Coverage, quality Are changes adequately tested?

Severity Classification

Level Icon When to Use Response Required
Blocker Security vulnerability, data loss, crash Must fix before merge
Critical 🔴 Bug, incorrect logic, broken functionality Must fix before merge
Warning Code smell, suboptimal pattern, minor issue Should address
Suggestion 💡 Improvement opportunity, alternative approach Consider
Info ℹ Observation, documentation note Optional

Language-Specific Quick Checks

Python

□ Type hints on public functions
□ No mutable default arguments
□ Context managers for resources
□ f-strings over .format() or %
□ Proper exception handling (not bare except)
□ __init__.py exports are intentional

JavaScript / TypeScript

□ async/await with try-catch (no unhandled promises)
□ No implicit any (TypeScript strict mode)
□ Proper null/undefined handling
□ No direct DOM manipulation in React
□ Keys in list rendering
□ useEffect dependencies complete

Java

□ try-with-resources for Closeable
□ Optional for nullable returns
□ Proper equals/hashCode implementation
□ No raw types (generics)
□ Stream API used appropriately
□ Thread safety considered

Go

□ Error handling (not ignored)
□ defer for cleanup
□ Context passed as first parameter
□ No goroutine leaks
□ Proper mutex usage
□ go vet and golangci-lint clean

Rust

□ No unnecessary clones
□ Proper error types (Result)
□ Lifetimes annotated correctly
□ No unsafe blocks without justification
□ Iterator chains over loops where appropriate
□ Clippy warnings addressed

C#

□ async/await patterns correct
□ using statements for IDisposable
□ Nullable reference types enabled
□ LINQ queries efficient
□ Proper exception filtering
□ CancellationToken usage

Ruby

□ No N+1 queries (includes/eager_load)
□ Proper error handling (rescue)
□ Bang methods for mutating operations
□ Frozen string literals
□ RuboCop clean

PHP

□ Type declarations on parameters/returns
□ Prepared statements (no SQL injection)
□ Proper error handling (try-catch)
□ No global state
□ PSR standards followed

Common Anti-Patterns to Flag

Security

  • Hardcoded credentials or API keys
  • SQL/NoSQL injection via string interpolation
  • XSS via unescaped output
  • Insecure deserialization
  • Missing rate limiting on public endpoints
  • Overly permissive CORS configuration

Performance

  • N+1 query patterns
  • Unbounded result sets (missing LIMIT)
  • Synchronous operations in hot paths
  • Missing caching for expensive computations
  • Inefficient data structures (O(n²) where O(n log n) possible)
  • Memory leaks (unclosed resources, growing caches)

Maintainability

  • God classes or functions over 50 lines
  • Deep nesting (3+ levels)
  • Magic numbers without constants
  • Duplicated logic across files
  • Tight coupling between modules
  • Missing or outdated documentation

Concurrency

  • Race conditions on shared state
  • Missing synchronization primitives
  • Deadlock potential (lock ordering)
  • Thread-unsafe collections
  • Improper async/await usage

Review Output Formats

Format 1: Markdown (Default)

See TEMPLATES.md for detailed markdown templates.

Format 2: JSON (Machine-Readable)

{
  "summary": "Brief overview",
  "issues": [
    {
      "severity": "critical",
      "file": "src/auth.py",
      "line": 42,
      "category": "security",
      "message": "SQL injection vulnerability",
      "suggestion": "Use parameterized queries"
    }
  ],
  "positive_notes": ["Good use of type hints"],
  "recommendation": "approve_with_changes"
}

Format 3: Checklist Report

Review Summary for PR #123
==========================
[✓] Correctness - 2 issues found
[✓] Security - 1 critical issue
[✓] Performance - No issues
[✓] Maintainability - 3 suggestions
[✓] Testing - Coverage adequate
[✓] Observability - Missing error context

Recommendation: Changes required before merge

Additional Resources

  • CHECKLIST.md - Comprehensive review checklist
  • TEMPLATES.md - Feedback templates for various scenarios
  • examples.md - Real-world review examples

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,033
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,018
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,016
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,012
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,012
Skill 文件
  • SKILL.md
    • Code Review v2
    • Intelligent Review Workflow
      • Phase 1: Context Analysis
      • Phase 2: Automated Analysis
      • Phase 3: Manual Review
      • Phase 4: Feedback Generation
    • Quick Reference: Review Dimensions
    • Severity Classification
    • Language-Specific Quick Checks
      • Python
      • JavaScript / TypeScript
      • Java
      • Go
      • Rust
      • C#
      • Ruby
      • PHP
    • Common Anti-Patterns to Flag
      • Security
      • Performance
      • Maintainability
      • Concurrency
    • Review Output Formats
      • Format 1: Markdown (Default)
      • Format 2: JSON (Machine-Readable)
      • Format 3: Checklist Report
    • Additional Resources
  • 项目或源文件

相关 Skill

更多
Code Analysis Code Analysis 执行多维度高级代码分析,包括知识图谱生成、代码质量评估、性能分析、安全审查、架构...
Openclaw Shield 1.0.3 Openclaw Shield 1.0.3 Enterprise AI security scanner combining static code analysis, runtime guards, ClamAV integration, and tamper-proof audit logging to detect threats and enfor...
Code Review Assistant Code Review Assistant 自动化代码审查助手,支持 PR 审查、代码质量分析、潜在 bug 检测与安全漏洞扫描。
Analyzes code for improvements including code smells, design patterns, and best practices. Invoke when user asks for code analysis, code review, or suggestions to improve code quality. Analyzes code for improvements including code smells, design patterns, and best practices. Invoke when user asks for code analysis, code review, or suggestions to improve code quality. 分析代码以改进,包括代码异味、设计模式和最佳实践。当用户请求代码分析、代码审查或建议时调用。
cnnvd-cve-report-generator cnnvd-cve-report-generator Generate CNNVD (中国国家信息安全漏洞库) vulnerability report forms and CVE (Common Vulnerabilities and Exposures) descriptions from security audit reports, reproduction scripts, or code analysis results. Use whenever the user mentions CVE, CNNVD, vulnerability reports, security advisory drafting, 漏洞填报, 漏洞报告, 安全公告, or needs to submit findings to vulnerability databases. Also use when the user provides audit results and asks to "write up" or "document" vulnerabilities for submission.