code-simplification

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

665|3|Updated Sep 12, 2026
One-click install
npx skills add https://github.com/rizqinrr/viserys-agent --skill code-simplification-rizqinrr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-simplification
Source: https://github.com/rizqinrr/viserys-agent/tree/main/skills/code-simplification
Command: npx skills add https://github.com/rizqinrr/viserys-agent --skill code-simplification-rizqinrr

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: Every simplification must keep inputs, outputs, side effects, and error behavior identical, verified by running the existing test suite after each change. - Concrete Simplification Patterns: Provides lookup tables of signals and fixes for structural complexity, naming issues, and redundancy, plus language-specific examples for TypeScript, JavaScript, Python, and React. - Scope and Safety Guardrails: Enforces Chesterton's Fence (understand before changing), incremental one-at-a-time changes, the Rule of 500 for large refactors, and anti-rationalization tables to prevent over-simplification. - Use Case: After shipping a feature with passing tests, run a simplification pass on the modified files to flatten nested conditionals, rename generic variables, and extract duplicated logic before opening the pull request. ## Quick Start Ask the agent to simplify the recently modified code in this branch 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. If tests fail, revert that change. All inputs, outputs, side effects, and error behavior must remain identical, and existing tests should pass without modification.

How to simplify deeply nested conditionals in Python or TypeScript?

Replace nested conditionals with guard clauses that handle error cases early and return immediately. This flattens the control flow so the happy path reads top to bottom without indentation buildup.

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, code about to be rewritten entirely, and code that is already clean. Comprehension must come before simplification.

Should refactoring and feature changes go in the same pull request?

No. Refactoring changes should be submitted separately from feature or bug fix changes. Mixed PRs are harder to review, revert, and understand in history, so split them into two pull requests.

What are the risks of over-simplifying code?

Over-simplification includes inlining named helpers, merging unrelated functions, removing abstractions that exist for testability, and optimizing for line count. The goal is faster comprehension, not fewer lines.