AgentSkillsCN

scaffold-update-operation

在后端新增 UPDATE 操作(向流中追加内容)。当实现 PUT 或 PATCH 端点以修改现有资源时,可使用此技能。

SKILL.md
--- frontmatter
name: scaffold-update-operation
description: Adds a new UPDATE operation (appending to stream) to the Backend. Use this when implementing PUT or PATCH endpoints to modify existing resources.

Follow this guide to implement an Update Operation in the ApiService.

  1. Define the Domain Event

    • Create a record in src/BookStore.ApiService/Events/
    • Naming: {Resource}Updated or specific action (e.g., BookPublished)
    • Template: templates/Event.cs
  2. Define the Command

    • Create a record in src/BookStore.ApiService/Commands/{Resource}/
    • Naming: {Verb}{Resource} (e.g., UpdateAuthor, PublishBook)
    • Template: templates/Command.cs
  3. Implement the Endpoint

    • Create/Update src/BookStore.ApiService/Endpoints/{Resource}Endpoints.cs
    • Pattern: Wolverine.HTTP
    • Features: Use [Aggregate] attribute to auto-load state.
    • Logic: Pure function receiving aggregate and returning (IResult, IEvent).
    • Template: templates/Endpoint.cs
  4. Update Read Models

    • Ensure your projections handle the events.

Related Skills

  • /scaffold-create-operation: For creating new resources.
  • /scaffold-delete-operation: For deleting resources.