Skip to content
cccskills
FreePublished on GitHub

api-design-principles

Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.

The English summary is being prepared. Showing the original description.

See how to install

Files included (6)

  • SKILL.md4.7 KB
  • assets/api-design-checklist.md3.8 KB
  • assets/rest-api-template.py5.2 KB
  • references/graphql-schema-design.md8.8 KB
  • references/rest-best-practices.md7.4 KB
  • resources/implementation-playbook.md12.7 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

API Design Principles

Design APIs that developers love to use — consistent, predictable, and well-documented.

When to Use

  • Designing new REST or GraphQL APIs
  • Reviewing API specs before implementation
  • Establishing API design standards for a team
  • Migrating between API paradigms

When NOT to Use

  • Framework-specific implementation details (use stack skills instead)
  • Infrastructure-only work without API contracts
  • Existing APIs that cannot be versioned

Core Rules

1. Resources Are Nouns, Methods Are Verbs

✅ GET    /api/users          → List users
✅ POST   /api/users          → Create user
✅ GET    /api/users/{id}     → Get user
✅ PATCH  /api/users/{id}     → Update user fields
✅ DELETE /api/users/{id}     → Delete user

❌ POST   /api/createUser
❌ GET    /api/getUserById
❌ POST   /api/deleteUser

2. HTTP Methods Have Meaning

MethodPurposeIdempotentSafeRequest Body
GETRead✅✅No
POSTCreate❌❌Yes
PUTReplace✅❌Yes
PATCHPartial update❌❌Yes
DELETERemove✅❌No

3. Status Codes Tell the Story

CodeWhenExample
200Success with bodyGET returns resource
201CreatedPOST creates new resource
204Success, no bodyDELETE succeeds
400Client sent bad dataMalformed JSON
401Not authenticatedMissing/invalid token
403Authenticated but not authorizedWrong role
404Resource doesn't existInvalid ID
409ConflictDuplicate email
422Valid JSON, invalid contentEmail format wrong
429Rate limitedToo many requests
500Server errorUnhandled exception

4. Error Responses Are Structured

{
  "error": "ValidationError",
  "code": "INVALID_EMAIL",
  "message": "Email address is not valid",
  "details": {
    "field": "email",
    "value": "not-an-email",
    "constraint": "Must be a valid email format"
  }
}

Rules:

  • Same envelope for every error
  • Machine-readable code for client logic
  • Human-readable message for display
  • details for field-level validation errors
  • NEVER include stack traces in production

5. Always Paginate Collections

GET /api/users?page=2&page_size=20

Response:
{
  "items": [...],
  "total": 243,
  "page": 2,
  "page_size": 20,
  "pages": 13
}

For GraphQL, use cursor-based pagination (Relay spec):

type UserConnection {
  edges: [UserEdge!]!
  pageInfo: PageInfo!
  totalCount: Int!
}

6. Version From Day One

StrategyURLHeaderQuery
Example/api/v1/usersAccept: application/vnd.api+json; version=1/api/users?version=1
ProsSimple, visibleClean URLsSimple to add
ConsURL pollutionHidden from browsersCaching complexity
Best forMost APIsInternal APIsQuick prototypes

7. Rate Limit Everything Public

Every public endpoint must return rate limit headers:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 42
X-RateLimit-Reset: 1625097600

API Design Checklist

Before implementing any endpoint:

  • Resource name is a plural noun
  • HTTP method matches the operation semantics
  • Request/response schemas are defined (contract-first)
  • Error responses use consistent envelope
  • Pagination is implemented for collection endpoints
  • Authentication and authorization rules are specified
  • Rate limiting is configured
  • API version is specified
  • Input validation rules are documented per field

Anti-Patterns

Don'tDo
Verbs in URLs (/getUser)Nouns + HTTP methods (GET /users)
200 for everythingCorrect status codes per operation
Generic errors ("Something went wrong")Structured errors with codes
Return all fields alwaysSupport field selection or use GraphQL
Nest resources >2 levels deep/users/{id}/orders max; flatten after that
Ignore backward compatibilityVersion APIs; deprecation headers before removal

Extended Reference

See resources/implementation-playbook.md for:

  • Full pagination implementation (FastAPI)
  • HATEOAS patterns
  • GraphQL schema design with Relay-style connections
  • DataLoader patterns for N+1 prevention
  • Complete code templates

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Audit and improve web accessibility following WCAG 2.1 guidelines. Use when asked to "improve accessibility", "a11y audit", "WCAG compliance", "screen reader support", "keyboard navigation", or "make accessible".

The English summary is being prepared. Showing the original description.

RepairYourTech/cfsa-antigravity6Updated Aug 16, 2026

Structured methodology for adversarial thinking — generating attack scenarios, abuse cases, race conditions, and security edge cases against specs and implementations. Produces spec-level gap items, not code-level fixes.

The English summary is being prepared. Showing the original description.

RepairYourTech/cfsa-antigravity6Updated Aug 16, 2026

Orchestrate multiple Antigravity skills through guided workflows for SaaS MVP delivery, security audits, AI agent builds, and browser QA.

The English summary is being prepared. Showing the original description.

RepairYourTech/cfsa-antigravity6Updated Aug 16, 2026

Manage API versioning and evolution with URL/header/query strategies, deprecation workflows, breaking change classification, sunset headers, and consumer-driven contract testing. Use when designing versioning strategy, deprecating endpoints, or evolving API contracts.

The English summary is being prepared. Showing the original description.

RepairYourTech/cfsa-antigravity6Updated Aug 16, 2026

Analyzes codebase structure, data flow, module relationships, and key patterns to generate and maintain a living architecture document (ARCHITECTURE.md).

The English summary is being prepared. Showing the original description.

RepairYourTech/cfsa-antigravity6Updated Aug 16, 2026

Orchestrate ambiguity auditing across selected layers with rubric-driven scoring, remediation flow, and next-step gating

The English summary is being prepared. Showing the original description.

RepairYourTech/cfsa-antigravity6Updated Aug 16, 2026

See all skills by RepairYourTech

Report a problem with this skill