Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/devcxl/mattpocock-skills-zh/codebase-designnpx skills add devcxl/mattpocock-skills-zh --skill codebase-designgit clone --depth 1 https://github.com/devcxl/mattpocock-skills-zhWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/devcxl/mattpocock-skills-zh/codebase-design)<a href="https://agentmods.dev/skills/devcxl/mattpocock-skills-zh/codebase-design"><img src="https://agentmods.dev/badge/skills/devcxl/mattpocock-skills-zh/codebase-design.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00059 | $0.01608 |
| Opus 5 | $0.00030 | $0.00804 |
| Sonnet 5 | $0.00012 | $0.00322 |
| Haiku 4.5 | $0.00006 | $0.00161 |
Grade A, and why
codebase-design scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 115 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Codebase Design
设计 深度模块(deep modules):一个小接口背后承载大量行为,放置在干净的 seam 处,通过该接口可测试。在设计和重构代码的任何地方,都使用这套语言和原则。目标是:对调用者而言是杠杆效应(leverage),对维护者而言是局部性(locality),对所有人而言是可测试性。
词汇表
精确使用以下术语 —— 不要替换为"组件"、"服务"、"API"或"边界"。使用一致的语言正是关键所在。
Module(模块) —— 任何具有接口和实现的东西。特意与规模无关:一个函数、类、包或跨层级切片。避免使用:单元、组件、服务。
Interface(接口) —— 调用者正确使用该模块所需知道的一切:类型签名,还包括不变性约束、顺序约束、错误模式、所需配置和性能特征。避免使用:API、签名(过于狭隘 —— 它们仅指类型层面的表面)。
Implementation(实现) —— 模块内部的内容,它的代码主体。与 Adapter(适配器) 不同:某个东西可以是一个小型适配器配大型实现(如 Postgres 仓库),也可以是一个大型适配器配小型实现(如内存中的假实现)。当讨论重点是 seam 时使用"adapter";否则使用"implementation"。
Depth(深度) —— 接口处的杠杆效应:调用者(或测试)每学习一个单位的接口就能调用的行为量。当一个模块在小型接口背后承载了大量行为时,它是 深的(deep);当接口几乎和实现一样复杂时,它是 浅的(shallow)。
Seam(接缝) (Michael Feathers) —— 可以在不修改某处的情况下改变行为的位置;模块接口所在的位置。seam 放在哪里本身就是一个设计决策,与它背后放什么不同。避免使用:边界(与 DDD 的限界上下文 overloaded)。
Adapter(适配器) —— 在 seam 处满足接口的具体实现。描述的是角色(它填充什么槽位),而非实质(内部是什么)。
Leverage(杠杆效应) —— 调用者从深度中获得的好处:每学习一个单位的接口就能获得更多能力。一次实现在 N 个调用点和 M 个测试中回报。
Locality(局部性) —— 维护者从深度中获得的好处:变更、缺陷、知识和验证集中在一个地方,而不是分散在调用者之间。一次修复,处处生效。
深 vs 浅
深度模块 = 小接口 + 大量实现:
┌─────────────────────┐
│ 小型接口 │ ← 少量方法,简单参数
├─────────────────────┤
│ │
│ 深度实现 │ ← 隐藏的复杂逻辑
│ │
└─────────────────────┘
浅模块 = 大接口 + 少量实现(避免):
┌─────────────────────────────────┐
│ 大型接口 │ ← 大量方法,复杂参数
├─────────────────────────────────┤
│ 薄实现 │ ← 仅透传
└─────────────────────────────────┘
设计接口时,问自己:
- 我能减少方法数量吗?
- 我能简化参数吗?
- 我能在内部隐藏更多复杂性吗?
原则
- 深度是接口的属性,而不是实现的属性。 一个深度模块内部可以由小的、可 mock、可替换的部分组成 —— 它们只是不属于接口而已。一个模块可以有 内部 seam(对其实施私有的,由其自身测试使用)以及其接口处的 外部 seam。
- 删除测试。 想象删除这个模块。如果复杂性消失了,它就是一个透传。如果复杂性在 N 个调用者之间重新出现,那么它是有价值的。
- 接口就是测试面。 调用者和测试穿过同一个 seam。如果你想测试越过接口,那模块的形状可能有问题。
- 一个适配器意味着一个假设的 seam。两个适配器意味着一个真实的 seam。 除非有东西实际在 seam 处变化,否则不要引入 seam。
设计可测试性
好的接口让测试变得自然:
-
接受依赖,不要创建依赖。
// 可测试 function processOrder(order, paymentGateway) {} // 难以测试 function processOrder(order) { const gateway = new StripeGateway(); }
What ships with it
3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 5d ago First seen · 115 lines · 59 tokens per session scan A c0a75072ca88
codebase-design is a skill published in the GitHub repository devcxl/mattpocock-skills-zh (302 stars, last pushed today), licensed MIT. It adds 59 tokens to every session and 1,608 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
chinese-code-review
中文 review 沟通参考——话术模板、分级标注(必须修复/建议修改/仅供参考)、国内团队常见反模式应对。仅在用户显式 /chinese-code-review 时调用,不要根据上下文自动触发。.
chinese-commit-conventions
中文 commit 与 changelog 配置参考——Conventional Commits 中文适配、commitlint/husky/commitizen 中文模板、conventional-changelog 中文配置。仅在用户显式 /chinese-commit-conventions 时调用,不要根据上下文自动触发。.
chinese-documentation
中文文档排版参考——中英文空格、全半角标点、术语保留、链接格式、中文文案排版指北约定。仅在用户显式 /chinese-documentation 时调用,不要根据上下文自动触发。.
systematic-debugging
Skill "systematic-debugging" from jnMetaCode/superpowers-zh, covering 系统化调试, 概述, 铁律, 何时使用 and 四个阶段.
dispatching-parallel-agents
当面对 2 个以上可以独立进行、无共享状态或顺序依赖的任务时使用.
executing-plans
当你有一份书面实现计划需要在单独的会话中执行,并设有审查检查点时使用.