Agent Skillsmohitagw15856/pm-claude-skills › code-simplification

code-simplification

GitHub

用于简化已验证工作的代码,移除过度抽象、死代码和无谓间接,保持行为一致。适用于AI生成代码重构或代码审查前清理,输出简化版及移除清单。

plugins/pm-method/skills/code-simplification/SKILL.md mohitagw15856/pm-claude-skills

Trigger Scenarios

功能上线后要求简化 收到过度设计的AI生成代码 文件变得难以理解 代码审查前的清理阶段

Install

npx skills add mohitagw15856/pm-claude-skills --skill code-simplification -g -y
More Options

Non-standard path

npx skills add https://github.com/mohitagw15856/pm-claude-skills/tree/main/plugins/pm-method/skills/code-simplification -g -y

Use without installing

npx skills use mohitagw15856/pm-claude-skills@code-simplification

指定 Agent (Claude Code)

npx skills add mohitagw15856/pm-claude-skills --skill code-simplification -a claude-code -g -y

安装 repo 全部 skill

npx skills add mohitagw15856/pm-claude-skills --all -g -y

预览 repo 内 skill

npx skills add mohitagw15856/pm-claude-skills --list

SKILL.md

Frontmatter
{
    "name": "code-simplification",
    "description": "Simplify code that works — remove speculative abstraction, dead flexibility, and needless indirection while keeping behaviour identical and verified. Use after a feature lands ('now simplify it'), when AI-generated code arrives over-engineered, when a file has grown hard to follow, or as the cleanup pass before review. Produces a smaller, flatter version with identical behaviour, plus a ledger of what was removed and why it was safe. For finding bugs use code-review-checklist \/ ai-code-review — this skill assumes it works and makes it simple."
}

Code Simplification Skill

Code accretes defensive complexity: abstractions for futures that never came, options nobody passes, indirection that once had a reason. AI-generated code arrives pre-accreted — interfaces with one implementer, config objects with nine unused knobs. Simplification is its own pass with its own rule: behaviour identical, verified; complexity removed, listed.

What This Skill Produces

  • The simplified code — smaller, flatter, same behaviour
  • A removal ledger: each simplification, why it was safe, and what future it forecloses (honestly)
  • Verification evidence that behaviour held

What to Hunt (in order of payoff)

  1. Speculative generality — the interface with one implementation, the parameter always called with the same value, the config option no caller sets, the "pluggable" thing nothing plugs into. Rule: the future that justified it must be on a roadmap, not in an imagination. YAGNI is a removal warrant.
  2. Indirection without insulation — layers that only forward: the wrapper that calls one function, the factory returning one type, the event fired for one listener sitting next door. Each hop costs a reader a jump; collapse hops that don't isolate change.
  3. Dead and duplicate paths — unreachable branches, handled-nowhere flags, the local re-implementation of a utility that exists (grep before believing anything is unique).
  4. Cleverness taxing readers — the nested ternary, the reduce that should be a loop, the regex doing four jobs. Rewrite for the next reader; "fewer characters" is not "simpler".
  5. Flatten control flow — guard clauses over nested ifs; early returns over else-pyramids; splitting the function that needs a comment per section into functions named by those comments.

The Safety Discipline (what makes this different from vandalism)

  • Behaviour-preserving means verified, not asserted: run the full relevant suite before AND after; if coverage is thin over the code being simplified, add the pinning test first — simplifying untested code is refactoring blind.
  • One hunt-class per pass where the code is load-bearing (remove speculation, verify; collapse indirection, verify) — mirrors incremental-implementation's rule.
  • Chesterton's fence check on anything weird: git log/blame the strange bit before deleting it. Some "needless" complexity is a bug fix wearing an odd shape — if the history shows a fix, keep it and comment WHY it's shaped that way instead.
  • Public surface needs a wider net: simplifying exported/shared code means checking callers across the codebase, not just the local file.

Output Format

Simplification: [target]

Verification: [suite/build run before → after: identical] · pinning tests added: [n or none-needed because…]

Removal ledger

What was removed/flattened Class Why safe Future foreclosed (honest)

Kept deliberately: [the weird-but-load-bearing bits, with their Chesterton evidence] Size: [LOC/complexity before → after]

Quality Checks

  • Full verification ran before and after — identical behaviour, evidenced
  • Thinly-tested code got pinning tests before simplification
  • Every removal states the future it forecloses — "none" must be argued, not assumed
  • Strange code was history-checked before deletion (Chesterton's fence)
  • The result is simpler for a READER, not just shorter

Anti-Patterns

  • Do not simplify and change behaviour in one pass — the moment behaviour shifts, this became a rewrite without a spec
  • Do not delete weirdness without checking why it's weird — some of it is a production incident's scar tissue
  • Do not confuse terse with simple — code golf raises the reading tax this skill exists to cut
  • Do not remove flexibility that's actually on the roadmap — YAGNI applies to imagined futures, not planned ones
  • Do not skip the ledger — invisible simplification is indistinguishable from unexplained deletion in review

Version History

  • a38bc30 Current 2026-07-05 11:23

Same Skill Collection

exports/openclaw/360-feedback-template/SKILL.md
exports/openclaw/401k-plan-decoder/SKILL.md
exports/openclaw/ab-test-planner/SKILL.md
exports/openclaw/ab-test-readout/SKILL.md
exports/openclaw/accessibility-audit/SKILL.md
exports/openclaw/account-plan/SKILL.md
exports/openclaw/acquirer-red-team/SKILL.md
exports/openclaw/ad-copy/SKILL.md
exports/openclaw/aeo-optimizer/SKILL.md
exports/openclaw/agenda-or-cancel/SKILL.md
exports/openclaw/agent-design-review/SKILL.md
exports/openclaw/agent-observability-spec/SKILL.md
exports/openclaw/agent-spec/SKILL.md
exports/openclaw/ai-ethics-review/SKILL.md
exports/openclaw/ai-eval-plan/SKILL.md
exports/openclaw/ai-feature-prd/SKILL.md
exports/openclaw/ai-product-canvas/SKILL.md
exports/openclaw/air-quality/SKILL.md
exports/openclaw/altitude-shifter/SKILL.md
exports/openclaw/ambiguity-resolver/SKILL.md
exports/openclaw/analyst-relations-brief/SKILL.md
exports/openclaw/announcement-card/SKILL.md
exports/openclaw/api-docs-writer/SKILL.md
exports/openclaw/api-test-plan/SKILL.md
exports/openclaw/api-versioning-strategy/SKILL.md
exports/openclaw/apology-letter/SKILL.md
exports/openclaw/architecture-decision-record/SKILL.md
exports/openclaw/architecture-diagram/SKILL.md
exports/openclaw/archive-strategy/SKILL.md
exports/openclaw/assumption-bounty/SKILL.md
exports/openclaw/assumption-mapper/SKILL.md
exports/openclaw/async-update-format/SKILL.md
exports/openclaw/auto-repair-estimate-decoder/SKILL.md
exports/openclaw/autopilot-charter/SKILL.md
exports/openclaw/benefits-decoder/SKILL.md
exports/openclaw/bid-tender-review/SKILL.md
exports/openclaw/board-deck-narrative/SKILL.md
exports/openclaw/board-minutes/SKILL.md
exports/openclaw/board-pre-read/SKILL.md
exports/openclaw/bom-cost-review/SKILL.md
exports/openclaw/bookkeeping-categorization/SKILL.md
exports/openclaw/boolean-search-builder/SKILL.md
exports/openclaw/brag-doc/SKILL.md
exports/openclaw/brainstorming/SKILL.md
exports/openclaw/brief-builder/SKILL.md
exports/openclaw/briefing-note/SKILL.md
exports/openclaw/budget-builder/SKILL.md
exports/openclaw/budget-variance-analysis/SKILL.md
exports/openclaw/bug-diagnosis/SKILL.md
exports/openclaw/bug-report/SKILL.md

Metadata

Files
0
Version
471c606
Hash
8cb4d49c
Indexed
2026-07-05 11:23

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-30 23:15
浙ICP备14020137号-1 $방문자$