mattpocock/skills

codebase-design

为模块设计提供一套共同语言:用较小的接口隐藏更多行为,让调用方少了解细节,让维护与验证集中在同一个位置。它是设计参考和方法,不是运行一次就完成重构的扫描器。

  • SKILL.md 已保存
  • 中文用法已整理
  • 安装与运行未实测
先判断是否解决你的问题

codebase-design 是什么?

为模块设计提供一套共同语言:用较小的接口隐藏更多行为,让调用方少了解细节,让维护与验证集中在同一个位置。它是设计参考和方法,不是运行一次就完成重构的扫描器。

中文说明由本站依据来源整理;英文原文保留在页面下方。

按客户端选择安装入口

怎么接入你的 Agent?

  1. 定位完整 Skill 目录

    打开本项目来源,核对 SKILL.md 及其引用的脚本和资料。

  2. 交给你正在用的 Agent

    在下面选择客户端,展开并复制安装指令,让 Agent 读取来源后选择安装方式。

  3. 确认识别,再做具体任务

    让 Agent 回报安装目录和识别到的名称 codebase-design,然后按本页使用示例提供材料。

展开并复制给 Codex 的安装指令
发送给 Codex

安装并检查 codebase-design

请在 Codex 的当前工作环境中安装并检查 codebase-design 这个 Skill。

项目身份:mattpocock/skills / codebase-design
来源:https://github.com/mattpocock/skills/blob/5863806dd4e15c63174bee4e7515a4256792ecfa/skills/engineering/codebase-design/SKILL.md
已定位的源文件:skills/engineering/codebase-design/SKILL.md

1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。
准备输入,再按步骤执行

装好以后,具体怎么用?

准备哪些材料

  • 提供要设计或改造的模块、调用者和现有测试;进一步研究依赖分类或多方案接口时,保留DEEPENING.md与DESIGN-IT-TWICE.md。

会得到什么

  • 对模块接口、seam位置与复杂度归属的设计判断;具体代码取决于后续实施任务。

实际使用顺序

  1. 把接口视为调用者必须知道的全部事实,包括参数、顺序、错误、配置和性能,而不只看TypeScript interface。
  2. 检查删除模块后复杂度是消失还是散回调用方;后者说明它确实承担了有价值的封装。
  3. 确定可替换行为的seam和满足接口的adapter,避免只有一种实际实现时就为了假想变化增加抽象。
  4. 设计让调用者和测试使用同一接口:依赖作为输入,能返回结果时不要藏成副作用,减少需要理解的方法和参数。
使用示例

从一个具体任务开始

本站根据源文件编写的使用示例,未在本站实际运行。示例中的文件由你提供。

安装并识别 Skill 后发送

复制一个具体任务

教学示例:请用codebase-design审视订单计算模块。列出调用者必须知道的事实,做deletion test,比较把折扣规则散在调用方与收进模块两种接口。给出leverage、locality和测试入口的差异,先讨论设计,不改代码。
预期结果

预期得到有依据的接口比较和复杂度分配,不按实现行数机械评估模块好坏;本例未运行。

使用前先看这些限制

使用条件与边界

  • 源文明确不以实现行数/接口行数比例衡量深度;堆内部代码不能证明封装有价值。
  • 模块可以内部拆小,但内部细节不应自动变成外部调用者和测试必须知道的结构。
针对这个 Skill 的疑问

常见问题

是不是文件越少、类越大越好?

不是。它关心接口给调用者提供的能力和维护局部性,允许内部有小部件;文件数和行数都不是判定标准。

需要核对时再展开原文

来源原文与资料状态

源文件
已保存 SKILL.md,抓取于 2026-11-16T12:36:35.145Z
中文使用说明
已针对下方源文件版本整理用途、用法和常见问题
安装与任务测试
本站未执行安装或任务测试
来源复核
本页中文用法已对照保存版本的完整 SKILL.md 阅读整理
展开 SKILL.md 原文、章节与历史收录资料

skills/engineering/codebase-design/SKILL.md · 抓取时间 2026-11-16T12:36:35.145Z

以下保留源文件的 description、章节及摘录,供核对中文说明;完整文件通过上方链接打开。

抓取成功不代表已完成安装或任务测试。

来源 description(原文)

Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.

查看源文件章节 / Source sections
  • 原文:Codebase Design
  • 原文:Glossary
  • 原文:Deep vs shallow
  • 原文:Principles
  • 原文:Designing for testability
  • 原文:Relationships
  • 原文:Rejected framings
  • 原文:Going deeper
原文:Codebase Design

Design **deep modules**: a lot of behaviour behind a small interface, placed at a clean seam, testable through that interface. Use this language and these principles wherever code is being designed or restructured. The aim is leverage for callers, locality for maintainers, and testability for everyone.

原文:Glossary

Use these terms exactly: don't substitute "component," "service," "API," or "boundary." Consistent language is the whole point. **Module**: anything with an interface and an implementation. Deliberately scale-agnostic: a function, class, package, or tier-spanning slice. _Avoid_: unit, component, service. **Interface**: everything a caller must know to use the module correctly: the type signature, but also invariants, ordering constraints, error modes, required configuration, and performance characteristics. _Avoid_: API, signature (too narrow, they refer only to the type-level surface). **Implementation**: what's inside a module, its body of code. Distinct from **Adapter**: a thing can be a small adapter with a large implementation (a Postgres repo) or a large adapter with a small implementation (an in-memory fake). Reach for "adapter" when the seam is the topic; "implementation" otherwise. **Depth**: leverage at the interface. The amount of behaviour a caller (or test) can exercise per unit of interface they have to learn. A module is **deep** when a large amount of behaviour sits behind a small interface, **shallow** when the interface is nearly as complex as the implementation. **Seam** _(Michael Feathers)_: a place where you can alter behaviour without editing in that place; the *location* at which a module's interface lives. Where to put the seam is its own design decision, distinct from what goes behind it. _Avoid_: boundary (overloaded with DDD's bounded context). **Adapter**: a concrete thing that satisfies an interface at a seam. Describes *role* (what slot it fills), not substance (what's inside). **Leverage**: what callers get from depth. More capability per unit of interface they learn. One implementation pays back across N call sites and M tests. **Locality**: what maintainers get from depth. Change, bugs, knowledge, and verification concentrate in one place rather than spreading across callers. Fix once, fixed everywhere.

原文:Deep vs shallow

**Deep module** = small interface + lots of implementation: ``` ┌─────────────────────┐ │ Small Interface │ ← Few methods, simple params ├─────────────────────┤ │ │ │ Deep Implementation│ ← Complex logic hidden │ │ └─────────────────────┘ ``` **Shallow module** = large interface + little implementation (avoid): ``` ┌─────────────────────────────────┐ │ Large Interface │ ← Many methods, complex params ├─────────────────────────────────┤ │ Thin Implementation │ ← Just passes through └─────────────────────────────────┘ ``` When designing an interface, ask: - Can I reduce the number of methods? - Can I simplify the parameters? - Can I hide more complexity inside?

原文:Principles

- **Depth is a property of the interface, not the implementation.** A deep module can be internally composed of small, mockable, swappable parts; they just aren't part of the interface. A module can have **internal seams** (private to its implementation, used by its own tests) as well as the **external seam** at its interface. - **The deletion test.** Imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep. - **The interface is the test surface.** Callers and tests cross the same seam. If you want to test *past* the interface, the module is probably the wrong shape. - **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a seam unless something actually varies across it.

原文:Designing for testability

Good interfaces make testing natural: 1. **Accept dependencies, don't create them.** ```typescript // Testable function processOrder(order, paymentGateway) {} // Hard to test function processOrder(order) { const gateway = new StripeGateway(); } ``` 2. **Return results, don't produce side effects.** ```typescript // Testable function calculateDiscount(cart): Discount {} // Hard to test function applyDiscount(cart): void { cart.total -= discount; } ``` 3. **Small surface area.** Fewer methods = fewer tests needed. Fewer params = simpler test setup.

原文:Relationships

- A **Module** has exactly one **Interface** (the surface it presents to callers and tests). - **Depth** is a property of a **Module**, measured against its **Interface**. - A **Seam** is where a **Module**'s **Interface** lives. - An **Adapter** sits at a **Seam** and satisfies the **Interface**. - **Depth** produces **Leverage** for callers and **Locality** for maintainers.

文件 SHA256:2c20617f87ec8af6a434859f381b2f061a69b530444e74eb39e78bb016a6d1e2

仓库许可证记录:MIT;repository-license-recorded-scope-unverified,查看来源。

Skills.sh收录简介 · 2026-07-28

Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a…

查看历史简介来源

这份历史简介在采集时已截断;完整用途和触发条件需打开来源核对。

历史收录数据

Skill标识codebase-design
来源仓库mattpocock/skills
榜单快照2026-07-28
榜单口径Skills.sh累计安装量
快照名次88
快照累计安装量261262

历史资料说明

  • 所保留的来源简介在采集时已截断;完整触发条件、依赖及排除项须阅读源文件,本站不补写缺失部分。
  • 安装量用于说明当时的收录次序,不是效果、可信度或当前可用性的证明。

此页用于识别项目与来源。安装入口可在该Skill的Skills.sh页面查看;当前目录是否仍存在、附带脚本和账户依赖尚需按具体版本确认。

返回 Skills 目录,按任务继续筛选 · MCP与Skills教程与资源