reclaim-code-entropy
Find, rank, and safely remove accidental codebase complexity by proving real consumers, dynamic entrypoints, compatibility obligations, duplicate representations, speculative surfaces, and lifecycle ownership. Use when asked to simplify or clean up a repository, reclaim code entropy, reduce over-engineering or redundancy, find deletion candidates, collapse duplicate state/APIs, remove dead or added-then-abandoned code beyond static-tool output, or implement an evidence-backed simplification pass in any language or stack. Also trigger for 代码化简、熵回收、删代码、清理冗余、收敛抽象、去除过度设计. Do not use as a performance audit unless simplification is the stated goal.
Yevanchen · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add Yevanchen/reclaim-code-entropy --skill reclaim-code-entropy技能说明
name: reclaim-code-entropy description: Find, rank, and safely remove accidental codebase complexity by proving real consumers, dynamic entrypoints, compatibility obligations, duplicate representations, speculative surfaces, and lifecycle ownership. Use when asked to simplify or clean up a repository, reclaim code entropy, reduce over-engineering or redundancy, find deletion candidates, collapse duplicate state/APIs, remove dead or added-then-abandoned code beyond static-tool output, or implement an evidence-backed simplification pass in any language or stack. Also trigger for 代码化简、熵回收、删代码、清理冗余、收敛抽象、去除过度设计. Do not use as a performance audit unless simplification is the stated goal.
Reclaim Code Entropy
Treat code entropy as maintenance surface with no current load-bearing reason: extra representations, states, APIs, branches, packages, policies, or tests that the product must keep coherent.
Core rule: a scanner produces candidates; only consumer, ownership, history, and verification evidence justify deletion. Prefer a few proved cuts over a long speculative list. Finding nothing safe to remove is a valid result.
Choose The Mode
- For "audit", "find", "review", or "report", inspect only and return ranked candidates. Do not edit.
- For "apply", "remove", "clean up", "simplify", or "refactor", implement the safest requested cuts and verify them.
- Treat removal of a reachable user capability, supported public API, persisted format, or compatibility path as a product decision. Surface the visible tradeoff before changing it unless the user already made that decision explicitly.
Establish The Contract
- Read repository instructions and the nearest scoped equivalents:
AGENTS.md,CONTRIBUTING, architecture docs, ADRs/RFCs/decision notes, package manifests, and test guidance. - Inspect
git status; preserve unrelated work. Identify generated, vendored, migration, fixture, and public-package paths before classifying code. - Trace the real runtime flow through entrypoints, configuration, registries, dependency injection, events, queues, persistence, processes/workers, and wire protocols.
- In apply mode, discover the repository's actual narrow and broad verification commands and run a proportional baseline when feasible. A red baseline limits what later checks can prove; record it instead of claiming a regression.
Do not simplify away validation at trust boundaries, authorization, security controls, accessibility basics, data-loss prevention, durable-data compatibility, or cleanup that establishes resource quiescence.
Survey For Entropy
Start with large or central production surfaces, not only obvious unused symbols. Use repository-native tools first: rg --files, rg, compiler/linter output, dependency manifests, and git log. Run installed dead-code or dependency tools when useful, but treat every result as a lead.
Look for these candidate classes:
- Unconsumed surface: public methods, exports, events, config keys, hooks, packages, registry notifications, or protocol fields with no production consumer.
- Mirrored fact: two events, caches, summaries, state stores, snapshots, or adapters record the same truth and must be synchronized.
- Speculative generality: unset knobs, fixed feature flags, unused fallbacks, one-implementation interfaces, abandoned stubs, or extension points with no owner.
- Extra route or layer: multiple front doors to one behavior, forwarding-only wrappers, pass-through packages, or helpers that obscure a single caller.
- Lifecycle duplication: several flags, sentinels, promises, queues, or controllers represent one transition such as ready, stopped, settled, flushed, or disposed.
- Misplaced defense: copies, freezes, validators, rollback paths, or hostile-object tests protect a same-process typed handoff rather than an actual trust or ownership boundary.
- Hand-rolled infrastructure: local parsers, retry loops, globbing, framing, diffing, or data structures already covered by the standard library, native platform, or an installed dependency.
- Support-only residue: tests or docs are the only consumers; duplicate expected outputs; obsolete inventories; demo/test packages that impose runtime or publishing cost.
- Added-then-abandoned residue: implementation disappeared but flags, schemas, docs, tests, compatibility branches, or decision notes still describe it.
Do not confuse duplication with necessary independence. Separate backends, adapters, representations, or lifecycle mechanisms may intentionally test a contract or protect distinct owners.
Prove Or Reject A Candidate
For each exact symbol, behavior, or artifact:
- Search its symbol, file path, package name, config key, event/wire string, and alternate call syntax across the whole repository.
- Classify every hit:
- Production: runtime source, shipped configuration, real entrypoints, migrations, operational scripts.
- Non-production: tests, docs, comments, snapshots, generated expected output.
- Ambiguous: examples, fixtures, plugins, reflection, registries, lazy imports, code generation, externally consumed exports. Inspect before classifying.
- Inspect callers and callees, not only search counts. Check dynamic loading, stringly typed dispatch, routes, plugin manifests, DI containers, serialization, environment-keyed lookup, and external package contracts.
- Read history and decision records. Ask what problem created the surface, whether that problem still exists, and what evidence now beats the original rationale.
- Draw ownership for asynchronous or stateful code. Map each state flag, disposer, cancellation path, readiness promise, and terminal outcome to a distinct owner or transition.
- State what capability or behavior the deletion gives up, even if the answer is "none observable".
- Estimate net reduction: code, tests dedicated only to that code, docs, config, generated artifacts, dependencies,