All skills
asyrafhussin avatar

/api-design-patterns

@1de3a7a

RESTful API design, error handling, versioning, and best practices. Use when designing APIs, reviewing endpoints, implementing error responses, or setting up API structure. Triggers on "design API", "review API", "REST best practices", or "API patterns".

Use this Skill: https://skilld.dev/gh/asyrafhussin/agent-skills/api-design-patterns

This session only. Nothing lands on disk.

rulesver-backward-compatible.md

≈609 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Maintain Backward Compatibility

Impact: HIGH (Prevents breaking existing integrations and avoids costly emergency client fixes)

Breaking changes in a live API force every consumer to update simultaneously or face outages. Maintaining backward compatibility within a version means clients continue working after deployments, and new features are delivered through additive changes only. Reserve breaking changes for new major versions.

Incorrect

# Before: GET /api/v1/users/1
{
  "id": 1,
  "name": "Jane Smith",
  "email": "jane@example.com",
  "role": "admin"
}
# After deploy (same v1): field renamed, field removed, type changed
{
  "id": 1,
  "full_name": "Jane Smith",
  "email_address": "jane@example.com",
  "roles": ["admin", "editor"]
}

Problems:

  • Renaming name to full_name breaks every client reading response.name
  • Renaming email to email_address breaks form bindings and display logic
  • Changing role (string) to roles (array) causes type errors in client deserialization
  • Removing fields with no notice gives consumers zero time to adapt

Correct

# Additive changes only within v1: new fields added, old fields preserved
GET /api/v1/users/1
{
  "id": 1,
  "name": "Jane Smith",
  "full_name": "Jane Smith",
  "email": "jane@example.com",
  "email_address": "jane@example.com",
  "role": "admin",
  "roles": ["admin", "editor"],
  "avatar_url": "https://cdn.example.com/avatars/1.jpg"
}
# Deprecation communicated via response headers
HTTP/1.1 200 OK
Content-Type: application/json
X-Deprecated-Fields: name, email, role
# New endpoints are always safe to add
GET /api/v1/users/1/preferences    # new endpoint, no existing contract

Benefits:

  • Existing clients continue working without any code changes after every deploy
  • New clients can adopt new field names immediately while old names remain available
  • Deprecation headers give automated tooling a way to detect and flag stale usage
  • New endpoints and new fields never conflict with existing client expectations

Reference: Stripe API - Backward Compatibility

Source: SKILL.md on GitHub

1 alert16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill is a comprehensive documentation library for RESTful API design patterns. It provides best practices for resource design, error handling, security, and documentation. The skill contains no executable code, malicious instructions, or hidden functionality, and its references are restricted to well-known technical documentation sources.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer6mo

    4/28 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 1de3a7a. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 7 months ago
metadata
{
  "author": "agent-skills",
  "version": "2.0.0"
}

README badge

README badge for asyrafhussin/agent-skills/api-design-patterns