用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill code-simplifier命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | code-simplifier |
| description | > Use when this capability is needed. |
Automated code refactoring that reduces lines while maintaining identical functionality. Focus on deleting code, not writing more.
Determine what to refactor:
git diff --name-only HEAD~3git diff --name-only HEAD~5.Skip: node_modules/, .next/, dist/, build/, vendor/, lockfiles, generated files, test files (unless explicitly asked).
Read each file fully. Evaluate against these smell categories:
| Category | What to Look For |
|---|---|
| Loop bloat | for loops → map/filter/reduce/find/some/every/flatMap |
| Conditional complexity | Nested ifs, missing guard clauses, missing ?. / ?? / ??= |
| Dead code | Unused vars, unreachable branches, redundant returns, unused imports |
| Duplication | Repeated logic (3+ lines appearing 2+ times in same file) |
| Verbose idioms | Missing destructuring, spread, template literals, modern APIs |
| Boolean bloat | if (x) return true; else return false;, double negation, De Morgan |
| Function bloat | Unnecessary wrappers, missing implicit returns, unnecessary IIFEs |
| React smells | Unnecessary fragments, derived state in useState, inline handler duplication |
Rate each file (1-10, lower = better):
| Metric | Measures |
|---|---|
| Complexity | Branch paths: if, else, case, &&, ` |
| Length | Average function length in lines |
| Working Memory | Max simultaneous variables in any function scope |
| Duplication | Repeated logic blocks across the file |
Present findings as a structured report per file:
## File: path/to/file.js
### Metrics
| Metric | Score | Notes |
|--------|-------|-------|
| Complexity | 6/10 | processOrder() has 12 branches |
| Length | 4/10 | Avg 18 lines/function |
| Working Memory | 7/10 | handleSubmit() juggles 8 vars |
| Duplication | 5/10 | Error handling repeated 3x |
### Proposed Changes (N changes, ~M lines saved)
#### 1. [SAFE] Loop → array method (lines 24-31)
**Before** (8 lines):
```js
// current code
After (2 lines):
// refactored code
Lines saved: 6 | Risk: Safe
Tag every change:
- **[SAFE]** — Mechanical transformation, zero behavior change
- **[CAUTION]** — Likely safe but verify (truthiness semantics, evaluation order, side effects)
### 5. Apply Changes
After user approves:
- Apply via Edit tool, one change at a time, largest savings first
- Re-read file after all edits to verify no syntax breakage
- Note if user should run their linter/formatter
## Rules
1. **Never change behavior.** Any ambiguity → mark [CAUTION] and explain the edge case.
2. **Never add code.** Only exception: extracting a helper to DRY 3+ duplications (net lines must still decrease).
3. **Never add comments, docstrings, or type annotations** unless explicitly requested.
4. **Preserve formatting style.** Match existing indentation, quotes, semicolons.
5. **One file at a time.** Complete analysis + review before moving to next file.
6. **Respect the user's stack.** Maintain React conventions in JSX. Don't convert class → functional unless asked.
## Quick Mode
If user says "just fix it" or "auto-apply": skip review table, apply all [SAFE] changes directly. Still present [CAUTION] changes for review.
## Pattern Reference
For detailed before/after patterns, load only when actively refactoring:
- **JavaScript/JSX**: [references/patterns-javascript.md](references/patterns-javascript.md)
---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/BEIRUX) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-16 -->