一键导入
api-service-contracts
Generate API and service communication contracts with sequence diagram
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate API and service communication contracts with sequence diagram
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | api-service-contracts |
| description | Generate API and service communication contracts with sequence diagram |
Analyze the project to document all services, API endpoints, communication patterns (sync/async), DTOs, and retry/circuit-breaker policies. Generate a Mermaid sequence diagram showing the primary request flow across services. Save to .github/modernize/assessment/engines/facts/api-service-contracts.md.
workspace-path (optional): Path to the project to analyze (defaults to current directory)This skill is part of a set of four complementary assessment skills. To avoid content duplication across their output documents, observe these scope rules:
data-architecture skill. In the DTOs & Contracts section, list entity/DTO class names and their role in the API contract (request type, response type, immutability). Do NOT reproduce full field lists, ORM annotations (cascade, fetch strategy), or table names — reference data-architecture.md instead.@NotBlank, custom validators) are owned by the business-workflows skill. Mention validation only when it affects the API contract (e.g., "returns 400 if validation fails"). Do NOT enumerate individual field constraints.data-architecture skill. In the sequence diagram, you may show cache hit/miss behavior, but do NOT repeat the cache provider name, configuration details, or rationale.spring.jpa.*, database profiles) are owned by the configuration-inventory skill. Do NOT list property keys/values.configuration-inventory skill. Mention startup order only if it directly affects API availability. Do NOT repeat probe paths or wait mechanisms.Identify all independently deployable services/modules and produce the complete ## Service Catalog section:
pom.xml <modules>), Gradle subprojects (settings.gradle), .NET solutions (.sln → .csproj projects), monorepo workspaces (package.json workspaces)docker-compose.yml service definitions) — note third-party containers vs source-built servicesFor each service extract:
docker-compose.yml, or application.properties/appsettings.json)pom.xml, .csproj, package.json)Scan source code for API endpoint definitions and produce the complete ## API Endpoints Inventory section:
@RestController, @Controller, @GetMapping, @PostMapping, @PutMapping, @DeleteMapping, @RequestMapping@Path, @GET, @POST, @PUT, @DELETE (JAX-RS)[ApiController], [HttpGet], [HttpPost], [HttpPut], [HttpDelete], [Route]app.get, app.post, router.get), Fastify routes, NestJS decorators (@Get, @Post)For each endpoint extract:
Identify management and observability endpoints and produce the complete ## Management & Observability Endpoints section:
/actuator/health, /actuator/info, /actuator/metrics, /actuator/prometheus)/health, /healthz), Swagger UI (/swagger)@Timed (Micrometer), [Meter], custom metric registrations — note the metric name and which service exposes itAnalyze DTO and contract definitions and produce the complete ## DTOs & Contracts section:
data-architecture.md.@Value, Java records, C# records, frozen data classes)openapi.yaml, swagger.json, Springdoc/Swashbuckle annotations).proto files) or GraphQL schemasIdentify inter-service and intra-service communication and produce the complete ## Communication Patterns section:
configuration-inventory.md.@PreAuthorize, role checks) are implemented at the API level. If absent, state it explicitly — e.g., "No authentication or TLS configured; all endpoints are publicly accessible with no authorization checks." Do NOT duplicate CWE security scan findings; focus only on presence or absence at the API contract level.For each service, identify which cross-cutting capabilities it uses and produce the complete ## Service Technology Matrix section:
Create a Mermaid sequenceDiagram and produce the complete ## Service Communication Sequence section:
Example:
sequenceDiagram
participant Client
participant Gateway as "API Gateway"
participant CustSvc as "Customers Service"
participant VisitSvc as "Visits Service"
participant DB as "Database"
Client->>Gateway: GET /api/gateway/owners/1
Gateway->>CustSvc: GET /owners/1
CustSvc->>DB: findById(1)
DB-->>CustSvc: Owner + Pets
CustSvc-->>Gateway: OwnerDetails(pets=[Pet1,Pet2])
Gateway->>VisitSvc: GET /pets/visits?petId=1,2
alt Visits Service Available
VisitSvc->>DB: findByPetIdIn([1,2])
DB-->>VisitSvc: Visits list
VisitSvc-->>Gateway: Visits(items=[...])
else Circuit Breaker Open
Gateway-->>Gateway: Fallback - empty visits
end
Gateway->>Gateway: Merge visits into pets
Gateway-->>Client: 200 OwnerDetails + Visits
Save to .github/modernize/assessment/engines/facts/api-service-contracts.md with this exact structure:
# API & Service Communication Contracts
A brief introduction (1-2 sentences) summarizing the API surface and communication patterns found.
## Service Catalog
[Table: Service | Port | Category | Purpose]
## API Endpoints Inventory
[Table: Service | Method | Path | Request Type | Response Type]
## Management & Observability Endpoints
[Table: Service | Endpoint | Custom Metrics (if any)]
## DTOs & Contracts
[Description of gateway-level DTOs vs service-level entities, immutability, serialization]
## Communication Patterns
[Description of sync/async patterns, gateway aggregation/composition logic, circuit breaker/retry policies with timeout values, service discovery, startup dependency chain, and security posture (authentication/authorization/TLS — or explicit statement that none is configured)]
## Service Technology Matrix
[Table: Service | Web | Data Access | Discovery | Gateway | Actuator | Cache | Metrics]
## Service Communication Sequence
< Mermaid sequenceDiagram here >
The diagram must parse cleanly under Mermaid >= 9.x. Anything outside the legal subset crashes the entire diagram with Syntax error in text.
sequenceDiagram@, #, $, %, &) in participant labels — use plain text or quoted labels->> for synchronous calls and -->> for responses/async messagesparticipant with alias syntax for readable labels: participant Svc as "OrderService"alt/else/end blocks to show circuit breaker fallback paths\n for line breaks inside participant aliases, messages, or notes. The literal \n escape was removed in modern Mermaid and triggers "Syntax error in text".participant Svc as "Order Service" — not "Order\nService".Note over / Note right of: keep the note on one line, or split into multiple Note statements.participant API as "REST API\n(SubsonicController)"participant API as "REST API (SubsonicController)"\n — remove or split the line. Zero \n must remain.alt/opt/loop/par block is closed by end.> ERROR: Unsupported project type. This skill supports Java, .NET, JavaScript, and TypeScript projects only.> ERROR: No recognized API endpoints found at {workspace-path}. Verify the path is correct.> Note: Some endpoints or communication patterns could not be fully identified..github/modernize/assessment/engines/facts/api-service-contracts.mdGenerate architecture diagram with component relationship details from project analysis
Run application assessment for a single repository
Generate core business workflow documentation with sequence diagram
Generate comprehensive configuration and externalized settings inventory
Create a modernization plan to migrate the project to Azure
Generate task DAGs for modernization projects — select fragments from task catalog, produce initial DAG (Stage 1), and execute/validate DAG from plan artifacts (Stage 2).