simplify
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSimplify
代码简化
Overview
概述
Use this as a pre-review cleanup gate. The goal is not formal approval; it is to inspect changed code for reuse opportunities, code quality issues, and efficiency issues, then fix the worthwhile findings without changing behavior.
将此作为预审查清理环节使用。目标并非正式审批,而是检查变更代码中的复用机会、代码质量问题和效率问题,然后在不改变代码行为的前提下修复有价值的问题。
When to Use
适用场景
- The user wants a -style cleanup pass before
/simplifyorreviewercode-reviewer - A feature is complete and the diff likely contains duplication, rough edges, or avoidable inefficiency
- You want to reduce avoidable reviewer comments before formal review
- The change spans enough files or logic that one simplification pass is not enough
Do not use this skill for:
- Tiny diffs where a single local cleanup is enough
- Behavior changes, feature work, or bug fixes that alter requirements
- Large architectural redesigns across untouched modules
- Formal spec validation or security review
- 用户希望在使用或
reviewer技能前,进行一次类似code-reviewer风格的清理/simplify - 功能开发完成,代码差异中可能存在重复代码、粗糙实现或可避免的低效问题
- 希望在正式审查前减少可避免的评审意见
- 变更涉及足够多的文件或逻辑,单次简化处理不足以完成
请勿将此技能用于:
- 微小代码差异,单次本地清理即可完成的情况
- 改变代码行为、功能开发或修改需求的 bug 修复
- 涉及未改动模块的大型架构重设计
- 正式规范验证或安全审查
Place in Review Flow
在审查流程中的位置
Recommended placement:
text
implement -> simplify -> code-reviewer and/or reviewer -> receiving-code-reviewSkip the full three-agent pass when:
- the change is tiny and obvious
- only one or two trivial lines changed
- the user wants immediate formal review instead of cleanup
推荐流程:
text
implement -> simplify -> code-reviewer and/or reviewer -> receiving-code-review在以下情况可跳过完整的三Agent流程:
- 变更微小且明显
- 仅修改了一两行无关紧要的代码
- 用户希望直接进行正式审查而非清理
Workflow
工作流程
Phase 1: Identify Changes
阶段1:识别变更内容
- If the user gives a base/head range, use that
- If staged changes exist, inspect so both staged and unstaged changes are included
git diff HEAD - Otherwise use
git diff - If there is no git diff, review the most recently modified files the user mentioned or that you edited earlier in the session
- Keep a compact summary of touched files plus the full diff text for the reviewers
- 如果用户提供了基准/目标版本范围,使用该范围
- 如果存在暂存变更,检查,包含暂存和未暂存的变更
git diff HEAD - 否则使用
git diff - 如果没有git差异,审查用户提及的或会话中之前编辑过的最近修改的文件
- 保留一份简洁的受影响文件摘要以及完整的差异文本供评审人员使用
Phase 2: Read Local Standards
阶段2:查阅本地规范
- Check local instructions first such as , repo conventions, and any relevant skills
AGENTS.md - Follow existing naming, formatting, and structure in the touched files
- If local conventions conflict with generic cleanup preferences, local conventions win
- 首先查看本地说明,如、仓库约定和任何相关技能文档
AGENTS.md - 遵循受影响文件中已有的命名、格式和结构规范
- 如果本地约定与通用清理偏好冲突,以本地约定为准
Phase 3: Launch Three Review Agents in Parallel
阶段3:并行启动三个评审Agent
For medium or large diffs, spawn three read-only subagents in parallel in a single round. Use agents when possible because this is codebase analysis, not implementation.
explorerEach agent must receive:
- the full diff
- the touched file list
- the cleanup constraint: no behavior changes, no edits, findings only
The three review domains are:
- Code reuse review
- Code quality review
- Efficiency review
Use the prompt templates in:
- references/reuse-reviewer.md
- references/quality-reviewer.md
- references/efficiency-reviewer.md
Important:
- Review agents are read-only; they do not edit files
- The main agent aggregates findings and performs the fixes
- Do not spawn multiple worker agents to edit the same touched files in parallel
对于中等或大型代码差异,在一轮中并行生成三个只读子Agent。尽可能使用 Agent,因为这是代码库分析而非实现工作。
explorer每个Agent必须接收:
- 完整的代码差异
- 受影响文件列表
- 清理约束:不改变代码行为,不编辑文件,仅输出检查结果
三个评审领域分别是:
- 代码复用评审
- 代码质量评审
- 效率评审
使用以下参考中的提示模板:
- references/reuse-reviewer.md
- references/quality-reviewer.md
- references/efficiency-reviewer.md
重要提示:
- 评审Agent为只读,不编辑文件
- 主Agent汇总检查结果并执行修复
- 不要生成多个工作Agent并行编辑同一受影响文件
Phase 4: Fix the Worthwhile Issues
阶段4:修复有价值的问题
- Wait for all reviewers to finish
- Aggregate findings and remove duplicates
- Fix issues directly if they improve the code without changing behavior
- If a finding is a false positive or not worth the churn, note that and skip it without arguing at length
- 等待所有评审Agent完成检查
- 汇总检查结果并去除重复项
- 直接修复那些能改进代码且不改变行为的问题
- 如果检查结果为误报或不值得修改,记录并跳过,无需过多争论
Phase 5: Verify
阶段5:验证
- Run the narrowest meaningful verification for the changed area
- Prefer targeted tests first, then lint/build if appropriate
- If no automated verification exists, state that explicitly and mention residual risk
- Briefly summarize what was fixed, or state that the code was already clean enough
- 对变更区域运行最具针对性的有意义验证
- 优先使用针对性测试,必要时再进行代码检查/构建
- 如果没有自动化验证机制,明确说明并提及剩余风险
- 简要总结已修复的内容,或说明代码已足够整洁
Quick Reference
快速参考
| Goal | Prefer | Avoid |
|---|---|---|
| Readability | Clear names, explicit branches, small coherent helpers | Dense one-liners, clever tricks |
| Scope control | Touched files, recent diff, user-specified paths | Repo-wide cleanup without request |
| Safety | Targeted verification after edits | Assuming refactor is safe |
| Comments | Intent and constraints | Narrating obvious code |
| Agent usage | Three parallel read-only reviewers, one controller applying fixes | Multiple editing agents touching the same files |
| 目标 | 推荐做法 | 避免做法 |
|---|---|---|
| 可读性 | 清晰的命名、明确的分支、小巧连贯的辅助函数 | 密集的单行代码、花哨的技巧 |
| 范围控制 | 受影响文件、近期差异、用户指定路径 | 未经请求的全仓库范围清理 |
| 安全性 | 编辑后进行针对性验证 | 假设重构是安全的 |
| 注释 | 说明意图和约束 | 对明显代码进行赘述 |
| Agent使用 | 三个并行只读评审Agent,一个控制Agent执行修复 | 多个编辑Agent修改同一文件 |
Common Mistakes
常见错误
- Turning simplification into redesign
- Extracting abstractions too early
- Renaming broadly across unrelated files
- Optimizing for fewer lines instead of easier maintenance
- Skipping verification because the change "looks mechanical"
- Letting all three agents edit code instead of only reporting findings
- Using this skill as a substitute for formal review or spec validation
- 将简化变成重设计
- 过早提取抽象
- 在无关文件中广泛重命名
- 为减少代码行数而非便于维护进行优化
- 因变更“看起来是机械性的”而跳过验证
- 让三个Agent都编辑代码而非仅报告检查结果
- 将此技能作为正式审查或规范验证的替代品
Upstream Reference
上游参考
This Codex skill adapts the flow used in Claude-based workflows into a Codex-native skill. See references/upstream-agent.md for the source notes and adaptation details.
/simplify此Codex技能将基于Claude的工作流中使用的流程适配为Codex原生技能。有关源说明和适配细节,请参阅references/upstream-agent.md
/simplify