Communitygithub.com

最小程式碼自律

YAGNI 階梯式程式碼撰寫規範,強調存在優先、先重用再撰寫、依賴階梯、最短正確差異,且包含絕不可因最小化而捨棄的不可妥協事項。

最小程式碼自律 是什麼?

本技能(Minimal Code Discipline)導入「YAGNI(You Ain't Gonna Need It)階梯」原則,引導開發者在規劃與撰寫程式碼變更時,維持差異(diff)最小且明顯正確,同時不犧牲使用者安全所需的檢查。它與 `ai-slop-cleaner` 互補:後者在程式碼落地後清理多餘內容,而本技能則從源頭防止多餘程式碼被寫入。技能定義了六道核心紀律,包括存在優先、重用現有資源、依賴階梯(標準函式庫優先,避免引入新套件)、在最小化前先理解程式碼、偏好樸實正確而非取巧,以及標記刻意簡化的上限。此外,它設有不可妥協事項,絕不能因最小化壓力而捨棄驗證、錯誤處理、安全控制、可及性基礎或用戶明確要求的範疇。支援所有主流開發環境(如 Claude Code、Cursor、Codex),適用於規劃、撰寫或審查差異時,確保變更精簡且不偏離原始需求。

相容平台~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 或最小可能差異的實作
  • 計劃或正在進行的變更已超出原始請求的範圍
  • 正在撰寫可能出現範圍蔓延、重造輔助函式或投機式一般化的新程式碼
  • 在實作前審查提議的差異大小

不使用時機

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

  • 使用者明確要求廣泛、功能豐富或具未來擴充性的建置(其明確範圍優先)
  • 任務是使用者標記為可拋棄的探索性原型
  • 最小化壓力會觸及受保護的行為(請參閱「不可妥協事項」)

規範

存在優先。 先問變更是否需要存在;跳過僅服務於投機性未來需求的工作。

重用優先於撰寫。 在撰寫任何新程式碼前,先搜尋程式碼庫中是否已有現成的輔助函式、型別或模式。切勿複製已存在於附近檔案中的輔助函式 — 應重用或將其提取至一個共用位置。

依賴階梯。 優先使用標準函式庫,其次才是平台原生能力,再來是已安裝的依賴項。手寫程式碼是最後的手段。當幾行程式碼足以解決問題時,不要引入新的依賴項,除非使用者明確要求或同意。

在最小化前先理解。 先閱讀受影響的程式碼並追蹤其執行路徑。一旦理解問題,再送出最短的正確差異 — 從未撰寫的程式碼永遠不會出錯。

樸實勝於取巧。 偏好樸實、明顯正確的程式碼,而非取巧的程式碼。

標記上限。 以簡短註解記錄刻意簡化的內容,命名所接受的上限以及未來可證明需要替換它的理由。

根本原因,而非症狀。 在每個呼叫端共用的根本原因處修復錯誤,而不是為每個回報的症狀分別打補丁。

不可妥協事項

絕不能因最小化而捨棄:

  • 任何跨越信任邊界時的驗證
  • 防止資料遺失的錯誤處理
  • 安全控制
  • 可及性基礎
  • 使用者明確要求的範圍

驗證

在回報完成前,請確認:

  • 每一行新增的程式碼都有其存在的理由(沒有投機式一般化,沒有重複的輔助函式)
  • 差異是正確解決所述問題的最短版本
  • 不可妥協事項完好無損
  • 測試仍然通過,且行為除要求變更外未改變

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

相關技能