codebase-design

codebase-design is a skill for Claude Code, Codex from devcxl/mattpocock-skills-zh. It costs 59 tokens per session (1,608 once invoked), scanned A, original, MIT.

A design vocabulary and set of principles for organizing software modules, meaning pieces of code with an interface and an implementation. It focuses on small interfaces that hide substantial behavior, clear points for changing behavior, and code that is easier to test.

In plain words
What is it for?
Designing or improving module interfaces, choosing where behavior can be replaced for tests, finding opportunities to make modules deeper, and helping people or coding agents navigate a codebase.
Why use it?
Shared terms make design discussions more precise and help developers judge whether a module is doing useful work behind a manageable interface or merely adding another layer.

Skill for Claude CodeCodex

Part of the mattpocock-skills plugin — 37 skills shipped together

Install

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.

agentmods
npx agentmods add skills/devcxl/mattpocock-skills-zh/codebase-design
Any agent
npx skills add devcxl/mattpocock-skills-zh --skill codebase-design
Clone the repo
git clone --depth 1 https://github.com/devcxl/mattpocock-skills-zh

Made for: Claude Code, Codex.

Or install mattpocock-skills, the plugin that ships this one along with the rest of its 37 skills.

Wrote 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.

agentmods badge for codebase-design

README.md
[![agentmods](https://agentmods.dev/badge/skills/devcxl/mattpocock-skills-zh/codebase-design.svg)](https://agentmods.dev/skills/devcxl/mattpocock-skills-zh/codebase-design)
Your own site
<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>
Per session 59 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,608 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce 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

Measured 5d ago against content hash c0a75072ca88, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

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.

skills/engineering/codebase-design/SKILL.md · 115 lines

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。

设计可测试性

好的接口让测试变得自然:

  1. 接受依赖,不要创建依赖。

    // 可测试
    function processOrder(order, paymentGateway) {}
    
    // 难以测试
    function processOrder(order) {
      const gateway = new StripeGateway();
    }
    

Read the full file on GitHub · 115 lines

Files

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.

Changes

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.

  1. 5d ago First seen · 115 lines · 59 tokens per session scan A c0a75072ca88

Subscribe to this mod's changes

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.