agentleFS
HaibaraAiAPTXHaibaraAiAPTX/frontend-openapi-skills/skills/generate-models/SKILL.md

generate-models

Skill1 starsChanged 47 days agoMITView on GitHub

Generate TypeScript interfaces and enums from OpenAPI schemas using aptx-ft CLI. Use when user asks to: (1) generate types/models from OpenAPI/Swagger, (2) create TypeScript interfaces from API schema, (3) extract type definitions from openapi.json, (4) generate selective models with --name filter, (5) preserve translated enum values, (6) track generated files with manifest, (7) preview changes before generation, or (8) update barrel files automatically. Do NOT use for full artifact generation with request layer or Material UI enum adaptation.

  • Installs packages

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 4 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    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:

    Why: When regenerating models in a non-empty directory, --preserve keeps manually translated enum names while adding new values.

    line 73
  2. Distinctive:

    When manifest tracking is enabled (default), the following files are generated:

    line 105
  3. Distinctive:

    LLM suggestions: Follow-up actions for handling deleted files

    line 122
  4. Very specific:

    Does NOT generate request layer code (functions, hooks) → use generate-artifacts

    line 207
  5. Very specific:

    Does NOT adapt Materal-specific enum semantics → use adapt-materal-enums

    line 208
  6. Distinctive:

    Does NOT validate OpenAPI specification correctness

    line 209
  7. Distinctive:

    Only supports JSON format (not YAML)

    line 210

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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

Generate TypeScript Models

Generate TypeScript interfaces/enums from OpenAPI via aptx-ft.

Prerequisites

pnpm add -D @aptx-js/frontend-tk-cli

Discovery Phase - MANDATORY FIRST STEP

Before executing any generation command, you MUST discover the actual project configuration.

For Monorepo Projects

  1. Find packages directory:
    ls -d packages/*/
  2. Identify model package and get its name:
    # Find package that likely contains models (domains, models, types, shared, etc.)
    cat packages/domains/package.json 2>/dev/null || cat packages/models/package.json 2>/dev/null
    Extract the "name" field - this is your --model-path value.

Critical Rules

❌ NEVER Do This✅ ALWAYS Do This
Guess package name from project directoryRead package.json to get actual "name"
Assume @project-name/modelsUse the exact value from "name" field
Infer from packages/domains/ pathPackage name ≠ directory name

Example Discovery

# User says: "generate to packages/domains"

$ cat packages/domains/package.json
{ "name": "@repo/domains", ... }  ← Package name is @repo/domains

Workflow

  1. Discovery → Read package.json files to get actual package names
  2. Identify project type → recommend parameters
  3. Check output directory → determine if --preserve is needed
  4. Confirm with user → output dir, style, filters
  5. Execute → show command, get approval, run

Preserve Parameter Logic

ALWAYS check if target directory contains existing models before generating:

# Check if output directory has existing model files
ls ./src/models/*.ts 2>/dev/null || echo "empty"
Directory StateAction
Empty or not existsGenerate WITHOUT --preserve
Has existing .ts filesGenerate WITH --preserve to keep enum translations

Why: When regenerating models in a non-empty directory, --preserve keeps manually translated enum names while adding new values. Only skip --preserve for fresh generation.

Project Types

TypeOutputCommand
Single project./src/modelspnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models --style module
Monorepo./packages/models/srcpnpm exec aptx-ft -i ./openapi.json model gen --output ./packages/models/src --style module

Key Options

OptionPurpose
--style moduleES modules, individual exports (default, recommended)
--style declarationSingle declaration file (legacy compatibility)
--name <Schema>Generate only specified models (repeatable)
--preserveKeep manually translated enum names on regeneration

Manifest Tracking

The CLI automatically tracks generated files and detects changes between generations.

Manifest CLI Options

OptionDefaultPurpose
--no-manifestfalseDisable manifest tracking
--manifest-dir <path>.generatedCustom manifest directory
--dry-runfalsePreview mode: generate report without updating manifest

Generated Manifest Files

When manifest tracking is enabled (default), the following files are generated:

<output>/
├── .generated/
│   ├── manifest.json           # Tracks all generated files
│   ├── deletion-report.json    # Machine-readable change report
│   └── deletion-report.md      # Human-readable change report with LLM suggestions
└── models...

Manifest Report Contents

The deletion-report.md includes:

  • Summary table: Added/deleted/unchanged file counts
  • Deleted files: List of files removed since last generation
  • Added files: List of new files added
  • LLM suggestions: Follow-up actions for handling deleted files

When to Use Manifest Options

ScenarioCommand
Normal generationOmit manifest options (default)
CI/CD without trackingAdd --no-manifest
Preview changes before applyingAdd --dry-run
Custom manifest locationAdd --manifest-dir ./meta

Automatic Barrel Updates

The CLI automatically updates barrel files (index.ts) after generation.

You no longer need to manually run barrel gen after generating models - the model gen command handles this automatically.

What Gets Updated

  • <output>/index.ts - Barrel file for the models directory

When Manual Barrel Update is Needed

The automatic update handles most cases. Use manual barrel gen only when:

  • Fixing corrupted barrel files
  • Processing non-standard directory structures
  • One-time batch updates across multiple directories

Preserve Workflow

Preserve Workflow

Recommended when regenerating models after API updates. Keeps manually translated enum names while adding new values.

  1. Generate models
  2. Manually translate enums (e.g., Value1 → Success)
  3. API updates with new enum values
  4. Regenerate with --preserve → keeps translations, adds new values
# First generation
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models

# After translating enums, regenerate with preserve
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models --preserve

Quick Reference

# Check if output directory has existing models first
ls ./src/models/*.ts 2>/dev/null

# First generation (empty directory)
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models

# Regeneration (non-empty directory) - use --preserve
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models --preserve

# Declaration style
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models --style declaration

# Selective generation
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models --name User --name Role

# Preview changes without updating manifest
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models --dry-run

# Disable manifest tracking (CI/CD)
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models --no-manifest

# Custom manifest directory
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models --manifest-dir ./meta

# Without pnpm
npx aptx-ft -i ./openapi.json model gen --output ./src/models

Output

TypeScript model files (interface/enum). Does not include request layer code.

Boundaries

This skill generates TypeScript models only:

  • Does NOT generate request layer code (functions, hooks) → use generate-artifacts
  • Does NOT adapt Materal-specific enum semantics → use adapt-materal-enums
  • Does NOT validate OpenAPI specification correctness
  • Only supports JSON format (not YAML)

Related Skills

  • generate-artifacts: Full generation (models + request layer)
  • adapt-materal-enums: Materal framework enum adaptation
  • download-openapi: Fetch OpenAPI spec from URL

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.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.