code-simplification

Simplify code complexity while preserving exact behavior and project conventions.

6.3k|548|Updated Jan 18, 2017
One-click install
npx skills add https://github.com/sanity-io/sanity --skill code-simplification-sanity-io
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-simplification
Source: https://github.com/sanity-io/sanity/tree/main/.agents/skills/code-simplification
Command: npx skills add https://github.com/sanity-io/sanity --skill code-simplification-sanity-io

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Code Simplification reduces complexity in code without altering behavior, enabling easier maintenance and faster onboarding for engineers.

Core Features & Use Cases

  • Preserve Behavior Exactly: inputs, outputs, side effects, and error handling remain identical to the original implementation.
  • Follow Project Conventions: align with the team's style, tests, and architecture to avoid introducing instability.
  • Prefer Clarity Over Cleverness: replace dense constructs with readable, well-named constructs that express intent.
  • Stepwise Refactoring Process: follow a guided sequence—understand the code, identify simplification opportunities, apply changes incrementally, and verify with tests.
  • Language-Specific Guidance: TypeScript/JavaScript, Python, and React/JSX patterns provide practical readability improvements.

Quick Start

Provide a high-level refactoring plan that preserves behavior while improving readability for a given code sample.

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 to improve readability without changing behavior?

Code simplification reduces complexity without altering behavior by following a guided sequence: understand the code, identify simplification opportunities, apply changes incrementally, and verify with tests to ensure inputs, outputs, and side effects remain identical.

How do I simplify complex code during a code review?

Simplify code during reviews by enforcing clarity-first improvements, replacing clever constructs with readable alternatives, and verifying adherence to project conventions. This reduces complexity while preserving exact error handling and side effects.

Does code simplification support React and TypeScript refactoring patterns?

Yes, code simplification provides language-specific guidance for TypeScript, JavaScript, Python, and React/JSX patterns. These targeted improvements help refactor dense constructs into expressive, well-named code without altering runtime behavior.

What is the best way to reduce code complexity while preserving side effects?

The best way to reduce complexity while preserving side effects is to apply incremental refactoring steps guided by tests. This structured approach ensures inputs, outputs, error handling, and side effects remain identical to the original implementation.

When should I avoid refactoring code for readability?

Avoid refactoring for readability when the code lacks adequate test coverage to verify behavior preservation. Without tests confirming that inputs, outputs, and error handling remain identical, incremental simplification risks introducing instability.