agentleFS
mike22890mike22890/opencode-skills-cn/skills/simplify/SKILL.md

simplify

Skill1 starsChanged 59 days agoMITView on GitHub

代码简化与复杂度降低。当需要重构代码、提升可读性、降低圈复杂度、消除重复、简化逻辑、清理代码、让代码更简洁、更易维护、减少嵌套、提取方法、重命名变量、删除死代码、代码瘦身时使用。

119 other projects use a version of this, 2 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use codex-system, design-tracker and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • gaebalaiSkill

    codex-system

    PROACTIVELY consult Codex CLI, your highly capable supporter with exceptional reasoning and task completion abilities. Codex is a trusted expert you should ALWAYS consult BEFORE making decisions on: design choices, implementation approaches, debugging strategies, refactoring plans, or any non-trivial problem. When uncertain, consult Codex. Don't hesitate - Codex provides better analysis. Explicit triggers: "think deeper", "analyze", "second opinion", "consult codex".

    Also in 3 projects that use this

  • gaebalaiSkill

    design-tracker

    PROACTIVELY track and document project design decisions without being asked. Activate automatically when detecting architecture discussions, implementation decisions, pattern choices, library selections, or any technical decisions. Also use when user explicitly says "記録して", "設計どうなってる", "record this". Do NOT wait for user to ask - record important decisions immediately.

    Also in 3 projects that use this

  • mdrubelamin2Skill

    verification-planning

    Plans how to prove a change works or broke nothing: frames the claim, designs an evidence path from the system itself, and requires every check to be able to fail.

    Also in 3 projects that use this

  • devbrother2024Skill

    artifact-design

    단독 self-contained HTML 산출물(랜딩 페이지, 정적 문서·리포트, 독립 대시보드, 데모·게임, 개발 전 UX/UI 대안 비교 목업)을 만들 때 팔레트·타이포그래피·레이아웃을 의도적으로 설계하고 템플릿·AI스러운 디자인을 피하도록 돕는 디자인 가이드. HTML/CSS를 쓰기 전에 로드한다. "랜딩 만들어줘", "이 내용 단일 HTML로 예쁘게", "UX 대안 HTML로 비교해줘", "디자인 잡아줘"처럼 단독 HTML 아티팩트를 만들거나 비교하는 요청에 활성화하고, 기존 앱(React·Vue 등)의 인앱 컴포넌트 수정이나 순수 백엔드·로직 작업에는 쓰지 않는다.

    Also in 3 projects that use this

  • codebycoreySkill

    batch

    Create multiple proposals from free-form feature descriptions. Use when planning several features at once, batch creating proposals, or setting up related changes.

    Also in 4 projects that use this

  • mehd-ioSkill

    dataviz

    Also in 3 projects that use this

  • +3 more from gaebalai

The file

Show its rules and text

We split this skill into the rules it gives an agent

22 rules. 0 are common, 22 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 110 edited versions we read keep these.

  • 22

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    After a feature is working and tests pass, but the implementation feels heavier than it needs to be

    line 19
  2. Distinctive:

    When you encounter deeply nested logic, long functions, or unclear names

    line 21
  3. Distinctive:

    When refactoring code written under time pressure

    line 22
  4. Distinctive:

    When consolidating related logic scattered across files

    line 23
  5. Distinctive:

    After merging changes that introduced duplication or inconsistency

    line 24
  6. Distinctive:

    Don't change what the code does - only how it expresses it.

    line 37
  7. Distinctive:

    Before every change, ask:

    line 39
  8. Distinctive:

    Read AGENTS.md / project conventions

    line 52
  9. Distinctive:

    Keep helpful names even if they cost a few extra lines

    line 64
  10. Distinctive:

    Don't inline away names that carry meaning

    line 70
  11. Distinctive:

    Don't merge unrelated logic into one larger function

    line 71
  12. Distinctive:

    Don't remove abstractions that serve testability or extensibility

    line 72
  13. Distinctive:

    Don't optimize for line count over comprehension

    line 73
  14. Distinctive:

    Default to simplifying recently modified code.

    line 77
  15. Distinctive:

    Before changing or removing anything, understand why it exists.

    line 83
  16. Distinctive:

    If you can't answer these, read more context first.

    line 93
  17. Distinctive:

    Use the proportionate final-state verification plan to check preservation

    line 116
  18. Distinctive:

    Keep it only when the evidence supports preservation

    line 117
  19. Distinctive:

    No behavior, error handling, or side effects changed

    line 128
  20. Distinctive:

    Prefer straightforward TypeScript over clever compression

    line 132
  21. Distinctive:

    Keep refactors tightly scoped to the task or review feedback

    line 135
  22. Distinctive:

    Use a proportionate final-state verification plan for the final diff.

    line 139

“Common” is measured: kept by at least 6 in 10 of the 110 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Code Simplification

何时触发

关键词命中即触发:简化/降复杂度/消重复/减少嵌套/提取方法/重命名/清理/代码瘦身/可读性。

Overview

Simplify code by reducing complexity while preserving exact behavior. The goal is not fewer lines - it's code that is easier to read, understand, modify, and debug. Every simplification must pass a simple test: "Would a new team member understand this faster than the original?"

When to Use

  • After a feature is working and tests pass, but the implementation feels heavier than it needs to be
  • During code review when readability or complexity issues are flagged
  • When you encounter deeply nested logic, long functions, or unclear names
  • When refactoring code written under time pressure
  • When consolidating related logic scattered across files
  • After merging changes that introduced duplication or inconsistency

When NOT to use:

  • Code is already clean and readable - don't simplify for the sake of it
  • You don't understand what the code does yet - comprehend before you simplify
  • The code is performance-critical and the "simpler" version would be measurably slower
  • You're about to rewrite the module entirely - simplifying throwaway code wastes effort

The Five Principles

1. Preserve Behavior Exactly

Don't change what the code does - only how it expresses it. All inputs, outputs, side effects, error behavior, and edge cases must remain identical. If you're not sure a simplification preserves behavior, don't make it.

Before every change, ask:

  • Does this produce the same output for every input?
  • Does this maintain the same error behavior?
  • Does this preserve the same side effects and ordering?
  • What proportionate final-state verification will reveal a behavior change?

2. Follow Project Conventions

Simplification means making code more consistent with the codebase, not imposing external preferences.

Before simplifying:

  1. Read AGENTS.md / project conventions
  2. Study how neighboring code handles similar patterns
  3. Match the project's style for imports, naming, function style, error handling, and type annotations

Simplification that breaks project consistency is not simplification - it's churn.

3. Prefer Clarity Over Cleverness

Explicit code is better than compact code when the compact version requires a mental pause to parse.

  • Replace nested ternaries with readable control flow
  • Replace dense inline transforms with named intermediate steps when they clarify intent
  • Keep helpful names even if they cost a few extra lines

4. Maintain Balance

Watch for over-simplification:

  • Don't inline away names that carry meaning
  • Don't merge unrelated logic into one larger function
  • Don't remove abstractions that serve testability or extensibility
  • Don't optimize for line count over comprehension

5. Scope to What Changed

Default to simplifying recently modified code. Avoid unrelated drive-by refactors unless explicitly asked.

Process

Step 1: Understand Before Touching

Before changing or removing anything, understand why it exists.

Answer:

  • What is this code's responsibility?
  • What calls it? What does it call?
  • What are the edge cases and error paths?
  • Are there tests that define expected behavior?
  • Why might it have been written this way?

If you can't answer these, read more context first.

Step 2: Look for Simplification Opportunities

Signals:

  • Deep nesting
  • Long functions with mixed responsibilities
  • Nested ternaries
  • Boolean flag arguments
  • Repeated conditionals
  • Generic or misleading names
  • Duplicated logic
  • Dead code
  • Wrappers or abstractions that add no value

Step 3: Apply Changes Incrementally

Make one simplification at a time.

For each simplification:

  1. Make the change
  2. Use the proportionate final-state verification plan to check preservation
  3. Keep it only when the evidence supports preservation

Separate refactoring from feature work whenever possible.

Step 4: Verify the Result

After simplifying, confirm:

  • The code is genuinely easier to understand
  • The diff is clean and reviewable
  • Project conventions still match
  • No behavior, error handling, or side effects changed

Guidance for This Repository

  • Prefer straightforward TypeScript over clever compression
  • Preserve existing runtime behavior, tests, and hooks
  • Favor explicit names and smaller focused helpers when they improve readability
  • Keep refactors tightly scoped to the task or review feedback

Final-state verification

Use a proportionate final-state verification plan for the final diff. Run checks required by repository and release instructions; add or repeat evidence only when the changed scope or a stated uncertainty warrants it.


链式触发(与 code-mastery 配合)

本 skill 通常不独立使用,必须与 code-mastery 链式触发:

[1] code-mastery (找标准) → [2] simplify (自动简化) → [4] /code-review (确认)

触发规则:

  • 用户说"简化这段代码" / "清理" / "重写" → 先调 code-mastery 看标准,再调本 skill 自动简化
  • 用户说"重构"(语义模糊)→ 优先调 code-mastery + 本 skill(小改动),需要 AST 级重构才调 code-refactor-ast
  • /code-review 输出"应该改"项时 → 自动用本 skill 处理能自动化的部分

职责边界:

  • ✅ 本 skill 管:单文件内命名清理、控制流清晰、嵌套变早返回、提取局部函数、删除冗余代码
  • ❌ 不管:跨文件重构、AST 变换、架构解耦、提取接口(→ code-refactor-ast)

铁律:

  • ❌ 跳过 code-mastery 直接调本 skill(可能"简化"出违反大师标准的代码)
  • ❌ 用本 skill 做行为变更(必须 100% 保留行为)
  • ✅ 改动后跑测试 + 调 /code-review 确认

与其他 skill 协作:

  • 在三件套链中位置:[1] code-mastery → [2] simplify → [3] code-refactor-ast → [4] /code-review
  • 处理不了的上抛 [3] code-refactor-ast
  • 不与 [3] 并行调用(必须先 [2] 再 [3])

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.