rest-conventions
Use when designing API endpoints. Use when using wrong HTTP methods. Use when POST is used for reads.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use when designing API endpoints. Use when using wrong HTTP methods. Use when POST is used for reads.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use when writing tests. Use when test structure is unclear. Use when arrange/act/assert phases are mixed.
Use when designing or modifying APIs. Use when adding breaking changes. Use when clients depend on API stability.
Use when implementing authentication. Use when storing passwords. Use when asked to store credentials insecurely.
Use when same data is fetched repeatedly. Use when database queries are slow. Use when implementing caching without invalidation strategy.
Use when tempted to use class inheritance. Use when creating class hierarchies. Use when subclass needs only some parent behavior.
Use when acquiring multiple locks. Use when operations wait for each other. Use when system hangs without crashing.
| name | rest-conventions |
| description | Use when designing API endpoints. Use when using wrong HTTP methods. Use when POST is used for reads. |
Use HTTP methods correctly. GET for reads. POST for creates. PUT/PATCH for updates. DELETE for deletes.
REST conventions exist for caching, bookmarking, and semantic clarity. Violating them breaks HTTP infrastructure.
NEVER use POST for read operations. NEVER put verbs in URLs.
No exceptions:
If endpoints have verbs or wrong methods, STOP:
// ❌ VIOLATIONS
POST /getOrders // POST for read
POST /users/create // Verb in URL
GET /deleteUser?id=123 // GET for delete
POST /api/fetchProducts // Verb + wrong method
// ✅ CORRECT: RESTful design
// Collections: plural nouns
GET /users // List users
POST /users // Create user
GET /users/:id // Get one user
PUT /users/:id // Replace user
PATCH /users/:id // Update user partially
DELETE /users/:id // Delete user
// Nested resources
GET /users/:id/orders // User's orders
POST /users/:id/orders // Create order for user
GET /orders/:id // Get specific order
// Filtering via query params
GET /orders?status=pending&userId=123
GET /products?category=electronics&limit=20
| Method | Use For | Idempotent | Safe |
|---|---|---|---|
| GET | Read/fetch | Yes | Yes |
| POST | Create | No | No |
| PUT | Replace entirely | Yes | No |
| PATCH | Partial update | Yes | No |
| DELETE | Remove | Yes | No |
Safe: Doesn't modify state Idempotent: Same result if called multiple times
GET /orders?status=pending
GET /products?minPrice=10&maxPrice=100
GET /users?role=admin&active=true
GET /orders?page=2&limit=20
GET /orders?cursor=abc123&limit=20
GET /products?sort=price:asc
GET /users?sort=createdAt:desc
For actions that don't fit CRUD, use sub-resources:
POST /orders/:id/cancel // Action on order
POST /users/:id/verify // Action on user
POST /payments/:id/refund // Action on payment
Pressure: "Just use POST for everything"
Response: POST requests aren't cacheable and break HTTP semantics.
Action: Use the correct method. It's the same amount of code.
Pressure: "GET can't have a body, so we use POST"
Response: Use query parameters for filtering. Bodies on GET are non-standard.
Action: GET /orders?userId=123 instead of POST /getOrders
Pressure: "Query string might get too long"
Response: If your query is that complex, you might need a search endpoint. Or paginate.
Action: For complex searches, POST /search is acceptable as an exception.
Pressure: "Our existing API uses POST for reads"
Response: New endpoints should follow conventions. Migrate old ones gradually.
Action: Follow REST for new endpoints. Document inconsistencies.
/getUser, /createOrder)All of these mean: Redesign the endpoint.
| Bad | Good |
|---|---|
POST /getOrders | GET /orders |
POST /createUser | POST /users |
GET /deleteUser/123 | DELETE /users/123 |
POST /updateProduct | PATCH /products/:id |
POST /fetchByFilter | GET /items?filter=x |
| Excuse | Reality |
|---|---|
| "POST is simpler" | Same code, better semantics. |
| "Need request body" | Use query parameters. |
| "GET URLs too long" | Paginate or use search endpoint. |
| "That's how we do it" | New code should be correct. |
| "Doesn't matter" | Caching, bookmarking, tools all depend on it. |
Nouns in URLs. Correct HTTP methods. Query params for filtering.
GET reads. POST creates. PUT/PATCH updates. DELETE removes. URLs are nouns (resources), not verbs (actions).