rest-patterns

from 0xdarkmatter/claude-mods

Custom commands, skills, and agents for Claude Code

4 stars0 forksUpdated Jan 25, 2026
npx skills add https://github.com/0xdarkmatter/claude-mods --skill rest-patterns

SKILL.md

REST Patterns

Quick reference for RESTful API design patterns and HTTP semantics.

HTTP Methods

MethodPurposeIdempotentCacheable
GETRetrieve resource(s)YesYes
POSTCreate new resourceNoNo
PUTReplace entire resourceYesNo
PATCHPartial updateMaybeNo
DELETERemove resourceYesNo

Essential Status Codes

CodeNameUse
200OKSuccess with body
201CreatedPOST success (add Location header)
204No ContentSuccess, no body
400Bad RequestInvalid syntax
401UnauthorizedNot authenticated
403ForbiddenNot authorized
404Not FoundResource doesn't exist
422UnprocessableValidation error
429Too Many RequestsRate limited
500Server ErrorInternal failure

Resource Design

GET    /users              # List
POST   /users              # Create
GET    /users/{id}         # Get one
PUT    /users/{id}         # Replace
PATCH  /users/{id}         # Update
DELETE /users/{id}         # Delete

# Query parameters
GET /users?page=2&limit=20          # Pagination
GET /users?sort=created_at:desc     # Sorting
GET /users?role=admin               # Filtering

Security Checklist

  • HTTPS/TLS only
  • OAuth 2.0 or JWT for auth
  • Validate all inputs
  • Rate limit per client
  • CORS headers configured
  • No sensitive data in URLs
  • Use no-store for sensitive responses

Common Mistakes

MistakeFix
Verbs in URLs/getUsers/users
Deep nestingFlatten or use query params
200 for errorsUse proper 4xx/5xx
No paginationAlways paginate collections
Missing rate limitsProtect against abuse

Quick Reference

TaskPattern
Paginate?page=2&limit=20
Sort?sort=field:asc
Filter?status=active
Sparse fields?fields=id,name
Include related?include=orders

When to Use

  • Designing new API endpoints
  • Choosing HTTP methods and status codes
  • Implementing caching headers
  • Setting up rate limiting
  • Structuring error responses

Additional Resources

For detailed patterns, load:

  • ./references/status-codes.md - Complete status code reference with examples
  • ./references/caching-patterns.md - Cache-Control, ETag, CDN patterns
  • ./references/rate-limiting.md - Rate limiting strategies and headers
  • ./references/response-formats.md - Errors, versioning, bulk ops, HATEOAS

Repository Stats

Stars4
Forks0