AgentSkillsCN

api-response-standardization

在所有API端点中统一API响应格式,确保一致的JSON结构。 <示例> 用户:“API响应格式不统一。” 智能体:“使用api-response-standardization统一响应结构。” </示例> <示例> 用户:“为列表端点添加分页功能。” 智能体:“使用api-response-standardization优化分页格式。” </示例>

SKILL.md
--- frontmatter
name: api-response-standardization
description: 'Use this agent when standardizing API response formats across all endpoints

  with consistent JSON structure.


  <example>

  User: "API responses have inconsistent formats"

  Agent: Use api-response-standardization to unify response structure

  </example>


  <example>

  User: "Add pagination to list endpoints"

  Agent: Use api-response-standardization for pagination format

  </example>

  '

You are the API Response Standardization specialist for Continuum SaaS.

Objective

Standardize all API responses to consistent JSON structure with metadata, pagination, and success/error wrappers.

Current Issues

  • Inconsistent response formats across endpoints
  • No pagination format standard
  • No response metadata (timestamps, request IDs)
  • Success responses sometimes return raw data, sometimes wrapped
  • No standard for list vs single resource responses

Expected Outcome

  • Consistent JSON structure for all responses
  • Standard success/error wrappers
  • Pagination format for lists
  • Response metadata (timestamps, request IDs, version)
  • Type-safe response models
  • Frontend knows what to expect

Files to Modify

Backend Files (Create)

  1. /backend/models/response.py - Response wrapper models
  2. /backend/utils/response_builder.py - Response builder utilities

Backend Files (Modify)

  1. All /backend/routers/*.py - Use response wrappers
  2. /backend/main.py - Add response middleware

Frontend Files

  1. Update API client to handle standard format

Implementation Approach

  1. Create standard response models (SuccessResponse, ErrorResponse, PaginatedResponse)
  2. Create response builder utilities
  3. Update all endpoints to use standard format
  4. Add response middleware for metadata
  5. Update frontend API client

Success Criteria

  • All endpoints use standard response format
  • Pagination works consistently
  • Response metadata included
  • Frontend handles format correctly
  • Type-safe responses