fresh-eyes

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Fresh Eyes Review

全新视角代码复审

Re-read all code you just wrote or modified with a fresh perspective. Look for obvious bugs, errors, problems, and confusion that are easy to miss when deep in implementation.
以全新视角重读你刚编写或修改的所有代码。找出在深入开发过程中容易忽略的明显漏洞、错误、问题和易混淆点。

When to Use

适用场景

  • After completing a feature or fix
  • Before committing changes
  • When you feel like something might be off
  • After a long coding session
  • 完成功能开发或漏洞修复后
  • 提交代码变更前
  • 感觉代码存在异常时
  • 长时间编码后

Process

操作流程

1. Identify Changed Code

1. 确定变更代码

Find all files you modified in this session. If unclear, ask the user or check recent git changes:
bash
git diff --name-only HEAD~1
git diff --name-only --cached
找出本次编码会话中你修改的所有文件。若不确定,可询问用户或查看近期Git变更:
bash
git diff --name-only HEAD~1
git diff --name-only --cached

2. Re-read with Fresh Eyes

2. 以全新视角重读代码

Read each modified file completely. Pretend you've never seen this code before. Look for:
Logic errors
  • Off-by-one errors
  • Inverted conditions
  • Missing null/undefined checks
  • Race conditions
  • Incorrect comparisons (== vs ===, > vs >=)
Obvious bugs
  • Typos in variable names
  • Copy-paste errors
  • Forgotten return statements
  • Unused variables that should be used
  • Wrong function called
Missing pieces
  • Error handling gaps
  • Edge cases not covered
  • Cleanup code missing (close connections, clear timeouts)
  • Validation missing at boundaries
Confusion risks
  • Misleading variable names
  • Complex logic without comments
  • Inconsistent patterns within the file
  • Magic numbers without explanation
完整阅读每个修改过的文件,假装你从未见过这段代码。重点检查以下内容:
逻辑错误
  • 差一错误
  • 条件判断颠倒
  • 缺失null/undefined检查
  • 竞态条件
  • 错误的比较操作(==与===混淆、>与>=误用)
明显漏洞
  • 变量名拼写错误
  • 复制粘贴错误
  • 遗漏return语句
  • 应使用却未使用的变量
  • 调用错误的函数
缺失内容
  • 错误处理缺失
  • 未覆盖边界场景
  • 缺失清理代码(如关闭连接、清除定时器)
  • 边界处缺失校验
易混淆风险
  • 变量名具有误导性
  • 复杂逻辑未添加注释
  • 文件内代码模式不一致
  • 未注释的魔术数字

3. Fix Issues

3. 修复问题

For each issue found:
  1. Explain what's wrong in 1 sentence
  2. Fix it immediately
  3. Move to the next issue
Don't ask for permission. Just fix obvious problems.
针对每个发现的问题:
  1. 用一句话说明问题所在
  2. 立即修复问题
  3. 处理下一个问题
无需请求许可,直接修复明显问题。

4. Report Summary

4. 提交复查总结

After fixing, provide a brief summary:
undefined
修复完成后,提供简短总结:
undefined

Fresh Eyes Review

Fresh Eyes Review

Fixed 3 issues:
  • api/users.ts:47
    — Missing null check on user.profile
  • api/users.ts:82
    — Off-by-one in pagination (used > instead of >=)
  • utils/format.ts:15
    — Typo:
    formattedDte
    formattedDate
No other issues found.

If nothing found:
Fixed 3 issues:
  • api/users.ts:47
    — Missing null check on user.profile
  • api/users.ts:82
    — Off-by-one in pagination (used > instead of >=)
  • utils/format.ts:15
    — Typo:
    formattedDte
    formattedDate
No other issues found.

若未发现问题:

Fresh Eyes Review

Fresh Eyes Review

Reviewed 4 files. No issues found.
undefined
Reviewed 4 files. No issues found.
undefined

What NOT to Do

禁止操作

  • Don't refactor working code
  • Don't add features
  • Don't change style preferences
  • Don't optimize prematurely
  • Don't add comments to obvious code
  • Don't reorganize file structure
Focus only on bugs, errors, and problems. If it works and isn't broken, leave it alone.
  • 不要重构可正常运行的代码
  • 不要新增功能
  • 不要修改代码风格偏好
  • 不要过早进行优化
  • 不要给明显易懂的代码添加注释
  • 不要调整文件结构
仅聚焦于漏洞、错误和问题。若代码可正常运行且无问题,请勿改动。

Checklist

检查清单

Run through mentally for each file:
  • All variables initialized before use?
  • All functions return what they should?
  • All loops terminate correctly?
  • All conditions handle both branches?
  • All async operations awaited?
  • All errors caught or propagated?
  • All resources cleaned up?
  • All edge cases handled (empty, null, zero, negative)?
针对每个文件,在脑海中过一遍以下检查项:
  • 所有变量是否在使用前已初始化?
  • 所有函数是否返回预期结果?
  • 所有循环是否能正确终止?
  • 所有条件判断是否覆盖分支场景?
  • 所有异步操作是否已添加await?
  • 所有错误是否已捕获或向上抛出?
  • 所有资源是否已清理?
  • 所有边界场景是否已处理(空值、null、零、负数)?