code-simplification

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

1|Updated May 25, 2020
One-click install
npx skills add https://github.com/titaneric/dotfiles --skill code-simplification-titaneric
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-simplification
Source: https://github.com/titaneric/dotfiles/tree/main/dot_agents/skills/code-simplification
Command: npx skills add https://github.com/titaneric/dotfiles --skill code-simplification-titaneric

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. - Four-Step Process: Understand the code first (Chesterton's Fence), identify concrete simplification patterns, apply changes incrementally with tests after each step, and verify the result against the original. - Language-Specific Guidance: Concrete before/after examples for TypeScript, JavaScript, Python, and React/JSX, plus pattern tables for structural complexity, naming, and redundancy. - Use Case: After shipping a feature with passing tests, run a simplification pass on the modified code to flatten nested conditionals into guard clauses, rename generic variables, and extract duplicated logic—then submit the refactor as a separate, reviewable commit. ## Quick Start Ask the agent to simplify the recently modified functions 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, error behavior, and edge cases remain identical, and revert any change that breaks a test rather than modifying the test.

What code patterns signal that simplification is needed?

Look for nesting deeper than three levels, functions over 50 lines, nested ternaries, boolean parameter flags, generic names like data or temp, duplicated logic blocks, dead code, and wrappers that add no value.

When should I not simplify code?

Skip simplification when the code is already readable, when you do not yet understand what it does, when it is performance-critical and the simpler version is measurably slower, or when the module is about to be rewritten entirely.

Should refactoring and feature changes go 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.

Why does over-simplification make code worse?

Inlining helpers that named a concept, merging unrelated functions, and removing abstractions that exist for testability all reduce clarity. Simplicity is measured by comprehension speed, not line count.