code-simplification

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

Updated Jul 1, 2026
One-click install
npx skills add https://github.com/raishoemi/traffic-sim-v2 --skill code-simplification-raishoemi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-simplification
Source: https://github.com/raishoemi/traffic-sim-v2/tree/main/.github/skills/code-simplification
Command: npx skills add https://github.com/raishoemi/traffic-sim-v2 --skill code-simplification-raishoemi

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 - Behavior-Preserving Refactoring: Applies five principles (preserve behavior, follow project conventions, prefer clarity, maintain balance, scope to changes) so every simplification keeps inputs, outputs, side effects, and error behavior identical. - Pattern-Based Detection: Identifies concrete simplification signals such as 3+ levels of nesting, 50+ line functions, nested ternaries, boolean flag parameters, duplicated logic, and dead code. - Language-Specific Guidance: Includes before/after examples for TypeScript, JavaScript, Python, and React/JSX, plus incremental apply-test-commit workflow and a verification checklist. - Use Case: After shipping a feature whose tests pass but whose implementation has deeply nested conditionals and cryptic variable names, run this Skill to restructure the code into guard clauses and well-named helpers, verifying tests still pass after each change. ## Quick Start Ask the agent to simplify the recently modified module using the code-simplification process while keeping all existing tests passing 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 tests.

What code patterns signal that simplification is needed?

Look for nesting deeper than three levels, functions over 50 lines, nested ternaries, boolean flag parameters, generic names like data or temp, duplicated logic blocks, and unreachable or commented-out code.

When should I not simplify 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. Also avoid refactoring outside the scope of the current task.

Should refactoring and feature changes be in the same commit?

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

How do I handle large-scale refactoring across many files?

Apply the Rule of 500: if a refactoring touches more than 500 lines, invest in automation such as codemods, sed scripts, or AST transforms instead of manual edits, which are error-prone at that scale.