AGENT SKILL

api-design

Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.

License 许可
MIT
所属仓库
microsoft/haste
最近更新
2026-11-13
Stars
★ 110
Forks
19

01 前言 Front Matter

name
api-design
level
intermediate
agents
[ "backend-dev", "gis" ]
domain
architecture
source
Internal engineering practices, REST API conventions
status
draft
description
Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.
created_date
2026-04-27
validated_by
last_validated

02 资源文件 131

03 SKILL.md 正文

API Design

Overview

Standards and patterns for designing consistent, well-documented RESTful APIs. Covers naming, HTTP methods, error handling, status codes, and documentation requirements.

Key Concepts

Naming Conventions

  • Plural nouns for resources: /users, /orders, /products
  • Kebab-case for multi-word: /user-profiles
  • Nest related resources: /users/{id}/orders
  • Query params for filtering: /users?role=admin&active=true

HTTP Methods

Method Purpose Idempotent Response
GET Read Yes 200 + body
POST Create No 201 + body + Location
PUT Replace Yes 200 + body
PATCH Partial update No 200 + body
DELETE Remove Yes 204 (no body)

Error Response Format

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Human-readable description",
    "details": [
      {"field": "email", "message": "Invalid email format"}
    ]
  }
}

Status Codes

  • 200: Success — 201: Created — 204: No content
  • 400: Bad request — 401: Unauthorized — 403: Forbidden
  • 404: Not found — 409: Conflict — 422: Unprocessable
  • 429: Rate limited — 500: Internal error

Decision Framework

Scenario Method Path Status
List items GET /items 200
Get one item GET /items/{id} 200 / 404
Create item POST /items 201
Full update PUT /items/{id} 200 / 404
Partial update PATCH /items/{id} 200 / 404
Delete item DELETE /items/{id} 204 / 404
Search GET /items?q=term 200
Bulk action POST /items/batch 200 / 207

Documentation Requirements

Every endpoint must document:

  1. HTTP method and path
  2. Description
  3. Request parameters (path, query, body) with types
  4. Response schema with examples
  5. Error codes and descriptions
  6. Authentication requirements

Common Pitfalls

  • Using verbs in URLs — Use nouns: /users not /getUsers
  • Inconsistent error format — Use the same error schema everywhere
  • Missing pagination — Any list endpoint that can grow needs pagination
  • No versioning strategy — Decide early: URL (/v1/) or header-based

04 同仓库更多 Skills

microsoft
microsoft/haste

validation-diagnostics

Validation and diagnostic skill for HASTE. Compare planned vs implemented work, generate diagnostic reports, and feed misses back into skill refinement. Use when: 'validate implementation', 'compare to spec', 'diagnostic report', 'drift analysis', 'coverage check', 'implementation review'.

★ 110
microsoft
microsoft/haste

security-analysis

Dependabot and security analysis skill for HASTE. Parse alerts, group related vulnerabilities, apply severity rules, and produce structured reports. Use when: 'Dependabot alert', 'security scan', 'vulnerability triage', 'dependency audit', 'npm audit', 'pip audit', 'CVE analysis'.

★ 110
microsoft
microsoft/haste

release-notes

Generate release notes from commit history. Use when asked to draft release notes, create a changelog, or summarize changes for a release.

★ 110
microsoft
microsoft/haste

imagery-provider-adaptation

Imagery provider adaptation skill for HASTE. Encapsulates provider-specific logic for satellite imagery sources (Planet, Vantor, Airbus, etc.). Use when: 'new imagery provider', 'add source type', 'satellite provider', 'Planet', 'Vantor', 'Airbus', 'Pleiades', 'WorldView', 'SkySat', 'imagery ingestion', 'provider adapter'.

★ 110
microsoft
microsoft/haste

deterministic-scripts

Deterministic script execution skill for HASTE. Execute scripts instead of free-form LLM behavior for consistent, repeatable operations. Use when: 'run preprocessing', 'convert format', 'parse metadata', 'generate tiles', 'build wheel', 'deploy functions'. Prevents hallucinated scripts.

★ 110
microsoft
microsoft/haste

dependency-update

Guide for safely updating project dependencies. Use when asked to update packages, upgrade dependencies, or check for outdated libraries.

★ 110