agentleFS
HybridAIOneHybridAIOne/hybridclaw/skills/code-simplification/SKILL.md

code-simplification

Skill157 starsChanged 7 months agoMITView on GitHub

Refactor code to reduce complexity and duplication without changing behavior.

46 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use constraint-driven-development, observability-and-instrumentation and 10 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.
  • vinvcnSkill

    constraint-driven-development

    把一个项目的质量线确立为书面契约,并阻止 agent 悄悄降低它。通过访谈确定用户在意哪些维度,当用户心里没有数字时提供合理的默认阈值,把一切记录进 CONSTRAINTS.md,并盯住 diff 中质量线被削弱的迹象——新增的 @ts-ignore 或 eslint-disable 抑制注释、被跳过或删除的测试、被剥掉的断言、未实现的 stub、被调低的阈值。当没有任何质量线被写下来时使用;当用户说 "set up constraints" 或 "define our standards" 时;当用户希望把他们在意的维度——无障碍性、Web 性能、覆盖率——设置成被强制执行的约束时;当 agent 为了变绿不断静默检查或跳过测试时;当你需要一个覆盖率或性能阈值却不知道该选什么数字时;或者当 agent 写下的代码超出任何人会读的体量时。

    Also in 4 projects that use this

  • borhen68Skill

    observability-and-instrumentation

    Instruments code so production behavior is visible and diagnosable. Use when adding logging, metrics, tracing, or alerting. Use when shipping any feature that runs in production and you need evidence it works. Use when production issues are reported but you can't tell what happened from the available data.

    Also in 13 projects that use this

  • mycelium-hqSkill

    doubt-driven-development

    Use when correctness matters more than speed: about to commit non-trivial code, make an architectural call under uncertainty, work in unfamiliar code, or assert what the compiler cannot check (''this is safe'', ''thread-safe'', ''this scales'', ''matches the spec''). Strongest on high-stakes surfaces (production deploys, security-sensitive logic, data migrations, irreversible operations) and when the user asks to sanity-check, red-team, double-check, or get a second opinion on a decision.

    Also in 19 projects that use this

  • galandoSkill

    source-driven-development

    Version-aware, source-driven development — fetch official docs before writing framework code

    Also in 23 projects that use this

  • luischanciSkill

    interview-me

    Interactive interview to formalize a research idea into a structured specification with hypotheses and empirical strategy.

    Also in 16 projects that use this

  • Jonathan0823Skill

    minimalist-ui

    Clean editorial-style interfaces. Warm monochrome palette, typographic contrast, flat bento grids, muted pastels. No gradients, no heavy shadows.

    Also in 4 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 45 edited versions we read keep these.

  • 16

    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
  1. Distinctive:

    Use this skill for deeper code simplification work while preserving current behavior.

    line 20
  2. Distinctive:

    Read the surrounding code, types, and tests before editing.

    line 30
  3. Distinctive:

    Stop when the code is materially clearer, not when it is merely different.

    line 34
  4. Distinctive:

    Prefer deleting code over adding a new abstraction when both solve the problem.

    line 47
  5. Distinctive:

    Keep refactors small enough that failures are easy to localize.

    line 52
  6. Distinctive:

    Use existing project patterns instead of inventing a new style.

    line 53
  7. Distinctive:

    Avoid introducing generic helpers until there are at least a few stable call sites that justify them.

    line 54
  8. Distinctive:

    If the code is complex because of a real domain constraint, document that before trying to flatten it away.

    line 56
  9. Distinctive:

    Use whichever move makes the code simpler without broad churn:

    line 61
  10. Distinctive:

    Before changing anything, identify the most relevant checks.

    line 72
  11. Distinctive:

    When reporting simplification work, explain:

    line 86
  12. Distinctive:

    If the requested simplification is too risky without first adding tests, say so directly and recommend the smallest safe precursor change.

    line 93
  13. Distinctive:

    Do not mix simplification with unrelated feature work.

    line 98
  14. Distinctive:

    Do not create a framework-sized abstraction to remove a few repeated lines.

    line 99
  15. Distinctive:

    Do not collapse meaningful names into shorter but less clear code.

    line 100
  16. Distinctive:

    Do not rewrite a large module in one pass when incremental cleanup is possible.

    line 101

“Common” is measured: kept by at least 6 in 10 of the 45 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

Use this skill for deeper code simplification work while preserving current behavior.

This is intentionally narrower than a generic "simplify" skill: it is for behavior-preserving refactors in a live codebase, with explicit attention to tests, surrounding types, and incremental validation.

Default Workflow

  1. Identify the exact behavior that must stay the same.
  2. Read the surrounding code, types, and tests before editing.
  3. Establish a baseline with the smallest relevant checks.
  4. Simplify in small reversible steps.
  5. Re-run validation after each meaningful change.
  6. Stop when the code is materially clearer, not when it is merely different.

What to Simplify

Prioritize complexity that makes defects more likely:

  • deep nesting that can become guard clauses
  • duplicated logic that can become one local helper
  • conditionals split across too many locations
  • wrappers or abstractions with no real caller benefit
  • long functions that can be split by responsibility
  • state transitions that are hard to follow or partially duplicated

Prefer deleting code over adding a new abstraction when both solve the problem.

Working Rules

  • Preserve behavior first; simplification is not a license for feature changes.
  • Keep refactors small enough that failures are easy to localize.
  • Use existing project patterns instead of inventing a new style.
  • Avoid introducing generic helpers until there are at least a few stable call sites that justify them.
  • If the code is complex because of a real domain constraint, document that before trying to flatten it away.

Common Moves

Use whichever move makes the code simpler without broad churn:

  • convert nested if chains into early returns
  • extract one focused helper from repeated branches
  • replace boolean flag tangles with clearer named conditions
  • inline one-off wrappers that only obscure data flow
  • split data gathering from side effects
  • rename unclear variables when the current names hide intent

Validation

Before changing anything, identify the most relevant checks. Typical examples:

git diff --stat
npm run typecheck
npm run test:unit

Replace generic commands with repo-native validation after inspecting the project. If tests are missing for the behavior you are simplifying, add or note that gap before making broad structural changes.

Output Expectations

When reporting simplification work, explain:

  1. what complexity was removed
  2. what behavior was intentionally preserved
  3. what validation was run
  4. any remaining complexity that should stay for now

If the requested simplification is too risky without first adding tests, say so directly and recommend the smallest safe precursor change.

Pitfalls

  • Do not mix simplification with unrelated feature work.
  • Do not create a framework-sized abstraction to remove a few repeated lines.
  • Do not collapse meaningful names into shorter but less clear code.
  • Do not rewrite a large module in one pass when incremental cleanup is possible.

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.