code-simplification

Refactors code to reduce complexity while preserving exact behavior and project conventions.

Updated Jul 22, 2026
One-click install
npx skills add https://github.com/Chau165/local_skill --skill code-simplification-chau165
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-simplification
Source: https://github.com/Chau165/local_skill/tree/main/codex/skills/code-simplification
Command: npx skills add https://github.com/Chau165/local_skill --skill code-simplification-chau165

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Working code often accumulates unnecessary complexity—deep nesting, long functions, unclear names, and duplicated logic—that makes it hard to read, maintain, and extend. This Skill provides a disciplined, behavior-preserving process for simplifying code without introducing regressions. ## Core Features & Use Cases - Five Simplification Principles: Preserve behavior exactly, follow project conventions, prefer clarity over cleverness, avoid over-simplification, and scope changes to what changed. - Pattern Detection Tables: Concrete signals for structural complexity, naming issues, and redundancy, each paired with a specific simplification technique. - Incremental Process: Understand before touching (Chesterton's Fence), apply one change at a time, run tests after each step, and keep refactoring separate from feature work. - Language-Specific Guidance: Before/after examples for TypeScript, JavaScript, Python, and React/JSX. - Use Case: After shipping a feature with passing tests, run a simplification pass to flatten nested conditionals into guard clauses, rename generic variables, and extract duplicated logic—producing a clean, reviewable diff. ## Quick Start Ask the AI to simplify the recently modified code in this 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, and error behavior remain identical, and revert any change that requires modifying tests to pass.

How to simplify deeply nested conditionals in code?

Replace deep nesting with guard clauses that handle error and edge cases early, then return. This flattens the happy path to the top level, making control flow easier to follow without changing logic.

When should I not simplify or refactor code?

Avoid simplifying code you do not yet understand, performance-critical code where the simpler version is measurably slower, code about to be rewritten, and code already clean. Unscoped drive-by refactors also create noisy diffs and regression risk.

Should refactoring and feature changes be in the same commit?

No. Submit refactoring separately from feature or bug fix changes. Mixed changes are harder to review, revert, and understand in history, and batching simplifications makes it impossible to identify which change caused a failure.

What are signs of over-simplification in code?

Over-simplification includes inlining helpers that gave concepts a name, merging unrelated functions into one complex function, removing abstractions that exist for testability, and optimizing for line count instead of comprehension speed.