Skill

Simplify Code While Preserving Functionality

A code-simplification specialist that improves clarity and maintainability of recently-touched code without changing its behavior.


73
Spark score
out of 100
Updated last month
Version 1.0.0
Models
claude

Add to Favorites

Why it matters

Enhance code clarity, consistency, and maintainability by simplifying existing code without altering its core functionality. This asset applies project-specific best practices to refine code for better readability and adherence to standards.

Outcomes

What it gets done

01

Refactor code to improve readability and reduce complexity.

02

Ensure code adheres to project-specific coding standards (e.g., ES modules, explicit types).

03

Eliminate redundant code and overly compact solutions.

04

Preserve exact functionality and behavior of the original code.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/ag-code-simplifier | bash

Overview

Code Simplifier

A code simplification specialist that reduces unnecessary complexity, nested ternaries, and redundant abstractions in recently-modified code, applying project-specific CLAUDE.md standards while preserving exact behavior. Use when code needs simplifying or cleaning up without changing behavior, or recent edits need aligning with project standards - not for feature work.

What it does

Acts as a code simplification specialist that improves clarity, consistency, and maintainability while preserving exact functionality, never changing what code does, only how it does it. Refinement follows five principles: preserve functionality completely, with all original features, outputs, and behaviors staying intact; apply project-specific standards pulled from the project's own CLAUDE.md, like ES modules with proper import sorting, preferring the function keyword over arrow functions, explicit return type annotations on top-level functions, proper React component patterns with explicit Props types, and consistent naming; enhance clarity by reducing unnecessary nesting, eliminating redundant code and abstractions, improving names, consolidating related logic, removing comments that just describe obvious code, and specifically avoiding nested ternary operators in favor of switch statements or if/else chains; maintain balance by not over-simplifying into overly clever or hard-to-debug solutions, not collapsing too many concerns into one function or component, and not sacrificing clarity purely to save lines; and focus scope on only the code recently modified in the current session, unless explicitly told to review more broadly. A trivial wrapper function like:

function isNotEmpty(arr: unknown[]): boolean {
  return arr.length > 0;
}

if (isNotEmpty(items)) {
  // ...
}

gets replaced with the direct length check it wraps, removing an abstraction that added a name without adding real value.

The refinement process itself is a six-step loop: identify the recently modified sections, analyze them for elegance and consistency opportunities, apply the project's specific standards, ensure all functionality remains unchanged, verify the result is genuinely simpler and more maintainable, and document only the changes significant enough to affect understanding. Worked examples cover the recurring patterns this catches: a nested ternary chain rewritten as an explicit function with early returns, and a filter-map-reduce one-liner split into three clearly-named intermediate steps instead.

When to use - and when NOT to

Use it when code needs simplifying or cleaning up without changing behavior, when readability improvements or reducing unnecessary complexity is the goal, or when recent edits need aligning with a project's own standards, not for feature work. It is explicitly scoped to recently touched code by default, so it will not go rewriting the rest of a codebase unless asked to look wider.

Inputs and outputs

Takes recently modified code plus the project's own coding standards from CLAUDE.md; produces the same code with unchanged behavior but reduced complexity, clearer names, and standards-compliant structure, with only significant changes documented.

Who it's for

Developers who want a pass of clarity-focused refinement on code they just wrote or edited, following their own project's conventions, rather than a generic make-it-shorter pass that risks trading readability for brevity.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.