重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
code-review by mgd34msu/goodvibes-plugin
npx skills add https://github.com/mgd34msu/goodvibes-plugin --skill code-reviewscripts/
validate-code-review.sh
references/
review-patterns.md
此技能教你如何使用 GoodVibes 精准工具执行彻底的企业级代码审查。系统化的代码审查能及早发现问题、确保一致性、验证安全性和性能,并在整个代码库中保持高质量标准。
在以下情况加载此技能:
触发短语:"review this code", "check the PR", "quality audit", "security review", "performance review", "validate implementation"。
在审查之前,先理解变更内容、原因及影响范围。
使用 discover 来映射所有更改的文件并识别变更类型。
discover:
queries:
- id: changed_files
type: glob
patterns: ["src/**/*"] # 列出待审查的更改文件
- id: new_files
type: glob
patterns: ["**/*"]
- id: test_files
type: glob
patterns: ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"]
verbosity: files_only
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
从 git 提取:
precision_exec:
commands:
- cmd: "git diff --name-only HEAD~1..HEAD"
verbosity: minimal
这揭示了什么:
使用 precision_read 来检查实际更改。
precision_read:
files:
- path: "src/api/user-routes.ts" # 示例更改文件
extract: content
- path: "src/components/UserProfile.tsx"
extract: content
output:
max_per_item: 200
verbosity: standard
获取差异上下文:
precision_exec:
commands:
- cmd: "git diff HEAD~1..HEAD -- src/api/user-routes.ts"
verbosity: standard
使用 discover 查找已更改符号的导入、导出和使用情况。
discover:
queries:
- id: function_exports
type: grep
pattern: "export (function|const|class) (createUser|updateUser|deleteUser)"
glob: "**/*.{ts,tsx,js,jsx}"
- id: usage_sites
type: grep
pattern: "(createUser|updateUser|deleteUser)\\("
glob: "**/*.{ts,tsx,js,jsx}"
- id: related_tests
type: grep
pattern: "(createUser|updateUser|deleteUser)"
glob: "**/*.test.{ts,tsx}"
verbosity: locations
这揭示了什么:
安全问题至关重要,必须在审查中发现。
使用 discover 查找安全反模式。
discover:
queries:
# SQL 注入
- id: sql_injection
type: grep
pattern: '(query|execute|sql).*[`$].*\$\{'
glob: "**/*.{ts,tsx,js,jsx}"
# XSS 漏洞
- id: dangerous_html
type: grep
pattern: "(dangerouslySetInnerHTML|innerHTML|outerHTML)"
glob: "**/*.{ts,tsx,jsx}"
# 硬编码密钥
- id: hardcoded_secrets
type: grep
pattern: '(password|secret|api[_-]?key|token)\s*=\s*["''][^"'']+["'']'
glob: "**/*.{ts,tsx,js,jsx,json}"
# 缺少身份验证
- id: unauthed_routes
type: grep
pattern: "export (async )?function (GET|POST|PUT|DELETE|PATCH)"
glob: "src/app/api/**/*.ts"
verbosity: locations
需要检查的关键模式:
| 模式 | 严重性 | 重要性 |
|---|---|---|
| SQL 注入 | 关键 | 允许攻击者读取/修改数据库 |
| XSS 漏洞 | 关键 | 允许脚本注入、会话劫持 |
| 硬编码密钥 | 关键 | 在源代码中暴露凭据 |
| 缺少身份验证检查 | 关键 | 暴露受保护资源 |
| 不安全的反序列化 | 关键 | 远程代码执行 |
| CORS 配置错误 | 主要 | 允许未经授权的来源 |
| 弱密码规则 | 主要 | 账户泄露 |
| 缺少输入验证 | 主要 | 数据损坏、注入 |
所有外部输入都必须经过验证。
discover:
queries:
# 检查验证模式
- id: zod_schemas
type: grep
pattern: "z\\.(object|string|number|array|enum)"
glob: "**/*.{ts,tsx}"
# 检查未经验证的直接 request.json()
- id: unvalidated_input
type: grep
pattern: "(await request\\.json\\(\\)|req\\.body)(?!.*safeParse)"
glob: "src/app/api/**/*.ts"
# 检查 SQL 参数化
- id: parameterized_queries
type: grep
pattern: "(db\\.(query|execute)|prisma\\.|sql`)"
glob: "**/*.{ts,js}"
verbosity: locations
需要验证的最佳实践:
验证受保护资源是否需要身份验证。
discover:
queries:
# 查找身份验证中间件使用情况
- id: auth_middleware
type: grep
pattern: "(getServerSession|auth\\(\\)|requireAuth|withAuth)"
glob: "src/app/api/**/*.ts"
# 查找资源所有权检查
- id: ownership_checks
type: grep
pattern: "(userId|authorId|ownerId)\s*===\s*(session|user|currentUser)"
glob: "**/*.{ts,tsx}"
# 查找 RBAC 检查
- id: rbac_checks
type: grep
pattern: "(role|permission|can)\s*===\s*"
glob: "**/*.{ts,tsx}"
verbosity: locations
关键检查项:
性能问题会导致用户体验差和扩展成本高。
N+1 查询是数据库性能的头号杀手。
discover:
queries:
# 查找包含数据库调用的循环
- id: n_plus_one
type: grep
pattern: "(for|forEach|map).*await.*(prisma|db|query|find)"
glob: "**/*.{ts,tsx,js,jsx}"
# 查找 Prisma include 使用情况
- id: prisma_includes
type: grep
pattern: "(findMany|findUnique|findFirst).*include:"
glob: "**/*.{ts,js}"
verbosity: locations
如何修复:
include 来预加载相关记录(Prisma)SELECT IN 进行批量加载React 重新渲染问题会损害前端性能。
discover:
queries:
# 查找 JSX 中的内联对象/数组创建
- id: inline_objects
type: grep
pattern: "(onClick|onChange|style)=\\{\\{|=\\{\\["
glob: "**/*.{tsx,jsx}"
# 查找缺失的 useMemo/useCallback
- id: missing_memoization
type: grep
pattern: "(map|filter|reduce)\\("
glob: "**/*.{tsx,jsx}"
# 查找没有依赖项的 useEffect
- id: missing_deps
type: grep
pattern: "useEffect\\([^)]+\\)\\s*$"
glob: "**/*.{tsx,jsx}"
verbosity: locations
常见问题:
| 反模式 | 修复方法 |
|---|---|
| props 中的内联对象 | 提取为常量或使用 useMemo |
| props 中的内联函数 | 用 useCallback 包装 |
| 没有 key 的大列表 | 添加稳定的 key 属性 |
| useEffect 缺少依赖项 | 将所有使用的变量添加到依赖项数组 |
| Context 重新渲染所有内容 | 拆分上下文或使用状态管理器 |
缺少索引会导致查询缓慢。
precision_read:
files:
- path: "prisma/schema.prisma"
extract: content
output:
max_per_item: 500
verbosity: standard
验证以下字段是否存在索引:
代码质量影响可维护性和可靠性。
TypeScript 应在编译时而非运行时捕获错误。
discover:
queries:
# 查找 any 类型
- id: any_usage
type: grep
pattern: ":\s*any(\\s|;|,|\\))"
glob: "**/*.{ts,tsx}"
# 查找类型断言 (as)
- id: type_assertions
type: grep
pattern: "as (unknown|any|string|number)"
glob: "**/*.{ts,tsx}"
# 查找非空断言 (!)
- id: non_null_assertions
type: grep
pattern: "![.;,)\\]]"
glob: "**/*.{ts,tsx}"
# 查找不安全的成员访问
- id: unsafe_access
type: grep
pattern: "\\?\\."
glob: "**/*.{ts,tsx}"
verbosity: locations
类型安全问题:
| 问题 | 严重性 | 修复方法 |
|---|---|---|
any 类型使用 | 主要 | 使用正确的类型或 unknown |
as any 断言 | 主要 | 修复底层类型问题 |
! 非空断言 | 次要 | 添加空值检查 |
| 缺少返回类型 | 次要 | 显式声明函数返回类型 |
| 隐式 any 参数 | 主要 | 添加参数类型 |
所有异步操作和 API 调用都必须处理错误。
discover:
queries:
# 查找悬空的 Promise
- id: floating_promises
type: grep
pattern: "^\\s+[a-z][a-zA-Z]*\\(.*\\);$"
glob: "**/*.{ts,tsx,js,jsx}"
# 查找空的 catch 块
- id: empty_catch
type: grep
pattern: "catch.*\\{\\s*\\}"
glob: "**/*.{ts,tsx,js,jsx}"
# 查找 console.error(应使用日志记录器)
- id: console_error
type: grep
pattern: "console\\.(error|warn|log)"
glob: "**/*.{ts,tsx,js,jsx}"
verbosity: locations
错误处理检查清单:
.catch() 或 try/catch文件过大和复杂度高会使代码难以维护。
precision_exec:
commands:
- cmd: "find src -not -path '*/node_modules/*' -not -path '*/dist/*' -name '*.ts' -o -name '*.tsx' -print0 | xargs -0 wc -l | sort -rn | head -20"
verbosity: standard
代码组织规则:
测试验证正确性并防止回归。
每个更改的文件都应该有测试。
discover:
queries:
# 查找测试文件
- id: test_files
type: glob
patterns: ["**/*.test.{ts,tsx}", "**/*.spec.{ts,tsx}"]
# 查找没有测试的文件
- id: source_files
type: glob
patterns: ["src/**/*.{ts,tsx}"]
# 检查测试导入
- id: test_imports
type: grep
pattern: "from ['\"].*/(api|lib|components)/"
glob: "**/*.test.{ts,tsx}"
verbosity: files_only
比较源文件和测试文件:
// 伪逻辑(使用 precision tools 实现)
const sourceFiles = results.source_files.files;
const testFiles = results.test_files.files;
const missingTests = sourceFiles.filter(f => !testFiles.some(t => t.includes(f.replace('.ts', ''))));
测试应测试行为,而非实现。
discover:
queries:
# 查找跳过的测试
- id: skipped_tests
type: grep
pattern: "(it\\.skip|test\\.skip|describe\\.skip)"
glob: "**/*.test.{ts,tsx}"
# 查找聚焦的测试 (.only)
- id: focused_tests
type: grep
pattern: "(it\\.only|test\\.only|describe\\.only)"
glob: "**/*.test.{ts,tsx}"
# 查找 expect 断言
- id: assertions
type: grep
pattern: "expect\\("
glob: "**/*.test.{ts,tsx}"
# 查找模拟使用情况
- id: mocks
type: grep
pattern: "(vi\\.mock|jest\\.mock|vi\\.fn)"
glob: "**/*.test.{ts,tsx}"
verbosity: locations
测试质量检查清单:
.skip 或 .only(应在合并前移除)架构违规会产生技术债务。
依赖关系应从外层流向内层。
discover:
queries:
# 在 UI 中查找领域导入
- id: ui_imports_domain
type: grep
pattern: "from ['\"].*/(domain|core|lib)/"
glob: "src/components/**/*.{ts,tsx}"
# 在领域层中查找 UI 导入
- id: domain_imports_ui
type: grep
pattern: "from ['\"].*/(components|pages|app)/"
glob: "src/domain/**/*.{ts,tsx}"
# 查找循环依赖
- id: imports
type: grep
pattern: "^import.*from"
glob: "src/**/*.{ts,tsx}"
verbosity: locations
依赖规则:
discover:
queries:
# 组件中的数据库访问
- id: db_in_components
type: grep
pattern: "(prisma|db\\.(query|execute))"
glob: "src/components/**/*.{ts,tsx}"
# API 路由中的业务逻辑
- id: logic_in_routes
type: grep
pattern: "export (async )?function (GET|POST)"
glob: "src/app/api/**/*.ts"
verbosity: files_only
阅读路由处理程序以检查:
无障碍访问确保你的应用可供所有人使用。
为无障碍访问使用正确的 HTML 元素。
discover:
queries:
# 查找 div 按钮(应为 <button>)
- id: div_buttons
type: grep
pattern: "<div.*(onClick|onKeyDown)"
glob: "**/*.{tsx,jsx}"
# 查找缺少 alt 文本
- id: missing_alt
type: grep
pattern: "<img(?![^>]*alt=)"
glob: "**/*.{tsx,jsx}"
# 查找缺少标签
- id: missing_labels
type: grep
pattern: "<input(?![^>]*aria-label)(?![^>]*id=)"
glob: "**/*.{tsx,jsx}"
# 查找缺少 ARIA 角色
- id: missing_roles
type: grep
pattern: "<(nav|header|footer|main)(?![^>]*role=)"
glob: "**/*.{tsx,jsx}"
verbosity: locations
无障碍访问检查清单:
<button>,而非 <div onClick>alt 文本aria-labeloutline: none 且无替代方案)discover:
queries:
# 查找自定义组件
- id: custom_components
type: grep
pattern: "(Accordion|Dialog|Dropdown|Tabs|Tooltip)"
glob: "src/components/**/*.{tsx,jsx}"
verbosity: files_only
阅读组件以验证:
使用 review-scoring 技能提供结构化反馈。
完整评分细则请参见 plugins/goodvibes/skills/protocol/review-scoring/SKILL.md。
10 个维度(加权):
any每个维度评分 1-10:
总分 = 加权平均值
通过/失败阈值:
运行自动化检查以发现问题。
precision_exec:
commands:
# 类型检查
- cmd: "npm run typecheck"
# 代码检查
- cmd: "npm run lint"
# 测试
- cmd: "npm run test"
# 安全审计
- cmd: "npm audit --audit-level=moderate"
verbosity: standard
所有检查必须在批准前通过。
结构化反馈是可操作且具体的。
审查输出格式:
## 审查摘要
**总分**: 8.2/10
**结论**: 批准,附带建议
**变更内容**: 添加了带身份验证的用户个人资料 API
**审查文件**: 8 个文件(5 个源文件,3 个测试文件)
## 维度得分
1. 正确性: 9/10
2. 类型安全: 7/10
3. 安全性: 9/10
4. 性能: 8/10
5. 错误处理: 7/10
6. 测试: 8/10
7. 代码质量: 9/10
8. 架构: 8/10
9. 无障碍访问: 8/10
10. 文档: 7/10
## 发现的问题
### 主要问题(应修复)
- **FILE:LINE** - 类型安全:函数 `updateProfile` 具有隐式 `any` 返回类型
- 修复:添加显式返回类型 `Promise<User>`
- 影响:TypeScript 无法在调用方捕获类型错误
### 次要问题(最好修复)
- **src/api/profile.ts:42** - 错误处理:空的 catch 块吞没了错误
- 修复:在重新抛出前记录带有上下文的错误
- 影响:使调试更加困难
## 做得好的方面
- 使用 Zod 模式进行出色的输入验证
- 全面的测试覆盖率 (95%)
- 所有路由都有正确的身份验证检查
- 关注点分离清晰(路由 -> 服务 -> 存储库)
反馈指南:
按类别组织的详细反模式请参见 references/review-patterns.md。
快速参考:
any 类型、类型断言expect(result).toBeTruthy().skip 或 .only并行运行多个 grep/glob 查询以查找模式。
示例:查找安全问题
discover:
queries:
- id: sql_injection
type: grep
pattern: 'query.*\$\{'
- id: hardcoded_secrets
type: grep
pattern: 'api[_-]?key\s*=\s*["''][^"'']+'
- id: xss
type: grep
pattern: 'dangerouslySetInnerHTML'
verbosity: locations
支持上下文搜索、多行支持和令牌限制。
示例:查找错误处理
precision_grep:
queries:
- id: catch_blocks
pattern: "try\\s*\\{[\\s\\S]*?\\}\\s*catch"
output:
format: context
context_after: 3
context_before: 1
verbosity: standard
运行验证命令。
precision_exec:
commands:
- cmd: "npm run typecheck"
- cmd: "npm run lint"
- cmd: "npm test -- --coverage"
verbosity: standard
使用 scripts/validate-code-review.sh 验证审查的完整性。
./scripts/validate-code-review.sh /path/to/review-output.md
脚本检查:
审查前:
git diff 或 GitHub PR)审查中:
any、断言、返回类型审查后:
关键(必须在合并前修复):
主要(应在合并前修复):
any 使用、缺少类型)次要(最好修复,或在后续工作中处理):
分数虚高:
模糊反馈:
getUser 添加返回类型 Promise<User>"忽视优点:
严重性不一致:
并行审查多个 PR 或文件。
discover:
queries:
- id: all_changes
type: grep
pattern: ".*"
path: "src/"
verbosity: files_only
然后批量读取文件:
precision_read:
files:
- path: "src/changed-file-1.ts"
- path: "src/changed-file-2.ts"
extract: content
output:
max_per_item: 100
verbosity: standard
使用带上下文的 precision_grep 来理解周围代码。
precision_grep:
queries:
- id: auth_checks
pattern: "getServerSession|auth\\(\\)"
output:
format: context
context_before: 5
context_after: 10
verbosity: standard
仅关注更改的行。
precision_exec:
commands:
- cmd: "git diff HEAD~1..HEAD --unified=5"
verbosity: standard
解析差异并仅审查更改的部分。
创建一批安全/性能检查。
discover:
queries:
# 安全性
- { id: sql_injection, type: grep, pattern: 'query.*\$\{' }
- { id: xss, type: grep, pattern: 'dangerouslySetInnerHTML' }
- { id: secrets, type: grep, pattern: 'password\s*=\s*["''][^"'']+' }
# 性能
- { id: n_plus_one, type: grep, pattern: 'for.*await.*prisma' }
- { id: inline_objects, type: grep, pattern: 'onClick=\{\{', glob: '**/*.tsx' }
# 质量
- { id: any_usage, type: grep, pattern: ':\s*any', glob: '**/*.ts' }
- { id: empty_catch, type: grep, pattern: 'catch.*\{\s*\}' }
verbosity: locations
汇总结果并根据发现进行评分。
references/review-patterns.md - 按类别分类的常见反模式scripts/validate-code-review.sh - 自动化审查验证plugins/goodvibes/skills/protocol/review-scoring/SKILL.md - 评分细则详情每周安装次数
61
仓库
GitHub 星标数
6
首次出现
2026年2月16日
安全审计
安装于
opencode60
gemini-cli58
github-copilot58
codex57
cursor57
amp56
scripts/
validate-code-review.sh
references/
review-patterns.md
This skill teaches you how to perform thorough, enterprise-grade code reviews using GoodVibes precision tools. A systematic code review catches issues early, ensures consistency, validates security and performance, and maintains high quality standards across the codebase.
Load this skill when:
Trigger phrases: "review this code", "check the PR", "quality audit", "security review", "performance review", "validate implementation".
Before reviewing, understand what changed, why, and the scope of impact.
Use discover to map all changed files and identify the type of change.
discover:
queries:
- id: changed_files
type: glob
patterns: ["src/**/*"] # List changed files for review
- id: new_files
type: glob
patterns: ["**/*"]
- id: test_files
type: glob
patterns: ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"]
verbosity: files_only
Extract from git:
precision_exec:
commands:
- cmd: "git diff --name-only HEAD~1..HEAD"
verbosity: minimal
What this reveals:
Use precision_read to examine the actual changes.
precision_read:
files:
- path: "src/api/user-routes.ts" # Example changed file
extract: content
- path: "src/components/UserProfile.tsx"
extract: content
output:
max_per_item: 200
verbosity: standard
Get diff context:
precision_exec:
commands:
- cmd: "git diff HEAD~1..HEAD -- src/api/user-routes.ts"
verbosity: standard
Use discover to find imports, exports, and usage of changed symbols.
discover:
queries:
- id: function_exports
type: grep
pattern: "export (function|const|class) (createUser|updateUser|deleteUser)"
glob: "**/*.{ts,tsx,js,jsx}"
- id: usage_sites
type: grep
pattern: "(createUser|updateUser|deleteUser)\\("
glob: "**/*.{ts,tsx,js,jsx}"
- id: related_tests
type: grep
pattern: "(createUser|updateUser|deleteUser)"
glob: "**/*.test.{ts,tsx}"
verbosity: locations
What this reveals:
Security issues are critical and must be caught in review.
Use discover to find security anti-patterns.
discover:
queries:
# SQL Injection
- id: sql_injection
type: grep
pattern: '(query|execute|sql).*[`$].*\$\{'
glob: "**/*.{ts,tsx,js,jsx}"
# XSS vulnerabilities
- id: dangerous_html
type: grep
pattern: "(dangerouslySetInnerHTML|innerHTML|outerHTML)"
glob: "**/*.{ts,tsx,jsx}"
# Hardcoded secrets
- id: hardcoded_secrets
type: grep
pattern: '(password|secret|api[_-]?key|token)\s*=\s*["''][^"'']+["'']'
glob: "**/*.{ts,tsx,js,jsx,json}"
# Missing authentication
- id: unauthed_routes
type: grep
pattern: "export (async )?function (GET|POST|PUT|DELETE|PATCH)"
glob: "src/app/api/**/*.ts"
verbosity: locations
Critical patterns to check:
| Pattern | Severity | Why It Matters |
|---|---|---|
| SQL injection | Critical | Allows attackers to read/modify database |
| XSS vulnerabilities | Critical | Allows script injection, session hijacking |
| Hardcoded secrets | Critical | Exposes credentials in source code |
| Missing auth checks | Critical | Exposes protected resources |
| Unsafe deserialization | Critical | Remote code execution |
| CORS misconfiguration | Major | Allows unauthorized origins |
| Weak password rules | Major | Account compromise |
| Missing input validation | Major | Data corruption, injection |
All external input must be validated.
discover:
queries:
# Check for validation schemas
- id: zod_schemas
type: grep
pattern: "z\\.(object|string|number|array|enum)"
glob: "**/*.{ts,tsx}"
# Check for direct request.json() without validation
- id: unvalidated_input
type: grep
pattern: "(await request\\.json\\(\\)|req\\.body)(?!.*safeParse)"
glob: "src/app/api/**/*.ts"
# Check for SQL parameterization
- id: parameterized_queries
type: grep
pattern: "(db\\.(query|execute)|prisma\\.|sql`)"
glob: "**/*.{ts,js}"
verbosity: locations
Best practices to validate:
Verify that protected resources require authentication.
discover:
queries:
# Find auth middleware usage
- id: auth_middleware
type: grep
pattern: "(getServerSession|auth\\(\\)|requireAuth|withAuth)"
glob: "src/app/api/**/*.ts"
# Find resource ownership checks
- id: ownership_checks
type: grep
pattern: "(userId|authorId|ownerId)\s*===\s*(session|user|currentUser)"
glob: "**/*.{ts,tsx}"
# Find RBAC checks
- id: rbac_checks
type: grep
pattern: "(role|permission|can)\s*===\s*"
glob: "**/*.{ts,tsx}"
verbosity: locations
Critical checks:
Performance issues cause poor UX and cost scalability.
N+1 queries are the #1 database performance killer.
discover:
queries:
# Find loops with database calls
- id: n_plus_one
type: grep
pattern: "(for|forEach|map).*await.*(prisma|db|query|find)"
glob: "**/*.{ts,tsx,js,jsx}"
# Find Prisma include usage
- id: prisma_includes
type: grep
pattern: "(findMany|findUnique|findFirst).*include:"
glob: "**/*.{ts,js}"
verbosity: locations
How to fix:
include to eager load related records (Prisma)SELECT IN for batch loadingReact re-render issues harm frontend performance.
discover:
queries:
# Find inline object/array creation in JSX
- id: inline_objects
type: grep
pattern: "(onClick|onChange|style)=\\{\\{|=\\{\\["
glob: "**/*.{tsx,jsx}"
# Find missing useMemo/useCallback
- id: missing_memoization
type: grep
pattern: "(map|filter|reduce)\\("
glob: "**/*.{tsx,jsx}"
# Find useEffect without dependencies
- id: missing_deps
type: grep
pattern: "useEffect\\([^)]+\\)\\s*$"
glob: "**/*.{tsx,jsx}"
verbosity: locations
Common issues:
| Anti-pattern | Fix |
|---|---|
| Inline object in props | Extract to constant or useMemo |
| Inline function in props | Wrap in useCallback |
| Large list without key | Add stable key prop |
| useEffect missing deps | Add all used variables to deps array |
| Context re-renders everything | Split context or use state managers |
Missing indexes cause slow queries.
precision_read:
files:
- path: "prisma/schema.prisma"
extract: content
output:
max_per_item: 500
verbosity: standard
Validate indexes exist for:
Code quality affects maintainability and reliability.
TypeScript should catch errors at compile time, not runtime.
discover:
queries:
# Find any types
- id: any_usage
type: grep
pattern: ":\s*any(\\s|;|,|\\))"
glob: "**/*.{ts,tsx}"
# Find type assertions (as)
- id: type_assertions
type: grep
pattern: "as (unknown|any|string|number)"
glob: "**/*.{ts,tsx}"
# Find non-null assertions (!)
- id: non_null_assertions
type: grep
pattern: "![.;,)\\]]"
glob: "**/*.{ts,tsx}"
# Find unsafe member access
- id: unsafe_access
type: grep
pattern: "\\?\\."
glob: "**/*.{ts,tsx}"
verbosity: locations
Type safety issues:
| Issue | Severity | Fix |
|---|---|---|
any type usage | Major | Use proper types or unknown |
as any assertions | Major | Fix the underlying type issue |
! non-null assertion | Minor | Add null checks |
| Missing return types | Minor | Explicitly type function returns |
| Implicit any params | Major | Add parameter types |
All async operations and API calls must handle errors.
discover:
queries:
# Find floating promises
- id: floating_promises
type: grep
pattern: "^\\s+[a-z][a-zA-Z]*\\(.*\\);$"
glob: "**/*.{ts,tsx,js,jsx}"
# Find empty catch blocks
- id: empty_catch
type: grep
pattern: "catch.*\\{\\s*\\}"
glob: "**/*.{ts,tsx,js,jsx}"
# Find console.error (should use logger)
- id: console_error
type: grep
pattern: "console\\.(error|warn|log)"
glob: "**/*.{ts,tsx,js,jsx}"
verbosity: locations
Error handling checklist:
.catch() or try/catchLarge files and high complexity make code hard to maintain.
precision_exec:
commands:
- cmd: "find src -not -path '*/node_modules/*' -not -path '*/dist/*' -name '*.ts' -o -name '*.tsx' -print0 | xargs -0 wc -l | sort -rn | head -20"
verbosity: standard
Code organization rules:
Tests validate correctness and prevent regressions.
Every changed file should have tests.
discover:
queries:
# Find test files
- id: test_files
type: glob
patterns: ["**/*.test.{ts,tsx}", "**/*.spec.{ts,tsx}"]
# Find files without tests
- id: source_files
type: glob
patterns: ["src/**/*.{ts,tsx}"]
# Check test imports
- id: test_imports
type: grep
pattern: "from ['\"].*/(api|lib|components)/"
glob: "**/*.test.{ts,tsx}"
verbosity: files_only
Compare source files to test files:
// Pseudo-logic (implement with precision tools)
const sourceFiles = results.source_files.files;
const testFiles = results.test_files.files;
const missingTests = sourceFiles.filter(f => !testFiles.some(t => t.includes(f.replace('.ts', ''))));
Tests should test behavior, not implementation.
discover:
queries:
# Find skipped tests
- id: skipped_tests
type: grep
pattern: "(it\\.skip|test\\.skip|describe\\.skip)"
glob: "**/*.test.{ts,tsx}"
# Find focused tests (.only)
- id: focused_tests
type: grep
pattern: "(it\\.only|test\\.only|describe\\.only)"
glob: "**/*.test.{ts,tsx}"
# Find expect assertions
- id: assertions
type: grep
pattern: "expect\\("
glob: "**/*.test.{ts,tsx}"
# Find mock usage
- id: mocks
type: grep
pattern: "(vi\\.mock|jest\\.mock|vi\\.fn)"
glob: "**/*.test.{ts,tsx}"
verbosity: locations
Test quality checklist:
.skip or .only (should be removed before merge)Architecture violations create technical debt.
Dependencies should flow from outer layers to inner layers.
discover:
queries:
# Find domain imports in UI
- id: ui_imports_domain
type: grep
pattern: "from ['\"].*/(domain|core|lib)/"
glob: "src/components/**/*.{ts,tsx}"
# Find UI imports in domain
- id: domain_imports_ui
type: grep
pattern: "from ['\"].*/(components|pages|app)/"
glob: "src/domain/**/*.{ts,tsx}"
# Find circular dependencies
- id: imports
type: grep
pattern: "^import.*from"
glob: "src/**/*.{ts,tsx}"
verbosity: locations
Dependency rules:
discover:
queries:
# Database access in components
- id: db_in_components
type: grep
pattern: "(prisma|db\\.(query|execute))"
glob: "src/components/**/*.{ts,tsx}"
# Business logic in API routes
- id: logic_in_routes
type: grep
pattern: "export (async )?function (GET|POST)"
glob: "src/app/api/**/*.ts"
verbosity: files_only
Read the route handlers to check:
Accessibility ensures your app is usable by everyone.
Use proper HTML elements for accessibility.
discover:
queries:
# Find div buttons (should be <button>)
- id: div_buttons
type: grep
pattern: "<div.*(onClick|onKeyDown)"
glob: "**/*.{tsx,jsx}"
# Find missing alt text
- id: missing_alt
type: grep
pattern: "<img(?![^>]*alt=)"
glob: "**/*.{tsx,jsx}"
# Find missing labels
- id: missing_labels
type: grep
pattern: "<input(?![^>]*aria-label)(?![^>]*id=)"
glob: "**/*.{tsx,jsx}"
# Find missing ARIA roles
- id: missing_roles
type: grep
pattern: "<(nav|header|footer|main)(?![^>]*role=)"
glob: "**/*.{tsx,jsx}"
verbosity: locations
Accessibility checklist:
<button>, not <div onClick>alt textaria-labeloutline: none without replacement)discover:
queries:
# Find custom components
- id: custom_components
type: grep
pattern: "(Accordion|Dialog|Dropdown|Tabs|Tooltip)"
glob: "src/components/**/*.{tsx,jsx}"
verbosity: files_only
Read components to validate:
Use the review-scoring skill to provide structured feedback.
See plugins/goodvibes/skills/protocol/review-scoring/SKILL.md for the full rubric.
The 10 Dimensions (weighted):
anyScore each dimension 1-10:
Overall score = weighted average
Pass/fail thresholds:
Run automated checks to catch issues.
precision_exec:
commands:
# Type check
- cmd: "npm run typecheck"
# Lint
- cmd: "npm run lint"
# Tests
- cmd: "npm run test"
# Security audit
- cmd: "npm audit --audit-level=moderate"
verbosity: standard
All checks must pass before approval.
Structured feedback is actionable and specific.
Review output format:
## Review Summary
**Overall Score**: 8.2/10
**Verdict**: APPROVE with suggestions
**What changed**: Added user profile API with authentication
**Files reviewed**: 8 files (5 source, 3 test)
## Dimension Scores
1. Correctness: 9/10
2. Type Safety: 7/10
3. Security: 9/10
4. Performance: 8/10
5. Error Handling: 7/10
6. Testing: 8/10
7. Code Quality: 9/10
8. Architecture: 8/10
9. Accessibility: 8/10
10. Documentation: 7/10
## Issues Found
### Major (should fix)
- **FILE:LINE** - Type safety: Function `updateProfile` has implicit `any` return type
- Fix: Add explicit return type `Promise<User>`
- Impact: TypeScript can't catch type errors in callers
### Minor (nice to fix)
- **src/api/profile.ts:42** - Error handling: Empty catch block swallows errors
- Fix: Log error with context before re-throwing
- Impact: Makes debugging harder
## What Was Done Well
- Excellent input validation with Zod schemas
- Comprehensive test coverage (95%)
- Proper authentication checks on all routes
- Clean separation of concerns (route -> service -> repository)
Feedback guidelines:
See references/review-patterns.md for detailed anti-patterns organized by category.
Quick reference:
any types, type assertionsexpect(result).toBeTruthy().skip or .only left inRun multiple grep/glob queries in parallel to find patterns.
Example: Find security issues
discover:
queries:
- id: sql_injection
type: grep
pattern: 'query.*\$\{'
- id: hardcoded_secrets
type: grep
pattern: 'api[_-]?key\s*=\s*["''][^"'']+'
- id: xss
type: grep
pattern: 'dangerouslySetInnerHTML'
verbosity: locations
Search with context, multiline support, and token limits.
Example: Find error handling
precision_grep:
queries:
- id: catch_blocks
pattern: "try\\s*\\{[\\s\\S]*?\\}\\s*catch"
output:
format: context
context_after: 3
context_before: 1
verbosity: standard
Run validation commands.
precision_exec:
commands:
- cmd: "npm run typecheck"
- cmd: "npm run lint"
- cmd: "npm test -- --coverage"
verbosity: standard
Use scripts/validate-code-review.sh to validate review completeness.
./scripts/validate-code-review.sh /path/to/review-output.md
The script checks:
Before reviewing:
git diff or GitHub PR)During review:
any, assertions, return typesAfter review:
Critical (must fix before merge):
Major (should fix before merge):
any usage, missing types)Minor (nice to fix, or address in follow-up):
Score inflation:
Vague feedback:
Promise<User> to function getUser"Ignoring positives:
Inconsistent severity:
Review multiple PRs or files in parallel.
discover:
queries:
- id: all_changes
type: grep
pattern: ".*"
path: "src/"
verbosity: files_only
Then read files in batch:
precision_read:
files:
- path: "src/changed-file-1.ts"
- path: "src/changed-file-2.ts"
extract: content
output:
max_per_item: 100
verbosity: standard
Use precision_grep with context to understand surrounding code.
precision_grep:
queries:
- id: auth_checks
pattern: "getServerSession|auth\\(\\)"
output:
format: context
context_before: 5
context_after: 10
verbosity: standard
Focus on changed lines only.
precision_exec:
commands:
- cmd: "git diff HEAD~1..HEAD --unified=5"
verbosity: standard
Parse the diff and review only changed sections.
Create a batch of security/performance checks.
discover:
queries:
# Security
- { id: sql_injection, type: grep, pattern: 'query.*\$\{' }
- { id: xss, type: grep, pattern: 'dangerouslySetInnerHTML' }
- { id: secrets, type: grep, pattern: 'password\s*=\s*["''][^"'']+' }
# Performance
- { id: n_plus_one, type: grep, pattern: 'for.*await.*prisma' }
- { id: inline_objects, type: grep, pattern: 'onClick=\{\{', glob: '**/*.tsx' }
# Quality
- { id: any_usage, type: grep, pattern: ':\s*any', glob: '**/*.ts' }
- { id: empty_catch, type: grep, pattern: 'catch.*\{\s*\}' }
verbosity: locations
Aggregate results and score based on findings.
references/review-patterns.md - Common anti-patterns by categoryscripts/validate-code-review.sh - Automated review validationplugins/goodvibes/skills/protocol/review-scoring/SKILL.md - Scoring rubric detailsWeekly Installs
61
Repository
GitHub Stars
6
First Seen
Feb 16, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykFail
Installed on
opencode60
gemini-cli58
github-copilot58
codex57
cursor57
amp56
Lark Mail CLI 使用指南:邮件管理、安全规则与自动化工作流
40,400 周安装