微算力 · API 导航与自营网关
API 接入 EN
未登录登录
🗑️

用删除对抗代码熵增

Reducing Entropy · v0.1.0
入口已确认,内容待校验 文件树里有 SKILL.md,但正文还没采回,frontmatter 未核对。
开发 安全 A 级 作者 wpank 公开目录收录
1.2k 下载 0 安装 2.5k 收藏 16 浏览

简介

以代码行数为唯一度量标准,通过激进删除实现最小化代码库,抵制过早抽象与灵活性陷阱,适合重构与技术债清理场景。

原始描述

Minimize total codebase size through ruthless simplification. Measure success by final code amount, not effort. Bias toward deletion.

通过你的 Agent 添加

安装目录:reducing-entropy/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/reducing-entropy/
Codex CLI~/.codex/skills/reducing-entropy/
DeepSeek Harness~/.agents/skills/reducing-entropy/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

中文使用说明 来自收录源

核心用法

Reducing Entropy 是一种以"代码熵减"为核心的工程思维技能,将最终代码行数作为唯一成功指标,而非开发工作量或代码"优雅度"。激活后提供系统化的删除优先检查清单:在重构、新增功能、PR 评审、技术债清理时,强制回答三个核心问题——"解决该问题的最小代码库是什么?""改动后总代码是否减少?""能删除什么?"

显著优点

  • 量化决策:以代码行数前后对比消除主观争论,用客观数据对抗"更灵活""更好组织"等模糊辩护
  • 对抗复杂性累积:内置 8 条"红线禁令"(如禁止少于 3 个用例的抽象、禁止单函数文件),直接针对常见过度工程反模式
  • 实用主义哲学基础:整合了 Rich Hickey 的 Simple Made Easy、Grug Brain 极简主义、Out of the Tar Pit 等经典资源,提供可引用的理论支撑
  • 结构化执行流程:从加载思维模式 → 三问评估 → 红旗警示 → 删除清单 → 快速获胜模式,形成完整决策闭环

潜在缺点与局限性

  • 指标单一风险:代码行数并非万能,可能误伤必要防御性代码(如边界检查、日志、监控)、强类型安全代码,或合规要求的审计追踪
  • 维护性悖论:过度追求行数最小化可能导致内联过度、魔法字符串、隐式依赖,反而降低可读性——技能本身承认" genuinely unmaintainable"是罕见例外,但未给出判定标准
  • 协作摩擦:"删除优先"心态可能与团队既有代码情感、"沉没成本"心理冲突,需配套团队文化建设
  • 框架生态限制:明确警告在强约定框架中"不要对抗",适用范围受限

适合人群

  • 技术债严重的遗留系统维护者
  • 极简主义信奉的资深工程师/架构师
  • PR 评审中频繁遭遇过度抽象的 Tech Lead
  • 明确获得用户"简化代码"指令时的执行助手

常规风险

  • 过度删除:可能移除实际有依赖的"死代码"、测试覆盖率要求的边界 case、或未来确实需要的扩展点(YAGNI 误判)
  • 隐性复杂度转移:行数减少但认知负荷转移(如硬编码替换配置、内联替换显式接口)
  • 安全/合规盲区:技能将"监管/合规要求"列为例外场景,但未提供识别方法,存在误删风险

建议:作为人工决策的辅助框架使用,最终删除操作需配合测试套件、静态分析与团队 review,避免自动化执行。

技能正文


name: reducing-entropy model: reasoning category: testing description: Minimize total codebase size through ruthless simplification. Measure success by final code amount, not effort. Bias toward deletion. version: 1.0 keywords: [simplification, deletion, refactoring, complexity, entropy, YAGNI, less code, minimalism] activation: manual # Only activate when explicitly requested

Reducing Entropy

More code begets more code. Entropy accumulates. This skill biases toward the smallest possible codebase.


WHAT This Skill Does

Provides a mindset and checklist for:

  • Evaluating whether changes reduce or increase total code
  • Finding opportunities to delete code
  • Resisting premature abstraction
  • Choosing the simplest solution that solves the problem

Core question: "What does the codebase look like after?"

WHEN To Use

Activate this skill when:

  • Refactoring code and considering options
  • Adding a new feature and choosing implementation approach
  • Reviewing PRs to challenge unnecessary complexity
  • Paying down tech debt and prioritizing what to simplify
  • User explicitly asks for code reduction or simplification

The Goal

The goal is less total code in the final codebase — not less code to write right now.

Scenario Verdict
Writing 50 lines that delete 200 lines Net win ✓
Keeping 14 functions to avoid writing 2 Net loss ✗
"Better organized" but more code More entropy ✗
"More flexible" but more code More entropy ✗
"Cleaner separation" but more code More entropy ✗

Measure the end state, not the effort.


Before You Begin

Load a mindset from references/:

  1. List files in references/
  2. Read frontmatter descriptions
  3. Pick at least one that applies
  4. State which you loaded and its core principle

Available mindsets:

  • simplicity-vs-easy.md — Simple is objective; easy is subjective. Choose simple.
  • design-is-taking-apart.md — Good design separates concerns, removes dependencies.
  • data-over-abstractions.md — 100 functions on one structure beats 10 on 10.
  • expensive-to-add-later.md — When YAGNI doesn't apply (PAGNI exceptions).

Three Questions

1. What's the smallest codebase that solves this?

Not "what's the smallest change" — what's the smallest result.

  • Could this be 2 functions instead of 14?
  • Could this be 0 functions (delete the feature)?
  • What would we delete if we did this?

2. Does the proposed change result in less total code?

Count lines before and after. If after > before, challenge it.

Before: 847 lines across 12 files
After:  623 lines across 8 files
Verdict: ✓ Net reduction of 224 lines

3. What can we delete?

Every change is an opportunity to delete. Ask:

  • What does this make obsolete?
  • What was only needed because of what we're replacing?
  • What's the maximum we could remove?

Red Flags

Phrase What It Hides Challenge
"Keep what exists" Status quo bias "Total code is the metric, not churn"
"This adds flexibility" Speculative generality "Flexibility for what? Is it needed now?"
"Better separation of concerns" More files = more code "Separation isn't free. Worth how many lines?"
"Type safety" Sometimes bloats code "Worth how many lines? Could runtime checks work?"
"Easier to understand" More things ≠ easier "14 things are not easier than 2 things"
"This is the pattern" Pattern worship "Does the pattern fit, or are we forcing it?"
"We might need this later" YAGNI violation "Delete it. Git remembers."

Deletion Checklist

Before completing any refactor, ask:

  • Did I count lines before and after?
  • Did I delete everything this change makes obsolete?
  • Did I remove any now-unnecessary abstractions?
  • Did I consolidate files that are too small to stand alone?
  • Did I delete tests for deleted code?
  • Did I update imports to remove dead dependencies?

When This Doesn't Apply

  • The codebase is already minimal for what it does
  • You're in a framework with strong conventions (don't fight it)
  • Regulatory/compliance requirements mandate certain structures
  • The "simpler" version would be genuinely unmaintainable (rare)

NEVER Do

  1. NEVER keep code "in case we need it" — delete it; git has history
  2. NEVER add abstractions for fewer than 3 use cases — wait for the pattern to emerge
  3. NEVER create new files for single functions — colocate with usage
  4. NEVER preserve code just because someone wrote it — evaluate on merit
  5. NEVER accept "more organized" as justification for more code — organization should reduce, not increase
  6. NEVER skip the line count — measure before and after; feelings lie
  7. NEVER add "flexibility" without immediate need — YAGNI applies
  8. NEVER refactor without deleting something — if nothing becomes obsolete, question the value

Quick Wins

Pattern Action
Wrapper that just forwards calls Inline the wrapped code
Config file with 2 settings Move to environment variables
Utils file with 1 function Move function to where it's used
Interface with 1 implementation Delete the interface
Abstract class with 1 subclass Merge into concrete class
Module that re-exports everything Delete; import from source
Comments explaining obvious code Delete comments; code is clear

The Grug Perspective

"complexity very very bad. say again: complexity very bad. you think you not, but you are."

Grug brain developer knows:

  • Complexity demon hides in abstraction
  • More code = more bugs = more complexity
  • Best code is no code
  • Second best code is simple code
  • If you can't understand it in your head, it's too complex

References

Philosophical foundations for simplicity thinking:

Reference Core Principle
simplicity-vs-easy.md Simple (objective) vs easy (subjective) — choose simple
design-is-taking-apart.md Good design separates; composition beats construction
data-over-abstractions.md Generic data + many functions beats many custom types
expensive-to-add-later.md PAGNI exceptions — what you probably are gonna need

External resources:

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

refactoringcode-simplicityyagnitechnical-debtminimalismdeletion

同类 Skill