Skip to content
Back to skills

Api Design Principles

ASecurity

Designs REST, GraphQL, event APIs. NOT for mk:backend-development.

  • 17 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 6, 2026
ai-agentsgosqlexpressapidatabasebackenddevopssecurityperformance

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned November 24, 2026

npx -y skills add ngocsangyem/MeowKit --skill api-design-principles --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Api Design Principles?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Api Design Principles
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ngocsangyem-api-design-principles/badge)](https://www.skillsdirectory.com/skills/ngocsangyem-api-design-principles)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: mk:api-design-principles
description: "Designs REST, GraphQL, event APIs. NOT for mk:backend-development."
version: 1.0.0
argument-hint: '[contract or review] [--rest|--graphql|--rpc|--event]'
source: local
allowed-tools:
  - Read
  - Write
  - Glob
  - Grep
keywords:
  - api-contract
  - rest
  - graphql
  - rpc
  - event-contract
  - contract-compatibility
  - pagination
  - error-semantics
  - deprecation
  - consumer-discovery
when_to_use: "API contract."
user-invocable: true
owner: portability
criticality: high
status: active
runtime: portable
---

# API Design Principles

Durable interface contracts. Discover the existing contract before proposing a new one.

<!-- shared:backend-routing -->
## Ownership

| Owner | Owns | Does NOT own |
|---|---|---|
| `mk:api-design-principles` | Interface contract: resource/type/message shape, error and authorization *requirements*, compatibility and deprecation, consumer discovery | Implementation, persistence, security verdict, release |
| `mk:backend-development` | End-to-end backend change: discovery, classification, service/handler/integration work, wiring the specialists together | Contract authorship, schema/SQL, security verdict, deploy |
| `mk:database` | Data invariants, schema, migration and recovery, query/index evidence, ORM data-access boundary | API contract, authorization verdict, infrastructure execution |
| `mk:devops` | Infrastructure-as-code, containers, CI, runtime config, deployment safety design, rollback planning, incident diagnosis | Deploy approval and execution, security verdict, code root-cause, schema semantics |

Routing rules — identical in all four skills:

- **Contract-only API question → `mk:api-design-principles`**, even in the middle of a task
  owned by another skill. "Contract" means what a consumer can observe: field set, error
  shape, status semantics, pagination, versioning. Extending an endpoint without changing
  any of those is not a contract change.
- **End-to-end backend change → `mk:backend-development`**, which invokes the API skill only
  when a new, public, or breaking contract is in scope.
- **A message-based change (event, webhook, RPC) splits**: the message contract belongs to
  `mk:api-design-principles`; the producer or consumer implementation belongs to
  `mk:backend-development`.
- **Schema, migration, query, index, or ORM work → `mk:database`.** No other skill writes a
  migration or generic SQL.
- **Infrastructure, containers, delivery, or deployment safety → `mk:devops`.**
- **An unscoped performance request is triaged by evidence, never by guess**:
  `mk:backend-development` locates where the time actually goes, then hands a query or index
  question to `mk:database` and a capacity or runtime question to `mk:devops`. No skill
  invents the target.
- **Code root cause → `mk:investigate`.** `mk:devops` owns the operational picture — what
  changed, where it fails, which signal proves it — and hands the defect over.
- **An auth-sensitive change**: the owning skill states the *requirement*; `mk:cso`
  owns the verdict.
- **Any production effect → `mk:ship` or a human.**
<!-- /shared:backend-routing -->

## Workflow

For a small additive change (one optional field on an existing operation), steps 1 and 3 are enough; run step 4 for new or breaking contracts.

1. **Discover.** Find existing consumers, the current contract surface, versioning scheme,
   error envelope, pagination shape, and contract tests. Record what already exists before
   proposing anything. Never invent a convention the repository already answers.
2. **Classify the interface.** Preserve the discovered style. On greenfield, choose from
   evidence — client shape, query flexibility, streaming need, and who owns the consumer —
   not from habit. Say why.
3. **Model the contract.** Define resource/type/message shape, the authorization
   *requirement* per operation, validation and error semantics, and only the idempotency,
   concurrency, or pagination the use case actually needs.
4. **Review with examples.** Walk success, invalid input, forbidden, conflict/not-found, and
   one evolution case. A new or breaking contract with no failure example is unreviewed.
5. **Hand off.** Implementation to `mk:backend-development`, persistence to `mk:database`,
   security verdict to `mk:cso`, release to `mk:ship`.

Load `references/rest-principles.md` for HTTP-specific detail, `references/graphql-principles.md`
for schema-language detail. Load neither for an RPC, event, or webhook contract.

## Compatibility and evolution

Style-neutral; applies to every shared or public contract change.

- **Additive is safe.** A new optional field, a new operation, a new enum member consumers
  already tolerate. Ship it without a version bump.
- **Breaking is everything a current consumer can observe:** removing or renaming a field,
  narrowing a type, changing a default, tightening validation, changing an error code or
  status for an existing case, or changing pagination shape.
- **Prove the consumer set before breaking.** Name every consumer found in discovery. If
  the consumer set is unknown, that is the finding — do not assume it is empty.
- **Deprecate before removing.** Announce, keep the old shape working, give consumers an
  observable signal, and remove only after migration is evidenced.
- **Versioning follows the discovered scheme.** Do not introduce a new versioning mechanism
  to an API that already has one. On greenfield, pick a mechanism only when a breaking
  change is actually foreseeable, and say which one and why.
- **Do not invent a page size, rate limit, cache policy, or sunset window.** Read it from
  the repository or ask.

## Other interface patterns

RPC, event, and webhook contracts get the same discipline, expressed in message terms:
name the message and its version, define the payload shape and required fields, state
delivery expectations the system actually provides (ordering, at-least-once, replay) rather
than assumed ones, and define failure semantics for the consumer.

Do not translate a message contract into an invented REST resource. Do not design a queue,
retry policy, or dead-letter path when the repository has no broker — say the capability is
absent and stop.

## Output

A compact contract decision record: discovered evidence, consumer set and stability class,
style rationale, contract delta, error/authorization/compatibility semantics, validation
proof (the reviewed examples), and handoffs.

## References

| File | Load when |
|---|---|
| `references/rest-principles.md` | The contract is HTTP-shaped — methods, status codes, resource paths |
| `references/graphql-principles.md` | The contract is a GraphQL schema — types, fields, resolver-visible shape |

## Gotchas

Each default holds until its condition flips. Detail and reasons sit in the references.

- **Consistency with the discovered API beats any convention** (plural nouns, nesting depth, pagination style, one error envelope): `references/rest-principles.md`.
- **Changing pagination shape, an error code, or a status for an existing case is breaking**, even when the body is unchanged. Converging two error envelopes is itself breaking: document the target and migrate deliberately.
- **Address GraphQL relationship-fetch cost before the schema ships** when a field fans out per parent row; hand the measurement and the fix to `mk:database`: `references/graphql-principles.md`.
- **An error body must not leak internals** — no stack trace, driver error, file path, or host detail.

Files in this skill

  • SKILL.md8.2 KB
  • references/graphql-principles.md4.5 KB
  • references/rest-principles.md4.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.