agentleFS
K95M65K95M65/AI_ONBOARD/skills/simplify-code-safely/SKILL.md

simplify-code-safely

Skill0 starsChanged 4 months agoMITView on GitHub

Simplifies existing code while preserving externally observable behavior, public contracts, and required performance. Use when reducing accidental complexity, removing dead or duplicated logic, clarifying control flow, shrinking an over-engineered change, or performing a focused behavior-preserving refactor; do not use for feature development, architecture replacement, or read-only code review.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    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:

    Read the project instructions, callers, tests, public interfaces, error behavior, side effects, data formats, performance constraints, and …

    line 12
  2. Distinctive:

    Do not collapse distinct domain concepts merely because their current implementations look similar.

    line 27
  3. Distinctive:

    Prefer deletion, direct control flow, precise names, and existing language features.

    line 33
  4. Distinctive:

    Run the narrow checks after each risky transformation.

    line 36
  5. Distinctive:

    Avoid speculative frameworks, generic helpers without a stable concept, broad formatting changes, and dependency upgrades unrelated to the …

    line 39
  6. Distinctive:

    Run focused tests and the relevant broader suite.

    line 44
  7. Distinctive:

    Use a separate reviewer agent when independent code review is requested.

    line 48

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “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 safely

Make the code easier to understand without quietly changing what it does.

Establish the behavior boundary

Read the project instructions, callers, tests, public interfaces, error behavior, side effects, data formats, performance constraints, and compatibility requirements. State the simplification target and what must not change. If behavior is unclear, characterize it with focused tests before refactoring.

Find accidental complexity

Look for:

  • dead code, unreachable branches, stale flags, and unused indirection;
  • duplicated rules that represent the same concept;
  • conditionals that can become early exits or explicit state transitions;
  • abstractions with one caller and no meaningful policy boundary;
  • misleading names, hidden side effects, and values recomputed across layers;
  • comments that compensate for unclear structure rather than explain intent.

Do not collapse distinct domain concepts merely because their current implementations look similar.

Simplify in small steps

  1. Record a passing baseline for the relevant checks.
  2. Make one coherent transformation at a time.
  3. Prefer deletion, direct control flow, precise names, and existing language features.
  4. Preserve public APIs, error semantics, ordering, concurrency, persistence, and security checks unless the user explicitly includes them in scope.
  5. Run the narrow checks after each risky transformation.
  6. Review the final diff for accidental behavior changes and unnecessary churn.

Avoid speculative frameworks, generic helpers without a stable concept, broad formatting changes, and dependency upgrades unrelated to the simplification.

Prove the result

Run focused tests and the relevant broader suite. Compare before/after behavior, and measure performance only when performance is part of the contract. Report what became simpler—deleted branches, reduced state, removed duplication, or clearer ownership—without using line count as the only quality measure.

Use a separate reviewer agent when independent code review is requested. This skill edits code; the reviewer remains read-only.

Finish when the behavior boundary still holds, the diff is smaller or conceptually clearer, and every claimed improvement is visible in the code rather than asserted from taste.

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.