design-an-api-or-interface
Design APIs/interfaces with Design It Twice: create alternatives, compare tradeoffs, choose one. Use when designing an API, module, class, or boundary.
- License 许可
- Apache-2.0
- 所属仓库
- r3dlex/skills
- 最近更新
- 2026-10-29
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- design-an-api-or-interface
- description
- Design APIs/interfaces with Design It Twice: create alternatives, compare tradeoffs, choose one. Use when designing an API, module, class, or boundary.
03 SKILL.md 正文
Design an API or Interface
Quick Start
- Gather requirements (problem, callers, key ops, constraints)
- Spawn 3+ sub-agents in parallel, each with different design constraints
- Present each design with signature, examples, trade-offs
- Compare and recommend
- Synthesize best elements
Workflow
Step 1 — Gather Requirements
Before generating designs, understand:
- Problem: What does this interface solve?
- Callers: Who will use it? What do they need?
- Key operations: Most common operations?
- Constraints: Performance, memory, API compatibility?
- Surface area: What to hide vs expose?
Step 2 — Generate Designs in Parallel
Spawn 3+ sub-agents with different constraints:
| Agent | Constraint |
|---|---|
| A | Minimize method count — leanest possible |
| B | Maximize flexibility — most general-purpose |
| C | Optimize for common case — prioritize frequent ops |
| D | Ports & adapters pattern for cross-boundary deps |
Each produces: interface signature, usage examples, internal complexity, trade-offs.
Step 3 — Present Each Design
Show: interface signature, usage code, hidden complexity, key trade-offs.
Step 4 — Compare Designs
Evaluate on: simplicity, flexibility, implementation efficiency, depth, ease of use vs misuse.
Step 5 — Synthesize
Combine insights. Often best design borrows from multiple options.
Key Principles
- Interface simplicity: Fewer methods with focused purpose
- General-purpose without over-generalization: Don't bloat for hypothetical needs
- Implementation efficiency: Interface shape allows performant internals
- Depth: Small surface area hiding significant complexity
Based on "A Philosophy of Software Design" by John Ousterhout — "Design It Twice" principle.
04 同仓库更多 Skills
skill
Fixture.
stable-skill
Fixture stable-skill.
experimental-skill
Fixture experimental-skill.
deprecated-skill
Fixture deprecated-skill.
karpathy-guidelines
Apply think-before-coding, simplicity, surgical-change, and goal-driven engineering rules. Use when planning, implementing, or reviewing code.
karpathy-guidelines
Apply think-before-coding, simplicity, surgical-change, and goal-driven engineering rules. Use when planning, implementing, or reviewing code.