code-simplification

Refactors working code to reduce complexity while preserving exact behavior.

Updated Sep 15, 2026
One-click install
npx skills add https://github.com/Qiuyi-Hong/addyosmani-skills --skill code-simplification-qiuyi-hong
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-simplification
Source: https://github.com/Qiuyi-Hong/addyosmani-skills/tree/main/skills/code-simplification
Command: npx skills add https://github.com/Qiuyi-Hong/addyosmani-skills --skill code-simplification-qiuyi-hong

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Working code often accumulates unnecessary complexity—deep nesting, long functions, unclear names, and duplication—that makes it harder to read, maintain, and extend. This Skill provides a disciplined process for simplifying code without changing its behavior. ## Core Features & Use Cases - Behavior-Preserving Refactoring: Applies five principles (preserve behavior, follow project conventions, prefer clarity over cleverness, maintain balance, scope to what changed) so every simplification keeps inputs, outputs, side effects, and error behavior identical. - Pattern Detection Checklists: Identifies concrete simplification signals such as 3+ levels of nesting, 50+ line functions, nested ternaries, boolean parameter flags, generic names, dead code, and over-engineered abstractions. - Language-Specific Guidance: Includes before/after examples for TypeScript, JavaScript, Python, and React/JSX, plus a verification checklist covering tests, builds, linting, and diff cleanliness. - Use Case: After shipping a feature with passing tests, run a simplification pass on the modified files to flatten nested conditionals into guard clauses, rename vague variables, and extract duplicated logic—one incremental, test-verified change at a time. ## Quick Start Ask the agent to simplify the recently modified code in your current module while keeping all tests passing and behavior unchanged.

Frequently Asked Questions about code-simplification

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor code without changing its behavior?

Make one simplification at a time and run the full test suite after each change. Verify that inputs, outputs, side effects, error behavior, and edge cases remain identical, and revert any change that breaks a test.

How to simplify deeply nested code and long functions?

Replace deep nesting with guard clauses and early returns, and split functions over 50 lines into focused helpers with descriptive names. Swap nested ternaries for if/else chains or lookup objects to reduce mental parsing effort.

When should I not simplify or refactor code?

Skip simplification when the code is already readable, when you do not yet understand what it does, when it is performance-critical and the simpler version is measurably slower, or when the module is about to be rewritten entirely.

Does code simplification work for Python and React projects?

Yes, the guidance covers TypeScript, JavaScript, Python, and React/JSX with concrete before-and-after examples. It also requires matching each project's existing conventions for naming, imports, and error handling before making changes.

Why should refactoring be separate from feature commits?

Mixing refactoring with feature work makes diffs harder to review, revert, and understand in history. Submit simplifications as their own commits or pull requests so regressions can be traced to a specific change.