代码审查
- 作者仓库星标 0
- 作者仓库 skills-registry
- 领域
- 安全
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @tomevault-io · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 即装即用
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- macOS · Linux · Windows
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 网络行为
- 允许外网请求
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
# Code Review
Use this skill when the user asks for a code review, second pass, pre-commit check, PR review, bug-risk review, or closeout review after non-trivial code edits.
This skill is for reviewing code. It may recommend fixes or apply small fixes when requested, but it should not become a broad refactor, redesign, or style-only cleanup pass.
## Contract
- Treat review findings as hypotheses until verified against the real code path.
- Read the changed files, adjacent callers/callees, and relevant tests before judging a finding.
- Check dependency docs, source, or types when behavior depends on an external API or library.
- Prioritize correctness, regressions, security-sensitive behavior, data loss, race conditions, error handling, and test coverage.
- Avoid speculative edge cases, broad rewrites, taste-based style comments, or fixes that over-complicate the codebase.
- Prefer no finding over a weak or speculative finding.
- Prefer small, local fixes at the right ownership boundary.
- Preserve existing project conventions unless they are part of the problem.
- Do not push, commit, or open a PR unless the user explicitly asks.
- Lead final responses with findings, ordered by severity, using concrete file and line references when possible.
## Pick Review Target
Choose the smallest target that matches the user's request.
### Dirty local changes
Use when files are staged, unstaged, or untracked:
```bash
git status --short
git diff --stat
git diff
```
Include staged changes when relevant:
```bash
git diff --cached
```
### Branch or PR changes
Use when reviewing a branch against its base:
```bash
git diff --stat origin/main...HEAD
git diff origin/main...HEAD
```
If a PR exists, use its actual base when available:
```bash
base=$(gh pr view --json baseRefName --jq .baseRefName)
git diff --stat "origin/$base...HEAD"
git diff "origin/$base...HEAD"
```
Fetch remote refs only when needed for an accurate branch/PR review. If network access is unavailable or fetching is inappropriate, use local refs and state that limitation.
### Single commit
Use when reviewing one committed change:
```bash
git show --stat --oneline HEAD
git show HEAD
```
## Workflow
1. Identify the review target, user constraints, and whether fixes are requested.
2. Inspect the diff first, then inspect surrounding code needed to understand each changed path.
3. Map changed behavior to callers, state, errors, permissions, data flow, and tests.
4. Verify each potential issue before reporting it.
5. Check whether existing or missing tests would catch the changed behavior.
6. Reject findings that are intentional, already covered, not reachable, or not worth the added complexity.
7. If making fixes, keep them minimal and rerun the most focused validation.
8. Stop when there are no accepted/actionable findings for the requested target.
## Review Checklist
Focus on the areas that apply to the change:
- Correctness: logic errors, broken invariants, off-by-one issues, bad assumptions, incomplete state updates.
- Regressions: changed public behavior, compatibility breaks, migration risks, missing fallbacks.
- Error handling: swallowed errors, misleading messages, unsafe retries, missing cleanup.
- Security-sensitive behavior: auth/permission checks, input validation, injection paths, secret handling, unsafe file/network access.
- Concurrency and state: races, stale caches, ordering issues, duplicate side effects, reentrancy where relevant.
- Data integrity: serialization, parsing, rounding, units, schema changes, persistence, destructive operations.
- Tests: missing coverage for changed behavior, weak assertions, untested failure paths, brittle snapshots.
- Maintainability: confusing ownership boundaries, unnecessary coupling, duplicated complex logic.
## Validation
Run the narrowest useful checks for the reviewed area. Prefer existing project commands from `package.json`, `Makefile`, CI config, README, or `AGENTS.md`.
Common examples:
```bash
npm test
npm run lint
npm run typecheck
pnpm test
pytest
cargo test
go test ./...
forge test
```
If validation is expensive, unavailable, or unrelated to the change, state what was skipped and why.
## External Review Tools
If the environment provides a dedicated review command, use it as an advisory pass only after understanding the diff yourself.
Examples:
```bash
codex review --uncommitted
codex review --base origin/main
codex review --commit HEAD
```
Do not blindly apply tool findings. Verify each one in the code, accept only actionable findings, and rerun focused validation after any review-triggered fix.
## Output
Final response should start with findings. Use this shape:
- Accepted findings ordered by severity. Include `path:line`, impact, and the smallest useful fix direction.
- If there are no actionable findings, say that directly.
- Review target inspected.
- Fixes made, if any.
- Validation run, or why validation was skipped.
- Remaining risks or assumptions.
Do not lead with a summary before findings. Mention rejected or intentionally ignored findings only when useful to explain judgment.
---
> Source: [Alacriity1/agent-skills](https://github.com/Alacriity1/agent-skills) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-22 -->
章节与文件索引
按说明文件中的顺序排列。
合同
选择审核目标
肮脏的局部变化
分支机构或 PR 变更
单次提交
文件/命令 -> package.json · Makefile · AGENTS.md · path:line
内容校验值 -> ef6d6b8f9b9e
当前原文的自动摘译,尚未人工审校。
合同
将审查结果视为假设,直到根据真实代码路径进行验证。在判断结果之前,请阅读更改的文件、相邻的调用者/被调用者以及相关测试。当行为依赖于外部 API 或库时,检查依赖文档、源或类型。优先考虑正确性、回归、安全敏感行为、数据丢失、竞争条件、错误处理和测试覆盖率。避免推测性的边缘情况、广泛的重写、基于品味的风格注释或使代码库过于复杂的修复。
选择审核目标
选择符合用户请求的最小目标。
肮脏的局部变化
当文件暂存、未暂存或未跟踪时使用:包括相关的暂存更改:
分支机构或 PR 变更
根据其基础审查分支时使用:如果 PR 存在,则在可用时使用其实际基础:仅在需要进行准确的分支/PR 审查时才获取远程引用。如果网络访问不可用或获取不合适,请使用本地引用并说明该限制。
单次提交
在审查一项已提交的更改时使用: