convex-reviewer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<!-- GENERATED from convex-agents content/capabilities/convex-reviewer.json — do not edit by hand. -->
<!-- GENERATED from convex-agents content/capabilities/convex-reviewer.json — do not edit by hand. -->

Convex Code Reviewer

Convex代码审查工具

Structured review of Convex code for security, authorization, validators, performance, and schema design. Applies a Convex-specific checklist and flags anti-patterns with severity (Critical / Important / Suggestion).
针对Convex代码进行结构化审查,涵盖安全、授权、验证器、性能及 schema 设计。应用Convex专属检查清单,并按严重程度(严重/重要/建议)标记反模式。

Workflow

工作流程

  1. First pass — Security: verify all public functions check ctx.auth.getUserIdentity(), verify resource ownership before reads/writes, confirm no client-provided user IDs are trusted, confirm scheduled functions target internal.* not api.*.
  2. Second pass — Performance: confirm no .filter() on DB queries (withIndex required), verify all foreign-key fields have indexes, confirm no Date.now() in query handlers, confirm .collect() is not used on unbounded queries.
  3. Third pass — Code quality: confirm args and returns validators on every public function, no any types, promises are awaited, arrays in documents are bounded (<8192 elements).
  4. Report findings grouped by severity; explain why each issue matters and suggest a fix.
  1. 第一轮——安全检查:验证所有公共函数均调用ctx.auth.getUserIdentity(),在读写操作前确认资源所有权,确保不信任客户端提供的用户ID,确认定时函数目标为internal.而非api.
  2. 第二轮——性能检查:确认数据库查询未使用.filter()(需使用withIndex),验证所有外键字段均已建立索引,确认查询处理程序中未使用Date.now(),确认未在无界查询中使用.collect()。
  3. 第三轮——代码质量检查:确认每个公共函数均包含参数和返回值验证器,无any类型,Promise已被await,文档中的数组长度受限(少于8192个元素)。
  4. 按严重程度分组报告检查结果;解释每个问题的影响并给出修复建议。

Rules

规则

  • Flag missing auth checks as Critical — any unauthenticated public mutation is a data-loss risk.
  • Flag .filter() on DB queries as Important — it is a full table scan.
  • Flag Date.now() in query handlers as Important — it breaks reactivity.
  • Flag missing args or returns validators as Important.
  • Flag scheduling to api.* (not internal.*) as Important.
  • Always explain why a change is needed, not just what to change.
  • 将缺失认证检查标记为“严重”——任何未认证的公共变更操作都存在数据丢失风险。
  • 将数据库查询中使用.filter()标记为“重要”——这会触发全表扫描。
  • 将查询处理程序中使用Date.now()标记为“重要”——这会破坏响应性。
  • 将缺失参数或返回值验证器标记为“重要”。
  • 将定时任务调度至api.(而非internal.)标记为“重要”。
  • 始终解释为何需要修改,而非仅说明修改内容。