code-review-and-quality
它能做什么
这个工具会审查你的代码,检查它是否正确、是否容易理解、结构是否合理、是否安全、运行是否够快。它能帮你在代码合并到主项目之前发现问题。
适用场景
- ✓在把代码改动加入项目之前。
- ✓当你想检查自己或别人写的代码质量时。
- ✓修复完 bug 或新增功能之后。
技能链接
https://github.com/addyosmani/agent-skills/blob/main/skills/code-review-and-quality/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请审查这段代码,确保它正确、易读、安全,并且性能良好。”
每周 5 个新技能,1 分钟读完。
工作原理
工具会从五个方面分析代码:它是否实现了预期功能(正确性)、是否容易阅读(可读性)、是否符合项目结构(架构)、是否能防范攻击(安全性),以及是否运行够快(性能)。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Code Review and Quality
Overview
Multi-dimensional code review with quality gates. Every change gets reviewed before merge — no exceptions. Review covers five axes: correctness, readability, architecture, security, and performance.
The approval standard: Approve a change when it definitely improves overall code health, even if it isn't perfect. Perfect code doesn't exist — the goal is continuous improvement. Don't block a change because it isn't exactly how you would have written it. If it improves the codebase and follows the project's conventions, approve it.
When to Use
- Before merging any PR or change
- After completing a feature implementation
- When another agent or model produced code you need to evaluate
- When refactoring existing code
- After any bug fix (review both the fix and the regression test)
The Five-Axis Review
Every review evaluates code across these dimensions:
1. Correctness
Does the code do what it claims to do?
- Does it match the spec or task requirements?
- Are edge cases handled (null, empty, boundary values)?
- Are error paths handled (not just the happy path)?
- Does it pass all tests? Are the tests actually testing the right things?
- Are there off-by-one errors, race conditions, or state inconsistencies?
2. Readability & Simplicity
Can another engineer (or agent) understand this code without the author explaining it?
- Are names descriptive and consistent with project conventions? (No
temp,data,resultwithout context) - Is the control flow straightforward (avoid nested ternaries, deep callbacks)?
- Is the code organized logically (related code grouped, clear module boundaries)?
- Are there any "clever" tricks that should be simplified?
- Could this be done in fewer lines? (1000 lines where 100 suffice is a failure)
- Are abstractions earning their complexity? (Don't generalize until the third use case)
- Would comments help clarify non-obvious intent? (But don't comment obvious code.)
- Are there dead code artifacts: no-op variables (
_unused), backwards-compat shims, or// removedcomments? - Is a new conditional bolted onto an unrelated flow? That's a design smell, not a nit — push the logic into its own helper, state, or policy instead of tangling an existing path.
- Do repeated conditionals on the same shape appear? They signal a missing model or dispatcher. A "temporary" branch is usually permanent debt.
3. Architecture
Does the change fit the system's design?
- Does it follow existing patterns or introduce a new one? If new, is it justified?
- Does it maintain clean module boundaries?
- Is there code duplication that should be shared?
- Are dependencies flowing in the right direction (no circular dependencies)?
- Is the abstraction level appropriate (not over-engineered, not too coupled)?
- Does this refactor reduce complexity or just relocate it? Count the concepts a reader must hold to follow the change. If a "cleaner" version leaves that count unchanged, it isn't cleaner — prefer the restructuring that makes whole branches, modes, or layers disappear over one that re-centralizes the same logic. Prefer deleting an abstraction to polishing it.
- Is feature-specific logic leaking into a shared or general-purpose module? Keep logic in its owning layer, reuse the existing canonical helper instead of a near-duplicate, and don't normalize architectural drift.
- Are type boundaries explicit? Question gratuitous
any/unknown/optional/casts and silent fallbacks that paper over an unclear invariant — making the boundary explicit often makes the surrounding control flow simpler.
4. Security
For detailed security guidance, see security-and-hardening. Does the change introduce vulnerabilities?
- Is user input validated and sanitized?
- Are secrets kept out of code, logs, and version control?
- Is authentication/authorization checked where needed?
- Are SQL queries parameterized (no string concatenation)?
- Are outputs encoded to prevent XSS?
- Are dependencies from trusted sources with no known vulnerabilities?
- Is data from external sources (APIs, logs, user content, config files) treated as untrusted?
- Are external data flows validated at system boundaries before use in logic or rendering?
5. Performance
For detailed profiling and optimization, see performance-optimization. Does the change introduce performance problems?
- Any N+1 query patterns?
…
常见问题
“多维度审查”是什么意思?
意思是代码会从几个重要方面来评估,比如正确性、清晰度、安全性和性能,而不是只看其中一个方面。
代码需要完美无缺吗?
不需要。目标是持续改进。即使代码并不完美,或者不是你会用的写法,只要它整体质量有所提升就行。
如果审查发现了问题,我该怎么办?
工具会给出修复建议,比如简化代码、拆分复杂的部分,或者确保安全性不受影响。
详情
作者的原始描述
Conducts multi-axis code review. Use before merging any change. Use when reviewing code written by yourself, another agent, or a human. Use when you need to assess code quality across multiple dimensions before it enters the main branch. Use when asked to review a diff or a pull request, even when the diff is pasted inline.
repo: addyosmani/agent-skills
热度
- GitHub 星标
- 107k
- 排名
- #764
- 许可证
- MIT
- 更新时间
- 2026/10/13
评论
- …
同一仓库的更多技能
api-and-interface-design
107k帮助设计定义清晰的 API 和接口。适用于规划软件不同部分之间的通信方式。
browser-testing-with-devtools
107k帮助你的智能体直接在真实浏览器中测试代码。适用于检查功能在实际使用环境中的表现,并发现错误和性能问题。
ci-cd-and-automation
107k教你的 AI 智能体自动化重复性任务、发布项目并管理基础设施。
code-simplification
107k简化代码,使其更易理解和维护。适用于代码能运行但过于复杂的情况,帮助提升清晰度。