codebase-design
用于设计深模块的共享词汇。适用于用户想设计或改进模块接口、寻找深化机会、决定 seam 放在哪里、让代码更容易测试或更适合 AI 导航,或其他技能需要深模块词汇时。
Skill by vinvcn
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/vinvcn-codebase-design
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: design, refactoring
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/codebase-design
What's inside
- Skill name
codebase-design- Description
- 用于设计深模块的共享词汇。适用于用户想设计或改进模块接口、寻找深化机会、决定 seam 放在哪里、让代码更容易测试或更适合 AI 导航,或其他技能需要深模块词汇时。
- License
- MIT
- Instructions
- 112 lines in SKILL.md · view on GitHub
Files (4)
- DEEPENING.md
- DESIGN-IT-TWICE.md
- SKILL.md
- openai.yaml · agents/
SKILL.md (first lines)
# 代码库设计
设计 **deep modules**:把大量行为放在小 interface 之后,把 interface 放在清晰 seam 上,并通过该 interface 测试。凡是在设计或重构代码时,都使用这套语言和原则。目标是给 callers 带来 leverage,给 maintainers 带来 locality,并让每个人都更容易测试。
## 术语表
准确使用这些术语,不要替换成 "component"、"service"、"API" 或 "boundary"。一致语言就是重点。
**Module** - 任何拥有 interface 和 implementation 的东西。它故意不限定尺度:function、class、package,或跨层 slice 都可以。_Avoid_: unit, component, service.
**Interface** - caller 为了正确使用 module 必须知道的一切:type signature,以及 invariants、ordering constraints、error modes、required configuration 和 performance characteristics。_Avoid_: API, signature(太窄,只指 type-level surface)。
**Implementation** - module 内部的代码体。它不同于 **Adapter**:一个东西可以是小 adapter 但有大 implementation(Postgres repo),也可以是大 adapter 但 implementation 很小(in-memory fake)。讨论 seam 时说 adapter;其他时候说 implementation。
**Depth** - interface 上的 leverage:caller(或 test)每学习一单位 interface,就能触达多少行为。大量行为藏在小 interface 后面时,module 是 **deep**;interface 几乎和 implementation 一样复杂时,module 是 **shallow**。
**Seam**(Michael Feathers)- 你可以在不编辑当前位置的情况下改变行为的地方;也就是 module 的 interface 所在的 *location*。seam 放在哪里是独立设计决策,不同于 seam 后面放什么。_Avoid_: boundary(它和 DDD bounded context 过载)。
**Adapter** - 在 seam 上满足某个 interface 的具体东西。描述的是 *role*(填哪个槽位),不是 substance(内部是什么)。
**Leverage** - callers 从 depth 获得的收益:每学习一单位 interface,就得到更多能力。一个 implementation 会在 N 个 call sites 和 M 个 tests 中回本。
**Locality** - maintainers 从 depth 获得的收益:change、bugs、knowledge 和 verification 集中在一个地方,而不是散到 callers 里。修一次,到处都修好。
## Deep 与 shallow
**Deep module** = small interface + lots of implementation:
```text
+------------------+
| Small Interface | -> few methods, simple params
+------------------+
| |
| Deep | -> complex logic hidden
| Implementation |
| |
+------------------+
```
**Shallow module** = large interface + little implementation(避免):
```text
+-------------------------------+
| Large Interface | -> many methods, complex params
+-------------------------------+
| Thin Implementation | -> mostly pass-through
+-------------------------------+
```
设计 interface 时问:
- 我能减少 methods 数量吗?
- 我能简化 parameters 吗?
- 我能把更多复杂度藏到内部吗?
## 原则
- **Depth 是 interface 的属性,不是 implementation 的属性。** Deep module 内部可以由小的、mockable、swappable parts 组成,只是它们不属于 interface。一个 module 可以同时拥有 **internal seams**(implementation 私有,供自身 tests 使用)和位于 interface 的 **external seam**。
- **Deletion test。** 想象删除这个 module。如果复杂度消失了,它只是 pass-through。如果复杂度重新散落到 N 个 callers 里,它就在发挥价值。
- **Interface is the test surface。** Callers 和 tests 穿过同一个 seam。若你想测试 interface 之后的内部细节,这个 module 形状可能不对。
- **One adapter means a hypothetical seam. Two adapters means a real one.** 除非确实有东西会跨 seam 变化,否则不要引入 seam。
## 为可测试性而设计
好的 interfaces 让测试自然发生:
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.** 更少 methods = 需要更少 tests。更少 params = 更简单的 test setup。
## 关系
- 一个 **Module** 恰好有一个 **Interface**(它呈现给 callers 和 tests 的 surface)。
- **Depth** 是 **Module** 的属性,并以其 **Interface** 衡量。
- **Seam** 是 **Module** 的 **Interface** 所在的位置。
- **Adapter** 位于 **Seam** 上,并满足 **Interface**。
- **Depth** 为 callers 产生 **Leverage**,为 maintainers 产生 **Locality**。
## 不采用的表述
- **把 depth 当作 implementation-lines 与 interface-lines 的比例**(Ousterhout):这会奖励 padding implementation。这里使用 depth-as-leverage。
- **把 "Interface" 理解为 TypeScript `interface` keyword 或 class public methods**:太窄;这里的 interface 包括 caller 必须知道的所有事实。
- **"Boundary"**:与 DDD bounded context 过载。说 **seam** 或 **interface**。
## 进一步深化
- **Deepening a cluster given its dependencies** - 见 [DEEPENING.md](DEEPENING.md):Dependency 分类、Seam 纪律和「替换,而不是叠加」的测试策略。
- **Exploring alternative interfaces** - 见 [DESIGN-IT-TWICE.md](DESIGN-IT-TWICE.md):启动并行 sub-agents,用几种截然不同的方式设计 interface,再按 depth、locality 和 seam placement 比较。From vinvcn/mattpocock-skills-zh-CN, MIT.
More from vinvcn/mattpocock-skills-zh-CN
- 0.848score
git-guardrails-claude-code
vinvcn
设置 Claude Code hooks,在危险 git commands(push、reset --hard、clean、branch -D 等)执行前阻止它们。适用于用户想防止破坏性 git 操作、添加 git safety hooks,或在 Claude Code 中阻止 git push/reset 时。
SkillAFreshness: A★ 5.2KClaude Code +9 - 0.844score
diagnosing-bugs
vinvcn
面向棘手缺陷和性能回退的诊断循环。适用于用户说 “diagnose” / “debug this”,或报告某些东西 broken、throwing、failing、slow 时。
SkillAFreshness: A★ 5.2KClaude Code +9 - 0.842score
setup-ts-deep-modules
vinvcn
在 TypeScript repo 中接入 dependency-cruiser,让每个 package 成为 deep module:implementation 隐藏在 subfolders 中,只能通过 entry-point files 访问。User-invoked。
SkillAFreshness: A★ 5.2KClaude Code +9 - 0.842score
to-tickets
vinvcn
把 plan、spec 或当前对话拆成一组 tracer-bullet tickets,每个 ticket 声明 blocking edges,并发布到已配置的 tracker;本地用每 ticket 一个文件中的文本 edge,真实 tracker 用 native blocking links。
SkillAFreshness: A★ 5.2KClaude Code +9 - 0.842score
wizard
vinvcn
生成一个交互式 bash wizard,逐步引导人完成只有他们能执行的手动流程。用于 provisioning 基础设施、设置 credentials 或 CI secrets、走查不熟悉的第三方 dashboard,或运行一次性 migration 或 cutover。对于 agent…
SkillAFreshness: A★ 5.2KClaude Code +9 - 0.842score
code-review
vinvcn
从固定点(commit、branch、tag 或 merge-base)开始,按 Standards(代码是否符合本仓库记录的编码标准?)和 Spec(代码是否符合来源 issue/spec 的要求?)两个轴线审查变更。两个审查会在并行子代理中运行,并并排报告。适用于用户想审查…
SkillAFreshness: A★ 5.2KClaude Code +9 - 0.842score
setup-pre-commit
vinvcn
在当前仓库设置 Husky pre-commit hooks,集成 lint-staged (Prettier)、类型检查和测试。适用于用户想添加 pre-commit hooks、设置 Husky、配置 lint-staged,或在提交时运行格式化、类型检查和测试时。
SkillAFreshness: A★ 5.2KClaude Code +9 - 0.842score
translate-skill
vinvcn
将 mattpocock/skills 的内容翻译、刷新或复核到简体中文本地化仓库 vinvcn/mattpocock-skills-zh-CN 时使用这个项目级 skill。适用于 skill files、README content、CLAUDE.md、GLOSSARY.md、docs,以及其他需要保留行为关键…
SkillAFreshness: A★ 5.2KClaude Code +9 - 0.838score
writing-beats
vinvcn
Writing, exploit——把原始素材组装成一段节拍旅程,在某个 beat 依赖一个术语之前先把它 grounded。
SkillAFreshness: A★ 5.2KClaude Code +9 - 0.838score
grilling
vinvcn
围绕计划、decision 或 idea 持续追问用户。适用于用户想对自己的思路做压力测试,或使用任何 “grill” 触发措辞时。
SkillAFreshness: A★ 5.2KClaude Code +9 - 0.838score
migrate-to-shoehorn
vinvcn
将测试文件从 `as` 类型断言迁移到 @total-typescript/shoehorn。适用于用户提到 shoehorn、想替换测试中的 `as`,或需要局部测试数据时。
SkillAFreshness: A★ 5.2KClaude Code +9 - 0.838score
scaffold-exercises
vinvcn
创建包含章节、题目、答案和讲解的练习目录结构,并确保通过 linting。适用于用户想 scaffold exercises、创建 exercise stubs,或设置新的课程章节时。
SkillAFreshness: A★ 5.2KClaude Code +9
Signals
- Stars
- 5,245
- Forks
- 416
- Open issues
- 0
- Last commit (this folder)
- Oct 8, 2026 (21 days ago)
- Last release
- Oct 8, 2026 (21 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
More from vinvcn
- 0.848score
git-guardrails-claude-code
vinvcn
设置 Claude Code hooks,在危险 git commands(push、reset --hard、clean、branch -D 等)执行前阻止它们。适用于用户想防止破坏性 git 操作、添加 git safety hooks,或在 Claude Code 中阻止 git push/reset 时。
SkillAFreshness: A★ 5.2KClaude Code +9 - 0.844score
diagnosing-bugs
vinvcn
面向棘手缺陷和性能回退的诊断循环。适用于用户说 “diagnose” / “debug this”,或报告某些东西 broken、throwing、failing、slow 时。
SkillAFreshness: A★ 5.2KClaude Code +9 - 0.842score
code-review
vinvcn
从固定点(commit、branch、tag 或 merge-base)开始,按 Standards(代码是否符合本仓库记录的编码标准?)和 Spec(代码是否符合来源 issue/spec 的要求?)两个轴线审查变更。两个审查会在并行子代理中运行,并并排报告。适用于用户想审查…
SkillAFreshness: A★ 5.2KClaude Code +9 - 0.842score
setup-pre-commit
vinvcn
在当前仓库设置 Husky pre-commit hooks,集成 lint-staged (Prettier)、类型检查和测试。适用于用户想添加 pre-commit hooks、设置 Husky、配置 lint-staged,或在提交时运行格式化、类型检查和测试时。
SkillAFreshness: A★ 5.2KClaude Code +9 - 0.842score
setup-ts-deep-modules
vinvcn
在 TypeScript repo 中接入 dependency-cruiser,让每个 package 成为 deep module:implementation 隐藏在 subfolders 中,只能通过 entry-point files 访问。User-invoked。
SkillAFreshness: A★ 5.2KClaude Code +9 - 0.842score
wizard
vinvcn
生成一个交互式 bash wizard,逐步引导人完成只有他们能执行的手动流程。用于 provisioning 基础设施、设置 credentials 或 CI secrets、走查不熟悉的第三方 dashboard,或运行一次性 migration 或 cutover。对于 agent…
SkillAFreshness: A★ 5.2KClaude Code +9
Cite this page
codebase-design skill. Agent Mart. https://agentmart.dev/skills/vinvcn-codebase-design (last updated 2026-10-24)