Command Palette

Search for a command to run...

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

simplify-code

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

Simplify, clean up, or refactor existing code in any language (JS/TS, Python, Java, Go, Rust, C#, C/C++, PHP, SQL, Bash…) while preserving behavior and public…

linkxzhouот linkxzhou578 установок в других каталогах

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

This file is longer than one read (~4,000 characters). Keep reading in chunks until the end (Golden rules, Output format, Quick checklist, References) before editing.

Simplify Code

Make code easier to read and change without changing what it does: the smallest readable equivalent, in small steps that are each checked. Non-negotiable (details in Golden rules below): preserve behavior and public APIs; claim only checks you ran; if a command, delete, or tool is denied, report it and leave it — don't route around it with another tool or script.

Workflow

Run the steps in order. Step labels are for your tracking; the user sees only the Step 7 report.

Step 0 — Mode and scope

  • Do: fix the scope (the code the user named; else this session's changes or the working diff); read AGENTS.md/CLAUDE.md, lint/formatter config, neighbouring code.
  • Output: mode + in-scope files/functions + language(s) (open that section of references/languages.md).
  • Decision: pasted snippet, no repo → Steps 1–7, verifying by reasoning or a tiny script · read-only assessment → R-branch, no edits · repository code → Steps 1–7 in place (references/assessment.md if large or tools are limited) · user asked for a risky change (||→??, === everywhere, Promise.all) → handle in Step 3.

Step 1 — Understand the contract

  • Do: state inputs, outputs, side effects, errors, edge cases; find the public surface (export, pub, public, __all__, callers).
  • Output: a 1–2 sentence contract + public symbols you must not change.
  • Done when: for every in-scope function you know who calls it and what it promises.

Step 2 — Baseline and safety net

  • Do: run existing tests/lint/build/type checker before any edit; with no tests, write a throwaway differential check (old vs new on edge inputs) outside the project or delete it afterwards. Edge inputs: 0, '', false, null/undefined, NaN, negatives, fractions, empty/duplicate collections, duplicate keys, boxed values (new String('x')), sync throws.
  • Output: baseline record (commands + results, or "not runnable: why") + edge-input list.
  • Done when: Step 6 has something to compare against.

Step 3 — Plan by payoff and risk

  • Do: list candidates: dead code → nesting → redundancy → duplication → naming → conditionals → structure (references/rules.md §19–20, language section). Tag each apply (private, provably equivalent), propose (changes behavior/API) or skip. For a risky user request, apply the safe parts and give a concrete input that would change for each unsafe part. If the requested form can't be made exactly equivalent, apply the closest equivalent form instead (e.g. collect(HashMap::new, (m, u) -> m.put(k, v), Map::putAll) when toMap would reject null values or duplicates) or keep the original — never ship a version with a known differing input, even with a note.
  • Output: ordered, tagged plan.
  • Decision: nothing to apply or propose → Already simple exit (change nothing, go to Step 7). Else → Step 4.

Step 4 — Apply one transformation

  • Do: make exactly one behavior-preserving edit from the plan.
  • Output: one small edit.
  • Done when: complete and inside scope → Step 5.

Step 5 — Check that transformation

  • Do: run fast checks (affected tests, type checker after any type change); review the lines against references/behavior-traps.md: which input makes old and new differ?
  • Output: pass, or the differing input.
  • Decision: pass → Step 4 for the next item · any known differing input (found by a check or by reasoning) = fail → revert only this edit, move it to propose with the input · plan done → Step 6.

Step 6 — Final verification

  • Do: re-run the Step 2 set and compare with the baseline; unavailable tools = partial verification, said plainly.
  • Output: each command + result; what wasn't run and why.
  • Decision: new failure vs baseline → revert the causing step, re-run · otherwise → Step 7.

Step 7 — Report

  • Do: write the Output format below in the user's language, then the diff or code. Call out semantics the user might not expect that you kept (e.g. "sync throws from run() are still caught by try/await", "|| kept: 0/'' fall back to defaults").
  • Output: the final message.
  • Done when: every "verified" matches a command you ran; every propose item is under Needs approval with its input; denied commands are listed.

R-branch — read-only assessment (no step may mutate the checkout; see references/assessment.md)

  • R1 Scope: name sampled files/revision and exclusions. Done when the sample is named; no repo-wide claim from a sample.
  • R2 Evidence: Step 1 for the sample; inspect test commands/CI without modifying anything. Done when each area has callers/tests or "unknown".
  • R3 Proposals: Step 3 with every item a proposal (priority, risk, rule, unsafe input). Nothing worth pro
Полный SKILL.md на ClawHub

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

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

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

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

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

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

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

FAQ

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

Simplify, clean up, or refactor existing code in any language (JS/TS, Python, Java, Go, Rust, C#, C/C++, PHP, SQL, Bash…) while preserving behavior and public APIs. Use whenever the user asks to simplify, tidy, clean up, refactor, de-nest, deduplicate, remove dead code, modernize syntax (const/let, ===, ??, streams, async/await, for..of), rewrite a function more concisely, polish recently written code, fix code smells (god class, feature envy, primitive obsession), or "make this cleaner" — including 简化代码, 精简代码, 重构, 整理代码, 代码整洁, 去除重复代码, 减少嵌套, 代码坏味道, 这段代码太乱了; read-only simplification assessments too. Not for performance tuning, bug fixes, new features, porting between languages, lint config, writing tests, security review, or prose (性能优化、修 bug、新功能、代码翻译、写单测、文章精简).

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

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

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

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

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

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