simplify
Skill này làm gì
Skill này làm code đang chạy đúng trở nên rõ ràng và đơn giản hơn mà không đổi hành vi. Skill dành cho developer muốn code dễ đọc và dễ thay đổi hơn cho người khác.
Khi nào nên dùng
- ✓Khi một tính năng đã chạy và test đã qua, nhưng code vẫn nặng nề hơn mức cần thiết.
- ✓Khi một hàm dài, lồng nhiều tầng hoặc có tên khó hiểu.
- ✓Khi việc review code chỉ ra vấn đề về khả năng đọc hoặc độ phức tạp.
Liên kết skill
https://github.com/alvinunreal/oh-my-opencode-slim/blob/master/src/skills/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
“Hàm này chạy đúng nhưng khó theo dõi. Hãy đơn giản hóa nó mà không đổi những gì nó làm.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill kiểm tra xem hành vi đã được hiểu đúng chưa, rồi thực hiện các thay đổi giữ nguyên đầu vào, đầu ra và cách xử lý lỗi. Code đã rõ ràng sẽ được bỏ qua.
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.
Code Simplification
Overview
Simplify code by reducing complexity while preserving exact behavior. The goal is not fewer lines - it's code that is easier to read, understand, modify, and debug. Every simplification must pass a simple test: "Would a new team member understand this faster than the original?"
When to Use
- After a feature is working and tests pass, but the implementation feels heavier than it needs to be
- During code review when readability or complexity issues are flagged
- When you encounter deeply nested logic, long functions, or unclear names
- When refactoring code written under time pressure
- When consolidating related logic scattered across files
- After merging changes that introduced duplication or inconsistency
When NOT to use:
- Code is already clean and readable - don't simplify for the sake of it
- You don't understand what the code does yet - comprehend before you simplify
- The code is performance-critical and the "simpler" version would be measurably slower
- You're about to rewrite the module entirely - simplifying throwaway code wastes effort
The Five Principles
1. Preserve Behavior Exactly
Don't change what the code does - only how it expresses it. All inputs, outputs, side effects, error behavior, and edge cases must remain identical. If you're not sure a simplification preserves behavior, don't make it.
Before every change, ask:
- Does this produce the same output for every input?
- Does this maintain the same error behavior?
- Does this preserve the same side effects and ordering?
- What proportionate final-state verification will reveal a behavior change?
2. Follow Project Conventions
Simplification means making code more consistent with the codebase, not imposing external preferences.
Before simplifying:
- Read
AGENTS.md/ project conventions - Study how neighboring code handles similar patterns
- Match the project's style for imports, naming, function style, error handling, and type annotations
Simplification that breaks project consistency is not simplification - it's churn.
3. Prefer Clarity Over Cleverness
Explicit code is better than compact code when the compact version requires a mental pause to parse.
- Replace nested ternaries with readable control flow
- Replace dense inline transforms with named intermediate steps when they clarify intent
- Keep helpful names even if they cost a few extra lines
4. Maintain Balance
Watch for over-simplification:
- Don't inline away names that carry meaning
- Don't merge unrelated logic into one larger function
- Don't remove abstractions that serve testability or extensibility
- Don't optimize for line count over comprehension
5. Scope to What Changed
Default to simplifying recently modified code. Avoid unrelated drive-by refactors unless explicitly asked.
Process
Step 1: Understand Before Touching
Before changing or removing anything, understand why it exists.
Answer:
- What is this code's responsibility?
- What calls it? What does it call?
- What are the edge cases and error paths?
- Are there tests that define expected behavior?
- Why might it have been written this way?
If you can't answer these, read more context first.
Step 2: Look for Simplification Opportunities
Signals:
- Deep nesting
- Long functions with mixed responsibilities
- Nested ternaries
- Boolean flag arguments
- Repeated conditionals
- Generic or misleading names
- Duplicated logic
- Dead code
- Wrappers or abstractions that add no value
Step 3: Apply Changes Incrementally
Make one simplification at a time.
For each simplification:
- Make the change
- Use the proportionate final-state verification plan to check preservation
- Keep it only when the evidence supports preservation
Separate refactoring from feature work whenever possible.
Step 4: Verify the Result
After simplifying, confirm:
- The code is genuinely easier to understand
- The diff is clean and reviewable
- Project conventions still match
- No behavior, error handling, or side effects changed
Guidance for This Repository
- Prefer straightforward TypeScript over clever compression
- Preserve existing runtime behavior, tests, and hooks
- Favor explicit names and smaller focused helpers when they improve readability
- Keep refactors tightly scoped to the task or review feedback
Final-state verification
Use a proportionate final-state verification plan for the final diff. Run checks required by r
Câu hỏi thường gặp
Skill có làm thay đổi cách code hoạt động không?
Skill nói hành vi phải giữ nguyên hoàn toàn, nên nó tránh mọi thay đổi mà nó không chắc chắn.
Mục tiêu có phải là ít dòng code hơn không?
Không. Mục tiêu là code dễ đọc, dễ hiểu và dễ thay đổi hơn.
Khi nào nên bỏ qua skill này?
Khi code đã sạch, hoặc khi code cần hiệu năng cao và phiên bản đơn giản hơn chậm hơn đáng kể.
Chi tiết
Mô tả gốc của tác giả
Simplifies code for clarity without changing behavior. Use for readability, maintainability, and complexity reduction after behavior is understood.
Độ phổ biến
- Sao GitHub
- 10k
- Vị trí xếp hạng
- #12017
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
cli-review
10kGiúp agent của bạn chạy đánh giá code Greptile trên nhánh hiện tại trước khi bạn mở pull request, rồi tóm tắt các phát hiện bằng lời đơn giản.
ai-estimates
10kGiúp agent của bạn ước tính thời gian làm việc khi có AI hỗ trợ, tách phần AI làm nhanh khỏi phần chờ đợi do con người hoặc bên ngoài gây ra.
clonedeps
10kGiúp agent của bạn sao chép mã nguồn của các phụ thuộc chính trong dự án vào một thư mục cục bộ, để đọc cách các thư viện đó hoạt động bên trong.
codemap
10kTạo bản đồ có cấu trúc cho dự án code lạ, giúp agent tìm nhanh các phần chính. Nên dùng khi bạn yêu cầu bản đồ code.
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á.