code-simplification
Fungsinya
Alat ini membantu membuat kode program lebih mudah dibaca dan dipahami. Alat ini meningkatkan kejelasan tanpa mengubah apa yang dilakukan kode.
Kapan dipakai
- βSaat kode sudah berjalan tetapi sulit dibaca.
- βSaat meninjau kode yang terlalu rumit.
- βSaat menemukan logika yang sangat kompleks atau nama yang tidak jelas.
Link skill
https://github.com/addyosmani/agent-skills/blob/main/skills/code-simplification/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βSederhanakan kode ini agar lebih mudah dipahami:β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Alat ini menganalisis kode dan mencari cara untuk membuatnya lebih lugas, misalnya dengan menggunakan nama yang lebih baik atau menata ulang logika. Alat ini memastikan kode tetap berfungsi persis seperti sebelumnya.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Code Simplification
Inspired by the Claude Code Simplifier plugin. Adapted here as a model-agnostic, process-driven skill for any AI coding agent.
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.
ASK BEFORE EVERY CHANGE:
β 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?
β Do all existing tests still pass without modification?
2. Follow Project Conventions
Simplification means making code more consistent with the codebase, not imposing external preferences. Before simplifying:
1. Read CLAUDE.md / project conventions
2. Study how neighboring code handles similar patterns
3. Match the project's style for:
- Import ordering and module system
- Function declaration style
- Naming conventions
- Error handling patterns
- Type annotation depth
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.
// UNCLEAR: Dense ternary chain
const label = isNew ? 'New' : isUpdated ? 'Updated' : isArchived ? 'Archived' : 'Active';
// CLEAR: Readable mapping
function getStatusLabel(item: Item): string {
if (item.isNew) return 'New';
if (item.isUpdated) return 'Updated';
if (item.isArchived) return 'Archived';
return 'Active';
}
// UNCLEAR: Chained reduces with inline logic
const result = items.reduce((acc, item) => ({
...acc,
[item.id]: { ...acc[item.id], count: (acc[item.id]?.count ?? 0) + 1 }
}), {});
// CLEAR: Named intermediate step
const countById = new Map<string, number>();
for (const item of items) {
countById.set(item.id, (countById.get(item.id) ?? 0) + 1);
}
4. Maintain Balance
Simplification has a failure mode: over-simplification. Watch for these traps:
- Inlining too aggressively β removing a helper that gave a concept a name makes the call site harder to read
- Combining unrelated logic β two simple functions merged into one complex function is not simpler
- Removing "unnecessary" abstraction β some abstractions exist for extensibility or testability, not complexity
- Optimizing for line count β fewer lines is not the goal; easier comprehension is
5. Scope to What Changed
Default to simplifying recently modified code. Avoid drive-by refactors of unrelated code unless explicitly asked to broaden scope. Unscoped simplification creates noise in diffs and risks unintended regressions.
The Simplification Process
Step 1: Understand Before Touching (Chesterton's Fence)
Before changing or removing anything, understand why it exists. This is Chesterton's Fence: if you see a fence across a road and don't understand why it's there, don't tear it down. First understand the reason, then decide if the reason still applies.
BEFORE SIMPLIFYING, ANSWER:
- What is this code's responsibility?
β¦
Pertanyaan umum
Apakah ini mengubah cara kerja kode?
Tidak. Tujuannya hanya untuk meningkatkan kejelasan. Kode akan melakukan hal yang sama persis seperti sebelumnya.
Apakah saya perlu bisa memrogram untuk memakainya?
Akan membantu jika Anda memiliki pemahaman dasar tentang pemrograman untuk mengerti apa yang dilakukan kode, tetapi alat ini dirancang untuk menyederhanakan sehingga lebih mudah diakses.
Bisakah saya memakainya untuk memperpendek kode?
Fokus utamanya adalah kejelasan dan kemudahan dipahami, bukan mengurangi jumlah baris. Terkadang, kode yang sedikit lebih panjang justru lebih mudah dibaca.
Detail
Deskripsi asli dari pembuat
Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.
repo: addyosmani/agent-skills
Popularitas
- Bintang GitHub
- 107k
- Peringkat
- #765
- Lisensi
- MIT
- Diperbarui
- 13/10/2026
Komentar
- β¦
Skill lain dari repositori ini
api-and-interface-design
107kMembantu merancang API dan antarmuka yang terdefinisi dengan baik. Berguna saat merancang cara berbagai bagian perangkat lunak saling berkomunikasi.
browser-testing-with-devtools
107kMembantu agent Anda menguji kode langsung di browser sungguhan. Berguna untuk memeriksa cara kerja di lingkungan penggunaannya, serta menemukan error dan masalah performa.
ci-cd-and-automation
107kMengajarkan agent AI Anda untuk mengotomatisasi tugas berulang, mengirim proyek, dan mengelola infrastruktur.
code-review-and-quality
107kMelakukan tinjauan kode mendetail dari berbagai sisi. Berguna sebelum menggabungkan perubahan baru untuk memastikan kualitas dan mencegah masalah di kemudian hari.
Skill serupa
diffs
394kMemungkinkan agent Anda menghasilkan diff perubahan yang nyata dan dapat dibagikan sebagai tautan viewer atau file gambar, bukan ringkasan yang ditulis manual.
coding-agent
394kMembantu agent Anda menyerahkan pekerjaan pemrograman besar ke Codex, Claude Code, atau OpenCode di latar belakang, lalu memeriksa kemajuannya.
gh-issues
394kMembantu agent Anda menemukan issue GitHub, memilih yang dikerjakan, dan membuka pull request perbaikan, termasuk tindak lanjut komentar tinjauan.