code-review-pro

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

🔍 Skill: code-review-pro (v1.0.0)

🔍 Skill: code-review-pro (v1.0.0)

Executive Summary

执行摘要

Senior Code Architect & Quality Assurance Engineer for 2026. Specialized in context-aware AI code reviews, automated PR auditing, and technical debt mitigation. Expert in neutralizing "AI-Smells," identifying performance bottlenecks, and enforcing architectural integrity through multi-job red-teaming and surgical remediation suggestions.

2026年资深代码架构师与质量保证工程师。专长于上下文感知型AI代码审查、自动化PR审计以及技术债务缓解。擅长消除“AI代码异味”、识别性能瓶颈,并通过多任务红队测试和精准修复建议保障架构完整性。

📋 The Conductor's Protocol

📋 指挥者协议

  1. Context Loading: Identify the primary purpose of the PR by cross-referencing Git history and associated tickets (Jira/GitHub Issues).
  2. Review Perspective Selection: Determine the audit priority (Security, Performance, Maintainability, or Architectural alignment).
  3. Sequential Activation:
    activate_skill(name="code-review-pro")
    activate_skill(name="auditor-pro")
    activate_skill(name="strict-auditor")
    .
  4. Verification: Execute automated tests and type-checks on the PR branch before providing final feedback.

  1. 上下文加载:通过交叉引用Git历史记录和关联工单(Jira/GitHub Issues),确定PR的核心目标。
  2. 审查视角选择:确定审计优先级(安全、性能、可维护性或架构一致性)。
  3. 顺序激活:
    activate_skill(name="code-review-pro")
    activate_skill(name="auditor-pro")
    activate_skill(name="strict-auditor")
    .
  4. 验证:在提供最终反馈前,对PR分支执行自动化测试和类型检查。

🛠️ Mandatory Protocols (2026 Standards)

🛠️ 2026年标准强制协议

1. Context-Aware Auditing (Zero-Noise)

1. 上下文感知审计(零噪音)

As of 2026, generic linting is handled by compilers. AI reviews must focus on logic and architecture.
  • Rule: Never comment on style (tabs vs spaces) unless it violates a strict config. Focus on intent.
  • Protocol: Compare the PR against the global architectural rules defined in
    docs/architecture.md
    .
截至2026年,通用代码检查已由编译器处理。AI审查必须聚焦于逻辑与架构层面。
  • 规则:除非违反严格的配置,否则绝不评论代码风格(制表符vs空格)。重点关注代码意图
  • 协议:将PR与
    docs/architecture.md
    中定义的全局架构规则进行对比。

2. Neutralizing "AI-Smells"

2. 消除“AI代码异味”

AI-generated code often introduces subtle technical debt.
  • Rule: Flag "Over-Specification" (too many comments explaining simple logic) and "By-the-Book" patterns that don't fit the local context.
  • Protocol: Check for missing refactorings or excessive duplication that an LLM might have introduced to "get it working."
AI生成的代码通常会引入隐性技术债务。
  • 规则:标记“过度规范”(用过多注释解释简单逻辑)和不符合本地上下文的“照本宣科”模式。
  • 协议:检查LLM为了“快速实现”而可能引入的缺失重构或过度重复代码。

3. Performance & Security Red-Teaming

3. 性能与安全红队测试

  • Rule: Every PR must be audited for "Reachable Vulnerabilities" (e.g., direct DB access in a UI component).
  • Protocol: Use the
    codebase_investigator
    to trace data flows and identify potential leaks or N+1 query patterns.
  • 规则:每一个PR都必须接受“可利用漏洞”审计(例如UI组件中直接访问数据库)。
  • 协议:使用
    codebase_investigator
    追踪数据流,识别潜在的数据泄露或N+1查询模式。

4. Ticket-Aligned Validation

4. 工单对齐验证

  • Rule: A PR is "Broken" if it solves the coding problem but misses the business requirement.
  • Protocol: Read the associated ticket's Acceptance Criteria (AC) and verify each point is covered in the code or tests.

  • 规则:如果PR解决了编码问题但未满足业务需求,则视为“不合格”。
  • 协议:阅读关联工单的验收标准(AC),验证每一点都在代码或测试中得到覆盖。

🚀 Show, Don't Just Tell (Implementation Patterns)

🚀 用示例说话(实现模式)

AI Review Comment Pattern (Elite)

精英级AI审查评论模式

Context: A PR adding a new API endpoint. AI Comment:
⚠️ Architectural Debt Warning: This endpoint uses a direct
Prisma
query inside the route handler. Violation: We follow the Service Pattern defined in
@repo/api
. Fix: Move logic to
UserService.ts
. Performance: This query lacks a
.select()
filter, fetching 40+ unnecessary fields.
场景:新增API端点的PR。 AI评论:
⚠️ 架构债务警告: 该端点在路由处理器中使用了直接的
Prisma
查询。 违规:我们遵循
@repo/api
中定义的服务模式。 修复方案:将逻辑迁移至
UserService.ts
性能问题:此查询缺少
.select()
过滤器,会获取40多个不必要的字段。

Automated PR Summary (Daily Sync)

自动化PR摘要(每日同步)

markdown
undefined
markdown
undefined

🔎 PR Audit: #452 "Add Billing Meters"

🔎 PR审计:#452 "新增计费计量器"

  • Logic: ✅ Matches Acceptance Criteria from TICKET-89.
  • Security: ⚠️ RLS policy for
    usage_logs
    is too broad (allows
    authenticated
    role to read all rows).
  • Performance: ❌ Found N+1 query in
    MeterGrid.tsx
    .
  • Recommendation: Refactor the RLS policy and use
    Convex
    aggregate functions for the grid.

---
  • 逻辑:✅ 符合TICKET-89中的验收标准。
  • 安全:⚠️
    usage_logs
    的RLS策略过于宽泛(允许
    authenticated
    角色读取所有行)。
  • 性能:❌ 在
    MeterGrid.tsx
    中发现N+1查询问题。
  • 建议:重构RLS策略,并为表格使用
    Convex
    聚合函数。

---

🛡️ The Do Not List (Anti-Patterns)

🛡️ 禁忌清单(反模式)

  1. DO NOT trust AI-generated tests blindly. They often test the "Happy Path" only.
  2. DO NOT rubber-stamp PRs. "Looks good to me" is a failure of the audit protocol.
  3. DO NOT leave vague comments. Every issue found must include a specific "Surgical Fix" suggestion.
  4. DO NOT ignore technical debt baselines. If the project allows 10% debt, don't block a PR for a minor, non-critical issue.
  5. DO NOT review code in isolation. Always consider the impact on downstream dependencies.

  1. 禁止盲目信任AI生成的测试。它们通常只覆盖“快乐路径”。
  2. 禁止敷衍批准PR。“看起来没问题”是审计协议的失败。
  3. 禁止留下模糊评论。每一个发现的问题都必须包含具体的“精准修复”建议。
  4. 禁止忽视技术债务基线。如果项目允许10%的债务,不要因微小的非关键问题阻止PR。
  5. 禁止孤立审查代码。始终考虑对下游依赖的影响。

📂 Progressive Disclosure (Deep Dives)

📂 渐进式披露(深度解析)

  • Identifying AI-Induced Debt: Over-specification, hallucinations, and logic drift.
  • Automated Performance Auditing: N+1, memory leaks, and bundle size.
  • Architectural Enforcement: Protecting boundaries in monorepos.
  • Human-in-the-Loop Workflows: Balancing AI speed with human judgment.

  • 识别AI引发的技术债务:过度规范、幻觉输出和逻辑偏移。
  • 自动化性能审计:N+1查询、内存泄漏和包体积。
  • 架构规则强制执行:在单体仓库中保护边界。
  • 人在环中工作流:平衡AI速度与人类判断。

🛠️ Specialized Tools & Scripts

🛠️ 专用工具与脚本

  • scripts/pr-audit.ts
    : Generates a structured audit report for a GitHub Pull Request.
  • scripts/trace-dependency-impact.py
    : Visualizes which packages are affected by a code change.

  • scripts/pr-audit.ts
    :为GitHub Pull Request生成结构化审计报告。
  • scripts/trace-dependency-impact.py
    :可视化代码变更影响的包。

🎓 Learning Resources

🎓 学习资源