agentleFS
subhash-arabhisubhash-arabhi/saas-playbook/skills/code-simplification/SKILL.md

code-simplification

Skill1 starsChanged 30 days agoMITView on GitHub

Simplifies code for clarity without changing behavior. Runs before a PR over the branch's changes, or on request. Use when code works but is harder to read, maintain or extend than it should be.

83 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use constraint-driven-development, performance-optimization and 9 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.
  • MrCipherSmithSkill

    constraint-driven-development

    Use when a project needs a persistent, measurable quality bar — starting a project without documented standards, 'set up constraints', or when coverage/perf/a11y thresholds get re-debated per-PR. Produces CONSTRAINTS.md with enforceable numbers, ratchets, and a guard against silent weakening. NOT for throwaway prototypes or a one-off CI setup.

    Also in 16 projects that use this

  • barisariburnuSkill

    performance-optimization

    Complete performance optimization guide for Next.js applications including frontend, backend, database, caching, and general optimization strategies. Use when improving performance, reducing bundle size, optimizing queries, or implementing caching.

    Also in 47 projects that use this

  • GSA-TTSSkill

    architecture-decision-records

    Load when a user wants architecture decision records (ADRs) drafted from requirements or a design discussion, asks which decisions need an ADR, or wants an ADR draft reviewed for one-sided trade-offs, weak alternatives or missing requirement links. Not for setting up a project's whole documentation system (project-documentation-system).

    Also in 4 projects that use this

  • JohnJBorenSkill

    ci-cd

    CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies

    Also in 3 projects that use this

  • OpenAISkill

    security-best-practices

    Perform language and framework specific security best-practice reviews and suggest improvements. Trigger only when the user explicitly requests security best practices guidance, a security review/report, or secure-by-default coding help. Trigger only for supported languages (python, javascript/typescript, go). Do not trigger for general code review, debugging, or non-security tasks.

    Also in 3 projects that use this

  • GitHubSkill

    conventional-commit

    Prompt and workflow for generating conventional commit messages using a structured XML format. Guides users to create standardized, descriptive commit messages in line with the Conventional Commits specification, including instructions, examples, and validation.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 5 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 77 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Project rules first: If the project has .agents/rules/ (installed with the SaaS playbook), read .agents/rules/git.md and …

    line 8
  2. Distinctive:

    On request: when the user asks, or acts on a review recommendation.

    line 19
  3. Distinctive:

    Don't simplify code that is already clean, code you don't yet understand, performance-critical code where the simpler version is measurably …

    line 21
  4. Distinctive:

    Scope: only code changed on the branch.

    line 25
  5. Distinctive:

    Follow project conventions,: not your preferences. Read agent instructions, rules and linter config.

    line 38
  6. Distinctive:

    Don't over-simplify: don't inline a helper that names a concept, merge unrelated functions, remove the wrapper tests fake around an outside …

    line 40

“Common” is measured: kept by at least 6 in 10 of the 77 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
<!-- Adapted from addyosmani/agent-skills@1401c8b (MIT, see licenses/). Changes: a short pass before each PR, separate steps/commits instead of separate PRs, project conventions, language-agnostic examples, trimmed; layered: general guidance here, playbook decisions in .agents/rules/. -->

Project rules first. If the project has .agents/rules/ (installed with the SaaS playbook), read .agents/rules/git.md and .agents/rules/repo-structure.md and follow them: they override this skill where they differ. Without them, follow this skill as written.

Code Simplification

Inspired by the Claude Code Simplifier plugin.

Make code easier to read, change and debug while keeping its behaviour exactly the same. The goal is faster comprehension, not fewer lines. Test for each change: would someone new understand it faster than the original?

When it runs

  • Before a PR: a short pass over code changed on the branch (git diff <base>...HEAD), before tests and review (in the playbook, step 1 of the pre-PR check).
  • On request: when the user asks, or acts on a review recommendation.

Don't simplify code that is already clean, code you don't yet understand, performance-critical code where the simpler version is measurably slower, or code outside the branch's changes unless asked.

Before a PR

  1. Scope: only code changed on the branch. Never tests, generated code (e.g. the OpenAPI client), migrations already applied anywhere, or config.
  2. One simplification at a time, running the relevant tests after each.
  3. Commit what passes separately from other work, e.g. Simplify <area> (one per area, or one for a small pass).
  4. If a test fails, revert that simplification and move on. Simplification never blocks the PR.
  5. Keep it short: a few minutes, never longer than the reviews. Only obvious, high-value changes. Judgement calls (restructuring UI data flow, splitting a module, changing a public interface) go in the report as suggestions, not applied.
  6. Run the full suite, build and linter afterwards: all pass, no new warnings, tests unmodified.
  7. Report what was simplified (commits) and what was reverted or only suggested.

Rules

  • Preserve behaviour exactly: same output for every input (including empty, null, zero), same errors, same side effects and ordering. If unsure, don't.
  • If a test needs changing, you changed behaviour. Revert.
  • Never remove or weaken error handling to make code look cleaner.
  • Follow project conventions, not your preferences. Read agent instructions, rules and linter config; copy how neighbouring code handles imports, function style, naming, errors and type annotations. Don't rename things to suit your taste.
  • Clarity over cleverness. A compact expression that needs a mental pause loses to explicit code.
  • Don't over-simplify: don't inline a helper that names a concept, merge unrelated functions, remove the wrapper tests fake around an outside service, or chase line count.
  • Remove speculative abstractions that nothing uses now.
  • Leave no dead code behind (unused imports, unreachable branches).
  • Keep refactoring separate from feature or bug-fix work: separate steps and commits. The diff contains only simplifications.
  • Rule of 500: a refactor touching more than 500 lines uses automation (codemods, AST transforms, scripted replacements) and is its own piece of work (its own plan), not part of a pre-PR pass.

Process

  1. Understand first (Chesterton's Fence). Know the code's responsibility, its callers and callees, edge cases and error paths, the tests that define it, and why it was written this way (check git blame and the plan or issue). If you can't answer these, read more.
  2. Find opportunities:
    • Nesting 3+ levels → guard clauses or helpers.
    • Functions 50+ lines with several jobs → split into named functions.
    • Nested ternaries → if/else, switch/match, or a lookup table.
    • Boolean flag params (do_thing(true, false)) → named options or separate functions.
    • Same check in several places → a named predicate.
    • Same 5+ lines in several places → a shared function.
    • Generic, abbreviated or misleading names → descriptive names (universal abbreviations like id, url are fine).
    • Comments saying what → delete. Comments saying why → keep.
    • Dead code, pass-through wrappers (unless tests fake them), one-strategy patterns, redundant casts → remove.
  3. Apply incrementally: change, test, keep or revert. Never batch untested changes.
  4. Step back: is the result genuinely easier to read, consistent with the codebase, and a clean diff a reviewer would approve? If not, revert.

For before/after examples of each pattern, read references/patterns.md.

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.