agentleFS
jars-demojars-demo/jars-skills/skills/simplify/SKILL.md

simplify

Skill0 starsChanged 32 days agoMITView on GitHub

Reducing code to its simplest correct form without changing behaviour: replaces verbose imperative loops with built-in expressions, collapses redundant conditionals, eliminates unnecessary abstraction layers, removes over-engineered patterns, applies early returns to flatten nesting, and spots where a standard library function already does what 40 lines of custom code is doing. Use when you want to simplify code, reduce lines of code, make this shorter, remove over-engineering, flatten nested ifs, replace a loop with a built-in, remove unnecessary abstraction, or make this more readable.

119 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use codex-system, design-tracker 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.
  • gaebalaiSkill

    codex-system

    PROACTIVELY consult Codex CLI, your highly capable supporter with exceptional reasoning and task completion abilities. Codex is a trusted expert you should ALWAYS consult BEFORE making decisions on: design choices, implementation approaches, debugging strategies, refactoring plans, or any non-trivial problem. When uncertain, consult Codex. Don't hesitate - Codex provides better analysis. Explicit triggers: "think deeper", "analyze", "second opinion", "consult codex".

    Also in 3 projects that use this

  • gaebalaiSkill

    design-tracker

    PROACTIVELY track and document project design decisions without being asked. Activate automatically when detecting architecture discussions, implementation decisions, pattern choices, library selections, or any technical decisions. Also use when user explicitly says "記録して", "設計どうなってる", "record this". Do NOT wait for user to ask - record important decisions immediately.

    Also in 3 projects that use this

  • mike22890Skill

    clonedeps

    将项目依赖的第三方库源码克隆到本地,便于深入阅读和调试。当需要查看库的实现细节、阅读源码、调试第三方依赖、理解 SDK/framework 内部机制、查看 node_modules 之外的原始代码、分析开源库架构、学习他人代码、查看依赖的 TypeScript 类型定义时使用。

    Also in 3 projects that use this

  • mdrubelamin2Skill

    verification-planning

    Plans how to prove a change works or broke nothing: frames the claim, designs an evidence path from the system itself, and requires every check to be able to fail.

    Also in 3 projects that use this

  • devbrother2024Skill

    artifact-design

    단독 self-contained HTML 산출물(랜딩 페이지, 정적 문서·리포트, 독립 대시보드, 데모·게임, 개발 전 UX/UI 대안 비교 목업)을 만들 때 팔레트·타이포그래피·레이아웃을 의도적으로 설계하고 템플릿·AI스러운 디자인을 피하도록 돕는 디자인 가이드. HTML/CSS를 쓰기 전에 로드한다. "랜딩 만들어줘", "이 내용 단일 HTML로 예쁘게", "UX 대안 HTML로 비교해줘", "디자인 잡아줘"처럼 단독 HTML 아티팩트를 만들거나 비교하는 요청에 활성화하고, 기존 앱(React·Vue 등)의 인앱 컴포넌트 수정이나 순수 백엔드·로직 작업에는 쓰지 않는다.

    Also in 3 projects that use this

  • codebycoreySkill

    batch

    Create multiple proposals from free-form feature descriptions. Use when planning several features at once, batch creating proposals, or setting up related changes.

    Also in 4 projects that use this

  • +3 more from gaebalai

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 111 edited versions we read keep these.

  • 8

    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:

    If there are no tests, write a characterisation test first — call the function with real inputs, record the output, pin it.

    line 13
  2. Distinctive:

    Never simplify and fix a bug in the same change.

    line 16
  3. Distinctive:

    Before writing any utility function, check the standard library and the project's existing dependencies.

    line 181
  4. Distinctive:

    If none of these apply, remove the layer.

    line 277
  5. Distinctive:

    If the answer is no, remove it.

    line 335
  6. Distinctive:

    Before marking a simplification done:

    line 341
  7. Distinctive:

    Never simplify code you do not understand.

    line 354
  8. Distinctive:

    Remove abstraction layers that add indirection without adding value.

    line 356

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

simplify

Find the simplest correct expression of what the code already does. No behaviour changes.

1. The rule before touching anything

Simplification must produce identical behaviour. Run the tests before and after every change. If there are no tests, write a characterisation test first — call the function with real inputs, record the output, pin it. Then simplify.

Never simplify and fix a bug in the same change. If you find a bug, note it separately.


2. Replace imperative loops with built-ins

The most common source of unnecessary lines. Built-in functions are faster to read, less likely to have off-by-one errors, and optimised by the runtime.

# ❌ 6 lines to filter a list
result = []
for user in users:
    if user.is_active:
        result.append(user)

# ✅ 1 line
result = [u for u in users if u.is_active]

# ❌ 7 lines to build a lookup map
mapping = {}
for item in items:
    mapping[item.id] = item

# ✅ 1 line
mapping = {item.id: item for item in items}

# ❌ 8 lines to sum a field
total = 0
for order in orders:
    total += order.amount

# ✅ 1 line
total = sum(order.amount for order in orders)

# ❌ Manual any() check
found = False
for record in records:
    if record.status == "failed":
        found = True
        break

# ✅
found = any(r.status == "failed" for r in records)
// ❌ Imperative filter + map in 7 lines
const result = [];
for (const user of users) {
  if (user.isActive) {
    result.push(user.email);
  }
}

// ✅ 1 line
const result = users.filter(u => u.isActive).map(u => u.email);

// ❌ Manual object build
const lookup: Record<string, Item> = {};
for (const item of items) {
  lookup[item.id] = item;
}

// ✅
const lookup = Object.fromEntries(items.map(i => [i.id, i]));

3. Early returns — flatten nesting, not logic

Deep nesting is the enemy of readability. Guard clauses at the top of a function eliminate the rightward drift that makes code hard to follow.

# ❌ Nested pyramid — 4 levels deep
def process_order(order):
    if order:
        if order.is_valid():
            if order.user:
                if order.user.is_active:
                    return charge(order)

# ✅ Flat — each guard exits immediately, happy path is obvious
def process_order(order):
    if not order:
        return None
    if not order.is_valid():
        return None
    if not order.user:
        return None
    if not order.user.is_active:
        return None
    return charge(order)
// ❌ 5-level nesting
function processOrder(order: Order | null) {
  if (order) {
    if (order.isValid()) {
      if (order.user) {
        return charge(order);
      }
    }
  }
}

// ✅ Guard clauses
function processOrder(order: Order | null) {
  if (!order) return null;
  if (!order.isValid()) return null;
  if (!order.user) return null;
  return charge(order);
}

4. Collapse redundant conditionals

# ❌ Returns True/False explicitly from a boolean expression
def is_eligible(user):
    if user.age >= 18 and user.is_verified:
        return True
    else:
        return False

# ✅
def is_eligible(user):
    return user.age >= 18 and user.is_verified

# ❌ Assigns variable only to return it
def get_label(status):
    if status == "active":
        label = "Active"
    elif status == "inactive":
        label = "Inactive"
    else:
        label = "Unknown"
    return label

# ✅ Return directly
def get_label(status):
    if status == "active":   return "Active"
    if status == "inactive": return "Inactive"
    return "Unknown"

# ❌ Ternary written as if/else block
if condition:
    value = a
else:
    value = b

# ✅
value = a if condition else b   # Python
value = condition ? a : b;      # JS/TS

5. Use standard library — don't rewrite what already exists

Before writing any utility function, check the standard library and the project's existing dependencies. Rewriting something that already exists creates two things to maintain.

# ❌ Custom flatten
def flatten(nested):
    result = []
    for sublist in nested:
        for item in sublist:
            result.append(item)
    return result

# ✅ Already exists
from itertools import chain
flat = list(chain.from_iterable(nested))

# ❌ Custom grouping — 10 lines
groups = {}
for item in items:
    key = item.category
    if key not in groups:
        groups[key] = []
    groups[key].append(item)

# ✅
from collections import defaultdict
groups = defaultdict(list)
for item in items:
    groups[item.category].append(item)

# ❌ Custom chunk function
def chunks(lst, n):
    result = []
    for i in range(0, len(lst), n):
        result.append(lst[i:i+n])
    return result

# ✅ Already a one-liner
chunks = [lst[i:i+n] for i in range(0, len(lst), n)]
// ❌ Custom deep clone — 15 lines of recursive copying
// ✅ Already exists (for JSON-serialisable data)
const clone = structuredClone(obj);

// ❌ Custom unique filter
const unique = [];
for (const item of items) {
  if (!unique.includes(item)) unique.push(item);
}
// ✅
const unique = [...new Set(items)];

// ❌ Custom last-element getter
function last(arr) { return arr[arr.length - 1]; }
// ✅
const last = arr.at(-1);

6. Remove unnecessary abstraction

Abstraction that adds indirection without adding clarity is overhead, not design.

# ❌ A function that wraps a single expression with no added logic
def get_user_email(user):
    return user.email

# called as:
email = get_user_email(user)

# ✅ Just use the attribute
email = user.email

# ❌ A class with one method that could be a function
class EmailSender:
    def send(self, to: str, body: str):
        smtp.send(to, body)

sender = EmailSender()
sender.send(to, body)

# ✅ If there is genuinely no state, use a function
def send_email(to: str, body: str):
    smtp.send(to, body)

When abstraction IS justified:

  • The function encapsulates a decision that could change (e.g. which SMTP provider)
  • The wrapper adds error handling, logging, or retry logic
  • The class manages state across calls
  • The abstraction makes tests significantly easier to write

If none of these apply, remove the layer.


7. Simplify boolean and None checks

# ❌ Verbose None / empty checks
if len(items) > 0:   ...
if items != []:      ...
if items is not None and len(items) > 0: ...

# ✅
if items: ...

# ❌ Double negative
if not user is None: ...

# ✅
if user is not None: ...

# ❌ Explicit comparison to True/False
if is_valid == True:  ...
if is_valid == False: ...

# ✅
if is_valid:  ...
if not is_valid: ...
// ❌
if (items.length > 0) { ... }
if (value !== null && value !== undefined) { ... }

// ✅
if (items.length) { ... }
if (value != null) { ... }   // != null catches both null and undefined

8. Spot over-engineered patterns

These patterns appear most often in AI-generated or over-abstracted code. When you see them, ask: does this complexity earn its keep?

PatternSignal it's over-engineeredSimpler form
Factory that creates one typeNo polymorphism neededDirect instantiation
Strategy pattern for one algorithmNo swappability neededInline the logic
Event bus for in-process callsNo decoupling benefitDirect function call
DTO that mirrors the model exactlyNo transformation happeningUse the model directly
Config object passed to every functionOnly 1–2 fields actually usedPass the fields directly
Custom error class with no extra fieldsAdds nothing over the baseUse base exception
Wrapper class around a single dictDict is already fineUse the dict

Apply the test: if you removed this layer, would anything break or become harder to test? If the answer is no, remove it.


9. Simplification checklist

Before marking a simplification done:

  • Tests pass (run the suite, not just syntax check)
  • Line count is actually lower — count before and after
  • No behaviour was changed (same inputs → same outputs)
  • No new dependencies introduced just to simplify
  • The simplified version is genuinely easier to read, not just shorter
  • Commit is isolated — only simplification, no feature changes

Rules

  • Shorter is not always simpler. A one-liner that needs a comment to explain it is not simpler than three readable lines. Optimise for clarity, not character count.
  • Never simplify code you do not understand. Read it, trace it, test it first.
  • Standard library over custom code — always check before writing a utility function.
  • Remove abstraction layers that add indirection without adding value.
  • One simplification concern per commit — loops, then conditionals, then abstractions. Mixing them makes the diff unreadable.

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.