AGENT SKILL

simplify-code

Use when the user asks to "simplify this code", "remove the fluff", or "clean up this over-engineered module", or wants working code that is bloated, duplicated, over-abstracted, or dependency-heavy reduced without changing behavior.

License 许可
MIT
所属仓库
adriancodes/skills
最近更新
2026-11-12
Stars
★ 1
Forks
0

01 前言 Front Matter

name
simplify-code
license
MIT
metadata
{ "summary": "Condenses scoped code by deleting unjustified concepts while preserving maintainability and observable contracts.", "category": "Quality" }
description
Use when the user asks to "simplify this code", "remove the fluff", or "clean up this over-engineered module", or wants working code that is bloated, duplicated, over-abstracted, or dependency-heavy reduced without changing behavior.

02 资源文件 15

03 SKILL.md 正文

Simplify Code

Delete unjustified concepts while preserving observable behavior. Prefer a direct implementation over fewer characters.

Scope

Use for explicit requests to simplify working code, remove duplication, or eliminate shallow wrappers and speculative abstractions.

Simplification authorizes local edits and meaningful verification within the requested scope. Preserve public APIs, persisted formats, errors, and meaningful performance characteristics unless the user authorizes their change.

Use diagnose, when installed, for unknown failures; otherwise establish the cause first. Use review-code, when installed, for read-only assessment. Handle new behavior through the project's implementation workflow. Broad architectural redesign needs a separate scope.

Workflow

  1. Pin the contracts. Read repository instructions, the requested code, callers, tests, and current diff. Preserve user-authored work. Identify exports, outputs, error behavior, mutation, and persistence that callers rely on.

    When behavior tests are absent, disclose the gap. Characterize the relevant behavior before editing using existing tools. Add local checks when they meaningfully protect this cleanup. Honor an explicit no-test or no-write restriction; use inline probes where allowed.

    Ask before installing tooling, crossing scope, or selecting an ambiguous behavior contract. Continue unaffected cleanup while a separate decision is pending.

    Done when the cleanup has a known boundary and a preservation check or explicit evidence limit.

  2. Find deletions that earn their keep. Check references and runtime paths before removing code. Target dead paths, duplicate behavior, pass-through wrappers, single-use machinery, and obsolete supporting artifacts.

    Keep abstractions that own an invariant or isolate actual variation. Reject changes that hide behavior, obscure names, or relocate complexity.

    Done when each proposed removal has evidence beyond line count.

  3. Apply the reduction. Delete dead code, inline shallow indirection, collapse equivalent branches, and reuse existing primitives. Remove newly unused artifacts only within the authorized scope.

    Keep error order, side effects, return shapes, and boundary values intact. Ask before an unrequested contract change. For generated output, change its source or generator instead.

    Done when the scoped reduction is coherent and no reference dangles.

  4. Prove preservation. Run the same characterization checks after editing. Run existing focused tests and affected type, lint, build, or integration checks. Inspect the diff for contract drift and unrelated changes.

    Separate tested behavior from static reasoning. Name missing evidence instead of claiming full preservation from inspection.

    Done when checks pass and each material contract has evidence or a named limitation.

Example

A factory constructs a one-use class whose only method normalizes an email and checks a list. After confirming no caller imports the class or factory, preserve the public function and replace the machinery with:

import assert from "node:assert/strict";

export function isBlockedEmail(email, blockedEmails) {
  const normalize = value => String(value).trim().toLowerCase();
  const blocked = new Set(blockedEmails.map(normalize));
  return blocked.has(normalize(email));
}

assert.equal(isBlockedEmail(" X@Example.com ", ["x@example.com"]), true);
assert.equal(isBlockedEmail("y@example.com", ["x@example.com"]), false);

Run the checks before and after the change. Preserve any additional mutation or performance contract revealed by callers; this example is not permission to change it.

Verification

Report the concrete reduction, changed files, executed checks, and evidence limits. Every edit must preserve the authorized contracts and reduce concepts without making the result harder to read.

Delete before abstracting. Stop where further reduction would change a contract or reduce clarity.

04 同仓库更多 Skills

adriancodes
adriancodes/skills

write-agent-instructions

Make the smallest evidence-backed change to persistent project instructions and test downstream behavior.

★ 1
adriancodes
adriancodes/skills

verify-work

Use when a finished, runnable artifact (a script, config, parser, prompt, or CLI, not a diff under review) must survive hostile input before shipping: the user asks to "verify this script", "find the loopholes", "test this properly against bad input", or asks "is this ready to ship" about one. Also when a shipped artifact failed on an input nobody tried, or when verification so far is a happy-path smoke test.

★ 1
adriancodes
adriancodes/skills

understand-codebase

Use when the user asks to "understand this codebase", "how does this feature work in this repo?", "trace this feature through the code", or needs onboarding, an architecture explanation, or answers about unfamiliar code. Also use for read-only code-path questions before a change.

★ 1
adriancodes
adriancodes/skills

tdd

Use when writing or changing production behavior: implementing a feature, fixing a bug whose cause is already known, or altering stored, transformed, migrated, serialized, or externally transmitted data. Also use when a user says "use TDD", "test first", or "red-green-refactor", and when code is being written before a failing test. For a failure whose cause is unknown, diagnose first.

★ 1
adriancodes
adriancodes/skills

review-session

Review an agent session for evidence-backed friction and the smallest measurable remedies.

★ 1
adriancodes
adriancodes/skills

review-code

Use when a user asks to "review this branch", "review this PR", "review my changes", or "review since main". Also use when asked whether a branch, PR, or diff is ready to merge or ship, and for work-in-progress diffs, staged changes, suspected regressions in a patch, or checking implementation against a specification.

★ 1