simplify-code
Simplify settled code in a named diff or recent change for reuse, readability, and efficiency while preserving behavior. Use after implementation and before final review; not for a broad redesign or bug fix.
- License 许可
- MIT
- 所属仓库
- yasik/skills
- 最近更新
- 2026-11-08
- Stars
- ★ 3
- Forks
- 1
01 前言 Front Matter
- name
- simplify-code
- description
- Simplify settled code in a named diff or recent change for reuse, readability, and efficiency while preserving behavior. Use after implementation and before final review; not for a broad redesign or bug fix.
02 资源文件 1
- 许可证LICENSE1.0 KB
03 SKILL.md 正文
Simplify code
Distilled from Compound Engineering. Preserve behavior while reducing unnecessary concepts and caller burden. Readability matters more than line count.
Resolve scope
Use the user's named scope first. Otherwise use the current branch changes against its verified base, including in-scope uncommitted edits. If no base is usable, inspect staged and unstaged edits. Outside Git, use the named or recently edited files. If no concrete code scope exists, ask rather than selecting unrelated code. Do not simplify generated, vendored, or lock files. Respect unrelated user edits.
Examine three lenses
- Reuse: find existing behavior-equivalent public types, utilities, and framework primitives. Name the actual replacement. Check callers, re-exports, dynamic use, and downstream guarantees before removing code.
- Clarity: remove redundant state, parameter sprawl, stale compatibility,
wrappers without responsibility, dead exports, and hidden mapping assumptions.
Apply the coding-style rules for constructs that must earn their place
(
coding-style/references/standards/README.md). Separate logical blocks and keep or add comments that explain non-obvious decisions; never delete a useful comment to shorten code. Preserve useful abstractions and deliberate separation; do not merge unrelated responsibilities. - Efficiency: identify repeated I/O, duplicated calls, unnecessary hot-path work, unbounded state, and missing cleanup. Parallelize only genuinely independent operations without changing observable ordering or resource guarantees.
Run these lenses in one focused pass. In a staged implementation, run a pass
after each stage rather than once at the end; small passes keep each review
readable. In a development cycle, leave independent
review to review-code; do not launch a second reviewer pipeline. For standalone
simplification, seek another read only when a specific risk warrants it and the
host permits delegation.
Apply only worthwhile changes
Each change must preserve outputs, errors, side effects, ordering, security, accessibility, and data-loss protection. A shorter serializer is not equivalent until its value semantics are established. If preservation is uncertain, skip and explain the issue; route actual defects to debugging separately.
A superseded unshipped shape may be removed only after checking that no public, persisted, deployed, external, dependent-branch, or other in-repo caller depends on it. Apply caller updates only inside the authorized mutation boundary. Keep explicitly settled design constraints unless new evidence exposes a real defect.
Do not add compatibility for hypothetical future needs or remove validation merely because current happy-path tests pass. Do not turn duplication removal into a new framework that costs more than the duplication.
Verify and finish
Run relevant repository lint/type checks and behavioral checks at the change's blast radius. Broaden checks for shared contracts; reuse still-valid results for unchanged inputs. Fix or undo only simplification-caused regressions. Never relax assertions, weaken types, or skip failures to make cleanup pass.
Report what became easier to understand or reuse, worthwhile changes skipped, and verification actually run. A justified no-change result is successful. Do not use lines deleted or the number of refactors as the success metric.
04 同仓库更多 Skills
terminal-report
Produce beautiful, structured terminal output for a CLI or analysis tool — ANSI colors, aligned data tables, inline bar charts, diverging/centered bars, tagged progress logs, sparklines, and section headers. Use this skill whenever you are building a command-line tool, analysis script, report generator, data dashboard, or status/progress display that prints to a terminal, OR whenever the user wants output to look "polished", "colored", "styled", "like a dashboard", or shows a screenshot of a pretty terminal and asks how to make one. Applies even when the user just says "print the results nicely" or "make a little CLI for this" without naming colors or charts explicitly.
technical-prose
Write and revise technical explanations, design docs, reviews, reports, and progress updates in clear, connected prose. Use when the reader needs to understand a mechanism or decision, or when a draft feels dense, choppy, jargon-heavy, or like compressed implementation notes. Preserve technical meaning while making the reasoning easy to follow.
teach
Teach a complex topic as one complete, self-paced written lesson — chaptered sections the learner reads top to bottom, a deep-dive that slows down on the single hardest concept and breaks it into steps with worked examples, diagrams only where they actually clarify, and real citations for going deeper. Works from an explicit topic ("teach me how Raft consensus works") or from one or more links/papers/docs the user wants to be brought up to speed on — it fetches them, falling back to a browser when a page is paywalled, JavaScript-rendered, or only partially retrievable. Use this whenever the user wants to *understand* something rather than just get an answer: "teach me X", "explain this <link>", "help me understand <topic>", "I want to learn <thing>", "break this down for me", "ELI5 but properly / but deep", or when they drop a URL and ask to be walked through it like a class. Distinct from a quick factual lookup or a terse summary — reach for this when the goal is durable understanding, not a TL;DR.
mermaid-render
Render a Mermaid diagram as a beautiful, optionally animated SVG (and PNG) in a calm editorial style, instead of stock Mermaid output. Supports flowchart, stateDiagram, and sequenceDiagram. Use whenever the user wants to render, draw, beautify, restyle, or "make nice" a Mermaid / flowchart / sequence / state diagram, add animated data-flow to a diagram, or turn a described process or architecture into a polished diagram for a doc, README, or slide. All styling — colors, fonts, shapes, borders, animation — is configurable in one theme file.
dev-docs
Write, rewrite, or review developer documentation to a complete, packaged technical-writing style guide: tone, grammar, punctuation, formatting, procedures, code samples, placeholders, UI text, linking, naming, and a word list of about 700 terms, plus an index of every rule. Use whenever the user asks for developer docs, technical docs, a README, API reference, quickstart, how-to, tutorial, concept page, release notes, docstrings or reference comments, or a docs style review, or wants docs that read like a major platform's documentation. Also use to check a draft against the style guide or to look up a term in the word list.
unit-test-coverage
Select, write, and review meaningful tests of public functions and interfaces. Use when adding behavior, fixing a regression, reviewing test quality, or diagnosing failing tests. Every test must protect a critical behavior or flow; never add tests only to increase coverage.