AgentSkillsCN

scaffold-get-by-id

新增 GET 操作,通过 ID 获取单个资源。支持 404 错误处理、缓存机制以及本地化支持。

SKILL.md
--- frontmatter
name: scaffold-get-by-id
description: Adds a new GET operation to fetch a single resource by ID. Handles 404s, caching, and localization.

Follow this guide to implement a Get By ID endpoint in the ApiService.

  1. Prerequisites

    • Ensure the Projection exists (/scaffold-single-stream-projection or similar).
  2. Create Endpoint

    • Create/Update src/BookStore.ApiService/Endpoints/{Resource}Endpoints.cs
    • Method: MapGet
    • Logic: GetOrCreateLocalizedAsync -> LoadAsync -> Map to DTO
    • Template: templates/GetByIdEndpoint.cs
  3. Client Integration

    • Create IGet{Resource}Endpoint.cs in Client project.

Related Skills

  • /scaffold-list-query: For fetching lists of resources.