Install
openclaw skills install @linkxzhou/simplify-code-allSimplify, clean up, and refactor existing code in any mainstream language (JS/TS, Python, Java, Go, Rust, C#, C/C++, PHP, SQL, Bash, and more) while preserving behavior and public APIs. Use whenever the user asks to simplify, tidy, refactor, de-nest, deduplicate, remove dead code, shorten code without changing behavior, polish recently written code, modernize syntax safely, or fix code smells (god class, feature envy, primitive obsession), or pastes code saying "make this cleaner" — including 简化代码, 精简代码, 重构, 代码重构, 优化代码可读性, 整理代码, 代码整洁, 去除重复代码, 减少嵌套, 代码坏味道, 这段代码太乱了. Not for performance tuning, bug fixes, new features, translating between languages, configuring linters/formatters, writing tests as the main task, general code review or security audits (read-only simplification assessments are supported), or prose editing (性能优化、修 bug、新功能、代码翻译、配置 lint、写单测、代码审查、文章精简).
openclaw skills install @linkxzhou/simplify-code-allMake code easier to read and change without changing what it does. The target is the smallest readable equivalent: fewer concepts, duplicated knowledge, nesting levels, and pointless hops — not the fewest characters. Small safe steps beat big rewrites, because each step can be checked on its own.
Rules 1–2 outrank everything else in this skill, including the checklists in references/. Users ask for cleanup expecting to merge it without re-testing the world; a silent behavior change betrays that trust.
Result, null→exception, parameter objects, and newtypes are API changes: propose, don't apply.AGENTS.md / CLAUDE.md, linter/formatter config, and neighbouring code; they beat generic advice here because consistency within a codebase matters more than any one style. Project lint/formatter rules also outrank this skill's stylistic preferences (including no nested ternaries): if de-nesting triggers max-depth or another lint rule, try a cohesive helper; otherwise retain the existing form — don't disable lint or rewrite its config. Let the formatter decide layout; hand-formatting creates diff noise that hides the real changes. Use only syntax the configured runtime/compiler supports; don't add dependencies or change config for cleanup.references/assessment.md for scope, priorities, and reporting; this is not a general correctness/security audit.references/assessment.md when the repository is large or verification is constrained.For read-only assessments, steps 2/6 inspect existing test commands and available evidence; don't add tests or run commands that mutate the checkout. Step 5 produces proposals rather than edits. State the mode and sampled scope before reporting findings.
export, pub, public, __all__, package entry points, callers in other modules).0, '', false, null/None/nil/undefined, NaN, negatives, empty and duplicate collections, duplicate keys, ties, unknown enum values, inherited properties, paths with spaces, size limits.references/rules.md for the full catalogue and §20 for the minimum-code procedure.references/languages.md, then read only the section for the language at hand in languages-tier1.md or languages-tier2.md. Each section lists common redundancy, the smaller replacement, and when it stops being equivalent.any, adding generics, narrowing nullability), since those break compilation in ways reasoning misses. Then review every rewritten line against references/behavior-traps.md and ask: which concrete input makes old and new differ? If one exists, revert only that step's own edits or flag it; never reset unrelated user changes. Compare failures/warnings against a pre-edit baseline. Missing/old tools, heavy builds, and untested platforms require explicitly partial verification, not a success claim; follow references/assessment.md.User asked for a risky change? (e.g. "replace || with ??", "strict comparisons everywhere", "use Promise.all") Apply the safe parts. For each unsafe part, decline or ask, citing a concrete input whose result would change.
Summary: <what was simplified>; behavior/API unchanged | changes needing approval listed below.
Changes:
- <rule/category>: <what and why, one line each>
Not changed: <tempting edits skipped and why (API, semantics, scope)>
Needs approval: <proposed behavior/API changes with the input that would differ> (omit if none)
Bugs found (not fixed): <file:line, suspected/confirmed, reproduction or reasoning; keep separate from simplifications> (omit if none)
Scope: <mode, files/modules sampled, revision if known, excluded areas; no repository-wide claim from a sample>
Verification: <each command actually run + result>; <what was not run and why>; <edge inputs checked by reasoning>
Then show the diff or the rewritten code. For a no-change result, state why the code is already minimal and stop. Keep it short.
Apply freely to private/local code; at public boundaries only propose.
continue, inverted conditions; aim for ≤2 levels.if c return true else false → return c (when c is boolean); merge branches with identical bodies; drop single-use temporaries and pass-through wrappers that add no meaning; replace hand-written stdlib operations only when semantics match exactly (check toMap, Object.keys, sort, Promise.all in the traps file).with/using/defer/RAII/try-with-resources when cleanup order and exceptions stay equivalent; never swallow errors that were previously raised.| File | Read when |
|---|---|
references/languages.md → languages-tier1.md / languages-tier2.md | Always, for the one language being edited (section only). |
references/behavior-traps.md | Step 6, for every rewritten line. |
references/rules.md | Planning non-trivial refactors; §20 for minimum-code decisions; §19 smell → refactoring map. |
references/examples.md | Unsure whether a rewrite is safe; contains safe, propose-only, and reject/leave-alone examples plus report samples. |
references/sources.md | User asks where a rule comes from. |
references/assessment.md | Read-only simplification assessments, large-repository sampling, priority/risk ratings, lint conflicts, unavailable tools, and partial/platform verification. |