AgentSkillsCN

modelkg-service-scaffold

基于 Dockerfile、配置文件与 API 路由,快速搭建全新的 ModelKG 后端微服务(FastAPI + modelkg_common)。当您需要将某个模块独立拆分为专属服务,或为新后端服务制定部署方案——该服务需运行于 Docker Compose 环境,并通过网关进行流量调度时,此技能将大显身手。

SKILL.md
--- frontmatter
name: modelkg-service-scaffold
description: Scaffold a new ModelKG backend microservice (FastAPI + modelkg_common) with a Dockerfile, config, and API routes. Use when extracting a module into its own service or when adding a new backend service that must run in Docker Compose and be routed through the gateway.

ModelKG Service Scaffold

Overview

Create a new backend service with the standard ModelKG structure, wiring, and conventions. Use this skill to keep new services consistent with existing ones.

Workflow

  1. Decide the service name, port, and API prefix.
  2. Scaffold files from the template (script or manual copy).
  3. Wire Docker Compose and gateway routing.
  4. Add the service to OpenAPI aggregation (if external consumers need it).
  5. Run and verify health + OpenAPI.

Quick Start (recommended)

Run the scaffold script from the repo root:

bash
python skills_proposal/modelkg-service-scaffold/scripts/scaffold_service.py \
  --name collaboration-engine \
  --port 8006 \
  --api-prefix /api/collaboration

This writes to backend/services/<name> and fills placeholders in the template.

Manual Scaffold (if needed)

Copy assets/service-template/ into backend/services/<name> and replace:

  • __SERVICE_NAME__
  • __SERVICE_PORT__
  • __API_PREFIX__

Wiring & Validation

  • Follow references/compose-gateway.md for Compose and Traefik labels.
  • Follow references/openapi-aggregation.md if the service should appear in /api/openapi.json.
  • Use references/service-checklist.md as the final checklist.

Resources

  • scripts/
    • scaffold_service.py: creates a service folder from the template.
  • references/
    • service-checklist.md: post-scaffold checklist.
    • compose-gateway.md: Compose and gateway routing snippets.
    • openapi-aggregation.md: how to add a service to the aggregated spec.
  • assets/
    • service-template/: Dockerfile, requirements, and FastAPI skeleton.