designing-backend-error-messageslisted
Install: claude install-skill msewell/agent-stuff
# Designing Backend Error Messages
Author backend error-message contracts with a REST-first workflow. Switch transport guidance only when the task explicitly targets gRPC, GraphQL, or async/event systems.
## Workflow
1. **Establish scope and transport**
- Identify API style: REST (default), gRPC, GraphQL, or async/event.
- Identify whether the task is design-from-scratch or refactor/review.
2. **Define the canonical error shape first**
- For REST, use `application/problem+json`.
- Include these baseline fields:
- `type`, `title`, `status`, `code`, `detail`, `trace_id`
- Add extensions only when needed:
- `errors[]` (validation), `is_transient`, `retry_after_ms`, `help_url`, domain metadata.
3. **Define status-code policy and error-code taxonomy**
- Map each failure mode to the most specific status code.
- Assign a stable namespaced machine code per failure mode (for example `validation.email.invalid_format`).
- Keep code names stable; never rename published codes.
4. **Write user-facing message copy**
- Keep `title` stable per error type.
- Make `detail` occurrence-specific and actionable.
- State the next action clearly: fix request, retry (with timing), or contact support with `trace_id`.
5. **Handle validation and retry semantics explicitly**
- Return all field errors in one response.
- Use JSON Pointer paths in `errors[].pointer`.
- Set retry semantics with `is_transient`; include `Retry-After` / equivalent hints