rest-api-guidelines
REST API Guidelines
Apply consistent default decisions for HTTP+JSON REST APIs. Favor predictability, interoperability, retry safety, and long-term compatibility over stylistic purity.
Overview
Use this skill for three kinds of work:
- Design a new REST API or refine an existing design.
- Review an API, OpenAPI spec, or endpoint proposal for rule violations and compatibility risks.
- Draft endpoint contracts with example request and response shapes.
Workflow
- Classify the request as
design,review, ordraft. - Start from the default decisions in this file unless the user or existing platform conventions require otherwise.
- Read only the reference files needed for the task.
- State any deviation from the defaults explicitly and explain why it is justified.
- Keep the contract internally consistent across naming, methods, status codes, pagination, error format, and versioning.
Design
- Prefer the simplest resource-oriented model that fits the behavior.
- Model actions as standard CRUD first; use custom actions only when the behavior does not fit a resource shape naturally.
- Choose one default pattern per concern and apply it consistently across the API.
- Return concrete endpoint, request, response, and error examples when they help remove ambiguity.
Review
- Present findings first.
- For each issue, identify the violated guideline, the concrete risk, and the recommended fix.
- Prioritize breaking changes, interoperability hazards, retry/idempotency problems, and compatibility risks over style-only issues.
- Call out ambiguous semantics even when they may still work in one framework.
Draft
- Produce endpoint contracts that include method, path, request body shape when applicable, success status codes, representative error responses, and relevant headers.
- Show the chosen defaults in the contract rather than describing them only abstractly.
- Explain major tradeoffs only when the design deviates from the default path.
Default Decisions
- Use resource-oriented URIs with noun-based paths.
- Use path major versioning such as
/v1/users. - Use
PATCHas the default update method. - Use
application/merge-patch+jsonfor ordinary partial updates. - Interpret repeated fields in PATCH as whole-list replacement unless the API exposes a dedicated subresource or alternate contract.
- Use token or cursor pagination with
pageSize,pageToken, andnextPageToken. - Use
application/problem+jsonfor structured errors. - Use opaque external string identifiers instead of exposing internal sequential IDs.
- Use RFC 3339 timestamps and prefer UTC.
- Treat new fields as additive and safe, but treat removals, renames, semantic changes, and enum value removals as breaking changes.
Review Output Rules
- Put findings before summary text.
- Name the exact endpoint, field, or pattern that is problematic.
- Distinguish clearly between a hard interoperability or compatibility problem and a softer consistency recommendation.
- When there is no issue, say so explicitly and mention any remaining assumptions or unreviewed areas.
Reference Map
- Read references/resource-design.md for resource modeling, URI naming, JSON representation, CRUD and PATCH strategy, status codes, and relationship modeling.
- Read references/list-and-operation-patterns.md for pagination, sorting, filtering, search, batch APIs, and long-running operations.
- Read references/compatibility-and-contracts.md for errors, security, versioning, observability, documentation, numeric and money rules, and enum or state policies.
- Read references/file-transfer.md for upload and download design.
More from wibaek/skills
python-starter
Automatically configures formatter and linter settings when initializing Python projects. Installs ruff by default and uses pyproject.toml for configuration. Detects or asks the user about venv/poetry/uv environments and installs as dev dependencies. Optionally configures pre-commit and ty. Suggests VSCode workspace settings when using VSCode. Use this skill when starting Python projects ("Start a Python project", "Create a FastAPI project", "Create a data analysis Python project", etc.).
8ts-starter
Configure TypeScript project tooling for existing Node or frontend projects without app scaffolding. Use for TS starter setup, TS lint/format/test setup, Node TypeScript starter, or Vite TypeScript config requests.
6github-pr-writer
Draft GitHub pull request titles and structured PR bodies from branch history, diffs, and validation results. Use when Codex needs to write a PR description, summarize a branch for review, choose a base branch, prepare `gh pr create`, or open a pull request that follows the repository template.
2git-commit-writer
Draft Conventional Commit messages and execute a safe git commit workflow from staged or changed files. Use when Codex needs to create a commit, suggest a commit message, inspect git diff before committing, split changes into sensible commits, or run `git commit` without including unrelated work.
2