minimal-code-discipline
它能做什么
这项技能指导智能体在保证正确的前提下,把代码改动尽可能缩小。适合希望改动集中、没有臃肿或猜测性附加内容的人。
适用场景
- ✓当你要求最小、精简或尽可能小的改动的时候。
- ✓当某个计划或改动超出了所要求的范围的时候。
- ✓当你希望在构建之前检查拟议改动是否有不必要的规模的时候。
技能链接
https://github.com/Yeachan-Heo/oh-my-claudecode/blob/main/skills/minimal-code-discipline/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请在报表页面添加一个简单的导出按钮。尽量让改动最小,并复用我们已有的东西。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会先询问这项改动是否真的需要,检查代码库中是否已有可复用的辅助函数,并优先选择能完成工作的最简单工具。它会在保持安全检查的同时,让改动保持简短。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Minimal Code Discipline
Use this skill to apply a minimal-code (YAGNI-ladder) discipline while planning and writing code changes. It keeps diffs small and obviously correct without sacrificing the checks that keep users safe.
This skill complements ai-slop-cleaner: that skill cleans slop after it lands; this one keeps it from being written.
When to Use
Use this skill when:
- the user asks for a minimal, lean, YAGNI, or smallest-possible-diff implementation
- a plan or in-flight change is growing beyond the stated request
- writing new code where scope creep, reinvented helpers, or speculative generality are likely
- reviewing a proposed diff for size before implementation
When Not to Use
Do not use this skill when:
- the user explicitly asks for a broad, feature-rich, or future-proofed build (their explicit scope wins)
- the task is exploratory scaffolding the user has marked as throwaway
- minimization pressure would touch protected behavior (see Non-Negotiables)
The Discipline
Existence first. Ask whether the change needs to exist at all; skip work that serves only a speculative future need.
Reuse before writing. Search the codebase for an existing helper, type, or pattern before writing anything new. Never copy a helper that already lives a few files away — reuse it or extract it to one shared location.
Dependency ladder. Reach for the standard library first, then platform-native capability, then an already-installed dependency. Hand-written code is the last resort. Do not introduce a new dependency when a few lines of code suffice, unless the user explicitly requested or approved it.
Understand before minimizing. Read the affected code and follow its execution path first. Ship the shortest correct diff once the problem is understood — code you never write never breaks.
Boring over clever. Prefer boring, obviously-correct code over clever code.
Mark the ceiling. Record deliberate simplifications with a short comment naming the accepted limit and what would justify replacing it.
Root cause, not symptoms. Fix bugs at the root cause shared by every caller, not with a separate patch for each reported symptom.
Non-Negotiables
Never minimize away:
- validation wherever a trust boundary is crossed
- error handling that guards against data loss
- security controls
- accessibility fundamentals
- scope the user explicitly requested
Verification
Before reporting completion, confirm:
- every added line earns its place (no speculative generality, no duplicate helpers)
- the diff is the shortest one that correctly solves the stated problem
- non-negotiables are intact
- tests still pass and behavior is unchanged except as requested
常见问题
为了让代码变小,它会删除安全检查吗?
不会。受保护的行为和安全检查绝不会为了节省行数而被删除。
如果我明确要求大型功能,它会覆盖我的要求吗?
不会。如果你明确要求广泛或面向未来的构建,你的范围要求优先。
它与清理类技能有何不同?
这项技能阻止多余的代码被写入,而清理类技能是在代码添加之后进行整理。
详情
作者的原始描述
YAGNI-ladder coding discipline for writing changes — existence-first, reuse before writing, dependency ladder, shortest correct diff, with non-negotiables that must never be minimized away
热度
- GitHub 星标
- 41k
- 排名
- #7010
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
agent-doc-discipline
41k教你的智能体编写其他 AI 智能体能够独立遵循的说明,规则可以检验,并且每条规则都附有明确的理由。
ai-slop-cleaner
41k帮你的智能体整理 AI 写出的代码,这些代码能运行但臃肿或重复,在不改变其功能的前提下删除多余部分。
architecture-survey
41k帮你的智能体审查代码库的结构,列出越来越难修改的部分并附上证据,且自身不做任何更改。
ask-navigator
41k帮你的智能体把模糊的项目整理成一张清晰的决策问题图,然后逐个处理,直到路径变得清楚。