AgentSkillsCN

api

当用户请求“设计 API”、“创建 REST 端点”、“撰写 API 规范”、“定义 API 合约”、“规划外部集成”或“创建 OpenAPI 规范”时,此功能将大显身手。它为 Wave B 并行执行设计 RESTful API 以及外部系统集成规范。

SKILL.md
--- frontmatter
name: api
description: This skill should be used when the user asks to "design API", "create REST endpoints", "document API specifications", "define API contracts", "plan external integrations", or "create OpenAPI spec". Designs RESTful APIs and external system integration specifications for Wave B parallel execution.
version: 2.0.0
model: sonnet

API Skill

API設計・外部システム連携仕様を作成するスキル。 RESTful API設計、エンドポイント定義、リクエスト/レスポンススキーマ、 外部サービス連携仕様の文書化に使用する。

実行タイミング: Wave B(architecture-detail と並列、Wave A 完了後)

前提条件

条件必須説明
docs/requirements/user-stories.mdAPI抽出元(web-requirements 出力)
docs/04_data_structure/data_structure.mdリクエスト/レスポンス型
Blackboard: decisions.entitiesWave A で確定したエンティティ一覧

出力ファイル

ファイルテンプレート説明
docs/05_api_design/api_design.md{baseDir}/references/api_design.mdAPI仕様
docs/05_api_design/integration.md{baseDir}/references/integration.md外部連携仕様

依存関係

種別対象
前提スキルweb-requirements, database(Wave A)
並列スキルarchitecture-detail(Wave B)
後続スキルdesign-detail(post-B), wave-aggregator

Wave B 契約出力

Blackboard に以下を登録する:

yaml
contract_outputs:
  - key: decisions.api_resources
    value:
      - id: API-001
        path: /users
        methods: [GET, POST]
        request_entity: null
        response_entity: ENT-User
      - id: API-002
        path: /users/{id}
        methods: [GET, PUT, DELETE]
        request_entity: ENT-User
        response_entity: ENT-User

ID採番ルール

項目ルール
形式API-XXX(3桁ゼロパディング)
開始001

ワークフロー

code
1. 機能要件・エンティティ定義を読み込み
2. 機能要件から必要なAPIを抽出
3. エンティティを使用してリクエスト/レスポンスを設計
4. リソースを特定(RESTful設計)
5. 各APIにAPI-IDを採番
6. エンドポイント・メソッドを決定
7. 外部連携がある場合は integration.md を生成

重要: このフェーズはエンティティ定義後、画面設計前に実行する。 エンティティを使用してAPIを設計し、画面はAPIを使用して設計する。

RESTful設計原則

URL設計

パターン
コレクションGET /products
単一リソースGET /products/{id}
作成POST /products
更新PUT /products/{id}
削除DELETE /products/{id}

命名規則

対象規則
エンドポイントkebab-case、複数形
クエリパラメータsnake_case
JSONフィールドcamelCase

認証・認可

方式用途
Bearer Token (JWT)一般的なAPI認証
API Keyサーバー間通信
OAuth 2.0外部サービス連携

エラーレスポンス(RFC 7807)

json
{
  "type": "https://api.example.com/errors/validation",
  "title": "Validation Error",
  "status": 400,
  "detail": "入力値が不正です"
}

SendMessage 完了報告

タスク完了時に以下の YAML 形式で Lead に SendMessage を送信する:

yaml
status: ok | needs_input
severity: null
artifacts:
  - docs/05_api_design/api_design.md
  - docs/05_api_design/integration.md
contract_outputs:
  - key: decisions.api_resources
    value:
      - id: API-001
        path: /users
        methods: [GET, POST]
        entities: [ENT-User]
      # 全 API を列挙
  - key: traceability.fr_to_api
    value:
      FR-001: [API-001, API-002]
  - key: traceability.api_to_ent
    value:
      API-001: [ENT-User]
open_questions: []
blockers: []

注意: project-context.yaml には直接書き込まない(Aggregator の責務)。

エラーハンドリング

エラー対応
user-stories 不在web-requirements の実行を促す
エンティティ不在Wave A(database)の実行を促す
未定義エンティティ参照P1 として記録、Wave A へ差し戻し提案