code-simplification

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

1|Updated May 29, 2026
One-click install
npx skills add https://github.com/memasanz/agent-harness --skill code-simplification-memasanz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-simplification
Source: https://github.com/memasanz/agent-harness/tree/main/.github/skills/code-simplification
Command: npx skills add https://github.com/memasanz/agent-harness --skill code-simplification-memasanz

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 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 Checklists: Identifies concrete simplification signals such as nested ternaries, boolean parameter flags, dead code, and over-engineered abstractions, with language-specific examples for TypeScript, JavaScript, Python, and React. - Incremental Verification Workflow: Enforces one-change-at-a-time edits with test runs after each step, plus a final verification checklist covering tests, linting, and diff cleanliness. - Use Case: After merging a feature that works but feels heavy, ask the agent to simplify the modified module—it will extract guard clauses, rename vague variables, remove duplication, and keep all tests passing. ## Quick Start Ask the agent to simplify the recently modified code in the current file while keeping all existing tests passing.

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 code in Python or TypeScript?

Replace deep nesting with guard clauses that handle error cases early and return immediately. In TypeScript, swap nested ternaries for if/else chains or lookup objects; in Python, flatten nested conditionals into sequential validation checks.

When should I not simplify or refactor code?

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

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

No. Mixing refactoring with feature work makes changes harder to review, revert, and understand in history. Submit simplification changes as a separate PR from feature or bug fix work.

What are the signs of over-simplification in code?

Over-simplification includes inlining helpers that gave concepts a name, merging unrelated functions into one complex function, and removing abstractions that exist for testability or extensibility. Fewer lines is not the goal—faster comprehension is.