Get the FREE Ultimate OpenClaw Setup Guide →

code-simplifier

npx machina-cli add skill dceoy/ai-coding-agent-skills/code-simplifier --openclaw
Files (1)
SKILL.md
3.7 KB

Code Simplifier

Simplify and refine code for clarity, consistency, and maintainability while preserving exact functionality.

When to Use

  • After writing or modifying code to ensure it meets quality standards.
  • When code has become complex or hard to read.
  • To apply project-specific coding standards consistently.
  • When refactoring for maintainability without changing behavior.
  • To reduce unnecessary complexity and nesting in existing code.

Inputs

  • Scope of code to simplify (recently modified files, specific files, or broader codebase).
  • Project coding standards (from CLAUDE.md/AGENTS.md if available).

If scope is unclear, default to recently modified code using git diff or git status.

Workflow

  1. Identify target code:

    • Run git status and git diff to find recently modified files.
    • Focus on files changed in the current session unless instructed otherwise.
  2. Read project standards:

    • Check CLAUDE.md, AGENTS.md, or similar for coding conventions.
    • Note language-specific patterns (ES modules, function syntax, type annotations).
  3. Analyze for simplification opportunities:

    • Unnecessary complexity and deep nesting.
    • Redundant code and over-abstraction.
    • Unclear variable and function names.
    • Scattered related logic that could be consolidated.
    • Unnecessary comments describing obvious code.
    • Nested ternary operators (prefer switch/if-else).
    • Overly compact code sacrificing readability.
  4. Apply refinements while preserving functionality:

    • Preserve Functionality: Never change what the code does, only how it does it.
    • Apply Project Standards: Follow established coding conventions.
    • Enhance Clarity: Simplify structure, improve naming, consolidate logic.
    • Maintain Balance: Avoid over-simplification that reduces maintainability.
  5. Verify changes:

    • Ensure all original features, outputs, and behaviors remain intact.
    • Confirm refined code is simpler and more maintainable.
    • Run tests if available to validate functionality is preserved.
  6. Document significant changes:

    • Note only changes that affect understanding.
    • Skip obvious or trivial refinements.

Guidelines

Preserve Functionality

  • Never change what the code does, only how it does it.
  • All original features, outputs, and behaviors must remain intact.

Enhance Clarity

  • Reduce unnecessary complexity and nesting.
  • Eliminate redundant code and abstractions.
  • Improve readability through clear naming.
  • Consolidate related logic.
  • Remove unnecessary comments describing obvious code.
  • Avoid nested ternary operators - prefer switch or if/else for multiple conditions.
  • Choose clarity over brevity - explicit code is often better than compact code.

Maintain Balance

Avoid over-simplification that could:

  • Reduce code clarity or maintainability.
  • Create overly clever solutions that are hard to understand.
  • Combine too many concerns into single functions or components.
  • Remove helpful abstractions that improve organization.
  • Prioritize "fewer lines" over readability.
  • Make the code harder to debug or extend.

Outputs

  • Simplified code with preserved functionality.
  • Summary of significant changes made.
  • Notes on applied coding standards.

Constraints

  • Functionality-preserving: All original behavior must remain unchanged.
  • Scope-limited: Focus on recently modified code unless explicitly directed otherwise.
  • Balance-aware: Prefer readable, explicit code over overly compact solutions.

Source

git clone https://github.com/dceoy/ai-coding-agent-skills/blob/main/skills/code-simplifier/SKILL.mdView on GitHub

Overview

Code Simplifier refines code to improve readability, maintainability, and consistency without changing functionality. It prioritizes recently modified code, applies project standards, and reduces unnecessary complexity and nesting to make code easier to maintain over time.

How This Skill Works

The tool identifies target code by inspecting recent changes with git status and git diff, then consults project standards (CLAUDE.md/AGENTS.md). It analyzes for complexity, redundant logic, and unclear naming, then applies clarity-focused refinements that preserve exact behavior. Finally, it verifies changes and documents significant updates.

When to Use It

  • After writing or modifying code to ensure quality standards are met and maintainability is improved.
  • When code is hard to read or contains deep nesting and unnecessary complexity.
  • To apply project coding standards consistently across the codebase.
  • During refactoring aimed at maintainability without altering behavior.
  • To remove redundant complexity and scattered logic in existing code.

Quick Start

  1. Step 1: Run git status and git diff to identify recently modified files targeted for simplification.
  2. Step 2: Review project standards (CLAUDE.md/AGENTS.md) to apply correct conventions.
  3. Step 3: Apply refinements that preserve functionality and run tests to confirm behavior remains unchanged.

Best Practices

  • Preserve functionality: never change what the code does.
  • Prioritize readability with explicit naming and straightforward control flow.
  • Align changes with CLAUDE.md/AGENTS.md and language-specific patterns.
  • Prefer targeted refinements over sweeping rewrites.
  • Run available tests to validate that behavior remains intact.

Example Use Cases

  • Refactor a recently touched utility function to reduce nesting and improve naming.
  • Consolidate scattered conditional logic in a feature branch into clear if/else blocks.
  • Rename unclear variables and functions to reflect their purpose more clearly.
  • Remove redundant comments describing obvious code behavior.
  • Replace nested ternaries with explicit switch or if/else statements for clarity.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers