Упрощение и выравнивание кода
Делает недавно изменённый код проще, не меняя поведения: меньше вложенности, без вложенных тернарников, понятные имена, без лишних абстракций, по соглашениям из CLAUDE.md. Для случаев, когда код работает, но читается тяжелее, чем нужно.
code-simplifier- Автор
- Sentry
- Источник
- getsentry/skills/skills/code-simplifier @ a582c51
- Лицензия
- Apache-2.0 · Copyright 2025 Functional Software, Inc. dba Sentry
Об этом скилле
Что делает
Скилл приводит в порядок уже работающий код, не меняя того, что он делает. В HTML-комментарии сказано, что он основан на агенте code-simplifier от Anthropic для Claude Code. От агента остались роль и пять принципов. Поведение не меняется, стандарты проекта берутся из CLAUDE.md, а ясность важнее краткости: меньше вложенности, никакого лишнего кода и абстракций, понятные имена, без комментариев, пересказывающих код, и без вложенных тернарных операторов. Перегибов вроде плотных однострочников или функций, в которые свалено слишком много обязанностей, скилл избегает. Трогает он только код, изменённый в текущей сессии, если вы не расширите рамки.
Дальше шесть шагов — от поиска недавно изменённых мест до описания только тех правок, которые влияют на понимание. Три примера «до и после» на TypeScript: вложенный тернарный оператор превращается в цепочку if, цепочка filter/map/reduce — в именованные шаги, однострочная вспомогательная функция — в прямую проверку.
Стандарты в разделе «Apply Project Standards» вполне конкретные: ES-модули с отсортированными импортами и расширениями, function вместо стрелочных функций, явные типы возврата у функций верхнего уровня, явные типы Props у компонентов React, по возможности без try/catch. SKILL.md подаёт их как стандарты из CLAUDE.md, так что они приходят вместе со скиллом, даже если в вашем CLAUDE.md их нет. В папке только SKILL.md и лицензия.
Когда включать и когда не надо
Сразу после того, как фича заработала, — как проход по только что изменённому коду.
Если в проекте приняты стрелочные функции или типы возврата не пишут, скажите об этом в запросе. Запуск тестов скилл не упоминает, так что попросите его сами, если хотите проверенного, а не предполагаемого поведения.
Как поставить и вызвать
Команда установки ниже скачивает папку. Агент сам подхватывает скилл по описанию, когда вы просите упростить или почистить код. Вызвать вручную:
- Claude Code:
/code-simplifierили попросить скилл по имени. - Codex:
$code-simplifier. - Cursor: наберите
/в чате Agent и выберитеcode-simplifier.
Пример: /code-simplifier Почисти то, что мы поменяли в src/checkout за эту сессию, стрелочные функции оставь, потом прогони тесты.
Чем отличается от похожих
Упрощение кода выросло из того же агента Anthropic, но добавляет метод: сначала понять, почему код устроен именно так, потом упрощать по одному шагу с тестами после каждого и откатывать при красных тестах. Берите его ради этой дисциплины, а этот скилл — для короткого прохода. Безопасный рефакторинг рассчитан на крупную перестройку и начинает с тестов, фиксирующих текущее поведение. Чистка комментариев в коде трогает только комментарии.
Установка
Выполните одну команду — она сохранит SKILL.md и файлы, которые он использует, в папку скиллов агента. Claude Code и Codex подхватывают новый скилл без перезапуска; если скилл не появился, перезапустите агента.
Скилл написан на английском — агент поймёт его и ответит вам по-русски.
curl -fsSL --create-dirs -o ~/.claude/skills/code-simplifier/SKILL.md https://anymodel.org/en/skills/sentry/code-simplifier/SKILL.md -o ~/.claude/skills/code-simplifier/LICENSE https://anymodel.org/en/skills/sentry/code-simplifier/LICENSE
curl -fsSL --create-dirs -o ~/.agents/skills/code-simplifier/SKILL.md https://anymodel.org/en/skills/sentry/code-simplifier/SKILL.md -o ~/.agents/skills/code-simplifier/LICENSE https://anymodel.org/en/skills/sentry/code-simplifier/LICENSE
foreach ($f in 'SKILL.md','LICENSE') { $p = Join-Path "$HOME\.claude\skills\code-simplifier" $f; New-Item -ItemType Directory -Force (Split-Path $p) | Out-Null; Invoke-WebRequest "https://anymodel.org/en/skills/sentry/code-simplifier/$f" -UseBasicParsing -OutFile $p }foreach ($f in 'SKILL.md','LICENSE') { $p = Join-Path "$HOME\.agents\skills\code-simplifier" $f; New-Item -ItemType Directory -Force (Split-Path $p) | Out-Null; Invoke-WebRequest "https://anymodel.org/en/skills/sentry/code-simplifier/$f" -UseBasicParsing -OutFile $p }Другой агент: сохраните файл в его папку скиллов или дайте ему ссылку на файл: https://anymodel.org/en/skills/sentry/code-simplifier/SKILL.md
SKILL.md
<!-- Based on Anthropic's code-simplifier agent: https://github.com/anthropics/claude-plugins-official/blob/main/plugins/code-simplifier/agents/code-simplifier.md -->
Code Simplifier
You are an expert code simplification specialist focused on enhancing code clarity, consistency, and maintainability while preserving exact functionality. Your expertise lies in applying project-specific best practices to simplify and improve code without altering its behavior. You prioritize readable, explicit code over overly compact solutions.
Refinement Principles
1. Preserve Functionality
Never change what the code does - only how it does it. All original features, outputs, and behaviors must remain intact.
2. Apply Project Standards
Follow the established coding standards from CLAUDE.md including:
- Use ES modules with proper import sorting and extensions
- Prefer
functionkeyword over arrow functions - Use explicit return type annotations for top-level functions
- Follow proper React component patterns with explicit Props types
- Use proper error handling patterns (avoid try/catch when possible)
- Maintain consistent naming conventions
3. Enhance Clarity
Simplify code structure by:
- Reducing unnecessary complexity and nesting
- Eliminating redundant code and abstractions
- Improving readability through clear variable and function names
- Consolidating related logic
- Removing unnecessary comments that describe obvious code
- Avoiding nested ternary operators - prefer switch statements or if/else chains for multiple conditions
- Choosing clarity over brevity - explicit code is often better than overly compact code
4. 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 code organization
- Prioritize "fewer lines" over readability (e.g., nested ternaries, dense one-liners)
- Make the code harder to debug or extend
5. Focus Scope
Only refine code that has been recently modified or touched in the current session, unless explicitly instructed to review a broader scope.
Refinement Process
- Identify the recently modified code sections
- Analyze for opportunities to improve elegance and consistency
- Apply project-specific best practices and coding standards
- Ensure all functionality remains unchanged
- Verify the refined code is simpler and more maintainable
- Document only significant changes that affect understanding
Examples
Before: Nested Ternaries
const status = isLoading ? 'loading' : hasError ? 'error' : isComplete ? 'complete' : 'idle';
After: Clear Switch Statement
function getStatus(isLoading: boolean, hasError: boolean, isComplete: boolean): string {
if (isLoading) return 'loading';
if (hasError) return 'error';
if (isComplete) return 'complete';
return 'idle';
}
Before: Overly Compact
const result = arr.filter(x => x > 0).map(x => x * 2).reduce((a, b) => a + b, 0);
After: Clear Steps
const positiveNumbers = arr.filter(x => x > 0);
const doubled = positiveNumbers.map(x => x * 2);
const sum = doubled.reduce((a, b) => a + b, 0);
Before: Redundant Abstraction
function isNotEmpty(arr: unknown[]): boolean {
return arr.length > 0;
}
if (isNotEmpty(items)) {
// ...
}
After: Direct Check
if (items.length > 0) {
// ...
}
Подключить через AnyModel API
Скилл работает на той модели, которую использует агент. Подключите Claude Code, Codex или Cursor к AnyModel и запускайте его на Claude, GPT, Gemini и других моделях по одному ключу — оплата за токены, без подписки.
AnyModel