antfu-simplify
Skill này làm gì
Skill này để AI rà soát các thay đổi code hiện tại của bạn và bỏ mọi phần không cần thiết. Skill dành cho lập trình viên muốn một thay đổi nhỏ gọn hơn, sạch hơn nhưng vẫn hoạt động.
Khi nào nên dùng
- ✓Khi pull request của bạn lớn hơn mức cần thiết.
- ✓Khi bạn muốn bỏ code thừa khỏi một thay đổi mà không làm thay đổi cách nó hoạt động.
- ✓Khi bạn muốn một phiên bản gọn hơn của công việc trước khi xin review.
Liên kết skill
https://github.com/antfu/skills/blob/main/skills/antfu-simplify/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Rút gọn các thay đổi trên nhánh hiện tại của tôi mà không làm thay đổi những gì code làm.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent bỏ từng phần của thay đổi một lần, chạy các bài kiểm thử và kiểm tra của dự án, và chỉ giữ những phần cần thiết. Hành vi được giữ nguyên.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Skill có thêm tính năng mới không?
Không. Skill chỉ rút gọn các thay đổi hiện có và báo cáo các vấn đề không liên quan thay vì sửa chúng.
Skill có thay đổi code ngoài phần thay đổi của tôi không?
Không. Skill chỉ làm việc trên code mà thay đổi của bạn đã thêm hoặc sửa.
Làm sao skill kiểm tra là không có gì bị hỏng?
Skill chạy các bài kiểm thử, kiểm tra kiểu dữ liệu và lint của repository sau mỗi đợt bỏ bớt.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 6.0k
- Vị trí xếp hạng
- #14438
- Giấy phép
- MIT
- Cập nhật
- 30/10/2026
Bình luận
- …
Thêm skill từ kho mã này
antfu-create-pr
6.0kGiúp agent của bạn mở một pull request GitHub rõ ràng từ nhánh của bạn, với bản tóm tắt đơn giản về những gì đã thay đổi và lý do.
antfu-issue-triage
6.0kGiúp agent của bạn rà soát các issue và pull request GitHub đang mở, phát hiện trùng lặp và mục đã sửa, rồi hỏi bạn trước khi hành động.
antfu-query
6.0kCho phép agent của bạn hỏi bạn từng bước về một kế hoạch hoặc ý tưởng cho đến khi hai bên cùng hiểu rõ và đã được kiểm chứng.
antfu
6.0kDạy agent của bạn các thói quen ưa thích của Anthony Fu cho dự án JavaScript và TypeScript, từ cách bố trí file đến lựa chọn công cụ.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.