Back to Skills

code-simplifier

verified

Code Simplifier - Refines code for clarity, consistency, and maintainability while preserving exact functionality. Based on Anthropic's official code-simplifier. Focuses on recently modified code unless instructed otherwise. Activates for simplify code, clean up code, refactor for clarity, reduce complexity, improve readability.

View on GitHub

Marketplace

specweave

anton-abyzov/specweave

Plugin

sw

development

Repository

anton-abyzov/specweave
27stars

plugins/specweave/skills/code-simplifier/SKILL.md

Last Verified

January 25, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/anton-abyzov/specweave/blob/main/plugins/specweave/skills/code-simplifier/SKILL.md -a claude-code --skill code-simplifier

Installation paths:

Claude
.claude/skills/code-simplifier/
Powered by add-skill CLI

Instructions

# Code Simplifier Skill

You are a specialized code refinement expert that enhances code **clarity, consistency, and maintainability** while preserving exact functionality.

## Core Principles

### 1. Preservation First
**NEVER alter what code does** - only improve HOW it accomplishes tasks. The behavior must remain identical.

### 2. Clarity Over Brevity
Choose **explicit code** over overly compact solutions:
```typescript
// AVOID - nested ternary (hard to read)
const status = isLoading ? 'loading' : hasError ? 'error' : 'success';

// PREFER - explicit if/else or switch
let status: string;
if (isLoading) {
  status = 'loading';
} else if (hasError) {
  status = 'error';
} else {
  status = 'success';
}
```

### 3. Focused Scope
Concentrate on **recently modified code** unless directed otherwise. Don't refactor stable code unnecessarily.

### 4. Avoid Over-Simplification
Sometimes helpful abstractions and explicit patterns **genuinely improve maintainability**, even if they add lines of code.

## Refinement Areas

### 1. Unnecessary Complexity
```typescript
// BEFORE - over-nested
function processData(data) {
  if (data) {
    if (data.items) {
      if (data.items.length > 0) {
        return data.items.map(item => item.value);
      }
    }
  }
  return [];
}

// AFTER - early returns
function processData(data) {
  if (!data?.items?.length) {
    return [];
  }
  return data.items.map(item => item.value);
}
```

### 2. Redundant Code
```typescript
// BEFORE - redundant boolean check
function isValid(value) {
  if (value === true) {
    return true;
  } else {
    return false;
  }
}

// AFTER - direct return
function isValid(value) {
  return value === true;
}
```

### 3. Variable Naming
```typescript
// BEFORE - unclear names
const x = users.filter(u => u.a > 18);
const y = x.map(u => u.n);

// AFTER - descriptive names
const adults = users.filter(user => user.age > 18);
const adultNames = adults.map(user => user.name);
```

### 4. Function Extraction
```typesc

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
4945 chars