antfu-simplify
它能做什么
这项技能让 AI 审阅你当前的代码改动,并删除其中任何不需要的内容。适合希望得到更小、更干净、且仍能正常工作的改动的开发者。
适用场景
- ✓当你的拉取请求比实际需要的更大时。
- ✓当你想在不改变行为的前提下,从改动中删除多余代码的时候。
- ✓当你在请求审阅之前,想让你的工作更加简洁时。
技能链接
https://github.com/antfu/skills/blob/main/skills/antfu-simplify/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请在不改变代码行为的前提下,精简我当前分支上的改动。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体每次删除改动中的一部分,运行项目的测试和检查,只保留需要的部分。行为保持不变。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Simplify Changes
Review the current changes (PR branch or working tree) and cut them down to the smallest correct diff, the way a skilled developer would. The method is an ablation study: remove each piece, check whether anything that matters breaks, and keep only what earns its place.
Goal: clean, minimal code with the just-right abstraction, that is also robust (handles real edge cases) and universal (solves the general case, not only the one that triggered the change).
Hard Rules
- Behavior stays the same. Simplify only. Do not add features, change public APIs, or fix unrelated issues. Report unrelated findings instead.
- Scope is the diff. Only touch code the change introduced or modified, plus code that must change to remove it. Do not refactor the surrounding codebase.
- Every removal is verified. Run the repo's tests, typecheck, and lint after each batch. If a check has no coverage for the removed piece, reason about it explicitly or keep it.
- Match the surrounding code's style, naming, and comment density.
Workflow
- Get the diff. Pick the base: PR target branch merge base (
git merge-base HEAD origin/<default>), elsegit diff HEADfor uncommitted work. Read the full diff and the files around it. Note the goal of the change in one sentence; it is the yardstick for everything below. - Inventory the pieces. List each unit the diff adds: function, parameter, option, branch, type, file, dependency, abstraction layer, comment, test. See Ablation Study.
- Ablate. For each piece, try removing, inlining, or merging it. Decide keep or cut using Keep vs Cut.
- Apply the cuts in small steps. After each batch run focused checks (tests, typecheck, lint). Revert a cut that breaks behavior; that piece is now proven needed.
- Check the result. Re-read the final diff as a reviewer. Is each remaining line explained by the one-sentence goal? Is it still robust and general?
- Report. Show a short table of what was cut or kept and why, plus the diff size before and after (
git diff --stat). Do not commit unless asked.
Ablation Study
For every piece in the diff, ask: if I delete this, what concretely breaks?
| Piece | Ablation | Keep if |
|---|---|---|
| New function / helper | Inline it at the call site | Called from 2+ places, or the name explains a non-obvious step |
| Wrapper / abstraction layer | Call the underlying thing directly | It hides real complexity or a likely-to-change boundary |
| Parameter / option / config | Hardcode the only used value | A real caller needs a different value now |
| Type / interface / generic | Use the inferred or existing type | It is exported, or inference gives a worse or wrong type |
| Branch / guard / try-catch | Delete it and run tests | It guards a reachable case (real input, real failure), not an impossible one |
| New file / module | Merge it into its only consumer | It has multiple consumers or a distinct responsibility |
| Dependency | Replace with a few lines or an existing dep | It handles hard edge cases you would otherwise get wrong |
| Duplicate logic | Reuse an existing util in the repo | No equivalent exists (search first) |
| Comment | Delete it | It explains why (constraint, workaround, surprising choice), not what |
| Test | Remove it and see what is unprotected | It covers behavior or a regression nothing else covers |
| Changed lines unrelated to the goal | Revert them | Never keep drive-by edits |
Keep vs Cut
Cut when the piece is:
- Speculative: built for a future need nobody has (extra options, hooks, plugin points, "just in case" generics).
- Redundant: repeats what the language, framework, types, or an existing util already provides.
- Defensive against the impossible: null checks on values the types or callers guarantee, fallbacks that never run, catch blocks that swallow errors.
- Indirection without payoff: one-use helpers, pass-through wrappers, classes where a function works, factories that build one thing.
- Noise: commented-out code, narrating comments, unused imports and exports, formatting-only churn.
Keep (or even add) when the piece is:
- Robustness: handles real edge cases (empty input, concurrency, cleanup, cross-platform paths, error propagation with context).
- Universality: solves the general problem instead of special-casing the reported one. If the fix hardcodes a name, path, or value from th
常见问题
它会添加新功能吗?
不会。它只精简现有改动,并报告无关的问题,而不去修复它们。
它会改动我的改动之外的代码吗?
不会。它只处理你的改动新增或修改的代码。
它怎样确认没有出问题?
每批删除之后,它都会运行代码仓库的测试、类型检查和 lint。
详情
作者的原始描述
Simplify the changes of the current PR or working tree with an ablation study - remove each piece of the diff and keep only what is proven needed - so the result has just-right abstraction, minimal clean code, and stays robust and universal. Use when asked to simplify, slim down, clean up, or reduce the current changes or PR.
repo: antfu/skills
热度
- GitHub 星标
- 6.0k
- 排名
- #14438
- 许可证
- MIT
- 更新时间
- 2026/10/30
评论
- …
同一仓库的更多技能
antfu-create-pr
6.0k帮你的智能体从你的分支开一个清晰的 GitHub 拉取请求,用通俗的摘要说明改了什么以及为什么改。
antfu-issue-triage
6.0k帮你的智能体梳理 GitHub 上未关闭的议题和拉取请求,找出重复和已修复的项目,并在行动前征求你的同意。
antfu-query
6.0k帮你的智能体逐步向你提问,关于一个计划或想法,直到你们对它有清晰、经过检验的共同理解。
antfu
6.0k教你的智能体掌握 Anthony Fu 偏好的 JavaScript 和 TypeScript 项目习惯,从文件布局到工具选择。