code-simplifier

Refactor complex or duplicated code while preserving behavior.

Updated Oct 29, 2013
One-click install
npx skills add https://github.com/whywaita/dotfiles --skill code-simplifier-whywaita
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-simplifier
Source: https://github.com/whywaita/dotfiles/tree/main/dot_codex/skills/code-simplifier
Command: npx skills add https://github.com/whywaita/dotfiles --skill code-simplifier-whywaita

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Refactor complex or duplicated code without changing behavior.

Core Features & Use Cases

  • Safe, incremental refactoring guidance
  • Heuristic-driven improvements for readability and maintainability
  • Optional tests suggested to verify behavior remains unchanged

Quick Start

Provide a target code snippet and I will propose safe incremental refactors that preserve behavior.

Frequently Asked Questions about code-simplifier

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

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

Refactor complex code safely by applying heuristic-driven improvements like reducing nesting depth and extracting duplicated logic. This approach ensures readability and maintainability improvements while strictly preserving the original behavior.

What is a safe function length limit for code simplification?

A safe function length for code simplification is roughly 20 lines. Keeping functions around 20 lines reduces complexity and improves readability while maintaining behavior across functions, classes, and modules.

How do I reduce code duplication across modules safely?

Reduce code duplication across modules by applying incremental refactoring techniques like deduplication. This process removes redundant logic while enforcing rules like nesting depth under 3 and argument counts of 4 or fewer to maintain behavior.

Do I need tests to verify behavior during code refactoring?

Tests are required to validate behavioral preservation during code refactoring. Running tests before and after applying readability improvements and complexity reduction ensures the refactored code maintains its original behavior.

What are the best practices for code readability and maintainability?

Best practices for code readability include enforcing magic-number constants, limiting function arguments to 4, and keeping nesting depth under 3. These heuristic-driven improvements reduce complexity while maintaining behavior.

Can I refactor duplicated code without breaking existing functions?

You can refactor duplicated code without breaking existing functions by following safe, incremental refactoring guidance. This method applies deduplication across classes and modules while using tests to verify behavior remains unchanged.