agentleFS
EmeaAppGbbEmeaAppGbb/spec2cloud/.github/skills/contract-generation/SKILL.md

contract-generation

Skill100 starsChanged 7 months agoMITView on GitHub

Generate API contracts, shared TypeScript types, and infrastructure resource definitions from Gherkin scenarios and test files. Produce the stable foundation for parallel frontend/backend implementation. Use when generating contracts, creating shared types, defining API specs, or updating infrastructure requirements per increment.

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 8 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use the simplified OpenAPI-inspired YAML format (see references/schemas.md).

    line 56
  2. Very specific:

    Use strict TypeScript: no any types, explicit null/undefined handling.

    line 70
  3. Distinctive:

    Ensure types compile standalone (no circular dependencies, no runtime imports).

    line 72
  4. Very specific:

    Consider the deployment target (Azure Container Apps via AZD) and existing infra/ Bicep templates.

    line 86
  5. Distinctive:

    After generating all contracts, verify:

    line 94
  6. Distinctive:

    If a Gherkin scenario cannot be mapped to an API endpoint, flag it as a gap.

    line 107
  7. Distinctive:

    If test files reference types not in the contracts, update the contracts.

    line 108
  8. Distinctive:

    After self-review, present all contracts to the orchestrator for human gate approval.

    line 109
  9. Distinctive:

    After completing contract generation for a feature:

    line 113
  10. Distinctive:

    After completing the infrastructure contract:

    line 134
  11. Distinctive:

    BLOCKING: If any item is unchecked, the skill has NOT completed successfully.

    line 163

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Contract Generation

Role

You are the contract generation agent. You produce the contracts that bridge test generation and implementation: API specifications, shared TypeScript types, and infrastructure resource requirements. Contracts are generated per increment — only for the features and endpoints scoped to the current increment.

Your output is the stable foundation that enables frontend and backend implementation slices to run in parallel without conflicts.

Inputs

  • The current increment's scope from specs/increment-plan.md
  • Approved FRDs scoped to this increment (specs/frd-*.md)
  • Gherkin feature files for this increment (specs/features/*.feature)
  • E2E test specs for this increment (Playwright specs, Page Object Models)
  • BDD test scaffolding for this increment (step definitions, unit test files)
  • Existing contracts from previous increments (to extend, not conflict)
  • Current .spec2cloud/state.json

Outputs

ArtifactLocationCardinality
API contractsspecs/contracts/api/{feature-id}.yamlOne per feature
Shared TypeScript typessrc/shared/types/{feature-id}.tsOne per feature
Infrastructure contractspecs/contracts/infra/resources.yamlSingle file

Tasks

Task 1 — Generate API Contracts

For each feature, produce an API contract in specs/contracts/api/{feature-id}.yaml:

  1. Extract endpoint definitions from Gherkin scenarios and test files.
  2. Define for each endpoint:
    • HTTP method and path (e.g., POST /api/auth/register)
    • Route parameters and query parameters
    • Request body schema with required/optional fields, types, and validation rules
    • Response body schema for success (2xx) and error (4xx, 5xx) cases
    • Authentication/authorization requirements (e.g., JWT required, admin role)
    • Status codes with descriptions
  3. Use the simplified OpenAPI-inspired YAML format (see references/schemas.md).
  4. Cross-reference Gherkin scenarios to ensure every behavior is covered by an endpoint.

Task 2 — Generate Shared TypeScript Types

For each feature, produce shared types in src/shared/types/{feature-id}.ts:

  1. Extract TypeScript interfaces from the API contracts.
  2. Include:
    • Request DTOs (e.g., RegisterRequest, LoginRequest)
    • Response DTOs (e.g., RegisterResponse, UserProfile)
    • Entity models shared between API and Web (e.g., User, Session)
    • Enum types and constants (e.g., UserRole, ErrorCode)
    • Component prop types derived from response shapes
  3. Use strict TypeScript: no any types, explicit null/undefined handling.
  4. Export all types as named exports.
  5. Ensure types compile standalone (no circular dependencies, no runtime imports).

Task 3 — Generate Infrastructure Contract

Produce a single infrastructure contract at specs/contracts/infra/resources.yaml:

  1. Aggregate resource needs across all features in this increment.
  2. Define for each Azure resource:
    • Resource type (e.g., Microsoft.App/containerApps)
    • SKU/tier with justification
    • Scaling: min/max replicas, CPU/memory allocation
    • Environment variables and secrets the resource needs
    • Dependencies between resources
    • Networking: ingress rules, CORS configuration, internal-only access
  3. Consider the deployment target (Azure Container Apps via AZD) and existing infra/ Bicep templates.
  4. Flag any gaps between current infrastructure and what the features require.

See references/schemas.md for the full infrastructure contract YAML format.

Task 4 — Self-Review and Cross-Validation

After generating all contracts, verify:

CheckWhat to verify
CompletenessEvery Gherkin scenario maps to at least one API endpoint
ConsistencyRequest/response types in API contracts match shared TypeScript types
Test alignmentTest files reference endpoints and types that exist in the contracts
Infra coverageEvery service (API, Web) has a corresponding infrastructure resource
No conflictsEndpoint paths don't collide across features; type names are unique or namespaced

Iteration Rules

  • Generate contracts for all features in the increment before presenting for review.
  • If a Gherkin scenario cannot be mapped to an API endpoint, flag it as a gap.
  • If test files reference types not in the contracts, update the contracts.
  • After self-review, present all contracts to the orchestrator for human gate approval.

State Updates

After completing contract generation for a feature:

{
  "contracts": {
    "api": {
      "{feature-id}": {
        "status": "done",
        "specFile": "specs/contracts/api/{feature-id}.yaml"
      }
    },
    "sharedTypes": {
      "{feature-id}": {
        "status": "done",
        "outputFiles": ["src/shared/types/{feature-id}.ts"]
      }
    }
  }
}

After completing the infrastructure contract:

{
  "contracts": {
    "infra": {
      "status": "done",
      "specFile": "specs/contracts/infra/resources.yaml"
    }
  }
}

Append to .spec2cloud/audit.log:

[ISO-timestamp] increment={id} step=contracts action=contracts-generated result=done

Mandatory Completion Checklist

The orchestrator MUST verify ALL of the following before marking contract-generation as complete:

  • API contracts exist in specs/contracts/api/ for every endpoint in the increment
  • Shared types in src/shared/types/ cover all data structures used across API and Web
  • specs/contracts/infra/resources.yaml is updated with any NEW infrastructure needs for this increment (new Azure resources, new model deployments, new env vars)
  • Any new Azure resources needed are flagged for provisioning and have corresponding Bicep definitions in infra/
  • Any new environment variables are documented in both resources.yaml (per-resource env_vars) and specs/tech-stack.md (per-increment map)

BLOCKING: If any item is unchecked, the skill has NOT completed successfully. The orchestrator must loop back and complete the missing items before advancing to implementation.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.