agentleFS
buildpad-aibuildpad-ai/skills/code-simplification/SKILL.md

code-simplification

Skill1 starsChanged 4 months agoMITView on GitHub

Simplifies code while preserving behavior. Use when code works but is harder to read or maintain than it should be. Use when complexity has accumulated and needs reduction.

46 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

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

  • galandoSkill

    source-driven-development

    Version-aware, source-driven development — fetch official docs before writing framework code

    Also in 23 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

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 45 edited versions we read keep these.

  • 7

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

    After a feature is complete and tests pass, before moving to the next phase

    line 16
  2. Distinctive:

    When NOT to use: Don't simplify code you don't understand yet.

    line 19
  3. Distinctive:

    Before changing anything that seems unnecessary, understand why it exists:

    line 25
  4. Distinctive:

    If a function exceeds ~500 lines, it's almost certainly doing too much.

    line 37
  5. Distinctive:

    Every abstraction has a cost.

    line 41
  6. Distinctive:

    Ensure tests pass: before making any changes

    line 131
  7. Distinctive:

    Run tests: after each change

    line 135

“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

Overview

Reduce complexity while preserving exact behavior. Simplification is not refactoring for its own sake — it's removing accidental complexity that makes code harder to understand, test, and maintain. The goal is clarity, not cleverness.

When to Use

  • Code works but is harder to read or maintain than it should be
  • A function or module has grown too complex
  • After a feature is complete and tests pass, before moving to the next phase
  • During Phase 5 (Polish) of DaaS development

When NOT to use: Don't simplify code you don't understand yet. Don't simplify during active feature development (finish the feature first).

Core Principles

Chesterton's Fence

Before changing anything that seems unnecessary, understand why it exists:

See code that looks wrong or unnecessary
├── Understand why it was written this way
│   ├── Has a good reason → Document the reason, leave it
│   └── Has no good reason → Safe to simplify
└── Don't understand → Research before changing

Rule of 500

If a function exceeds ~500 lines, it's almost certainly doing too much. But extract only when the extracted piece has a clear, independent purpose.

Complexity Budget

Every abstraction has a cost. Before adding one, ask:

  • Does this abstraction serve at least 3 use cases?
  • Is the complexity it adds less than the complexity it removes?
  • Could this be done with a simple function instead?

Simplification Patterns

Remove Dead Code

// Before: Accumulated unused code
function processTask(task: Task) {
  // const legacyFormat = convertToLegacy(task); // Removed in v2
  const result = validate(task);
  // if (USE_OLD_PIPELINE) { ... } // Feature flag removed
  return result;
}

// After: Only live code
function processTask(task: Task) {
  return validate(task);
}

Flatten Nested Logic

// Before: Deeply nested
function getStatus(task: Task) {
  if (task) {
    if (task.completed) {
      if (task.archived) {
        return 'archived';
      } else {
        return 'completed';
      }
    } else {
      return 'pending';
    }
  }
  return 'unknown';
}

// After: Early returns
function getStatus(task: Task) {
  if (!task) return 'unknown';
  if (task.archived) return 'archived';
  if (task.completed) return 'completed';
  return 'pending';
}

Replace Clever Code

// Before: Clever but unclear
const x = ~~(Math.random() * 100);
const y = arr.reduce((a, b) => (a[b] = (a[b] || 0) + 1, a), {});

// After: Clear intent
const x = Math.floor(Math.random() * 100);
const counts: Record<string, number> = {};
for (const item of arr) {
  counts[item] = (counts[item] ?? 0) + 1;
}

Inline Over-Abstractions

// Before: Abstraction for one use
class TaskStatusManager {
  getStatus(task: Task) { return task.status; }
  setStatus(task: Task, s: string) { task.status = s; }
}

// After: Direct and clear
task.status = 'completed';

DaaS-Specific Simplifications

  • Replace custom filter UI with FilterPanel component
  • Replace custom table + pagination with CollectionList
  • Replace manual permission checks with CollectionForm/CollectionList built-in RBAC
  • Replace custom form validation with DaaS extension hooks
  • Replace custom audit trail with DaaS built-in activity logging

Process

  1. Ensure tests pass before making any changes
  2. Identify complexity — what's hard to understand or maintain?
  3. Understand why — Chesterton's Fence check
  4. Make one change at a time
  5. Run tests after each change
  6. Commit each simplification separately
  7. Never mix simplification with behavior changes

Common Rationalizations

RationalizationReality
"It might be needed later"YAGNI. Remove it. If needed later, git has it.
"It's working, don't touch it"Working but unreadable code costs every time someone reads it.
"The abstraction makes it flexible"Unused flexibility is complexity. Simplify to what's actually used.
"I'll just quickly refactor this too"Simplification is its own commit. Don't mix with feature work.

Red Flags

  • Abstractions with only one implementation
  • Functions longer than 50 lines that do multiple things
  • Deep nesting (more than 3 levels)
  • Comments explaining what the code does (instead of the code being self-explanatory)
  • Unused imports, variables, or functions
  • Feature flags for features that shipped months ago

Verification

After simplification:

  • All existing tests still pass (behavior unchanged)
  • Build succeeds
  • No dead code remains
  • Each simplification is a separate commit
  • The "why" is documented for anything that looks unnecessary but was kept

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.