code-simplification

Refactors working code to reduce complexity while preserving exact behavior.

1|Updated Aug 4, 2026
One-click install
npx skills add https://github.com/Hamzaoui-Louai/LEAN-gym-dashboard-frontend --skill code-simplification-hamzaoui-louai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-simplification
Source: https://github.com/Hamzaoui-Louai/LEAN-gym-dashboard-frontend/tree/main/.opencode/skills/code-simplification
Command: npx skills add https://github.com/Hamzaoui-Louai/LEAN-gym-dashboard-frontend --skill code-simplification-hamzaoui-louai

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 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 with test runs, and verify the result against a review checklist. - Use Case: After shipping a feature with a 3-level nested conditional and a 60-line function, use this Skill to extract guard clauses, split responsibilities, and rename variables—keeping all tests passing unchanged. ## Quick Start Simplify the recently modified functions in this module for readability without changing any behavior, and keep all existing tests passing.

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 for readability without changing behavior?

Refactor incrementally: understand why the code exists first, make one simplification at a time, and run the full test suite after each change. All inputs, outputs, side effects, and error behavior must remain identical, and tests should pass without modification.

How to simplify deeply nested conditionals in code?

Replace deep nesting with guard clauses that handle error and edge cases early, then return the happy path at the end. You can also extract complex conditions into well-named predicate functions or helper functions to flatten the control flow.

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 that is already clean, and modules you are about to rewrite entirely. Also avoid drive-by refactors outside the scope of your current task.

Does code simplification mean fewer lines of code?

No. Simplification targets comprehension speed, not line count. A one-line nested ternary is harder to parse than a five-line if/else chain, so the clearer version is preferred even when it is longer.

Why should refactoring be separate from feature changes?

Mixing refactoring with feature work creates diffs that are hard to review, revert, and understand in history. Submit simplification changes as their own commit or pull request so regressions can be isolated to a specific change.