Communitygithub.com

最小化代码规范

基于YAGNI阶梯编码规范,确保每次变更都只写必要且正确的代码。

最小化代码规范 是什么?

本技能旨在指导AI代理在规划和编写代码变更时,严格遵循最小化代码规范(YAGNI阶梯)。其核心目标是生成体积小巧、正确性显而易见的代码差异(diff),同时绝不牺牲保障用户安全的关键检查。该技能与`ai-slop-cleaner`互补:后者负责清理事后产生的冗余代码,而它则从源头上杜绝冗余的产生。它支持所有主流AI代理平台(如Claude Code, Cursor等),通过一系列可操作的准则来达成目的:首先确认变更是否必要,其次优先复用现有代码,然后遵循“标准库→平台原生能力→已有依赖→最后手写”的依赖阶梯。此外,它还要求开发者先理解代码再动手,偏好“笨但正确”的实现,并明确标记任何已知的简化及其适用边界。最后,它定义了一组不可妥协的底线,例如绝对不允许简化或省略跨信任边界的验证、防止数据丢失的错误处理、安全控制、无障碍基础,以及用户明确要求的范围。完成前,需要逐行确认代码的贡献、差异的最短性,并确保所有不可妥协项和现有测试依然完好。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Yeachan-Heo/oh-my-claudecode/tree/main/skills/minimal-code-discipline

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

最小化代码规范 是做什么的?

使用本技能在规划和编写代码变更时应用最小化代码(YAGNI阶梯)规范。它能确保生成的diff既小又明显正确,同时不牺牲保障用户安全的关键检查。

本技能与 ai-slop-cleaner 互补:那个技能在冗余代码落地后进行清理;而本技能则从一开始就防止冗余代码被写出。

何时使用

请在以下情况使用本技能:

  • 用户要求实现最小化、精简、YAGNI 或尽可能小的 diff
  • 一个计划或正在进行的变更超出了所陈述的需求范围
  • 编写可能发生范围蔓延、重复造轮子或投机性通用性的新代码时
  • 在实现前审查提议的 diff 大小时

何时不使用

在以下情况下不要使用本技能:

  • 用户明确要求构建一个广泛、功能丰富或面向未来的系统(用户明确的范围优先)
  • 任务是用户标记为“可丢弃”的探索性脚手架
  • 最小化的压力会触及受保护的行为(见不可妥协项)

规范

存在优先。 先问变更是否真的需要存在;跳过仅为推测的未来需求而做的工作。

复用优先。 在编写任何新代码之前,先搜索代码库中已有的辅助函数、类型或模式。永远不要复制一个已经在几个文件之外存在的辅助函数——要么复用它,要么将其提取到一个共享位置。

依赖阶梯。 优先使用标准库,然后是平台原生能力,再是已安装的依赖项。手写代码是最后的选择。不要因为几行代码就引入新的依赖项,除非用户明确要求或批准。

理解优先。 先阅读受影响的代码并追踪其执行路径。一旦理解了问题,就编写最短的正确 diff——从未写出的代码永远不会出错。

笨但正确优先。 优先选择笨但明显正确的代码,而不是巧妙的代码。

标记上限。 用简短的注释记录故意的简化,命名所接受的上限以及什么情况下需要替换它。

根因优先。 修复所有调用者共享的根本原因,而不是为每个报告的症状打单独的补丁。

不可妥协项

永远不能简化或省略以下内容:

  • 跨信任边界进行的验证
  • 防止数据丢失的错误处理
  • 安全控制
  • 无障碍基础功能
  • 用户明确要求的范围

验证

在报告完成之前,请确认:

  • 每一行添加的代码都有其存在的价值(没有投机性通用性,没有重复的辅助函数)
  • diff 是解决所述问题的最短方案
  • 不可妥协项完好无损
  • 测试仍然通过,行为除了按要求变更外没有变化

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

agent-doc-discipline

Writing-time discipline for documents agents consume (the five surfaces, specs, tickets, .omc/skills/) — every rule checkable and carrying a why, steps before reference, one meaning in one home, no restating what the environment already says. Mandatory at drydock seed generation and the launch C5 sediment pass; opt-in for any other agent-facing doc edit. The companion of minimal-code-discipline: that one disciplines code, this one disciplines papers.

ai-slop-cleaner

Clean AI-generated code slop with a regression-safe, deletion-first workflow and optional reviewer-only mode

ask

Process-first advisor routing for Claude, Codex, Gemini, Antigravity, Grok, or Cursor via `omc ask`, with artifact capture and no raw CLI assembly

ask-navigator

Shipyard

autopilot

Full autonomous execution from idea to working code

autoresearch

Stateful single-mission improvement loop with strict evaluator contract, markdown decision logs, and max-runtime stop behavior

cancel

Cancel any active OMC mode (autopilot, ralph, ultragoal, swarm, ultrapilot, pipeline, team) and clean up retired legacy state

configure-notifications

Configure notification integrations (Telegram, Discord, Slack) via natural language

debug

Diagnose the current OMC session or repo state using logs, traces, state, and focused reproduction

deepinit

Deep codebase initialization with hierarchical AGENTS.md documentation

deep-interview

Socratic deep interview with mathematical ambiguity gating before explicit execution approval

drydock

Lay the keel of the shipyard harness in any repo — the 4-pillar shared environment (Context, Rules, Tools, Standards) across 5 surfaces (CLAUDE.md, skills, design-system, mcp/cli, shared context) so that every human and agent inherits the same design language and anyone can ship. Run once per repo; re-run with --check to audit drift.

execute

Carry an approved task through to working, verified code

external-context

Invoke parallel document-specialist agents for external web searches and documentation lookup

graph

Deterministic orchestration graph runtime - declarative DAG pipelines with journal-based crash recovery

harbor

Harbor intake for external work — the captain only handles unresolved decisions. Sweeps incoming issues and PRs, verifies every claim before disposition, reuses every decision already made, and hands the maintainer a docket whose pending items each carry one question with options, recommendation, impact and evidence. Agent-autonomous for facts and for actions covered by standing authorization; signed for every new judgment. Never merges.

hud

Configure HUD display options (layout, presets, display elements)

launch

Shipyard

loft

Loft the shape before cutting steel — answer a design question that prose cannot settle by building a throwaway artifact: a pure logic module in a clickable shell, or structurally different UI variants behind one route. The captain reacts to the artifact; the answer folds into the decision; the artifact never docks. Use when a design question stalls in words, when a navigator map carries a loft ticket, or when a spec discussion reaches

omc-doctor

Diagnose and fix oh-my-claudecode installation issues

相关技能