AgentSkillsCN

api-contract-validator

针对此Express服务,验证API契约。在新增或修改端点时使用,以验证状态码、JSON Schema/结构一致性、错误负载,以及与现有客户端的向后兼容性。

SKILL.md
--- frontmatter
name: api-contract-validator
description: Validate API contracts for this Express service. Use when adding or modifying endpoints to verify status codes, JSON schema/shape consistency, error payloads, and backward compatibility with existing clients.
license: MIT

API Contract Validator

When to Use This Skill

Use for any endpoint behavior change, including new routes, payload changes, status code updates, or error handling changes.

Validation Workflow

  1. Identify contract surface impacted (/, /health, and any new endpoints).
  2. Verify expected status codes and JSON response shapes for success and failure paths.
  3. Add/update unit tests that assert contract behavior (not internal implementation).
  4. Verify unknown-route behavior remains intentional.
  5. Confirm backward compatibility unless change is explicitly breaking.
  6. Update root README.md if externally visible API behavior changed.

Contract Rules

  • Always return explicit status codes.
  • Keep response keys stable where possible.
  • Keep error payloads consistent across endpoints.
  • For breaking changes, document migration expectations in the root README.

See API contract checklist.