mk:api-design-principles
Designs and reviews API contracts (REST, GraphQL, RPC, events) by finding the existing consumers and conventions first.
| Source | .claude/skills/api-design-principles/SKILL.md |
| Owner | portability |
| Runtime | portable |
| Risk | high |
mk:api-design-principles authors and reviews what an API promises consumers: shape, error and authorization requirements, compatibility, deprecation and pagination. It finds the existing consumers and conventions before recommending anything, so an extension matches the API it extends. Use it before handlers are written, or to review a contract.
When not to use it
| If you need | Use |
|---|---|
| The handler or service implemented | mk:backend-development |
| Schema, migration, query or index work | mk:database |
| Infrastructure, delivery or rollback | mk:devops |
| A security verdict | the security workflow (mk:cso) |
A contract-only question stays here even in the middle of a backend task. A backend task loads this skill only when a new, public or breaking contract is in scope. A message-based change splits: the message contract is here, the producer or consumer code is mk:backend-development.
Usage
/mk:api-design-principles [contract or review] [--rest|--graphql|--rpc|--event]| Flag | Meaning |
|---|---|
--rest | HTTP contract. Loads references/rest-principles.md |
--graphql | GraphQL schema. Loads references/graphql-principles.md |
--rpc, --event | Message contract. Loads neither reference |
What it does
- Discover: existing consumers, contract surface, versioning scheme, error envelope, pagination shape and contract tests.
- Classify: keep the discovered style. On greenfield work, choose from client shape, query flexibility, streaming need and consumer ownership, and say why.
- Model: shape, authorization requirement, validation and error semantics, and only the idempotency, concurrency or pagination the use case needs.
- Review with examples: success, invalid input, forbidden, conflict or not found, and one evolution case. A contract with no failure example is unreviewed.
- Hand off: implementation, persistence, security verdict and release go to their owners.
Compatibility rules
| Case | Rule |
|---|---|
| Additive (optional field, new operation) | Safe, no version bump |
| Breaking | Anything a current consumer can observe: removed or renamed field, narrowed type, changed default, tighter validation, changed status or error code, changed pagination shape |
| Before breaking | Name every consumer found. An unknown consumer set is itself a finding |
| Removal | Deprecate first, keep the old shape working, signal to consumers, remove after migration is evidenced |
| Versioning | Follow the discovered scheme |
Page sizes, rate limits, cache policies and sunset windows are read from the repository or asked for, never invented.
Output
A compact contract decision record: discovered evidence, consumer set and stability class, style rationale, contract delta, error, authorization and compatibility semantics, the reviewed examples, and hand-offs.
Gotchas
- Consistency with the shipped contract beats any convention. Plural nouns, shallow nesting and cursor pagination are defaults that yield to what the API already does.
- Two error envelopes already shipped means converging them is a breaking change. Document the target instead of adding a third.
- An error body must not leak stack traces, driver errors, file paths or host details.
- A GraphQL field that fans out per parent row needs its fetch cost addressed before the schema ships. The fix goes to
mk:database. - With no broker in the repository, the skill says the capability is absent and does not design a queue or retry path.