api-design-principles
Principles and checklists for designing and reviewing REST and GraphQL APIs; use when defining or evaluating API contracts (endpoints/schemas), naming, error models, pagination, versioning, and REST vs. GraphQL trade-offs.
Best use case
api-design-principles is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Principles and checklists for designing and reviewing REST and GraphQL APIs; use when defining or evaluating API contracts (endpoints/schemas), naming, error models, pagination, versioning, and REST vs. GraphQL trade-offs.
Teams using api-design-principles should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/api-design-principles/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How api-design-principles Compares
| Feature / Agent | api-design-principles | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Principles and checklists for designing and reviewing REST and GraphQL APIs; use when defining or evaluating API contracts (endpoints/schemas), naming, error models, pagination, versioning, and REST vs. GraphQL trade-offs.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
> **Source**: [https://github.com/aipoch/medical-research-skills](https://github.com/aipoch/medical-research-skills)
# API Design Principles
## When to Use
- Designing a new REST API contract for CRUD-style resources and you need consistent resource modeling, naming, and HTTP semantics.
- Designing a new GraphQL schema for multiple clients with different data shapes and you need clear type/field ownership and safe evolution.
- Reviewing an existing API (REST or GraphQL) to identify inconsistencies in naming, error handling, pagination/filtering, or versioning/deprecation.
- Deciding between REST vs. GraphQL (or defining boundaries when mixing both) and documenting trade-offs and constraints.
- Standardizing cross-cutting concerns (authn/authz, rate limiting, observability, long-running operations, idempotency) across multiple services.
## Key Features
- End-to-end workflow for API design/review: requirements → style choice → domain modeling → operations → cross-cutting concerns → deliverables.
- REST guidance: resource-oriented modeling, stable identifiers, relationship patterns, and correct HTTP verb usage.
- GraphQL guidance: schema/type modeling, Query vs. Mutation separation, input types for writes, and explicit side-effect handling.
- Cross-cutting design patterns: consistent error model, pagination/filtering/sorting, versioning and deprecation strategy, and operational concerns.
- Review checklist to validate completeness, highlight risks/gaps, and produce actionable follow-ups.
## Dependencies
- None (documentation-only skill).
- Reference documents:
- `references/rest.md`
- `references/graphql.md`
- `references/review-checklist.md`
## Example Usage
### Goal
Design (or review) an API for managing `Projects` and `Tasks`, and produce a contract with examples, error model, pagination, and a checklist summary.
### Step 1: Clarify requirements and constraints
- Consumers: Web app + mobile app + internal admin.
- Constraints: p95 latency < 200ms for list endpoints; PII present; audit logging required.
- Core use cases: list projects, view project, create task, update task status, search tasks by status/assignee.
### Step 2: Choose API style and boundaries
- Choose **REST** for resource-oriented CRUD with cacheable reads and straightforward endpoints.
- If GraphQL is later introduced for client-specific views, define boundaries (e.g., GraphQL for read aggregation; REST remains source-of-truth for writes).
### Step 3: Produce a REST contract skeleton (runnable examples)
**Base URL**
- `https://api.example.com/v1`
**Resources**
- `projects`
- `tasks` (scoped under a project)
**Endpoints**
- `GET /v1/projects`
- `POST /v1/projects`
- `GET /v1/projects/{projectId}`
- `GET /v1/projects/{projectId}/tasks`
- `POST /v1/projects/{projectId}/tasks`
- `PATCH /v1/projects/{projectId}/tasks/{taskId}`
#### List projects (pagination + filtering)
**Request**
```bash
curl -sS -X GET "https://api.example.com/v1/projects?limit=20&cursor=eyJpZCI6IjEwMCJ9&sort=createdAt:desc" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json"
```
**Response (200)**
```json
{
"data": [
{
"id": "proj_123",
"name": "Roadmap 2026",
"createdAt": "2026-01-10T12:00:00Z"
}
],
"page": {
"limit": 20,
"nextCursor": "eyJpZCI6InByb2pfMTIzIn0="
}
}
```
#### Create a task (idempotency)
**Request**
```bash
curl -sS -X POST "https://api.example.com/v1/projects/proj_123/tasks" \
-H "Authorization: Bearer $TOKEN" \
-H "Idempotency-Key: 2b7b1a2e-7f2b-4c2a-9c2b-0b3b7c9d1a11" \
-H "Content-Type: application/json" \
-d '{
"title": "Draft API spec",
"assigneeId": "user_42",
"dueAt": "2026-03-01T00:00:00Z"
}'
```
**Response (201)**
```json
{
"data": {
"id": "task_999",
"projectId": "proj_123",
"title": "Draft API spec",
"status": "OPEN",
"assigneeId": "user_42",
"dueAt": "2026-03-01T00:00:00Z",
"createdAt": "2026-02-25T09:00:00Z"
}
}
```
#### Error model example
**Response (409)**
```json
{
"error": {
"code": "CONFLICT",
"message": "A task with the same title already exists in this project.",
"details": {
"field": "title",
"reason": "DUPLICATE"
},
"requestId": "req_01HTZQ8K7Y9M2A3B4C5D6E7F8G"
}
}
```
### Step 4: Run the review checklist
Use `references/review-checklist.md` to validate:
- Naming consistency (resources, fields, enums)
- HTTP semantics and status codes
- Pagination/filtering/sorting rules
- Error model completeness and stability
- Versioning/deprecation plan
- Security and observability requirements
### Expected deliverable format (save to `outputs/`)
- API style choice + trade-offs
- Contract skeleton (endpoints or schema)
- Request/response (or query/mutation) examples
- Error model + pagination strategy
- Checklist results + risks/gaps
## Implementation Details
### Recommended workflow (design/review)
1. **Clarify requirements and constraints**
- Identify domain, core use cases, and consumer types (web/mobile/partners/internal).
- Capture constraints: latency, throughput, consistency, compliance, data sensitivity.
2. **Choose API style and boundaries**
- **REST**: best for resource-oriented APIs, cacheable reads, and simple CRUD.
- **GraphQL**: best for multiple clients with varying data shapes and frequent iteration.
- If mixing, define boundaries to avoid overlapping responsibilities.
3. **Domain modeling**
- REST: model stable resources (nouns), stable identifiers, and relationships.
- GraphQL: define types and field ownership; use input types for writes.
4. **Operation and behavior design**
- REST: map operations to HTTP verbs; represent actions via sub-resources or noun-based endpoints when needed.
- GraphQL: separate `Query` vs. `Mutation`; document side effects explicitly.
- Define **idempotency** (especially for creates) and patterns for **long-running tasks** when applicable.
5. **Cross-cutting concerns**
- Authentication/authorization
- Error model (stable codes, actionable messages, request correlation IDs)
- Pagination, filtering, sorting (document defaults and limits)
- Versioning and deprecation strategy
- Observability (logging/metrics/tracing), rate limiting
### Reference guides
- REST Principles and Patterns: `references/rest.md`
- GraphQL Principles and Patterns: `references/graphql.md`
- Review Checklist: `references/review-checklist.md`Related Skills
clinic-research-design
Generates a structured prompt framework for clinical study protocols. Supports Diagnostic, Efficacy, Etiology, and Prognosis studies. Calculates sample size and provides logic guides for LLMs.
basic-research-design
A biomedical research topic designer that generates progressive experimental subtitles and detailed research outlines based on a given subject. Use when the user wants to design a research proposal, outline experiments for a topic, or structure a biomedical study.
poster-designer
Generate professional poster design concepts and optimized image-generation prompts, then automatically run a drawing script to produce the final poster image when a user needs a poster.
kv-design
Generate professional Key Visual (KV) design proposals and images; use when you have a slogan/copy and a marketing scenario but need a clear visual direction and a ready-to-generate image prompt.
study-design-scale-selector
Determines the appropriate Risk of Bias assessment scale for a medical study based on its design (RCT, Cohort, etc.), using PubMed metadata lookup or text analysis. Use when the user wants to know which quality assessment tool to use for a specific paper (given PMID or abstract).
validation-strategy-designer
Designs internal, external, temporal, and functional validation strategies at the protocol stage for medical research studies.
real-world-evidence-study-designer
Designs a structured real-world evidence study using EHR, claims, or registry data, with explicit handling of time zero, eligibility windows, exposure definitions, outcome windows, censoring, confounding control, and target-trial-emulation logic. Use this skill when the user needs study-type design and protocol framing for an observational clinical study based on routine-care data. Do not invent database fields, follow-up completeness, linkage, coding validity, or causal identifiability.
prognostic-biomarker-protocol-designer
Designs discovery, modeling, and validation workflows for prognostic biomarkers in biomedical and clinical research. Always use this skill when the user needs a prognostic biomarker study blueprint rather than a diagnostic test protocol, predictive biomarker design, treatment recommendation, or a completed manuscript. Focus on endpoint family, follow-up horizon, time scale, candidate marker strategy, model-building logic, risk stratification framework, and internal/external validation requirements. Do not invent cohort size, event rate, assay readiness, literature support, or validation access.
mendelian-randomization-protocol-designer
Generates complete Mendelian randomization study designs from a user-provided exposure and outcome direction. Always use this skill whenever a user wants to design, plan, or build a Mendelian randomization study — even if phrased as "help me write a paper on X", "design an MR study for Y", or "I want to test whether A causally affects B using GWAS". Covers core two-sample MR design, optional bidirectional follow-up, optional multivariable MR, IV selection logic, ancestry alignment, harmonization, IVW as the default primary estimator, weighted median / MR-Egger / MR-PRESSO / leave-one-out sensitivity analyses, Steiger directionality, heterogeneity / pleiotropy checks, and explicit claim-boundary control. Always outputs four workload configs (Lite / Standard / Advanced / Publication+) with a recommended primary plan, stepwise workflow, method rationale, validation ladder, figure plan, minimal executable version, and strictly verified literature guidance with no fabricated references.
endpoint-definition-designer
Designs primary, secondary, and exploratory endpoints for biomedical and clinical research protocols. Always use this skill when a user needs to translate study aims into operational endpoint definitions with event rules, assessment timing, composite logic, interpretability, and protocol-stage auditability. Focus on endpoint precision, feasibility, clinical meaning, ambiguity reduction, and implementation readiness rather than generic study design advice.
clinical-cohort-protocol-designer
Designs retrospective or prospective clinical cohort study protocols for biomedical and clinical research. Always use this skill when the user needs a cohort-based study plan rather than a general study idea, evidence summary, or mechanistic experiment design. Focus on cohort appropriateness, enrollment logic, baseline time-zero definition, follow-up structure, endpoint definition, variable collection, confounding control, and a coherent primary statistical analysis line. Do not invent data availability, follow-up completeness, outcome ascertainment quality, sample size adequacy, or causal interpretability.
aim-and-hypothesis-designer
Designs primary aims, secondary aims, and testable hypotheses from broad biomedical research ideas. Use this skill when a user needs to convert a loose study idea into a tighter protocol-framing structure with clear aim hierarchy, hypothesis discipline, and separation between hypothesis-driven and exploratory components. Always keep aims answerable, non-overlapping, and aligned to the intended evidence type and study scope.