Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Codebase Design

ASecurity

設計深模組的共用詞彙。當使用者想設計或改進模組的介面、找深化的機會、決定接縫放哪裡、讓程式碼更容易測試或對 AI 更容易導覽,或另一個技能需要深模組詞彙時使用。

3 stars
0 votes
0 copies
0 views
Added 9/19/2026
ai-agentstypescriptapi

Works with

api

Security Analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned 9/19/2026

$npx -y skills add shumingyang-opencode/mattpocock-skills-zh-tw --skill codebase-design --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Codebase Design?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Codebase Design
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/shumingyang-opencode-codebase-design/badge)](https://www.skillsdirectory.com/skills/shumingyang-opencode-codebase-design)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: codebase-design
description: 設計深模組的共用詞彙。當使用者想設計或改進模組的介面、找深化的機會、決定接縫放哪裡、讓程式碼更容易測試或對 AI 更容易導覽,或另一個技能需要深模組詞彙時使用。
---

# 程式碼庫設計

設計**深模組**:小介面背後有大量行為、放在乾淨的接縫上、可以透過那個介面測試。在任何程式碼被設計或重構的地方使用這套語言與這些原則。目標是讓呼叫者獲得槓桿收益、維護者獲得局部性、所有人獲得可測試性。

## 詞彙表

精確使用這些術語——不要替換成「component」「service」「API」或「boundary」。一致的語言就是重點。

**模組**——任何有介面與實作的東西。刻意地與規模無關:一個函式、類別、套件,或橫跨層級的切片。_Avoid_: unit、component、service。

**介面**——呼叫者要正確使用模組所需知道的一切:型別簽名,也包括不變量、順序約束、錯誤模式、必要的設定,與效能特徵。_Avoid_: API、signature(太窄——它們只指型別層級的表面)。

**實作**——模組裡面的東西,它的程式碼本體。與**轉接器**區別:一個東西可以是小轉接器配大實作(Postgres repo),或大轉接器配小實作(記憶體中的假物件)。當主題是接縫時用「轉接器」;其他情況用「實作」。

**深度**——介面上的槓桿收益:呼叫者(或測試)每學習一單位介面所能行使的行為量。當大量行為藏在一個小介面後面時,模組是**深的**;當介面幾乎跟實作一樣複雜時是**淺的**。

**接縫** _(Michael Feathers)_——一個你可以不用在原地編輯就能改變行為的地方;模組介面所在的*位置*。接縫放哪裡本身是一個設計決策,與放在它後面的是什麼是兩回事。_Avoid_: boundary(與 DDD 的 bounded context 過載)。

**轉接器**——在接縫處滿足某個介面的具體東西。描述*角色*(它填補什麼槽位),不是實體(裡面是什麼)。

**槓桿收益**——呼叫者從深度得到的:每學習一單位介面獲得更多能力。一份實作在 N 個呼叫點與 M 個測試之間回本。

**局部性**——維護者從深度得到的:變更、bug、知識與驗證集中在一個地方,而不是散落在呼叫者之間。修一次,處處修好。

## 深 vs 淺

**深模組** = 小介面 + 大量實作:

```
┌─────────────────────┐
│   Small Interface   │  ← Few methods, simple params
├─────────────────────┤
│                     │
│  Deep Implementation│  ← Complex logic hidden
│                     │
└─────────────────────┘
```

**淺模組** = 大介面 + 少許實作(避免):

```
┌─────────────────────────────────┐
│       Large Interface           │  ← Many methods, complex params
├─────────────────────────────────┤
│  Thin Implementation            │  ← Just passes through
└─────────────────────────────────┘
```

設計介面時問:

- 我能減少方法數量嗎?
- 我能簡化參數嗎?
- 我能把更多複雜度藏在裡面嗎?

## 原則

- **深度是介面的屬性,不是實作的屬性。** 深模組可以在內部由小而可模擬、可替換的部件組成——它們只是不是介面的一部分。模組可以同時有**內部接縫**(實作私有、供自己的測試使用)以及位於其介面上的**外部接縫**。
- **刪除測試。** 想像刪掉這個模組。如果複雜度消失,它只是個轉送層。如果複雜度在 N 個呼叫者之間重現,它在賺自己的住宿費。
- **介面就是測試表面。** 呼叫者和測試跨越同一個接縫。如果你想測試到介面*之後*,模組大概形狀錯了。
- **一個轉接器意味著假設性接縫;兩個轉接器意味著真實接縫。** 除非有什麼東西真的跨越它而變化,否則不要引入接縫。

## 為可測試性設計

好介面讓測試很自然:

1. **接受相依,不要製造相依。**

   ```typescript
   // Testable
   function processOrder(order, paymentGateway) {}

   // Hard to test
   function processOrder(order) {
     const gateway = new StripeGateway();
   }
   ```

2. **回傳結果,不要製造副作用。**

   ```typescript
   // Testable
   function calculateDiscount(cart): Discount {}

   // Hard to test
   function applyDiscount(cart): void {
     cart.total -= discount;
   }
   ```

3. **小表面積。** 方法更少 = 需要的測試更少。參數更少 = 測試設定更簡單。

## 關係

- 一個**模組**剛好有一個**介面**(它呈現在呼叫者與測試面前的表面)。
- **深度**是**模組**的屬性,相對於它的**介面**來衡量。
- **接縫**是**模組**的**介面**所在之處。
- **轉接器**坐在**接縫**處並滿足**介面**。
- **深度**為呼叫者產生**槓桿收益**、為維護者產生**局部性**。

## 被否決的框架

- **把深度當成實作行數對介面行數的比率**(Ousterhout):獎勵灌水實作。我們改用深度即槓桿收益。
- **把「介面」當成 TypeScript 的 `interface` 關鍵字或類別的公開方法**:太窄——這裡的介面包含呼叫者必須知道的每一件事實。
- **「boundary」**:與 DDD 的 bounded context 過載。說**seam**或**interface**。

## 深入下去

- **考量其相依而深化一個叢集**——見 [DEEPENING.md](DEEPENING.md):相依分類、接縫紀律,以及「取代而不分層」的測試。
- **探索替代介面**——見 [DESIGN-IT-TWICE.md](DESIGN-IT-TWICE.md):並行啟動子代理,用幾種截然不同的方式設計介面,然後在深度、局部性與接縫位置之間比較。

Attribution

shumingyang-opencodeshumingyang-opencode
View sourceSee grades on GitHubMore from shumingyang-opencode →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698461 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →