用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill sdk-generation命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
基于 SOC 职业分类
正在显示 SKILL.md
| name | sdk-generation |
| description | > Use when this capability is needed. |
project.yamlproject.yaml specifies generation.tool for each SDK repoRead the source contract from the path specified in project.yaml:
# For OpenAPI:
CONTRACT_PATH=$(yq '.repos.api-server.contracts.produces[0].path' project.yaml)
# Validate:
npx @apidevtools/swagger-cli validate "$CONTRACT_PATH"
Based on project.yaml configuration and contract format:
| Contract Format | Recommended Tool | Alternatives |
|---|---|---|
| OpenAPI 3.x | Fern | Speakeasy, OpenAPI Generator |
| Protocol Buffers | Buf + protoc | grpc-tools |
| GraphQL | graphql-codegen | Apollo Codegen |
For each SDK repo specified in project.yaml:
# Using Fern (recommended for TypeScript):
cd sdk-typescript
fern generate --api ../api-server/openapi.yaml --language typescript
# Or using OpenAPI Generator:
npx @openapitools/openapi-generator-cli generate \
-i ../api-server/openapi.yaml \
-g typescript-fetch \
-o ./src/generated \
--additional-properties=supportsES6=true,npmName=@acme/api-client
Generated TypeScript SDK includes:
# Using Fern:
cd sdk-python
fern generate --api ../api-server/openapi.yaml --language python
# Or using OpenAPI Generator:
npx @openapitools/openapi-generator-cli generate \
-i ../api-server/openapi.yaml \
-g python \
-o ./src/generated \
--additional-properties=packageName=acme_api,projectName=acme-api-client
Generated Python SDK includes:
# Using Fern:
cd sdk-go
fern generate --api ../api-server/openapi.yaml --language go
# Or using OpenAPI Generator:
npx @openapitools/openapi-generator-cli generate \
-i ../api-server/openapi.yaml \
-g go \
-o ./generated \
--additional-properties=packageName=acmeapi
Generated Go SDK includes:
# Using Buf (recommended for protobuf):
cd api-server
buf generate # Generates code for all configured languages
# buf.gen.yaml configuration:
# version: v1
# plugins:
# - plugin: go
# out: ../sdk-go/proto
# opt: paths=source_relative
# - plugin: ts
# out: ../sdk-typescript/proto
# opt: target=web
# - plugin: python
# out: ../sdk-python/proto
After generation, the implementer agent customizes the SDK:
For each generated SDK:
For SDKs with publishing configured:
npm publish to npm registrytwine upload to PyPIPublishing is gated by convergence -- SDKs are only published after the full pipeline converges.
[sdk-repo]/src/generated/ -- generated SDK code[sdk-repo]/package.json or setup.py or go.mod -- package metadata[sdk-repo]/tests/ -- generated + custom tests[sdk-repo]/README.md -- usage documentation.factory-project/sdk-generation-report.md -- generation log per languageContract testing validates that implementations comply with API contracts.
The consumer (frontend, SDK) writes tests that describe what it expects from the provider (API server). These expectations are published as contracts. The provider's CI verifies it satisfies all consumer contracts.
Workflow:
Consumer repo (frontend):
1. Write Pact consumer tests defining expected API interactions
2. Run tests -> generate Pact contract files (.json)
3. Publish contracts to Pact Broker (or shared directory)
Provider repo (api-server):
4. Download all consumer contracts from Pact Broker
5. Start the API server
6. Verify each contract against the running server
7. If any verification fails -> provider has broken a consumer's expectations
Integration with Dark Factory phases:
| Pipeline Point | Contract Testing Role |
|---|---|
| During implementation | Consumer tests run as part of the test suite |
| During holdout evaluation | Contract compliance is a holdout dimension |
| During adversarial refinement | Adversary checks for contract violations |
| Feature mode (delta implementation) | Contract changes trigger consumer re-verification |
| Feature mode (scoped adversarial) | Cross-repo contract compliance validation |
Instead of consumer-driven contracts, use the OpenAPI spec itself as the contract. Specmatic auto-generates tests from the spec and validates both consumers and providers.
Workflow:
OpenAPI spec (source of truth):
1. Specmatic reads openapi.yaml
2. For consumer testing: Specmatic creates a mock provider from the spec
-> Consumer tests run against the mock
3. For provider testing: Specmatic creates synthetic requests from the spec
-> Provider must handle all spec-defined request shapes correctly
Advantage: No manual contract writing needed -- the OpenAPI spec IS the contract.
| Scenario | Pattern | Tool |
|---|---|---|
| Consumer expectations must be validated | Consumer-driven | Pact |
| OpenAPI spec is the source of truth | Specification-driven | Specmatic |
| Need to auto-discover breaking changes | Diff-based | openapi-diff, Optic |
| Property-based API testing | Generative | Schemathesis |
# Pact: Consumer test (in frontend repo)
npm test -- --reporter=pact # Generates pact contracts
# Pact: Provider verification (in api-server repo)
npx pact-verifier \
--provider-base-url=http://localhost:3000 \
--pact-urls=../frontend/pacts/frontend-api.json
# Specmatic: Auto-test from OpenAPI spec
npx specmatic test \
--contract=./openapi.yaml \
--host=http://localhost:3000
# Schemathesis: Property-based API testing
schemathesis run \
--url=http://localhost:3000 \
--schema=./openapi.yaml \
--checks all
For multi-repo projects, API contracts must be versioned, discoverable, and authoritative.
Implementation: A directory structure in the project root:
contracts/
+-- registry.yaml
+-- api-server/
| +-- openapi.yaml
| +-- openapi-v1.0.0.yaml
| +-- changelog.md
+-- events/
| +-- events.proto
| +-- changelog.md
+-- graphql/
+-- schema.graphql
+-- changelog.md
registry.yaml format:
contracts:
- name: "acme-api"
format: "openapi"
version: "2.1.0"
path: "./api-server/openapi.yaml"
producers: ["api-server"]
consumers: ["frontend", "sdk-typescript", "sdk-python"]
last_updated: "2026-03-15"
Contracts follow semantic versioning:
Changes that break existing consumers:
Protocol:
Changes that don't break consumers:
Changes that fix documentation without changing behavior:
# OpenAPI:
npx openapi-diff ./contracts/api-server/openapi-v2.0.0.yaml ./contracts/api-server/openapi.yaml
# Protocol Buffers:
buf breaking --against ./contracts/events/events-v1.0.0.proto ./contracts/events/events.proto
# GraphQL:
npx graphql-inspector diff ./contracts/graphql/schema-v1.0.0.graphql ./contracts/graphql/schema.graphql
When the same types must exist in multiple languages, the contract is the single source of truth for type generation.
The OpenAPI schema definition maps to language-specific types:
| Scenario | Pattern | Tool |
|---|---|---|
| OpenAPI-based REST API | Generate from OpenAPI | Fern, Speakeasy, OpenAPI Generator |
| gRPC services | Generate from protobuf | Buf, protoc |
| GraphQL API | Generate from schema | graphql-codegen |
| Rust -> TypeScript (no API contract) | Direct type sync | tsync |
| Any -> Any (complex migration) | Semantic porting | Semport (DF-014) |
.factory-project/sdk-generation-report.mdSource: drbothen/vsdd-factory — distributed by TomeVault.