Skip to content

Commit 1540006

Browse files
nicklemmonclaude
andcommitted
Merges domain vocabulary from CONTEXT.md into CLAUDE.md
CONTEXT.md was always-read only if explicitly fetched; CLAUDE.md is automatically loaded into every agent context, so the vocabulary is more reliably available there. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 34aeb42 commit 1540006

13 files changed

Lines changed: 646 additions & 249 deletions

File tree

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,53 @@
11
# Deepening
22

3-
How to deepen a cluster of shallow modules safely, given its dependencies. Assumes the vocabulary in [SKILL.md](SKILL.md)**module**, **interface**, **seam**, **adapter**.
3+
How to deepen a cluster of shallow modules safely, given its dependencies. Assumes the vocabulary in
4+
[SKILL.md](SKILL.md)**module**, **interface**, **seam**, **adapter**.
45

56
## Dependency categories
67

7-
When assessing a candidate for deepening, classify its dependencies. The category determines how the deepened module is tested across its seam.
8+
When assessing a candidate for deepening, classify its dependencies. The category determines how the
9+
deepened module is tested across its seam.
810

911
### 1. In-process
1012

11-
Pure computation, in-memory state, no I/O. Always deepenable — merge the modules and test through the new interface directly. No adapter needed.
13+
Pure computation, in-memory state, no I/O. Always deepenable — merge the modules and test through
14+
the new interface directly. No adapter needed.
1215

1316
### 2. Local-substitutable
1417

15-
Dependencies that have local test stand-ins (PGLite for Postgres, in-memory filesystem). Deepenable if the stand-in exists. The deepened module is tested with the stand-in running in the test suite. The seam is internal; no port at the module's external interface.
18+
Dependencies that have local test stand-ins (PGLite for Postgres, in-memory filesystem). Deepenable
19+
if the stand-in exists. The deepened module is tested with the stand-in running in the test suite.
20+
The seam is internal; no port at the module's external interface.
1621

1722
### 3. Remote but owned (Ports & Adapters)
1823

19-
Your own services across a network boundary (microservices, internal APIs). Define a **port** (interface) at the seam. The deep module owns the logic; the transport is injected as an **adapter**. Tests use an in-memory adapter. Production uses an HTTP/gRPC/queue adapter.
24+
Your own services across a network boundary (microservices, internal APIs). Define a **port**
25+
(interface) at the seam. The deep module owns the logic; the transport is injected as an
26+
**adapter**. Tests use an in-memory adapter. Production uses an HTTP/gRPC/queue adapter.
2027

21-
Recommendation shape: *"Define a port at the seam, implement an HTTP adapter for production and an in-memory adapter for testing, so the logic sits in one deep module even though it's deployed across a network."*
28+
Recommendation shape: _"Define a port at the seam, implement an HTTP adapter for production and an
29+
in-memory adapter for testing, so the logic sits in one deep module even though it's deployed across
30+
a network."_
2231

2332
### 4. True external (Mock)
2433

25-
Third-party services (Stripe, Twilio, etc.) you don't control. The deepened module takes the external dependency as an injected port; tests provide a mock adapter.
34+
Third-party services (Stripe, Twilio, etc.) you don't control. The deepened module takes the
35+
external dependency as an injected port; tests provide a mock adapter.
2636

2737
## Seam discipline
2838

29-
- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a port unless at least two adapters are justified (typically production + test). A single-adapter seam is just indirection.
30-
- **Internal seams vs external seams.** A deep module can have internal seams (private to its implementation, used by its own tests) as well as the external seam at its interface. Don't expose internal seams through the interface just because tests use them.
39+
- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a port
40+
unless at least two adapters are justified (typically production + test). A single-adapter seam is
41+
just indirection.
42+
- **Internal seams vs external seams.** A deep module can have internal seams (private to its
43+
implementation, used by its own tests) as well as the external seam at its interface. Don't expose
44+
internal seams through the interface just because tests use them.
3145

3246
## Testing strategy: replace, don't layer
3347

34-
- Old unit tests on shallow modules become waste once tests at the deepened module's interface exist — delete them.
48+
- Old unit tests on shallow modules become waste once tests at the deepened module's interface exist
49+
— delete them.
3550
- Write new tests at the deepened module's interface. The **interface is the test surface**.
3651
- Tests assert on observable outcomes through the interface, not internal state.
37-
- Tests should survive internal refactors — they describe behaviour, not implementation. If a test has to change when the implementation changes, it's testing past the interface.
52+
- Tests should survive internal refactors — they describe behaviour, not implementation. If a test
53+
has to change when the implementation changes, it's testing past the interface.
Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,46 @@
11
# Design It Twice
22

3-
When the user wants to explore alternative interfaces for a chosen deepening candidate, use this parallel sub-agent pattern. Based on "Design It Twice" (Ousterhout) — your first idea is unlikely to be the best.
3+
When the user wants to explore alternative interfaces for a chosen deepening candidate, use this
4+
parallel sub-agent pattern. Based on "Design It Twice" (Ousterhout) — your first idea is unlikely to
5+
be the best.
46

5-
Uses the vocabulary in [SKILL.md](SKILL.md)**module**, **interface**, **seam**, **adapter**, **leverage**.
7+
Uses the vocabulary in [SKILL.md](SKILL.md)**module**, **interface**, **seam**, **adapter**,
8+
**leverage**.
69

710
## Process
811

912
### 1. Frame the problem space
1013

11-
Before spawning sub-agents, write a user-facing explanation of the problem space for the chosen candidate:
14+
Before spawning sub-agents, write a user-facing explanation of the problem space for the chosen
15+
candidate:
1216

1317
- The constraints any new interface would need to satisfy
14-
- The dependencies it would rely on, and which category they fall into (see [DEEPENING.md](DEEPENING.md))
15-
- A rough illustrative code sketch to ground the constraints — not a proposal, just a way to make the constraints concrete
18+
- The dependencies it would rely on, and which category they fall into (see
19+
[DEEPENING.md](DEEPENING.md))
20+
- A rough illustrative code sketch to ground the constraints — not a proposal, just a way to make
21+
the constraints concrete
1622

17-
Show this to the user, then immediately proceed to Step 2. The user reads and thinks while the sub-agents work in parallel.
23+
Show this to the user, then immediately proceed to Step 2. The user reads and thinks while the
24+
sub-agents work in parallel.
1825

1926
### 2. Spawn sub-agents
2027

21-
Spawn 3+ sub-agents in parallel using the Agent tool. Each must produce a **radically different** interface for the deepened module.
28+
Spawn 3+ sub-agents in parallel using the Agent tool. Each must produce a **radically different**
29+
interface for the deepened module.
2230

23-
Prompt each sub-agent with a separate technical brief (file paths, coupling details, dependency category from [DEEPENING.md](DEEPENING.md), what sits behind the seam). The brief is independent of the user-facing problem-space explanation in Step 1. Give each agent a different design constraint:
31+
Prompt each sub-agent with a separate technical brief (file paths, coupling details, dependency
32+
category from [DEEPENING.md](DEEPENING.md), what sits behind the seam). The brief is independent of
33+
the user-facing problem-space explanation in Step 1. Give each agent a different design constraint:
2434

25-
- Agent 1: "Minimize the interface — aim for 1–3 entry points max. Maximise leverage per entry point."
35+
- Agent 1: "Minimize the interface — aim for 1–3 entry points max. Maximise leverage per entry
36+
point."
2637
- Agent 2: "Maximise flexibility — support many use cases and extension."
2738
- Agent 3: "Optimise for the most common caller — make the default case trivial."
2839
- Agent 4 (if applicable): "Design around ports & adapters for cross-seam dependencies."
2940

30-
Include both [SKILL.md](SKILL.md) vocabulary and CONTEXT.md vocabulary in the brief so each sub-agent names things consistently with the architecture language and the project's domain language.
41+
Include both [SKILL.md](SKILL.md) vocabulary and CONTEXT.md vocabulary in the brief so each
42+
sub-agent names things consistently with the architecture language and the project's domain
43+
language.
3144

3245
Each sub-agent outputs:
3346

@@ -39,6 +52,10 @@ Each sub-agent outputs:
3952

4053
### 3. Present and compare
4154

42-
Present designs sequentially so the user can absorb each one, then compare them in prose. Contrast by **depth** (leverage at the interface), **locality** (where change concentrates), and **seam placement**.
55+
Present designs sequentially so the user can absorb each one, then compare them in prose. Contrast
56+
by **depth** (leverage at the interface), **locality** (where change concentrates), and **seam
57+
placement**.
4358

44-
After comparing, give your own recommendation: which design you think is strongest and why. If elements from different designs would combine well, propose a hybrid. Be opinionated — the user wants a strong read, not a menu.
59+
After comparing, give your own recommendation: which design you think is strongest and why. If
60+
elements from different designs would combine well, propose a hybrid. Be opinionated — the user
61+
wants a strong read, not a menu.

.agents/skills/codebase-design/SKILL.md

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,52 @@
11
---
22
name: codebase-design
3-
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.
3+
description:
4+
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a
5+
module's interface, find deepening opportunities, decide where a seam goes, make code more
6+
testable or AI-navigable, or when another skill needs the deep-module vocabulary.
47
---
58

69
# Codebase Design
710

8-
Design **deep modules**: a lot of behaviour behind a small interface, placed at a clean seam, testable through that interface. Use this language and these principles wherever code is being designed or restructured. The aim is leverage for callers, locality for maintainers, and testability for everyone.
11+
Design **deep modules**: a lot of behaviour behind a small interface, placed at a clean seam,
12+
testable through that interface. Use this language and these principles wherever code is being
13+
designed or restructured. The aim is leverage for callers, locality for maintainers, and testability
14+
for everyone.
915

1016
## Glossary
1117

12-
Use these terms exactly — don't substitute "component," "service," "API," or "boundary." Consistent language is the whole point.
18+
Use these terms exactly — don't substitute "component," "service," "API," or "boundary." Consistent
19+
language is the whole point.
1320

14-
**Module** — anything with an interface and an implementation. Deliberately scale-agnostic: a function, class, package, or tier-spanning slice. _Avoid_: unit, component, service.
21+
**Module** — anything with an interface and an implementation. Deliberately scale-agnostic: a
22+
function, class, package, or tier-spanning slice. _Avoid_: unit, component, service.
1523

16-
**Interface** — everything a caller must know to use the module correctly: the type signature, but also invariants, ordering constraints, error modes, required configuration, and performance characteristics. _Avoid_: API, signature (too narrow — they refer only to the type-level surface).
24+
**Interface** — everything a caller must know to use the module correctly: the type signature, but
25+
also invariants, ordering constraints, error modes, required configuration, and performance
26+
characteristics. _Avoid_: API, signature (too narrow — they refer only to the type-level surface).
1727

18-
**Implementation** — what's inside a module, its body of code. Distinct from **Adapter**: a thing can be a small adapter with a large implementation (a Postgres repo) or a large adapter with a small implementation (an in-memory fake). Reach for "adapter" when the seam is the topic; "implementation" otherwise.
28+
**Implementation** — what's inside a module, its body of code. Distinct from **Adapter**: a thing
29+
can be a small adapter with a large implementation (a Postgres repo) or a large adapter with a small
30+
implementation (an in-memory fake). Reach for "adapter" when the seam is the topic; "implementation"
31+
otherwise.
1932

20-
**Depth** — leverage at the interface: the amount of behaviour a caller (or test) can exercise per unit of interface they have to learn. 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.
33+
**Depth** — leverage at the interface: the amount of behaviour a caller (or test) can exercise per
34+
unit of interface they have to learn. A module is **deep** when a large amount of behaviour sits
35+
behind a small interface, **shallow** when the interface is nearly as complex as the implementation.
2136

22-
**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 its own design decision, distinct from what goes behind it. _Avoid_: boundary (overloaded with DDD's bounded context).
37+
**Seam** _(Michael Feathers)_ — a place where you can alter behaviour without editing in that place;
38+
the _location_ at which a module's interface lives. Where to put the seam is its own design
39+
decision, distinct from what goes behind it. _Avoid_: boundary (overloaded with DDD's bounded
40+
context).
2341

24-
**Adapter** — a concrete thing that satisfies an interface at a seam. Describes *role* (what slot it fills), not substance (what's inside).
42+
**Adapter** — a concrete thing that satisfies an interface at a seam. Describes _role_ (what slot it
43+
fills), not substance (what's inside).
2544

26-
**Leverage** — what callers get from depth: more capability per unit of interface they learn. One implementation pays back across N call sites and M tests.
45+
**Leverage** — what callers get from depth: more capability per unit of interface they learn. One
46+
implementation pays back across N call sites and M tests.
2747

28-
**Locality** — what maintainers get from depth: change, bugs, knowledge, and verification concentrate in one place rather than spreading across callers. Fix once, fixed everywhere.
48+
**Locality** — what maintainers get from depth: change, bugs, knowledge, and verification
49+
concentrate in one place rather than spreading across callers. Fix once, fixed everywhere.
2950

3051
## Deep vs shallow
3152

@@ -59,10 +80,16 @@ When designing an interface, ask:
5980

6081
## Principles
6182

62-
- **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.
63-
- **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.
64-
- **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.
65-
- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a seam unless something actually varies across it.
83+
- **Depth is a property of the interface, not the implementation.** A deep module can be internally
84+
composed of small, mockable, swappable parts — they just aren't part of the interface. A module
85+
can have **internal seams** (private to its implementation, used by its own tests) as well as the
86+
**external seam** at its interface.
87+
- **The deletion test.** Imagine deleting the module. If complexity vanishes, it was a pass-through.
88+
If complexity reappears across N callers, it was earning its keep.
89+
- **The interface is the test surface.** Callers and tests cross the same seam. If you want to test
90+
_past_ the interface, the module is probably the wrong shape.
91+
- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a seam
92+
unless something actually varies across it.
6693

6794
## Designing for testability
6895

@@ -76,7 +103,7 @@ Good interfaces make testing natural:
76103

77104
// Hard to test
78105
function processOrder(order) {
79-
const gateway = new StripeGateway();
106+
const gateway = new StripeGateway()
80107
}
81108
```
82109

@@ -88,7 +115,7 @@ Good interfaces make testing natural:
88115

89116
// Hard to test
90117
function applyDiscount(cart): void {
91-
cart.total -= discount;
118+
cart.total -= discount
92119
}
93120
```
94121

@@ -104,11 +131,16 @@ Good interfaces make testing natural:
104131

105132
## Rejected framings
106133

107-
- **Depth as ratio of implementation-lines to interface-lines** (Ousterhout): rewards padding the implementation. We use depth-as-leverage instead.
108-
- **"Interface" as the TypeScript `interface` keyword or a class's public methods**: too narrow — interface here includes every fact a caller must know.
134+
- **Depth as ratio of implementation-lines to interface-lines** (Ousterhout): rewards padding the
135+
implementation. We use depth-as-leverage instead.
136+
- **"Interface" as the TypeScript `interface` keyword or a class's public methods**: too narrow —
137+
interface here includes every fact a caller must know.
109138
- **"Boundary"**: overloaded with DDD's bounded context. Say **seam** or **interface**.
110139

111140
## Going deeper
112141

113-
- **Deepening a cluster given its dependencies** — see [DEEPENING.md](DEEPENING.md): dependency categories, seam discipline, and replace-don't-layer testing.
114-
- **Exploring alternative interfaces** — see [DESIGN-IT-TWICE.md](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.
142+
- **Deepening a cluster given its dependencies** — see [DEEPENING.md](DEEPENING.md): dependency
143+
categories, seam discipline, and replace-don't-layer testing.
144+
- **Exploring alternative interfaces** — see [DESIGN-IT-TWICE.md](DESIGN-IT-TWICE.md): spin up
145+
parallel sub-agents to design the interface several radically different ways, then compare on
146+
depth, locality, and seam placement.

0 commit comments

Comments
 (0)