design-an-interface
БесплатноБез исполняемых скриптовНе проверенDesigns the public interface of a module before any implementation exists: writes the caller scenarios first, produces three candidates with genuinely…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Design an Interface
Overview
An interface is everything a caller must know to use a module: the names, the parameter and result types, the order calls have to happen in, how failures show up, and what is promised to stay stable. It is the part that costs most to change later, because every caller is written against it. This skill explores the alternatives while they are still free: caller scenarios come first, then three candidates of different shape, then a proof that each candidate can express the scenarios, a scored comparison and a short decision record. No implementation is written at any point.
Instructions
1. Collect the facts
Read the project before asking anything:
- Callers. Search for existing or future call sites (
grep -rn "sendNotification(" src/), count them, and note which arguments vary and which are always the same. - House conventions. How do neighbouring modules report errors (exceptions or result values), are they async, how are dependencies passed in, how are things named?
- Stability promise. If every caller lives in this repository the interface can change later with one refactoring commit. If it is published (a package, a public HTTP route, a CLI) every incompatible change costs a major version under Semantic Versioning and a migration for people you cannot reach.
Then ask the user only what the code cannot answer: the three to five things callers need to get done, hard constraints (latency, ordering, idempotency, permissions), two changes likely in the next year, and what is out of scope.
2. Write the caller scenarios first
Write three to five scenarios, each one a concrete task from a caller's point of view with real inputs and the outcome it expects. Include at least one failure path and one test scenario (how a caller's own test controls or replaces the module). The scenarios are the yardstick for every later step, so get the user to confirm them before drafting signatures.
3. Draft three candidates of different shape
Give each candidate one shape from this list, choosing three that could plausibly fit:
| Shape | What calling it feels like | Usually suits |
|---|---|---|
| Plain functions | data in, data out, nothing to hold on to | stateless transformations, one-shot operations |
| Handle object | create once with configuration, then call methods | connections, shared settings, anything with a lifecycle |
| Declarative table | describe the wanted result as data, the module works out the steps | rules, schemas, routing, pipelines |
| Stream or events | iterate or subscribe as results arrive | long-running, large or incremental work |
| Ecosystem mirror | looks like a library the callers already use | cases where familiarity beats invention |
Where sub-agents exist (Claude Code), start all three in one message so they run concurrently and cannot see each other's drafts. Elsewhere, write them one after another, each time starting again from the scenarios. Every drafter receives the facts, the scenarios, its assigned shape and this required output:
- Declarations only: types and signatures, no bodies.
- Every scenario written as real calling code against those declarations.
- What a caller has to know, and what the module keeps to itself.
- The single channel through which each failure is reported.
- For each of the two expected changes: does the interface absorb it, grow, or break?
Then run the difference test: put the scenario 1 code of the candidates side by side. If two differ only in names they are the same design; drop one and assign an unused shape.
4. Prove each candidate against the scenarios
Put the declarations and the scenario code in a scratch folder and run the type checker. Nothing is implemented; the question is only whether the scenarios can be written and whether wrong calls are rejected.
mkdir -p design/rate-limit && cd design/rate-limit
cat > tsconfig.json <<'JSON'
{ "compilerOptions": { "strict": true, "noEmit": true, "target": "ES2022", "module": "ESNext",
"moduleResolution": "Bundler", "skipLibCheck": true, "types": ["node"] }, "include": ["*.ts"] }
JSON
# candidate-a.ts + scenarios-a.ts, candidate-b.ts + scenarios-b.ts, ...
npx -p typescript tsc -p . # exit 0 = every scenario can be written
- Write the declarations in ordinary
.tsfiles (export declare function …), not.d.ts:skipLibCheckskips every.d.ts, so a misspelled type in a candidate would pass unnoticed. - Mark each wrong call that must be rejected with
// @ts-expect-error. The compiler then fails with error TS2578 if the interface accepts the call after all. - Python: declare the interface as a
typing.Protocolplus dataclasses, write the scenarios as functions, runmypy --strict notifier_draft.py scenarios.py. A deliberate misuse carries# type: ignore[arg-type]; strict mode reports an unused ignore, so an interface that accepts the misuse fails the check. - Go and Rust: an interface or trait in a
Установить design-an-interface в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл design-an-interface?
Designs the public interface of a module before any implementation exists: writes the caller scenarios first, produces three candidates with genuinely different shapes, type-checks each one against the scenarios, scores them on measurable criteria and records the decision. Use when someone says "design the API for this module", "what should this signature look like", "compare interface options", "this function is awkward to call", "show me alternatives before I build it", or is about to add a module, library entry point, endpoint or command that other code will depend on.
Как установить скилл design-an-interface?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл design-an-interface запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic