AGENT SKILL

codebase-design

Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.

License 许可
MIT
最近更新
2026-11-12
Stars
★ 0
Forks
0

01 前言 Front Matter

name
codebase-design
description
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.

03 SKILL.md 正文

Codebase Design

Design deep modules: a lot of behaviour behind a small interface, placed at a clean seam, testable through that interface. Aim for leverage for callers, locality for maintainers, and testability for everyone.

Glossary

Use these terms exactly: don't substitute "component," "service," "API," or "boundary."

Module: anything with an interface and an implementation; deliberately scale-agnostic (a function, class, package, or tier-spanning slice). Avoid: unit, component, service.

Interface: everything a caller must know to use the module correctly: the type signature, plus invariants, ordering constraints, error modes, required configuration, and performance characteristics. Avoid: API, signature (too narrow: they refer only to the type-level surface).

Implementation: the code inside a module. Distinct from Adapter: a small adapter can have a large implementation (a Postgres repo); a large adapter can have a small implementation (an in-memory fake). Use "adapter" when the seam is the topic, "implementation" otherwise.

Depth: leverage at the interface: the behaviour a caller or test can exercise per unit of interface learned. A module is deep when a large amount of behaviour sits behind a small interface, shallow when the interface is nearly as complex as the implementation.

Seam (Michael Feathers): a place where you can alter behaviour without editing in that place; the location at which a module's interface lives. Where to put the seam is a design decision distinct from what goes behind it. Avoid: boundary (overloaded with DDD's bounded context).

Adapter: a concrete thing that satisfies an interface at a seam. Describes a role, not a substance.

Leverage: what callers get from depth: more capability per unit of interface learned; one implementation pays back across N call sites and M tests.

Locality: what maintainers get from depth: change, bugs, knowledge, and verification concentrate in one place rather than spreading across callers. Fix once, fixed everywhere.

Deep vs shallow

Deep = small interface + lots of implementation. Shallow = large interface + little implementation (avoid).

When designing an interface, ask: can I reduce the number of methods, simplify the parameters, or hide more complexity inside?

Principles

  • Depth is a property of the interface, not the implementation. A deep module can be internally composed of small, mockable, swappable parts; they just aren't part of the interface. A module can have internal seams (private to its implementation, used by its own tests) as well as the external seam at its interface.
  • The deletion test. Imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep.
  • The interface is the test surface. Callers and tests cross the same seam. If you want to test past the interface, the module is probably the wrong shape.
  • One adapter means a hypothetical seam. Two adapters means a real one. Don't introduce a seam unless something actually varies across it.

Designing for testability

  1. Accept dependencies, don't create them. Pass collaborators in as parameters; a module that constructs its own gateway cannot be tested in isolation.
  2. Return results, don't produce side effects. Return new values rather than mutating shared state.
  3. Small surface area. Fewer methods and params mean fewer tests and simpler setup.

Relationships

  • A Module has exactly one Interface (the surface it presents to callers and tests).
  • Depth is a property of a Module, measured against its Interface.
  • A Seam is where a Module's Interface lives.
  • An Adapter sits at a Seam and satisfies the Interface.
  • Depth produces Leverage for callers and Locality for maintainers.

Rejected framings

  • Depth as ratio of implementation-lines to interface-lines (Ousterhout): rewards padding the implementation. We use depth-as-leverage instead.
  • "Interface" as the TypeScript interface keyword or a class's public methods: too narrow: interface here includes every fact a caller must know.
  • "Boundary": overloaded with DDD's bounded context. Say seam or interface.

Going deeper

  • Deepening a cluster given its dependencies, see DEEPENING.md: dependency categories, seam discipline, and replace-don't-layer testing.
  • Exploring alternative interfaces, see DESIGN-IT-TWICE.md: spin up parallel sub-agents to design the interface several radically different ways, then compare on depth, locality, and seam placement.

04 同仓库更多 Skills

khnker
khnker/opencode-wait-a-minute

writing-for-agents

Writing and reducing documents for agents. Use when creating, editing, pruning, or restructuring skills, or modifying AGENTS.md or CLAUDE.md.

★ 0
khnker
khnker/opencode-wait-a-minute

wizard

Generate an interactive bash wizard that walks a human through steps only they can perform. Use when provisioning infrastructure, setting up credentials or CI secrets, walking an unfamiliar third-party dashboard, or running a one-off migration or cutover. Don't invoke this for steps the agent can perform itself.

★ 0
khnker
khnker/opencode-wait-a-minute

web-design

Routes UI/frontend design work — interfaces, components, design systems, tokens, responsive layouts, accessibility, visual review, anti-slop, DESIGN.md.

★ 0
khnker
khnker/opencode-wait-a-minute

design-visual-frontend

Design, build, redesign, or critically review distinctive frontend interfaces with strong composition, domain authenticity, responsive behavior, component coherence, and browser-verified visual quality. Use for websites, landing pages, login and form flows, dashboards, admin tools, product pages, portfolios, visual UI reviews, anti-template redesigns, or any request where frontend aesthetics and usability both matter.

★ 0
khnker
khnker/opencode-wait-a-minute

verify

Evidence-backed verification before completion. Use when the user asks to verify, validate, test, or confirm work, or before claiming DONE, fixed, working, completed, or ready. Maps each mandatory criterion to an observable check and refuses completion while the runtime gate has pending work.

★ 0
khnker
khnker/opencode-wait-a-minute

unslop

暂无简介

★ 0