code-simplifier

whywaita's avatarfrom whywaita

Refactor complex or duplicated code without changing behavior. Use for refactoring tasks, simplifying logic, or improving readability.

⭐0stars🔀0forks📁View on GitHub🕐Updated Jan 10, 2026

When & Why to Use This Skill

The Code Simplifier skill is a specialized tool designed to refactor complex or duplicated code without altering its external behavior. It focuses on enhancing code readability, reducing technical debt, and simplifying logic through systematic workflows and proven heuristics—such as limiting nesting depth and function length—to ensure a cleaner and more maintainable codebase.

Use Cases

  • Legacy Code Modernization: Automatically refactor aging, complex functions into smaller, more manageable units to improve long-term maintainability.
  • Logic Simplification: Convert deeply nested conditional statements into early returns and guard clauses to enhance code clarity and reduce cognitive load.
  • Code Deduplication: Identify and consolidate repetitive logic patterns across files to adhere to the DRY (Don't Repeat Yourself) principle.
  • Technical Debt Reduction: Systematically replace magic numbers with constants and reduce function argument counts to improve API design and testability.
  • Pre-Review Polishing: Use the skill to optimize code structure and readability before submitting a Pull Request, ensuring faster approval cycles.
namecode-simplifier
descriptionRefactor complex or duplicated code without changing behavior. Use for refactoring tasks, simplifying logic, or improving readability.

Code Simplification

Rules

  • Do not change behavior.
  • Prefer small, safe steps.
  • Add or update tests if coverage is missing.

Workflow

  1. Read the target code and identify complexity drivers.
  2. Plan minimal refactors (early returns, extraction, deduplication).
  3. Apply changes incrementally and keep intent clear.
  4. Run relevant tests and linters.

Heuristics

  • Keep functions ~20 lines when possible.
  • Limit nesting depth to 3.
  • Reduce argument count to 4 or fewer.
  • Replace magic numbers with constants.

Report format

## Code Simplification Report

### Target files
- path

### Issues found
1. [Type] function - description

### Changes made
1. file:line - before/after summary

### Follow-ups
- tests to run