api-design
API design, REST, GraphQL, or authentication patterns.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
API design, REST, GraphQL, or authentication patterns.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Pi extensions and tool policy: extensions/*.ts, hooks, registerTool, promptGuidelines, registerCommand, footer/status UI, tool_result, session hooks, or subprocesses. Not for slash-command placement; use pi-command.
README, CHANGELOG, docs/, RFCs, ADRs, guides, or Markdown structure. Not for prose cleanup or archival work.
Prose cleanup for filler, hype, vague claims, repetition, detection tells, or uncited specifics. Not for Markdown architecture or archival work.
Requirements, user stories, acceptance/verification criteria, or testable outcomes. Not for PRD drafting (/prd) or Pi /goal prompts.
Use for /prd-it or to draft, refine, or review a Product Requirements Document. Not for acceptance criteria, planning, or Pi /goal prompts.
Pi session, trace, metrics, routing, workflow-friction, workflow-telemetry, usage, or local JSONL analysis with DuckDB. Use for aggregating or correlating Pi runtime logs. Not for adding telemetry, generic SQL/database design, or non-Pi logs.
| name | api-design |
| description | API design, REST, GraphQL, or authentication patterns. |
Language-agnostic patterns for designing REST and GraphQL APIs. Focus on solving real problems with simple, maintainable solutions that match the project's existing API conventions.
For detailed patterns and examples, see:
Adding patterns is easy. Adding patterns WORTH THE COMPLEXITY is hard.
Before recommending ANY API pattern, ask:
Does this solve a real problem or a hypothetical one?
Is the simpler approach sufficient?
What's the maintenance cost?
"If I remove this pattern, what specific problem occurs in production?"
If the answer is vague ("flexibility", "future-proofing", "best practices"), the pattern may be theater.
| Anti-Pattern | Example | Problem |
|---|---|---|
| Premature GraphQL | "Use GraphQL for flexibility" | When you have 3 endpoints and 10 users |
| Over-versioning | "v1, v2, v3 for every change" | When backwards-compatible changes suffice |
| Enterprise patterns | "Add HATEOAS for discoverability" | When your API has 5 endpoints |
| Pagination theater | "Cursor-based pagination everywhere" | When datasets are under 1000 items |
GET /users not GET /getUsers/users, /posts/users/{id}/postsGET /users?role=admin&status=active| Method | Purpose | Idempotent |
|---|---|---|
| GET | Retrieve | Yes |
| POST | Create | No |
| PUT | Replace | Yes |
| PATCH | Update | No |
| DELETE | Remove | Yes |
@deprecated directive| Code | Meaning | When to Use |
|---|---|---|
| 200 | OK | General success |
| 201 | Created | Resource created (POST) |
| 204 | No Content | Success, no body (DELETE) |
| 400 | Bad Request | Invalid input |
| 401 | Unauthorized | Missing/invalid auth |
| 403 | Forbidden | Authenticated, no permission |
| 404 | Not Found | Resource doesn't exist |
| 422 | Unprocessable | Validation errors |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Server Error | Unexpected error |
| Method | Best For | Complexity |
|---|---|---|
| API Key | Service-to-service, simple APIs | Low |
| JWT | Public APIs, stateless auth | Medium |
| OAuth2 | Third-party integrations, "Login with X" | High |
| Strategy | Best For |
|---|---|
| Offset/Limit | Small, static datasets |
| Cursor-based | Large, growing datasets (RECOMMENDED) |
| Keyset | Natural sort fields |
Standard structure:
{
"code": "ERROR_CODE",
"message": "Human-readable message",
"details": {}
}
Error codes (use consistently):
INVALID_REQUEST - Malformed requestVALIDATION_ERROR - Field validation failedAUTHENTICATION_FAILED - Invalid credentialsINSUFFICIENT_PERMISSIONS - Authorized but lacks permissionRESOURCE_NOT_FOUND - 404RESOURCE_ALREADY_EXISTS - 409 on duplicateINTERNAL_SERVER_ERROR - 500Bad: GET /users/admins, GET /users/active, GET /users/verified
Good: GET /users?role=admin&status=active&verified=true
Bad: GET /data?type=users&action=delete&id=123
Good: DELETE /users/123
Standardize error format across ALL endpoints.
Paginate collection endpoints when their requested contract needs bounded results; do not add pagination to small, intentionally complete collections.
Bad: "ERROR: Unique constraint violation on users_email_idx"
Good: { "code": "VALIDATION_ERROR", "message": "Email already in use" }
Bad: GET /api/data?api_key=secret123
Good: GET /api/data (Authorization: Bearer <token>)
Apply the items required by the requested API contract:
Note: For project-specific API patterns, check the active repo/client instruction files, such as AGENTS.md, CLAUDE.md, README files, or local API docs.