simplify

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Simplify

简化(Simplify)

Reviews all changed files through three parallel agents — reuse, quality, and efficiency — then fixes any issues found.
通过三个并行Agent(可复用性、质量、效率)审查所有变更文件,然后修复发现的所有问题。

Core Principle

核心原则

Changed code is the only review target. Each review dimension runs independently, sees the full diff, and reports findings without knowledge of the other agents' results. The main agent aggregates and applies fixes.
仅以变更代码为审查目标。每个审查维度独立运行,可查看完整diff,且在不知道其他Agent结果的情况下上报发现,主Agent负责聚合结果并执行修复。

Hard Gates

硬性规则

  1. Identify changes before reviewing. Always run
    git diff
    (or
    git diff HEAD
    if there are staged changes) first. Never review without knowing what changed.
  2. All three agents must run in parallel. Sequential execution of the three review agents is prohibited. Dispatch all three concurrently in a single message.
  3. Each agent receives the full diff. Do not split or filter the diff per agent. Every agent sees every change.
  4. Fix issues directly. This skill produces code changes, not just a report. If a finding is actionable, fix it.
  5. Skip false positives silently. If a finding is not worth addressing, move on. Do not argue with the finding or explain why it was skipped.
  6. Do not expand scope beyond the diff. Review only the changed code. Do not refactor untouched code, even if it has the same issues.
  1. 审查前先识别变更:必须先运行
    git diff
    (如果有暂存变更则运行
    git diff HEAD
    ),禁止在不清楚变更内容的情况下开展审查。
  2. 三个Agent必须并行运行:禁止顺序执行三个审查Agent,需在单条消息中同时调度所有三个Agent。
  3. 每个Agent都能获取完整diff:不要为单个Agent拆分或过滤diff,所有Agent都可查看所有变更内容。
  4. 直接修复问题:本功能会生成代码变更,而非仅输出报告。如果发现的问题可执行修复,直接处理。
  5. 静默跳过误报:如果发现的问题不值得处理,直接跳过,不要反驳问题或解释跳过的原因。
  6. 不要超出diff范围扩大 scope:仅审查变更代码,即使未修改的代码存在相同问题,也不要重构未改动代码。

When To Use

适用场景

  • After any implementation work when code quality verification is needed
  • When the user says "simplify", "clean up", "review the changes", or "check the code"
  • After run-plan execution, before review-work, as an intermediate quality pass
  • When the user suspects duplicated logic, inefficiencies, or hacky patterns in recent changes
  • 完成任意开发工作后需要做代码质量验证时
  • 当用户说出"simplify"、"clean up"、"review the changes"或"check the code"时
  • run-plan执行完成后、review-work执行前,作为中间质量检查环节
  • 用户怀疑近期变更存在重复逻辑、低效问题或临时 hack 写法时

When NOT To Use

不适用场景

  • When there are no changes (no diff output)
  • When the user wants a full codebase audit (this skill reviews only the diff)
  • When the user wants only formatting or linting fixes
  • When the goal is plan verification (use
    review-work
    instead)
  • 无代码变更(无diff输出)时
  • 用户需要全代码库审计时(本功能仅审查diff)
  • 用户仅需要格式化或lint修复时
  • 目标为方案验证时(请使用
    review-work

Process

执行流程

Phase 1: Identify Changes

阶段1:识别变更

  1. Run
    git diff
    to see unstaged changes
  2. If no output, run
    git diff HEAD
    to check staged changes
  3. If still no output, check for recently modified files that the user mentioned or that were edited earlier in this conversation
  4. If no changes can be identified, notify the user and stop
Capture the full diff output — this is the input for all three agents.
  1. 运行
    git diff
    查看未暂存变更
  2. 如果无输出,运行
    git diff HEAD
    检查暂存变更
  3. 如果仍然无输出,检查用户提到的、或本次会话中早前编辑过的最近修改文件
  4. 如果无法识别到任何变更,通知用户并终止流程
捕获完整的diff输出,作为三个Agent的输入。

Phase 2: Launch Three Review Agents in Parallel

阶段2:并行启动三个审查Agent

Dispatch all three agents concurrently via the Agent tool in a single message. Each agent receives the full diff and its review prompt below.
What to provide to each agent:
  • The full diff output from Phase 1
  • The agent's review prompt (copied verbatim from the corresponding section below)
What NOT to provide:
  • Other agents' findings (agents run independently)
  • Instructions to fix issues (agents only report findings)
通过Agent工具在单条消息中同时调度所有三个Agent,每个Agent接收完整diff和对应的审查提示词,如下所示。
提供给每个Agent的内容:
  • 阶段1输出的完整diff
  • 对应Agent的审查提示词(直接复制下方对应章节的原文)
禁止提供的内容:
  • 其他Agent的发现(Agent独立运行)
  • 修复问题的指令(Agent仅上报发现)

Agent 1: Code Reuse Review

Agent 1:代码复用审查

Provide this prompt to the agent:
You are reviewing a code diff for reuse opportunities. Your job is to find new code that duplicates functionality already in the codebase.
For each change in the diff:
  1. Search for existing utilities and helpers that could replace newly written code. Search utility directories (
    utils/
    ,
    helpers/
    ,
    lib/
    ,
    common/
    ,
    shared/
    ), files adjacent to the changed ones, and files imported by the changed files.
  2. Flag any new function that duplicates existing functionality. Report the new function, the existing function, and where the existing one lives.
  3. Flag inline logic that could use an existing utility. Common candidates: hand-rolled string manipulation, manual path handling, custom environment checks, ad-hoc type guards, manual array/object transformations, date/time formatting done inline.
  4. Flag reimplemented standard library features. Check if the change reimplements something available in the language's standard library or in already-installed dependencies.
For each finding, report:
  • Reuse opportunity: [brief description]
  • New code: [file:line] — [what was written]
  • Existing: [file:line] — [what already exists]
  • Suggestion: [how to replace]
If no reuse issues are found, report: "No reuse issues found."
向该Agent提供以下提示词:
你正在审查代码diff的可复用机会,你的工作是找出重复了代码库已有功能的新代码。
针对diff中的每个变更:
  1. 搜索可替换新写代码的现有工具函数和辅助方法:检索工具目录(
    utils/
    helpers/
    lib/
    common/
    shared/
    )、变更文件的相邻文件、变更文件导入的文件。
  2. 标记所有重复了已有功能的新函数:上报新函数、对应的已有函数、已有函数的位置。
  3. 标记可使用现有工具函数的内联逻辑:常见场景包括:手写的字符串处理、手动路径处理、自定义环境检查、临时类型守卫、手动数组/对象转换、内联的日期/时间格式化。
  4. 标记重复实现的标准库功能:检查变更是否重复实现了语言标准库或已安装依赖中已有的能力。
针对每个发现上报:
  • 可复用机会: [简要描述]
  • 新代码:[文件:行号] — [编写的内容]
  • 已有实现:[文件:行号] — [已存在的内容]
  • 建议:[替换方案]
如果未发现可复用问题,上报:"No reuse issues found."

Agent 2: Code Quality Review

Agent 2:代码质量审查

Provide this prompt to the agent:
You are reviewing a code diff for quality issues. Your job is to find hacky patterns, unnecessary complexity, and abstraction boundary violations.
Check for these patterns:
  1. Redundant state: new variables that are always derived from another variable, caches that store what could be computed on access, event listeners or observers that could be direct function calls.
  2. Parameter sprawl: functions that gained a new boolean flag parameter, functions with more than 4 parameters after the change, multiple parameters that are always passed together and should be a single object.
  3. Copy-paste with slight variation: two or more blocks that differ by only 1-2 lines, repeated conditional structures with different field names, similar error handling blocks across multiple locations.
  4. Leaky abstractions: accessing private fields or internal state from outside the module, passing implementation details across module boundaries, changes that make one module depend on another's internal structure.
  5. Stringly-typed code: new string comparisons against values already defined as constants, new string literals matching existing enum or union type values, magic strings appearing in multiple places without a shared constant.
  6. Unnecessary comments: comments explaining WHAT the code does, narrating the change, or referencing a task. Delete these. Keep only comments that explain non-obvious WHY — hidden constraints, subtle invariants, workarounds. Example to delete:
    // increment counter
    above
    counter++
    . Example to keep:
    // Redis returns nil for both "key missing" and "value is empty" — we must distinguish
    .
For each finding, report:
  • Quality issue: [category]
  • Location: [file:line]
  • Problem: [what is wrong]
  • Suggestion: [how to fix]
If no quality issues are found, report: "No quality issues found."
向该Agent提供以下提示词:
你正在审查代码diff的质量问题,你的工作是找出hack写法、不必要的复杂度、抽象边界违反问题。
检查以下模式:
  1. 冗余状态:始终从其他变量派生的新变量、存储了可实时计算内容的缓存、可替换为直接函数调用的事件监听器或观察者。
  2. 参数膨胀:新增了布尔标记参数的函数、变更后参数超过4个的函数、多个总是一起传递应该合并为单个对象的参数。
  3. 微小差异的复制粘贴:仅1-2行不同的两个及以上代码块、字段名不同但结构重复的条件分支、多个位置的相似错误处理块。
  4. 泄露的抽象:从模块外部访问私有字段或内部状态、跨模块边界传递实现细节、让一个模块依赖另一个模块内部结构的变更。
  5. 字符串类型滥用:与已定义为常量的值做新的字符串对比、匹配现有enum或联合类型值的新字符串字面量、没有共享常量的多位置魔法字符串。
  6. 不必要的注释:解释代码做了什么的注释、描述变更的注释、关联任务的注释,直接删除这类注释。仅保留解释非显而易见原因的注释——隐藏的约束、微妙的不变量、临时 workaround。需要删除的示例:
    counter++
    上方的
    // increment counter
    ;需要保留的示例:
    // Redis对"key不存在"和"值为空"都返回nil,我们必须区分
针对每个发现上报:
  • 质量问题: [分类]
  • 位置:[文件:行号]
  • 问题:[问题描述]
  • 建议:[修复方案]
如果未发现质量问题,上报:"No quality issues found."

Agent 3: Efficiency Review

Agent 3:代码效率审查

Provide this prompt to the agent:
You are reviewing a code diff for efficiency issues. Your job is to find unnecessary work, missed concurrency, and resource management problems. Do not optimize prematurely — flag only what is clearly unnecessary or clearly mismanaged.
Check for these patterns:
  1. Unnecessary work: the same value computed multiple times in a loop, the same file read more than once, the same API call made repeatedly when the result could be cached or batched, database queries inside loops that could be a single query with WHERE IN.
  2. Missed concurrency: multiple
    await
    calls in sequence where the operations are independent, sequential file reads that could be parallelized, independent API calls executed one after another.
  3. Hot-path bloat: synchronous file I/O added to a request handler, new computation in a render function that could be memoized, new initialization logic added to module load time.
  4. Recurring no-op updates: state setters called on every interval tick without checking if the value changed, store dispatches firing on every event without a change-detection guard, wrapper functions that take updater callbacks but do not honor "no change" returns — add a change-detection guard so downstream consumers are not notified when nothing changed.
  5. Unnecessary existence checks (TOCTOU):
    if (existsSync(path)) { readFileSync(path) }
    — operate directly and handle the error instead.
  6. Memory issues: collections that grow without bound, event listeners registered without corresponding removal, subscriptions without cleanup in dispose/destroy handlers, large objects held in closure scope longer than needed.
  7. Overly broad operations: reading entire files to extract a single value, fetching all records to find one by ID, loading an entire config when only one field is needed.
For each finding, report:
  • Efficiency issue: [category]
  • Location: [file:line]
  • Problem: [what is wasteful]
  • Suggestion: [how to fix]
If no efficiency issues are found, report: "No efficiency issues found."
向该Agent提供以下提示词:
你正在审查代码diff的效率问题,你的工作是找出不必要的工作、可并行的遗漏、资源管理问题。不要做过早优化——仅标记明显不必要或明显管理不当的问题。
检查以下模式:
  1. 不必要的工作:循环中多次计算同一个值、重复读取同一个文件、可缓存或批量处理的重复API调用、可替换为单个WHERE IN查询的循环内数据库查询。
  2. 可并行的遗漏:多个独立操作的顺序
    await
    调用、可并行的顺序文件读取、逐个执行的独立API调用。
  3. 热路径冗余:请求处理器中新增的同步文件IO、可做memoized的渲染函数内新增计算、模块加载时新增的初始化逻辑。
  4. 重复无意义更新:未检查值是否变化就在每个时间间隔调用状态setter、没有变更检测守卫的每个事件都触发的store dispatch、接收更新回调但不处理"无变更"返回的包装函数——新增变更检测守卫,避免无变更时通知下游消费者。
  5. 不必要的存在性检查(TOCTOU)
    if (existsSync(path)) { readFileSync(path) }
    ——直接操作并处理错误即可。
  6. 内存问题:无限制增长的集合、没有对应移除逻辑的事件监听器、dispose/destroy处理函数中没有清理的订阅、闭包中持有时间过长的大对象。
  7. 范围过大的操作:读取整个文件仅提取单个值、拉取所有记录仅按ID查找单个记录、仅需要单个字段却加载整个配置。
针对每个发现上报:
  • 效率问题: [分类]
  • 位置:[文件:行号]
  • 问题:[浪费资源的描述]
  • 建议:[修复方案]
如果未发现效率问题,上报:"No efficiency issues found."

Phase 3: Fix Issues

阶段3:修复问题

  1. Wait for all three agents to complete
  2. Aggregate findings from all three agents
  3. Deduplicate overlapping findings (different agents may flag the same code)
  4. For each actionable finding:
    • Apply the minimal fix that addresses the finding
    • Do not bundle unrelated improvements into the same change
    • Do not expand the fix beyond what was flagged
  5. For each false positive: skip silently
  6. Run the test suite to verify no regressions were introduced
  7. If tests fail after a fix: revert that fix, report it as a finding that needs manual attention
  8. Briefly summarize what was fixed (or confirm the code was already clean)
  1. 等待所有三个Agent执行完成
  2. 聚合三个Agent的所有发现
  3. 去重重叠的发现(不同Agent可能标记同一段代码)
  4. 针对每个可处理的发现:
    • 应用能解决问题的最小修复
    • 不要把不相关的优化合并到同一个变更中
    • 不要将修复范围扩大到标记内容之外
  5. 针对每个误报:静默跳过
  6. 运行测试套件验证没有引入回归
  7. 如果修复后测试失败:回滚该修复,将其标记为需要人工处理的问题上报
  8. 简要总结修复内容(或确认代码已经符合规范)

When To Stop

终止条件

  • No changes detected in Phase 1 — notify user and stop
  • All three agents report no findings — confirm code is clean
  • Fixes introduce test failures that cannot be resolved without expanding scope — stop, report the regression, suggest
    systematic-debugging
  • 阶段1未检测到变更——通知用户并终止
  • 三个Agent都上报无发现——确认代码符合规范
  • 修复引入了无法在不扩大scope的情况下解决的测试失败——终止,上报回归,建议使用
    systematic-debugging

Anti-Patterns

反模式

Anti-PatternWhy It Fails
Reviewing without running git diff firstReviews code that may not have changed, wastes time on irrelevant findings
Running agents sequentiallyUnnecessary delay; violates Hard Gate #2
Giving each agent only part of the diffAgent misses cross-cutting issues that span multiple files
Reporting findings without fixing themDefeats the purpose of the skill; user must do manual work
Arguing with or explaining skipped findingsWastes context and time; skip and move on
Reviewing unchanged code "while we're here"Scope creep; violates Hard Gate #6
Fixing issues without running tests afterwardMay introduce regressions silently
Bundling "while I'm here" improvements into fixesMixes review fixes with unrelated changes; muddles the diff
反模式问题原因
没有先运行git diff就开始审查可能审查了未变更的代码,浪费时间处理无关发现
顺序运行Agent不必要的延迟,违反硬性规则#2
仅给每个Agent提供部分diffAgent会错过跨多个文件的交叉问题
仅上报问题不修复违背本功能的设计目标,用户需要手动处理
反驳或解释跳过的发现浪费上下文和时间,直接跳过即可
"顺手"审查未变更的代码范围蔓延,违反硬性规则#6
修复后不运行测试可能静默引入回归
修复中合并"顺手"的优化混合审查修复和不相关变更,让diff含义模糊

Minimal Checklist

最简检查清单

  • Ran git diff to identify changes
  • Dispatched all three agents in parallel (single message)
  • Each agent received the full diff
  • Aggregated findings from all three agents
  • Applied fixes for actionable findings
  • Skipped false positives without argument
  • Ran tests after fixes — no regressions
  • Summarized results to the user
  • 运行了git diff识别变更
  • (单条消息)并行调度了所有三个Agent
  • 每个Agent都获取了完整diff
  • 聚合了所有三个Agent的发现
  • 为可处理的发现应用了修复
  • 无异议地跳过了误报
  • 修复后运行了测试——无回归
  • 向用户总结了结果

Transition

流程流转

After simplification is complete:
  • If this was a post-implementation quality pass → suggest transitioning to
    review-work
    for independent plan verification
  • If issues were found and fixed → user may want to run
    simplify
    again to verify the fixes are clean
  • If a bug was discovered during review → suggest
    systematic-debugging
This skill itself does not invoke the next skill. It reports results and lets the user decide the next step.
简化完成后:
  • 如果是开发后的质量检查环节→建议流转到
    review-work
    做独立方案验证
  • 如果发现并修复了问题→用户可能需要再次运行
    simplify
    验证修复后的代码符合规范
  • 如果审查过程中发现了bug→建议使用
    systematic-debugging
本功能本身不会调用下一个功能,它仅上报结果,由用户决定下一步操作。