agentleFS
jacksonwilliamsvajacksonwilliamsva/kiro-skills-library/skills/code-simplification/SKILL.md

code-simplification

Skill2 starsChanged 7 months agoMITView on GitHub

Use when refactoring code for clarity without changing behavior, when code works but is harder to read or maintain than it should be, or when reviewing code that has accumulated unnecessary complexity

46 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

Used with

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

  • 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

  • OpenAISkill

    image-to-code

    Implement a selected image, screenshot, mockup, or Image Gen reference as a faithful, responsive frontend.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

3 rules. 2 are common, 1 is distinctive, and 0 are very specific to this project.

  • 2

    Common

    Most of the 45 edited versions we read keep these.

  • 1

    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. Common:

    Don't change what code does — only how it's expressed.

    line 13
  2. Distinctive:

    Before changing or removing anything, understand why it exists.

    line 22
  3. Common:

    Default to simplifying recently modified code.

    line 25

“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

Reduce complexity while preserving exact behavior. Not fewer lines — code a new team member understands faster.

Five Principles

1. Preserve Behavior Exactly

Don't change what code does — only how it's expressed. Inputs, outputs, side effects, error behavior, and edge cases must remain identical. If unsure, don't make the change.

2. Follow Project Conventions

Simplification means consistency with the codebase, not imposing preferences. Study neighboring code for naming, error handling, and idioms. Simplification that breaks project consistency is churn.

3. Prefer Clarity Over Cleverness

Explicit beats compact when the compact version requires a mental pause. Early returns over deep nesting. Named functions over inline lambdas. Readable mappings over chained ternaries.

4. Chesterton's Fence

Before changing or removing anything, understand why it exists. Check git blame. If you can't explain the original reason, you're not ready to simplify.

5. Scope to What Changed

Default to simplifying recently modified code. Avoid drive-by refactors of unrelated code unless explicitly asked. Unscoped simplification creates noisy diffs and risks regressions.

Simplification Workflow

  1. Understand first — What does it do? What calls it? What are the edge cases? Why was it written this way?
  2. Identify opportunities — Deep nesting, long functions, generic names, duplicated logic, dead code, over-engineered patterns
  3. Apply incrementally — One simplification at a time. Run tests after each. Separate refactoring commits from feature/bugfix commits.
  4. Verify — Use the verification-before-completion skill. All existing tests must pass without modification. Build succeeds. Linter passes. Diff is clean.

Anti-Rationalization Table

RationalizationReality
"It's working, no need to touch it"Hard-to-read code is hard to fix when it breaks
"Fewer lines is always simpler"A 1-line nested ternary is not simpler than a 5-line if/else
"I'll simplify this unrelated code too"Unscoped simplification creates noisy diffs and risks regressions
"This abstraction might be useful later"Speculative abstractions are complexity without value — remove and re-add when needed
"The original author must have had a reason"Apply Chesterton's Fence — but accumulated complexity often has no reason
"I'll refactor while adding this feature"Separate refactoring from feature work. Mixed changes are harder to review and revert

Red Flags — STOP If You See

  • Simplification that requires modifying tests to pass (you changed behavior)
  • "Simplified" code that is longer or harder to follow than the original
  • Renaming to match your preferences rather than project conventions
  • Removing error handling because "it makes the code cleaner"
  • Simplifying code you don't fully understand
  • Batching many simplifications into one large commit
  • Refactoring code outside the current task's scope without being asked

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.