code-simplification

Refactors code to reduce complexity while preserving exact behavior and passing existing tests.

Updated Sep 17, 2026
One-click install
npx skills add https://github.com/authrain-cloud-abdullahformuli/agent-skills --skill code-simplification-authrain-cloud-abdullahformuli
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-simplification
Source: https://github.com/authrain-cloud-abdullahformuli/agent-skills/tree/main/skills/code-simplification
Command: npx skills add https://github.com/authrain-cloud-abdullahformuli/agent-skills --skill code-simplification-authrain-cloud-abdullahformuli

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 for simplifying code without changing its behavior. ## 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, and error handling identical. - Pattern Detection Checklist: Identifies concrete simplification signals such as 3+ level nesting, 50+ line functions, nested ternaries, boolean flag parameters, dead code, and over-engineered abstractions. - Language-Specific Guidance: Includes before/after examples for TypeScript, JavaScript, Python, and React/JSX, plus a verification checklist covering tests, linting, and diff cleanliness. - Use Case: After shipping a feature with passing tests, run a simplification pass on the modified files to flatten nested conditionals into guard clauses, rename generic variables, and extract duplicated logic—one incremental, test-verified change at a time. ## Quick Start Ask the agent to simplify the recently modified code in the current module while keeping all existing 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?

Refactor incrementally: make one simplification at a time and run the full test suite after each change. Verify that inputs, outputs, side effects, and error behavior remain identical, and revert any change that breaks tests.

How to simplify deeply nested conditionals in code?

Replace deep nesting with guard clauses that handle error and edge cases early, then return. You can also extract conditions into well-named predicate functions or replace nested ternaries with if/else chains or lookup objects.

When should I not simplify or refactor code?

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

Can I mix refactoring with feature changes in one PR?

No. Refactoring and feature work should be separate pull requests. Mixed changes are harder to review, revert, and understand in history, and they obscure which change caused a regression.

What are the limits of large-scale manual refactoring?

Manual edits become error-prone beyond roughly 500 touched lines. At that scale, invest in automation such as codemods, sed scripts, or AST transforms instead of hand-editing each occurrence.