code-simplification

Refactors working code to reduce complexity while preserving exact behavior.

1|Updated Mar 2, 2025
One-click install
npx skills add https://github.com/marjorg/setup --skill code-simplification-marjorg
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-simplification
Source: https://github.com/marjorg/setup/tree/main/home/.agents/skills/code-simplification
Command: npx skills add https://github.com/marjorg/setup --skill code-simplification-marjorg

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Working code often accumulates unnecessary complexity—deep nesting, long functions, unclear names, and duplicated logic—that makes it harder to read, maintain, and extend. This Skill provides a disciplined, process-driven approach to simplifying code without changing its behavior. ## Core Features & Use Cases - Five Core 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 test verification, and verify the final result. - Language-Specific Guidance: Includes before/after examples for TypeScript, JavaScript, Python, and React/JSX covering common simplification patterns. - Use Case: After shipping a feature with passing tests, use this Skill to refactor deeply nested conditionals into guard clauses, rename generic variables like data and temp, and extract duplicated logic into shared functions—one tested change at a time. ## Quick Start Ask the AI to simplify the recently modified code in your project 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 test suite after each change. If tests pass, continue; if they fail, revert that change. Keep refactoring commits separate from feature or bug fix changes so regressions are easy to isolate.

How to simplify deeply nested conditionals in code?

Replace deep nesting with guard clauses that handle error cases early and return immediately. This flattens the control flow so the main logic sits at the top level, making it easier to follow.

When should I not simplify or refactor code?

Avoid simplifying code you do not fully understand, performance-critical code where the simpler version is measurably slower, code about to be rewritten entirely, and code that is already clean and readable.

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 longer version can be the simpler one.

Why should refactoring be separate from feature changes?

Mixing refactoring with features creates noisy diffs that are hard to review, revert, and understand in history. Separate commits let reviewers verify behavior preservation independently from new functionality.