Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

code-simplifier

БесплатноБез исполняемых скриптовНе проверен

Analyze and simplify code by extracting reusable functions, removing redundancies, and improving overall code quality through refactoring techniques

Mieluoxxxот Mieluoxxx★ 19 звёзд на GitHub6 установок в других каталогах

Об этом скилле

What I do

I analyze code and automatically simplify it by:

  • Extracting repetitive code patterns into reusable functions
  • Removing redundant code, dead code, and unnecessary complexity
  • Applying idiomatic language patterns and best practices
  • Optimizing control flow and data structures
  • Improving readability while preserving functionality

When to use me

Use this skill when you need to:

  • Clean up legacy code with high complexity
  • Extract common patterns into helper functions
  • Reduce code duplication across files
  • Modernize code to follow current best practices
  • Simplify nested conditionals and loops
  • Improve variable naming and code structure

My workflow

  1. Code Analysis

    • Parse the code into abstract syntax tree (AST)
    • Identify code clones and repeated patterns
    • Measure cyclomatic complexity
    • Detect dead code and unreachable branches
    • Find anti-patterns and suboptimal constructs
  2. Simplification Strategies

    • Extract methods/functions from duplicated code
    • Replace nested conditionals with guard clauses
    • Simplify boolean expressions
    • Merge similar switch/if branches
    • Convert loops to iterator methods where applicable
    • Remove unused imports, variables, and functions
  3. Refactoring Execution

    • Apply changes incrementally, preserving git history
    • Maintain function signatures and behavior
    • Add minimal, focused unit tests for extracted functions
    • Update documentation for changed public APIs
  4. Validation

    • Ensure all existing tests still pass
    • Verify no semantic changes were introduced
    • Check that complexity metrics improved

Usage

/simplify --file src/utils/helper.ts
/simplify --dir src/components --recursive
/simplify --pattern "**/*.java" --dry-run
/simplify --aggressive --max-complexity 10

Options

Option Description
--file <path> Simplify a single file
--dir <path> Simplify all files in a directory
--recursive Include subdirectories (use with --dir)
--pattern <glob> Files matching glob pattern
--dry-run Show changes without applying them
--aggressive Apply more aggressive simplifications
--max-complexity <n> Target complexity threshold
--extract-methods Extract repeated code into methods
--remove-dead-code Remove unreachable code and unused items
--fix-idioms Apply language-specific idiomatic patterns

What I won't do

  • Change public API signatures without explicit approval
  • Modify code that doesn't have test coverage
  • Introduce behavioral changes (only refactoring)
  • Remove code comments (only unused imports/variables)
  • Force a specific coding style beyond simplification

Simplification Examples

1. Code Extraction

Before:

// Duplicate code in multiple places
const calculateTax = (amount: number) => amount * 0.08;
const calculateShipping = (weight: number) => weight * 0.5;
const calculateDiscount = (price: number) => price * 0.1;

// Later in the file...
const calculateTax = (amount: number) => amount * 0.08;
const calculateShipping = (weight: number) => weight * 0.5;
const calculateDiscount = (price: number) => price * 0.1;

After:

const calculateTax = (amount: number) => amount * 0.08;
const calculateShipping = (weight: number) => weight * 0.5;
const calculateDiscount = (price: number) => price * 0.1;

// Used where needed

2. Guard Clauses

Before:

function processUser(user: User): Result {
    if (user !== null) {
        if (user.isActive) {
            if (user.hasPermission) {
                // Main logic
                return performAction(user);
            }
        }
    }
    return defaultResult;
}

After:

function processUser(user: User): Result {
    if (!user || !user.isActive || !user.hasPermission) {
        return defaultResult;
    }
    return performAction(user);
}

3. Boolean Simplification

Before:

const isValid = (status: string) => {
    if (status === 'active' || status === 'pending') {
        return true;
    } else {
        return false;
    }
};

After:

const isValid = (status: string) => status === 'active' || status === 'pending';

4. Loop to Iterator

Before:

const names: string[] = [];
for (let i = 0; i < users.length; i++) {
    names.push(users[i].name);
}

After:

const names = users.map(user => user.name);

5. Optional Chaining & Nullish Coalescing

Before:

const city = user && user.address && user.address.city !== null
    ? user.address.city
    : 'Unknown';

After:

const city = user?.address?.city ?? 'Unknown';

Complexity Metrics

Metric Before After Target
Cyclomatic Complexity 15 8 ≤ 10
Lines of Code 450 32
Полный SKILL.md на GitHub

Установить code-simplifier в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл code-simplifier?

Analyze and simplify code by extracting reusable functions, removing redundancies, and improving overall code quality through refactoring techniques

Как установить скилл code-simplifier?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл code-simplifier запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить code-simplifier с