Home › API design › REST API design AGENTS.md

REST API design AGENTS.md

AGENTS.md for designing consistent HTTP/JSON APIs: resource naming, status codes, errors, pagination, and versioning.

AGENTS.mdAPI design

How to use

Save this as AGENTS.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

AGENTS.mdDownload  
# AGENTS.md: REST API design rules

## Resources and methods
- Plural nouns, kebab-case paths: `/v1/order-items/{id}`. Nest at most one level (`/users/{id}/orders`).
- `GET` read (safe), `POST` create or action, `PUT` full replace, `PATCH` partial update, `DELETE` remove. Actions that don't fit use a sub-resource (`POST /orders/{id}/cancel`).
- JSON fields in one casing across the API (match the existing API; default `camelCase`). Timestamps ISO 8601 in UTC; money as integer minor units + currency.

## Status codes
- `200` OK, `201` Created (with `Location`), `204` No Content, `400` malformed, `401` unauthenticated, `403` forbidden, `404` not found, `409` conflict, `422` validation failed, `429` rate limited (with `Retry-After`), `5xx` server faults only.

## Errors
- One shape everywhere, RFC 9457 Problem Details: `{ "type", "title", "status", "detail", "errors": [{ "field", "message" }] }`. Never return stack traces.

## Lists
- Paginate every list: cursor-based (`?limit=50&cursor=...` returning `nextCursor`). Cap `limit`.
- Filtering and sorting via query params (`?status=paid&sort=-createdAt`).

## Safety and evolution
- `POST` endpoints that create payments or orders accept an `Idempotency-Key` header.
- Additive changes only within a version: new optional fields are fine; removing/renaming fields or changing types needs a new version or deprecation period (`Deprecation`/`Sunset` headers).
- Update the OpenAPI spec (`openapi.yaml`) in the same change and keep it valid (`npx @redocly/cli lint`).

Related rules

Bevy game engine AGENTS.md

AGENTS.md for Bevy (0.16+) games in Rust: ECS systems, plugins, required components, and fast dev builds.

AGENTS.mdBevy (Rust)

Git commits & PRs AGENTS.md

AGENTS.md rules for how agents commit: Conventional Commits, atomic changes, safe git commands, and PR descriptions.

AGENTS.mdAgent workflows

CrewAI multi-agent AGENTS.md

AGENTS.md for CrewAI 1.x projects: YAML agents and tasks, crews and flows, tools, and cost-aware runs.

AGENTS.mdLLM apps & agents

Cypress end-to-end testing AGENTS.md

AGENTS.md for Cypress 15 E2E and component tests: selectors, cy.intercept, sessions, and flake-free waits.

AGENTS.mdTesting

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.