Codebase Design 标志

Codebase Design

社区
citypaul
codebase-design

设计和评估深模块:通过小巧、稳定、面向调用方的契约承载内聚的职责,并兼顾信息隐藏、合理的边界、明确的副作用、依赖策略和以行为为重点的测试。在设计或修改进程内模块或软件包契约、整合浅层透传模块、决定隐藏哪些内容、比较备选接口,或评估代码应合并还是拆分以提高杠杆效应和局部性时使用。物理布局请使用 structure-codebase;公共兼容性请使用 api-design;扫描整个代码库请使用 improve-codebase-architecture。若已选定完整路径需求,需要支持经过校准的「净机制减少」主张,请使用 reduce-system-complexity。

Add to TypingMind

概览

发布者citypaul
代码仓库.dotfiles
技能名称codebase-design
星标数
740
复刻数
96
附带文件
4
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 4 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 citypaul 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Codebase Design AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/citypaul/.dotfiles/tree/main/claude/.claude/skills/codebase-design
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/citypaul/.dotfiles.git /tmp/.dotfiles
mkdir -p .claude/skills
cp -r /tmp/.dotfiles/claude/.claude/skills/codebase-design .claude/skills/codebase-design
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Codebase Design,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Codebase Design。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Codebase Design 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Codebase Design

Design coherent deep modules: substantial, related behavior and design decisions hidden behind a small, stable caller-facing contract. Optimize for leverage for callers and locality for maintainers without creating a god module.

Use this skill for logical responsibility and contract shape. Use structure-codebase for physical paths, packages, exports, dependency direction, enforcement, and folder migration. Use reduce-system-complexity when the selected objective is an evidence-backed net-reduction claim over whole-path mechanism rather than a deeper contract. Use evaluate-existing-solutions for a consequential unresolved library, tool, application, service, framework, or platform choice.

When improve-codebase-architecture loads this skill during an unselected audit, use only its vocabulary, principles, evidence tests, and thin-edge safeguards. Do not run the contract-design workflow or propose an exact interface until the user selects a candidate.

Read the relevant reference before proposing a consequential design:

Vocabulary

TermMeaning
ModuleA cohesive unit with an implementation and one or more role-shaped caller contracts: a function, object, package, or capability. Scale alone does not make it a module.
Interface / public contractEverything a caller must know to use the module correctly: operations, types, invariants, errors, ordering, configuration, lifecycle, effects, and relevant performance characteristics. This is broader than a TypeScript interface or a type signature.
ImplementationThe decisions and behavior hidden behind the caller-facing contract. Private functions may be small and numerous without becoming public modules.
DepthHow much coherent capability and decision-making a caller gains for the contract burden it must learn. Do not measure depth by lines of code.
LeverageThe caller benefit of depth: one learned contract applies useful behavior consistently across many scenarios.
LocalityThe maintainer benefit of depth: related knowledge, changes, bugs, and verification concentrate in one owner.
SeamPer Michael Feathers, a place where behavior can be changed without editing at that place; every seam has an enabling point. Not every module contract is a seam.
AdapterA concrete translator or implementation selected at a seam. In hexagonal architecture, retain that skill's driving, driven, and test-interactor distinctions.

Use these terms to disambiguate, not to erase useful established vocabulary. API, component, service, signature, boundary, port, and bounded context remain valid when they name those specific concepts.

Design Principles

Hide decisions, not merely code

Place a responsibility behind a module when callers should not each know its policy, sequencing, representation, error recovery, or provider mechanics. A private helper extraction does not deepen a module if the same knowledge still leaks through its parameters and call order.

Keep depth cohesive

A tiny contract over an incoherent implementation is a god module, not a good deep module. Combine behavior only when it shares meaning, invariants, ownership, lifecycle, or a real axis of change. Preserve separate modules when they evolve, fail, deploy, or authorize independently. An extraction earns its boundary when the reader can name the decision or responsibility it owns and understand the caller with less cross-file reconstruction; a file per helper or a chain of trivial forwarding functions does not establish ownership.

Apply the behavior-preserving inlining test

Imagine inlining the module into every caller while preserving behavior:

  • If policy, sequencing, error handling, or representation knowledge spreads across callers, the module earns its place.
  • If callers become simpler because a pass-through disappears and no knowledge is duplicated, the module is shallow or misplaced.

This is the useful form of the deletion test. Do not imagine deleting the behavior itself.

Pull complexity downward deliberately

Make the common call simple. Accept complexity inside the implementation when doing so removes configuration, ordering, special cases, or provider knowledge from callers. Keep effects, failure modes, resource ownership, and performance costs explicit enough that callers can use the module safely.

Justify seams with evidence

Create a seam for a concrete need: substitution, independent testing, volatility isolation, ownership, trust, runtime failure, or deployment. Adapter count is evidence, not a rule. A production adapter plus a faithful test interactor may justify a seam; two accidental wrappers do not.

Test at the stable contract

Make caller-observable behavior the primary test surface. Do not export private helpers or expose internal seams solely to test them. A private subsystem may have focused tests when it is itself a coherent module or when an algorithm needs precise failure localization; those tests must not freeze incidental orchestration.

Preserve intentionally thin edges

Do not diagnose a route leaf, CLI command, adapter, generated client, or composition root as shallow merely because it is thin. Translation and wiring should often be thin. Judge whether policy is hidden in the correct inside module and whether the edge leaks provider or transport knowledge across its contract.

Workflow

1. Define the job and callers

State the behavior the module owns, its current and expected callers, the common case, and what must remain outside. Read project instructions, architecture decisions, glossary conventions, and relevant tests before naming anything new.

2. Inventory the full contract burden

List what each caller must know today:

  • operations and data shapes;
  • invariants and preconditions;
  • call ordering and lifecycle;
  • configuration and dependency construction;
  • errors, retries, partial failure, and effects;
  • latency, throughput, consistency, and transaction expectations.

Do not confuse a short type signature with a small interface.

3. Map hidden and leaked knowledge

Trace callers and collaborators. Identify duplicated decisions, pass-through chains, provider types, repeated orchestration, co-changing files, and tests that must reconstruct internals. Record counterevidence: independent ownership, different failure domains, or callers that genuinely need separate policy.

4. Choose responsibility before the seam

Write one sentence defining the module's coherent responsibility. Decide what knowledge belongs behind it. Only then place seams and select dependency strategies. Read references/deepening.md for existing clusters.

When a material generic dependency or subsystem is not already prescribed, feed this responsibility, caller scenarios, effects, and constraints into evaluate-existing-solutions before finalizing a dependency-shaped contract. Keep the chosen provider or library behind local application language when doing so preserves a useful change boundary; do not wrap every stable primitive by reflex or copy a vendor API into the module contract.

5. Design the contract from use scenarios

Design from representative caller examples, including invalid input, partial failure, cancellation, retries, and lifecycle where relevant. Specify types, invariants, ordering, errors, effects, and performance expectations—not methods alone.

For consequential choices, read references/design-it-twice.md and compare genuinely different designs before recommending one.

6. Test the depth claim

Ask:

  • Does the common caller learn less and coordinate less?
  • Did implementation knowledge move behind the contract, or merely change names?
  • Would a policy change concentrate here rather than fan out?
  • Are effects and failures still honest?
  • Can behavior be tested through the contract with faithful dependencies?
  • Did the design avoid speculative flexibility and a generic command-shaped god interface?

7. Route delivery to the owning skills

  • Use api-design for public HTTP and contracts published or versioned across an ownership boundary. Ordinary in-process component props remain with this skill and the applicable framework/design-system guidance.
  • Use structure-codebase for file/package placement and mechanical dependency enforcement.
  • Use render-code-shape first when the current composition is not yet visible: it returns cited boundaries, signatures, and a call graph, which is the evidence this skill's judgements need.
  • Use reduce-system-complexity when the accepted outcome must remove total branches, states, dependencies, layers, or operational moving parts rather than only improve caller leverage.
  • Use evaluate-existing-solutions when a material generic implementation choice remains unresolved after the responsibility and constraints are known.
  • Use hexagonal-architecture only for an opted-in ports-and-adapters system with purposeful actor conversations.
  • Use finding-seams when existing hard-coded dependencies block a test harness.
  • Use characterisation-tests before restructuring untested behavior.
  • Use tdd, testing, and refactoring during implementation according to whether behavior changes and whether the safety net is trustworthy. At PR readiness, follow the repository's mutation policy; where mutation is not meaningful, record proportionate alternate evidence.
  • Use ubiquitous-language when a domain term must be proposed or changed; never coin it silently.

Design Output

Produce:

  1. The module's one-sentence responsibility and explicit exclusions.
  2. Callers and representative usage scenarios.
  3. The complete proposed contract, including non-type obligations.
  4. Knowledge and behavior hidden behind it.
  5. Dependencies, seams, adapters or test interactors, and their fidelity strategy.
  6. Alternatives considered and why the recommendation wins.
  7. Compatibility and incremental migration constraints.
  8. Behavior tests that should survive implementation changes.
  9. Assumptions, risks, and evidence still needed.

Completion Check

  • Is the contract simpler than the coherent behavior it provides?
  • Does it hide decisions rather than expose orchestration knobs?
  • Is the common case obvious without making uncommon cases impossible?
  • Are cohesion, ownership, failure, and runtime boundaries still honest?
  • Are seams justified by real variation or isolation needs?
  • Can callers and behavior tests use the same stable contract?
  • Are thin edges still thin and policy-free?
  • Does every compatibility or migration claim have a verification path?

Attribution

Adapted from Matt Pocock's MIT-licensed codebase-design skill and linked resources, with deep-module and Design It Twice concepts credited to John Ousterhout and seam terminology credited to Michael Feathers. See references/source-notes.md and LICENSE for pinned provenance and license terms.

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Codebase Design AI 技能有什么作用?

设计和评估深模块:通过小巧、稳定、面向调用方的契约承载内聚的职责,并兼顾信息隐藏、合理的边界、明确的副作用、依赖策略和以行为为重点的测试。在设计或修改进程内模块或软件包契约、整合浅层透传模块、决定隐藏哪些内容、比较备选接口,或评估代码应合并还是拆分以提高杠杆效应和局部性时使用。物理布局请使用 structure-codebase;公共兼容性请使用 api-design;扫描整个代码库请使用 improve-codebase-architecture。若已选定完整路径需求,需要支持经过校准的「净机制减少」主张,请使用 reduce-system-complexity。

为什么在 TypingMind 中使用 Codebase Design?

因为您只需安装一次,就能搭配任何模型使用。Codebase Design 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Codebase Design?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/citypaul/.dotfiles/tree/main/claude/.claude/skills/codebase-design。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Codebase Design?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Codebase Design 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Codebase Design 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Codebase Design AI 技能免费吗?

citypaul 已在 GitHub 上发布了该技能。请查看代码仓库了解许可条款。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇