backend-api-response
Use when the user asks about API response format, ApiResponse<T> envelope, error codes, Problem Details (RFC 9457), validation error responses or pagination…
от j4flmao★ 47 звёзд на GitHub
Установить backend-api-response в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
API Response Design
Purpose
Define and enforce a universal API response contract with standardized envelopes, error codes, and pagination. Every response must be predictable regardless of success or failure.
Agent Protocol
Trigger
User request includes: api response, response envelope, response<T>, api error, exception handling, error code, api contract, pagination response, api standard.
Input Context
- Current API response format (if refactoring)
- Technology stack (language/framework)
- Error handling strategy (exceptions, result types, error codes)
- Pagination requirements
Output Artifact
A markdown document containing:
- Response envelope structure (Response with status, data, error, metadata)
- Error response format (error code, message, details, trace ID)
- Exception handling strategy (global handler, middleware, filter)
- Pagination envelope (page, pageSize, totalCount, totalPages)
- Validation error format (field-level errors)
- Success response rules (HTTP status codes per operation)
Response Format
Produce the artifact directly. No preamble, no postamble, no explanations. No filler, no hedging, no transitions. Strip articles a/an/the where unambiguous. Compress output. If response format already standardized, output API response standard already defined at: [path]. and stop.
Completion Criteria
- Envelope structure defined for success, error, validation, pagination
- Exception-to-response mapping defined for all common exception types
- HTTP status code mapping defined per operation type
- Pagination contract defined with required/optional fields
Max Response Length
4096 tokens
Architecture Decision Trees
Response Envelope Style
What is the primary client type?
├── Browser SPA / Mobile app
│ ├── Need minimal payload overhead?
│ │ ├── Yes → Wrapper envelope (success+data+error+meta)
│ │ └── No → Standard envelope with full metadata
│ └── Need GraphQL-style flexibility?
│ ├── Yes → Single endpoint with error array pattern
│ └── No → RESTful per-endpoint envelope
├── Service-to-service (internal)
│ ├── Use OpenAPI-generated clients?
│ │ ├── Yes → Full envelope with requestId for tracing
│ │ └── No → Result type pattern (monads/railway)
└── Third-party / Public API
├── Use standard envelope with domain-prefixed error codes
└── Include rate limit headers in every response
Pagination Strategy
Will the list have new items inserted while users browse?
├── Yes → Cursor-based pagination (stable, no duplicates/skips)
│ └── Encode cursor as base64 opaque string, not raw DB value
├── No → Do users need random page access?
│ ├── Yes → Offset-based pagination (page N access)
│ │ └── Warn: performance degrades with large offset
│ └── No → Keyset pagination (best performance, O(1))
└── Is this a real-time feed?
└── Cursor-based with live updates via WebSocket/SSE
Error Response Granularity
Who is the consumer?
├── External developer (public API)
│ ├── Generic messages for 5xx, specific for 4xx
│ ├── Include details array for field-level validation
│ └── Never expose stack traces or internal IDs
├── Internal service
│ ├── Include error codes for automated handling
│ ├── Optionally include correlation ID for debugging
│ └── Structured machine-parseable error codes
└── End-user facing (BFF)
├── User-friendly messages (not error codes)
├── Include actionable remediation hints
└── Log full details server-side only
Workflow
Step 1: Define Response Envelope
Standard ApiResponse<T> — Every API response MUST follow this envelope:
{
"success": true,
"data": { ... },
"error": null,
"metadata": {
"requestId": "req_abc123",
"timestamp": "2026-05-14T10:30:00Z",
"version": "1.0"
}
}
Error response:
{
"success": false,
"data": null,
"error": {
"code": "ORDER_NOT_FOUND",
"message": "Order with ID '123' not found",
"details": [
{ "field": "orderId", "reason": "Resource does not exist" }
],
"traceId": "trace_xyz789"
},
"metadata": {
"requestId": "req_abc123",
"timestamp": "2026-05-14T10:30:00Z",
"version": "1.0"
}
}
Step 2: Define Generic Type Definitions
TypeScript
interface ApiResponse<T> {
success: boolean;
data: T | null;
error: ApiError | null;
metadata: ResponseMetadata;
}
interface ApiError {
code: string;
message: string;
details?: ErrorDetail[];
traceId: string;
}
interface ErrorDetail {
field: string;
reason: string;
}
interface ResponseMetadata {
requestId: string;
timestamp: string;
version: string;
}
C#
public class ApiResponse<T>
{
public bool Success { get; init; }
public T? Data { get; init; }
public ApiError? Error { get; init; }
public ResponseMetadata Metadata { get; init; } = new();
public static ApiResponse<T> Ok(T dat
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/api-response-advanced.md
- references/api-response-compression.md
- references/api-response-formats.md
- references/api-response-fundamentals.md
- references/api-response-testing.md
- references/api-response-validation.md
- references/client-api-calls.md
- references/error-handling-patterns.md
- references/response-envelope.md
FAQ
Что делает скилл backend-api-response?
Use when the user asks about API response format, ApiResponse<T> envelope, error codes, Problem Details (RFC 9457), validation error responses or pagination envelopes. Produces a uniform success/error response contract. Not for endpoint and URL design (use backend-api-design).
Как установить скилл backend-api-response?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл backend-api-response запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…