Code Simplification Assistant
Paste the following prompt into your AI chat to install this skill:
Please follow https://skillhub.cn/install/skillhub.md to install @user_e40a4360/code-simplification.
About this skill
Problem
Code that works but is hard to maintain is the core issue this skill addresses. It does not optimize for fewer lines; it makes already-working code easier to read, modify, debug, and review. Typical cases include implementations that feel heavier than the problem, review feedback about deep nesting or vague names, duplicated logic scattered across files, and inconsistencies introduced after merges.
How It Works
The skill treats simplification as a controlled process:
- Understand first: Before removing or rewriting code, determine why it exists, so you do not delete a Chesterton’s Fence.
- Spot concrete signals: for example, 3+ levels of nesting, functions over 50 lines, boolean flags like doThing(true, false, true), names such as data or temp, duplicated blocks, and valueless wrappers.
- Apply incrementally: make one simplification at a time, run tests after each change, and keep refactoring separate from feature work.
- Verify the result: revert if the “simplified” version is harder to review, requires test changes, weakens error handling, or creates noisy diffs.
Scope and Limits
It is best used on stable, test-covered code. It is not intended for performance-critical paths, behavior you still do not understand, modules about to be rewritten, or code that is already clean. The goal is lower comprehension cost, not blind line-count reduction.
Use Cases
- A feature passes tests but has deep nesting; extract guard clauses and smaller functions without changing behavior.
- Review flags a long function and boolean flags; turn it into an options object or separate functions before submitting.
- Merged branches leave duplicated logic; identify repeated blocks and extract a shared function.
- A module written under time pressure needs cleanup of dead code and misleading names while tests remain green.
Best For
- Backend engineers who need to turn working feature code into reviewable changes.
- Tech leads who need to narrow refactoring scope and reduce diff noise.
- Frontend engineers who need to split complex business logic into clear functions.
- Senior engineers who need to separate refactoring from feature work and submit it independently.
Related Skills
A systematic code error fixing skill that follows a five-step workflow: Reproduce, Isolate, Understand, Fix, Verify, to help developers resolve code errors.
Supports inline SVG/HTML rendering and Mermaid code output, covering common technical diagram creation like architecture and flow diagrams.
A comprehensive browser automation guide covering navigation, interaction, multi-tab management, and data collection, tailored for domestic web ecosystems and tools like Playwright/Selenium.
Control Windows WeChat through GUI automation to search contacts and send text, images, or files without official APIs.