agentleFS
dvy1987dvy1987/agent-loom/.agents/skills/code-simplification/SKILL.md

code-simplification

Skill4 starsChanged 3 months agoMITView on GitHub

Simplify application code for clarity without changing behavior — refactor after tests pass, reduce nesting and duplication, match project conventions. Load when refactoring for readability, cleaning up after a feature ships, or when code review flags complexity. Also triggers on "simplify this code", "code simplification", "make this easier to read", "reduce complexity", "refactor for clarity". Not for compress/split/prune-skill (skill-library files). Pairs with technical-debt-audit.

84 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use constraint-driven-development, architecture-decision-records and 8 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

  • 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

  • silvainfmSkill

    marketing-ideas

    When the user needs marketing ideas, inspiration, or strategies for their SaaS or software product. Also use when the user asks for 'marketing ideas,' 'growth ideas,' 'how to market,' 'marketing strategies,' 'marketing tactics,' 'ways to promote,' or 'ideas to grow.' This skill provides 140 proven marketing approaches organized by category.

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

11 rules. 0 are common, 9 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 78 edited versions we read keep these.

  • 9

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never change observable behavior — same inputs, outputs, errors, side effects, ordering.

    line 29
  2. Distinctive:

    Run tests after each simplification.

    line 30
  3. Distinctive:

    Default scope: code touched in the current task — no drive-by refactors unless asked.

    line 31
  4. Distinctive:

    Do not simplify code you do not understand — read callers, tests, and blame first.

    line 33
  5. Very specific:

    If simplifying code with annotated simplify-ignore blocks, register hooks from hooks/SIMPLIFY-IGNORE.md before reads/edits.

    line 43
  6. Distinctive:

    Before changing anything, answer:

    line 47
  7. Distinctive:

    Do tests define expected behavior?

    line 51
  8. Distinctive:

    If you cannot answer, read more context — do not simplify yet.

    line 54
  9. Distinctive:

    If "simplified" code is harder to read, revert.

    line 70
  10. Very specific:

    Read tests + callers. Extract guard clauses (one commit, tests green).

    line 124
  11. Distinctive:

    No changes — citation audit passed.

    line 158

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

You reduce application-code complexity while preserving exact behavior. Goal: faster comprehension for the next reader — not fewer lines for its own sake.

Hard Rules

Never change observable behavior — same inputs, outputs, errors, side effects, ordering. Run tests after each simplification; revert if tests fail or need changing to pass. Default scope: code touched in the current task — no drive-by refactors unless asked. Separate refactoring commits from feature/bugfix commits. Do not simplify code you do not understand — read callers, tests, and blame first.

500 lines touched → prefer codemods/AST tools over manual edits. Protected blocks (simplify-ignore-start / end) must stay hidden — wire hooks/simplify-ignore.sh in Claude Code or read references/simplify-ignore.md.


Workflow

Step 0 — Optional: protect hot paths (Claude Code)

If simplifying code with annotated simplify-ignore blocks, register hooks from hooks/SIMPLIFY-IGNORE.md before reads/edits. Crash recovery: echo '{}' | bash hooks/simplify-ignore.sh.

Step 1 — Understand (Chesterton's Fence)

Before changing anything, answer:

  • What is this code's responsibility? Who calls it?
  • What edge cases and error paths exist?
  • Do tests define expected behavior?
  • Why might it look this way? (performance, platform, history)

If you cannot answer, read more context — do not simplify yet.

Step 2 — Identify opportunities

Scan for structural complexity, naming issues, redundancy — see references/simplification-patterns.md for the signal table.

Step 3 — Apply incrementally

For each change: edit → run test suite → commit or continue. One simplification per commit when possible.

Step 4 — Verify the whole

  • Is the result genuinely easier to understand?
  • Consistent with project conventions (AGENTS.md, neighboring files)?
  • Diff reviewable with no unrelated changes?
  • If "simplified" code is harder to read, revert.

When NOT to use

  • Code already clear — don't simplify for sport
  • Performance-critical path where simpler code is measurably slower
  • About to delete/rewrite the module entirely
  • Skill-library SKILL.md files — use compress-skill / split-skill instead

Gotchas

  • Simplification that requires test changes usually changed behavior.
  • Inlining a well-named helper hurts readability.
  • Fewer lines ≠ simpler (nested ternaries prove this).
  • Mixed refactor + feature PRs are hard to review and revert.

Common Rationalizations

ExcuseReality
"It works, don't touch it"Hard-to-read working code is expensive on every future fix.
"Fewer lines is always simpler"Comprehension speed matters, not line count.
"I'll simplify unrelated code too"Unscoped diffs risk regressions outside the task.
"Types make it self-documenting"Types show structure; names show intent.
"Refactor while adding the feature"Split PRs — mixed changes hide bugs.

Output Format

## Code simplification — [scope]

Before: [brief complexity summary]
Changes: [numbered list]
Tests: [command] → [pass/fail]
Commits: [advised messages]
Reverted: [any attempts that failed verification]

Examples

<examples> <example> <input>This handler has four levels of nesting after the feature landed; tests pass.</input> <output> Read tests + callers. Extract guard clauses (one commit, tests green). Rename `data` → `orderPayload` (second commit). Stop — out of scope for unrelated modules. </output> </example> </examples>

Verification

  • All existing tests pass without modification
  • Build/lint clean; no new warnings
  • Each change is incremental and reviewable
  • Scope limited to task-related files (unless user broadened)
  • No error handling removed or weakened
  • Simplified code matches project conventions

Red Flags

  • Simplification required test changes that alter behavior
  • Well-named helper inlined for fewer lines only
  • Nested ternaries introduced to reduce line count
  • Refactor bundled unrelated behavior changes

Reference Files

  • references/simplification-patterns.md: Pattern signal table — read at Step 2.
  • references/simplify-ignore.md: Block protection hooks + annotation syntax — read when code has simplify-ignore markers.
  • hooks/SIMPLIFY-IGNORE.md: Full setup, examples, limitations (repo root).

Prune Log

Last pruned: 2026-07-04

  • No changes — citation audit passed; content current (improve-skills full pass 2026-07-04)

Impact Report

Scope: [files] | Simplifications: N | Tests: [pass/fail]
Reverts: N | Separate refactor commit: [yes/no]

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.