跳到正文
cccskills
免费在 GitHub 公开

contract-scaffolding

Scaffolds OpenAPI contract component with type generation.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(5)

  • SKILL.md5.6 KB
  • schemas/input.schema.json646 B
  • schemas/output.schema.json1.4 KB
  • templates/openapi.yaml2.0 KB
  • templates/package.json333 B

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Contract Scaffolding Skill

Creates an OpenAPI contract component that defines the API specification and generates TypeScript types for use by server and webapp components.

When to Use

Use when creating a contract component. Contract components support multiple instances (e.g., contracts/customer-api/, contracts/back-office-api/).

What It Creates

The directory path is components/contracts/{name}/ based on the component name in sdd/sdd-settings.yaml. Delegate to the techpack-settings skill for directory path resolution — it maps component type (contract) + name to a filesystem path (e.g., type=contract, name=customer-api → components/contracts/customer-api/).

components/contracts/{name}/
├── package.json          # Component package metadata and devDependencies
├── openapi.yaml          # OpenAPI 3.0 specification
├── .gitignore            # Ignores generated/ directory
└── generated/            # Generated types (git-ignored)
    └── api-types.ts      # Generated TypeScript types (from openapi.yaml)

OpenAPI Template

The template openapi.yaml includes:

  • Basic info section with project name and description
  • Placeholder for paths (add endpoints as features are implemented)
  • Reusable Error schema and standard error responses

Note: Health check endpoints (/health, /readiness, /liveness) are NOT defined in the OpenAPI spec. They are infrastructure endpoints implemented directly in the controller.

Type Generation

The contract component generates TypeScript types from the OpenAPI spec via the system CLI:

<plugin-root>/fullstack-typescript/system/system-run.sh contract generate-types <component-name>
<plugin-root>/fullstack-typescript/system/system-run.sh contract validate <component-name>

This creates generated/api-types.ts inside the contract component. The contract is published as a workspace package — server and webapp components consume types by declaring a workspace dependency and importing:

import type { components } from '@project-name/contract';

type Greeting = components['schemas']['Greeting'];

Template Variables

VariableDescription
{{PROJECT_NAME}}Project name (used in API info)
{{PROJECT_DESCRIPTION}}API description

Usage

Generates the contract component directory with an OpenAPI spec and type generation scripts. Invoked by the scaffolding skill during project creation.

Templates Location

All templates are colocated in this skill's templates/ directory:

skills/components/contract/contract-scaffolding/templates/
├── package.json
└── openapi.yaml

Scaffold Spec

To scaffold a contract component, build a spec and invoke the engine:

<plugin-root>/fullstack-typescript/system/system-run.sh scaffolding apply --spec spec.json

Variables

VariableSource
PROJECT_NAMEFrom sdd-settings.yaml project name

Operations

{
  "target_dir": "<project-root>",
  "base_dir": "<plugin-root>/skills",
  "variables": { "PROJECT_NAME": "<project-name>" },
  "operations": [
    {
      "type": "template_dir",
      "source": "components/contract/contract-scaffolding/templates",
      "dest": "components/contracts/<contract-name>"
    },
    {
      "type": "write_file",
      "path": "components/contracts/<contract-name>/.gitignore",
      "content": "node_modules/\ngenerated/\n"
    }
  ]
}

No conditions needed.

Input

Schema: schemas/input.schema.json

Accepts contract name and optional project metadata for OpenAPI spec generation.

Output

Schema: schemas/output.schema.json

Returns the scaffolding engine result: created files, directories, and scripts; skipped paths; errors; and a human-readable summary.

Related Skills

  • techpack-settings — Authoritative source for contract component settings schema and directory mappings.
  • typescript-standards — Generated TypeScript types must follow these coding conventions. Defines strict typing, readonly patterns, and import standards.

Integration with Other Components

                    ┌─────────────────┐
                    │    contract/    │
                    │  openapi.yaml   │
                    └────────┬────────┘
                             │
                    contract generate-types
                             │
                    ┌────────▼────────┐
                    │   generated/    │
                    │    types.ts     │
                    │ (workspace pkg) │
                    └────────┬────────┘
                             │
              import type from '@project/contract'
                             │
              ┌──────────────┴──────────────┐
              │                             │
    ┌─────────▼─────────┐       ┌───────────▼───────────┐
    │      server/      │       │        webapp/        │
    │  "workspace:*"    │       │    "workspace:*"      │
    └───────────────────┘       └───────────────────────┘

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Standards for authoring SDD plugin agents — frontmatter, self-containment, skill references, and no-user-interaction rules.

中文简介正在准备中。当前显示原文说明。

LiorCohen/sdd432026年2月24日 更新

Scaffolds Node.js/TypeScript backend components with CMDO architecture, driven by component settings.

中文简介正在准备中。当前显示原文说明。

LiorCohen/sdd432026年2月24日 更新

CMDO architecture standards for Node.js/TypeScript backends with strict layer separation.

中文简介正在准备中。当前显示原文说明。

LiorCohen/sdd432026年2月24日 更新

Intent-to-command mappings for fullstack-typescript tech pack features.

中文简介正在准备中。当前显示原文说明。

LiorCohen/sdd432026年2月24日 更新

Create change specification and implementation plan with dynamic phase generation. Supports feature, bugfix, refactor, and epic types.

中文简介正在准备中。当前显示原文说明。

LiorCohen/sdd432026年2月24日 更新

Orchestrates the full change lifecycle — routes actions to phase-specific sub-files.

中文简介正在准备中。当前显示原文说明。

LiorCohen/sdd432026年2月24日 更新

查看 LiorCohen 的全部技能

报告此技能的问题