agentleFS
kevinforgekevinforge/orbit/.agents/skills/simplify-code/SKILL.md

simplify-code

Skill5 starsChanged 3 months agoMITView on GitHub

Simplify existing code for clarity without changing behavior. Use after a feature works, during code review, when code is difficult to read or maintain, when logic is deeply nested or duplicated, or when related code should be consolidated.

29 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use competitor-news-monitor, blocked-page-recovery 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.
  • aivrarSkill

    competitor-news-monitor

    Watch named companies for material news; cited digests.

    Also in 7 projects that use this

  • aivrarSkill

    blocked-page-recovery

    Recover blocked/paywalled/WAF'd pages via fallbacks.

    Also in 7 projects that use this

  • john-data-chenSkill

    teams-meeting-pipeline

    Operate the Teams meeting summary pipeline via Hermes CLI — summarize meetings, inspect pipeline status, replay jobs, manage Microsoft Graph subscriptions.

    Also in 8 projects that use this

  • mae616Skill

    p5js

    p5.js(クリエイティブコーディング)のProcessing由来「コードでスケッチ」思想を軸に、setup/drawループ・座標系・インタラクション・パフォーマンス最適化を整理する。p5.js、Processing、クリエイティブコーディング、ジェネラティブアート、インタラクティブ表現、ビジュアルプログラミング、Canvas描画、パーティクル、フラクタル、ノイズ表現に関する相談で必ず使うこと。ユーザーが「コードでアート」「動くビジュアル」「インタラクティブな描画」と言った場合にも適用する。

    Also in 11 projects that use this

  • john-data-chenSkill

    touchdesigner-mcp

    Control a running TouchDesigner instance via twozero MCP — create operators, set parameters, wire connections, execute Python, build real-time visuals. 36 native tools.

    Also in 5 projects that use this

  • Tommy-ywSkill

    popular-web-designs

    54 production-quality design systems extracted from real websites. Load a template to generate HTML/CSS that matches the visual identity of sites like Stripe, Linear, Vercel, Notion, Airbnb, and more. Each template includes colors, typography, components, layout rules, and ready-to-use CSS values.

    Also in 11 projects that use this

  • +4 more from aivrar

The file

Show its rules and text

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 28 edited versions we read keep these.

  • 26

    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:

    after a feature works and tests pass but the implementation feels heavier than necessary.

    line 14
  2. Distinctive:

    when logic is deeply nested, functions are long, or names are unclear.

    line 16
  3. Distinctive:

    when refactoring code written under time pressure.

    line 17
  4. Distinctive:

    when consolidating related logic scattered across files.

    line 18
  5. Distinctive:

    after a merge introduced duplication or inconsistency.

    line 19
  6. Distinctive:

    Do not use it when code is already clear, when you do not yet understand it, when the simpler version would be measurably slower in a …

    line 21
  7. Distinctive:

    Do existing tests pass without modification?

    line 32
  8. Distinctive:

    If unsure, do not simplify until the behavior is understood and covered.

    line 34
  9. Distinctive:

    Read the repository instructions and study neighboring code before editing.

    line 38
  10. Distinctive:

    Prefer explicit code when a compact expression requires a mental pause.

    line 42
  11. Distinctive:

    do not inline a helper that gives an important concept a name.

    line 48
  12. Distinctive:

    do not combine unrelated logic.

    line 49
  13. Distinctive:

    do not remove abstractions that provide extensibility or testability.

    line 50
  14. Distinctive:

    do not optimize for line count.

    line 51
  15. Distinctive:

    Default to simplifying recently modified code.

    line 55
  16. Distinctive:

    If these questions cannot be answered, read more context first.

    line 70
  17. Distinctive:

    Look for signals such as:

    line 74
  18. Distinctive:

    Run the relevant test suite.

    line 98
  19. Distinctive:

    If it passes, continue or create a save-point commit.

    line 99
  20. Distinctive:

    If it fails, revert that simplification and reconsider.

    line 100
  21. Distinctive:

    Do not batch several untested simplifications.

    line 102
  22. Distinctive:

    If the simplified version is harder to understand or review, revert it.

    line 113
  23. Distinctive:

    Stop and reconsider when:

    line 129
  24. Distinctive:

    After the simplification pass, confirm:

    line 141
  25. Distinctive:

    no error handling was removed or weakened.

    line 149
  26. Distinctive:

    no unused imports or unreachable branches remain.

    line 150

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

Simplify Code

Simplify code by reducing complexity while preserving exact behavior. The goal is not fewer lines; it is code that is easier to read, understand, modify, and debug. Every change should pass this test: would a new team member understand it faster than the original?

When to Use

Use this skill:

  • after a feature works and tests pass but the implementation feels heavier than necessary;
  • during review when readability or complexity is a concern;
  • when logic is deeply nested, functions are long, or names are unclear;
  • when refactoring code written under time pressure;
  • when consolidating related logic scattered across files;
  • after a merge introduced duplication or inconsistency.

Do not use it when code is already clear, when you do not yet understand it, when the simpler version would be measurably slower in a performance-critical path, or when the module is about to be discarded entirely.

Principles

Preserve behavior exactly

Change how the code is expressed, not what it does. Preserve all inputs, outputs, side effects, ordering, errors, timing assumptions, and edge cases. Ask before every change:

  • Does every input produce the same output?
  • Is error behavior unchanged?
  • Are side effects and their ordering preserved?
  • Do existing tests pass without modification?

If unsure, do not simplify until the behavior is understood and covered.

Follow project conventions

Read the repository instructions and study neighboring code before editing. Match its conventions for imports, module systems, declarations, naming, errors, and type annotations. A change that breaks local consistency is churn, not simplification.

Prefer clarity over cleverness

Prefer explicit code when a compact expression requires a mental pause. Replace dense ternary chains with guard clauses, named functions, or lookup data. Replace inline reductions with named intermediate values when they make the transformation easier to inspect.

Maintain balance

Avoid over-simplification:

  • do not inline a helper that gives an important concept a name;
  • do not combine unrelated logic;
  • do not remove abstractions that provide extensibility or testability;
  • do not optimize for line count.

Scope to what changed

Default to simplifying recently modified code. Do not perform drive-by refactors outside the current task unless the user explicitly broadens the scope.

Process

1. Understand before touching

Apply Chesterton's Fence: understand why a piece of code exists before removing or changing it. Answer:

  • What is its responsibility?
  • Who calls it and what does it call?
  • What are the edge cases and error paths?
  • Which tests define the behavior?
  • Was it written for performance, a platform constraint, compatibility, or a historical reason?
  • What does git blame reveal about its original context?

If these questions cannot be answered, read more context first.

2. Identify concrete opportunities

Look for signals such as:

  • three or more levels of nesting: use guard clauses or focused helpers;
  • functions longer than roughly 50 lines: split responsibilities;
  • nested ternaries: use conditionals, switch, or lookup objects;
  • boolean flag parameters such as doThing(true, false, true): use options or separate functions;
  • repeated conditions: extract a named predicate;
  • generic or abbreviated names such as data, temp, usr, or cfg: rename to describe their meaning;
  • misleading names, especially a function named get that mutates state;
  • comments that only restate what the code does: remove them;
  • comments that explain why a non-obvious decision exists: keep them;
  • duplicated logic of several lines: extract a shared function;
  • unreachable branches, unused variables, or commented-out blocks: remove after confirming they are dead;
  • wrappers that add no value: call the underlying function directly;
  • factories or strategies with only one meaningful implementation: use the direct approach;
  • redundant type assertions: remove them when inference already proves the type.

3. Apply changes incrementally

Make one simplification at a time. Run tests after each meaningful change. Keep refactoring separate from feature and bug-fix changes.

For each simplification:

  1. Make the change.
  2. Run the relevant test suite.
  3. If it passes, continue or create a save-point commit.
  4. If it fails, revert that simplification and reconsider.

Do not batch several untested simplifications. If something breaks, the cause should be identifiable. If a refactor would touch more than 500 lines, use codemods, AST transforms, or another repeatable automation instead of editing manually at that scale.

4. Verify the result

Compare before and after:

  • Is the new code genuinely easier to understand?
  • Does it follow project conventions?
  • Is the diff clean and reviewable?
  • Would a teammate approve it as a net improvement?

If the simplified version is harder to understand or review, revert it. Not every simplification attempt succeeds.

Common Rationalizations

RationalizationReality
"It works, so do not touch it."Hard-to-read code is harder to fix when it breaks.
"Fewer lines are always simpler."Comprehension speed matters more than line count.
"I will quickly clean up unrelated code too."Unscoped changes create noisy diffs and regression risk.
"The types document everything."Types describe structure; names and code must express intent.
"This abstraction may be useful later."Speculative abstractions add complexity without current value.
"The original author must have had a reason."Check history, but accumulated complexity may simply be iteration residue.
"I will refactor while adding the feature."Mixed changes are harder to review, revert, and understand.

Red Flags

Stop and reconsider when:

  • tests must be modified only to make the simplification pass;
  • the simplified code is longer or harder to follow;
  • names are being changed to match personal preference rather than project convention;
  • error handling is removed because it looks cleaner;
  • the code is not fully understood;
  • many simplifications are batched into one hard-to-review change;
  • unrelated code is being refactored without authorization.

Verification

After the simplification pass, confirm:

  • existing tests pass without modification;
  • the build succeeds without new warnings;
  • the linter and formatter pass;
  • each change is incremental and reviewable;
  • the diff has no unrelated changes;
  • project conventions are followed;
  • no error handling was removed or weakened;
  • no unused imports or unreachable branches remain;
  • a teammate or review agent would approve the result as a net improvement.

This Skill is adapted from Addy Osmani's code-simplification Skill and renamed to avoid colliding with the architecture-focused find-simplifications Skill.

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.