with one click
api-design
API design patterns including REST, GraphQL, and authentication. Activate when designing APIs or discussing API patterns.
Menu
API design patterns including REST, GraphQL, and authentication. Activate when designing APIs or discussing API patterns.
| name | api-design |
| description | API design patterns including REST, GraphQL, and authentication. Activate when designing APIs or discussing API 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.
Auto-activate when: Working with API routes, endpoints, REST design, GraphQL schemas, OpenAPI/Swagger specs, authentication tokens, API documentation, or discussing endpoint design, versioning strategies, or API architecture.
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.
MUST paginate all collection endpoints. No unbounded result sets.
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>)
MUST include:
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.
Brave browser tab URL capture. Activate when the user asks to capture, export, list, archive, save, or recover open Brave tabs, browser tabs, tab URLs, or session files.
Private datastore workflow. Activate when writing, saving, archiving, packing, encrypting, committing, or storing sensitive local files under private/ or Dolos encrypted archives.
Use when working with X/Twitter: x.com feed extraction, tweet/profile checks, following/follower lists, twitterapi.io, browser-agent pulls, or local encrypted X data handling.
Shell scripting, CLI development, Bash, PowerShell, Makefiles, and cross-platform tooling. Activate when working with .sh, .bash, .ps1, Makefile files or discussing shell/CLI patterns.
Use when the user asks to create, draft, write, improve, optimize, or build an inline Pi /goal command, goal prompt file, long-running objective, or goal_prompt_file.md. Triggers: /goal prompt, goal prompt, pi goal, goal_prompt_file.md, write a goal for, turn this into a goal.
Personal development philosophy emphasizing experiment-driven, fail-fast approach. Activate when planning implementations, reviewing code architecture, making design decisions, or when user asks to apply development principles. Guides against over-engineering and towards solving real problems with simple solutions.