Codebase Design logo

Codebase Design

Community
FeatherHunter
codebase-design

设计深模块时共用的词汇。当用户想设计或改进某个模块的接口、寻找加深机会、决定接缝放在哪里、让代码更可测试或更适合 AI 导航,或者当另一个技能需要深模块词汇时使用。

Overview

PublisherFeatherHunter
Repositorydsh-mattpocock-skills-deck
Skill namecodebase-design
Stars
263
Forks
22
Bundled files
2
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by FeatherHunter on GitHub. Read the source before you install it.

Installation

Install the Codebase Design AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/FeatherHunter/dsh-mattpocock-skills-deck/tree/main/package/bundled-skills-zh/codebase-design
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/FeatherHunter/dsh-mattpocock-skills-deck.git /tmp/dsh-mattpocock-skills-deck
mkdir -p .claude/skills
cp -r /tmp/dsh-mattpocock-skills-deck/package/bundled-skills-zh/codebase-design .claude/skills/codebase-design
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Codebase Design in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Codebase Design on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Codebase Design is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

代码库设计

设计深模块:把大量行为放在一个小接口后面,安放在一个干净的接缝处,并可通过这个接口测试。凡是正在设计或重构代码的地方,都使用这套语言和这些原则。目标是:让调用方得到杠杆,让维护者得到局部性,让所有人得到可测试性。

术语表

严格使用这些术语:不要替换成「组件」「服务」「API」或「边界」。语言一致正是全部意义所在。

模块:任何有接口和实现的东西。刻意不限定规模:它可以是一个函数、一个类、一个包,或者一个横跨多层的切片。避免:单元、组件、服务。

接口:调用方为了正确使用这个模块而必须知道的一切:类型签名,还有不变量、顺序约束、错误模式、必需的配置,以及性能特征。避免:API、签名(太窄,它们只指类型层面的表面)。

实现:模块内部的东西,也就是它的代码主体。与适配器不同:一个东西可以是一个实现很大的小适配器(一个 Postgres 仓储),也可以是一个实现很小的大适配器(一个内存里的假实现)。当话题是接缝时用「适配器」,其他情况用「实现」。

深度:接口处的杠杆。调用方(或测试)每学一单位接口,能驱动多少行为。当一个模块把大量行为放在一个小接口后面时,它是深的;当接口几乎和实现一样复杂时,它是浅的。

接缝 (Michael Feathers):一个你可以在不编辑该处代码的前提下改变行为的地方;它是模块的接口所在的位置。接缝放在哪里本身就是一项设计决策,与接缝后面放什么无关。避免:边界(这个词与 DDD 的限界上下文相冲突)。

适配器:在某个接缝处满足某个接口的具体东西。它描述的是角色(占据哪个位置),而不是实质(里面是什么)。

杠杆:调用方从深度中得到的东西。每学一单位接口,就多一分能力。一份实现,在 N 个调用点和 M 个测试上得到回报。

局部性:维护者从深度中得到的东西。改动、缺陷、知识和验证都集中在一处,而不是散布到各个调用方。修一次,处处都修好。

深与浅

深模块 = 小接口 + 大量实现:

┌─────────────────────┐
│   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 关键字或一个类的公开方法:太窄了:这里的接口包含调用方必须知道的每一个事实。
  • 「边界」:与 DDD 的限界上下文冲突。请说接缝或接口。

深入下去

  • 在给定依赖的情况下加深一簇代码,见 DEEPENING.md:依赖分类、接缝纪律,以及「替换而不是分层」的测试方式。
  • 探索备选接口,见 DESIGN-IT-TWICE.md:起多个并行子代理,用几种截然不同的方式设计这个接口,然后按深度、局部性和接缝位置做比较。

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Codebase Design AI skill do?

设计深模块时共用的词汇。当用户想设计或改进某个模块的接口、寻找加深机会、决定接缝放在哪里、让代码更可测试或更适合 AI 导航,或者当另一个技能需要深模块词汇时使用。

Why use Codebase Design on TypingMind?

Because you install it once and use it with any model. Codebase Design is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Codebase Design in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/FeatherHunter/dsh-mattpocock-skills-deck/tree/main/package/bundled-skills-zh/codebase-design. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Codebase Design?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Codebase Design?

As many as you like. As long as a model supports skills, you can use Codebase Design with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Codebase Design AI skill free?

Yes. It is published on GitHub by FeatherHunter under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇