generate-types

generate-types is a command for coding agents from HKTITAN/cursor-best-practices. It costs 0 tokens per session (443 once invoked), scanned A, original, MIT.

A command for creating TypeScript type definitions from sources such as OpenAPI descriptions, GraphQL schemas, JSON Schemas, or example API responses. TypeScript types describe the shape of data so code can use it more safely.

In plain words
What is it for?
Use it when connecting TypeScript code to an API or schema, creating type files, updating exports, and checking for import or circular-dependency problems.
Why use it?
It removes the need to write matching data definitions by hand and helps keep types organized with the project's existing conventions and imports.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/hktitan/cursor-best-practices/generate-types
Clone the repo
git clone --depth 1 https://github.com/HKTITAN/cursor-best-practices

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for generate-types

README.md
[![agentmods](https://agentmods.dev/badge/commands/hktitan/cursor-best-practices/generate-types.svg)](https://agentmods.dev/commands/hktitan/cursor-best-practices/generate-types)
Your own site
<a href="https://agentmods.dev/commands/hktitan/cursor-best-practices/generate-types"><img src="https://agentmods.dev/badge/commands/hktitan/cursor-best-practices/generate-types.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 443 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00443
Opus 5 $0.00000 $0.00221
Sonnet 5 $0.00000 $0.00089
Haiku 4.5 $0.00000 $0.00044

Measured 5d ago against content hash e9cd8f703667, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

generate-types scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

cursor-best-practices/assets/templates/commands/generate-types.md · 45 lines

What it actually says

Generate TypeScript types or type definitions from schemas, APIs, or data structures.

Steps

  1. Identify source

    • Check if I @-mentioned a file (OpenAPI spec, GraphQL schema, JSON schema, API response example).
    • Or identify the source from context (API endpoint, schema file, etc.).
    • Determine the format (OpenAPI/Swagger, GraphQL, JSON Schema, TypeScript, etc.).
  2. Generate types

    • Use appropriate tool or generate manually:
      • OpenAPI/Swagger: Use openapi-typescript or similar
      • GraphQL: Use graphql-codegen or similar
      • JSON Schema: Convert to TypeScript types
      • API Response: Infer types from example JSON
    • Generate types that match the project's style (interfaces vs types, naming conventions).
  3. Place types appropriately

    • Create or update type files in the project's types directory (e.g. types/, @types/, src/types/).
    • Follow project conventions for type file organization.
    • Use appropriate file naming (e.g. api.types.ts, schema.types.ts).
  4. Update imports

    • If types are used elsewhere, update imports.
    • Ensure type exports are correct.
    • Check for any circular dependencies.
  5. Verify types

    • Check that generated types are valid TypeScript.
    • Ensure types match the source schema/structure.
    • Test that types work with existing code (if applicable).
  6. Report

    • What source was used (file, API, schema)
    • Where types were generated (file path)
    • What types were created (interfaces, types, enums)
    • Any issues or warnings

Rules

  • Apply project rules from .cursor/rules or AGENTS.md when relevant (e.g. type naming, style preferences).
  • Generate types that are maintainable and well-documented.
  • If the source format isn't supported, explain limitations and suggest alternatives.
  • For API types, consider versioning and backward compatibility.
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 45 lines · 0 tokens per session scan A e9cd8f703667

Subscribe to this mod's changes

generate-types is a command published in the GitHub repository HKTITAN/cursor-best-practices (5 stars, last pushed 5mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 443 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.