youhai020616/pi-extensions/api-design

Claude Code and agent skill by youhai020616/pi-extensions

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when designing, building, or reviewing REST/GraphQL APIs — covers endpoint design, error handling, versioning, authentication, and documentation

Install

npx vskill@latest install youhai020616/pi-extensions/api-design

SKILL.md

API Design

Overview

Good APIs are consistent, predictable, and hard to misuse.

Core principle: Design the API from the consumer's perspective first, then implement.

RESTful Design Rules

URL Structure
GET /api/v1/users # List
POST /api/v1/users # Create
GET /api/v1/users/:id # Read
PUT /api/v1/users/:id # Replace
PATCH /api/v1/users/:id # Partial update
DELETE /api/v1/users/:id # Delete

Rules:

  • Nouns, not verbs (/users not /getUsers)
  • Plural resources (/users not /user)
  • Nested for relationships (/users/:id/posts)
  • Max 2 levels deep — beyond that, use query params or top-level resource
  • Lowercase, hyphen-separated (/user-profiles not /userProfiles)
HTTP Methods & Status Codes
MethodSuccessCommon Errors
GET200404 not found
POST201 + Location header400 validation, 409 conflict
PUT/PATCH200400 validation, 404 not found
DELETE204 (no body)404 not found
Error Response Format

Always use consistent error shape:

json
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Human-readable description",
"details": [
{ "field": "email", "message": "Invalid email format" }
]
}
}

Rules:

  • Machine-readable code (UPPER_SNAKE_CASE)
  • Human-readable message
  • details array for field-level errors
  • Never expose stack traces in production
Pagination
json
GET /api/v1/users?page=2&limit=20
{
"data": [...],
"pagination": {
"page": 2,
"limit": 20,
"total": 156,
"totalPages": 8
}
}

For large datasets, prefer cursor-based:

GET /api/v1/events?cursor=abc123&limit=50
Filtering & Sorting
GET /api/v1/users?status=active&role=admin # Filter
GET /api/v1/users?sort=-created_at,name # Sort (- = desc)
GET /api/v1/users?fields=id,name,email # Sparse fields

Versioning

Use URL versioning (/api/v1/) for simplicity:

  • Explicit and visible
  • Easy to route
  • Easy to deprecate

Deprecation flow:

  1. Add Sunset header with date
  2. Return Warning header
  3. Log usage for monitoring
  4. Remove after sunset date

Authentication

MethodWhen to Use
Bearer Token (JWT)SPAs, mobile apps
API KeyServer-to-server, third-party integrations
OAuth 2.0Third-party access delegation
Session CookieTraditional web apps

Security checklist:

  • [ ] HTTPS everywhere (no exceptions)
  • [ ] Rate limiting per endpoint
  • [ ] Input validation on all parameters
  • [ ] No sensitive data in URLs (use headers/body)
  • [ ] CORS configured correctly
  • [ ] Auth tokens expire and refresh

Documentation

Every API endpoint needs:

yaml
# Example: OpenAPI / Swagger format
paths:
/users:
get:
summary: List users
parameters:
- name: status
in: query
schema:
type: string
enum: [active, inactive]
responses:
200:
description: Success
401:
description: Unauthorized

Document:

  • All parameters with types and constraints
  • All response codes with examples
  • Authentication requirements
  • Rate limits
  • Breaking changes in changelog

Checklist Before Shipping

  • [ ] Consistent URL patterns across all endpoints
  • [ ] Consistent error format
  • [ ] Pagination on all list endpoints
  • [ ] Input validation with clear error messages
  • [ ] Authentication and authorization
  • [ ] Rate limiting
  • [ ] CORS headers
  • [ ] API documentation / OpenAPI spec
  • [ ] Versioning strategy decided
  • [ ] No breaking changes without version bump

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/youhai020616/pi-extensions/api-design/badge)](https://verified-skill.com/skills/youhai020616/pi-extensions/api-design)

Something wrong with this skill or its page? Tell us.