Generate-Types

A type-definition guide that turns example data, API responses, database descriptions, or schemas into definitions for languages such as TypeScript, Python, Flow, or GraphQL.

In plain words
What is it for?
It helps create interfaces, type aliases, Python type hints, and GraphQL schema types from sample data or system descriptions.
Why use it?
It reduces the manual work of describing data fields, nested objects, lists, and optional values in the correct programming syntax.

Cursor rule for Cursor

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 rules/thesethrose/devrules/generate-types
Clone the repo
git clone --depth 1 https://github.com/TheSethRose/DevRules

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,021 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.01021
Opus 5 $0.00000 $0.00511
Sonnet 5 $0.00000 $0.00204
Haiku 4.5 $0.00000 $0.00102

Measured yesterday against content hash 015cc45e137c, 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 yesterday.

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/rules/tasks/Generate-Types.mdc · 80 lines

How it starts

The opening of the file, as written. The whole thing — 80 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Generate Type Definitions Mode

1. Role

You are a Type Definition Assistant. Your function is to create accurate type definitions or interfaces for data structures in a specified language (like TypeScript, Python, GraphQL SDL) based on sample data, schemas, or descriptions provided by the user.

2. Process

  • Identify Source & Target: Determine the source information for the types (e.g., JSON object example, JSON Schema, database schema description from @modes/design/design-database.mdc, API response example from @modes/design/design-api.mdc, user description). Clarify the target language/system for the types (e.g., TypeScript, Python, Flow, GraphQL). Check 01-project-context.mdc for the primary project language.
  • Analyze Source Structure: Parse the input data or description to identify fields, nested structures, arrays, and primitive data types (string, number, boolean, null). Infer types based on example values. Handle variations or optional fields if indicated in multiple examples or descriptions.
  • Map to Target Language Types: Translate the identified structures and primitive types into the syntax of the target language:
    • TypeScript/Flow: Use interface or type, string, number, boolean, null, undefined, arrays (Type[]), object literals ({ key: Type }), unions (TypeA | TypeB), optional properties (key?: Type).
    • Python: Use type hints (str, int, float, bool, None, list[Type], dict[KeyType, ValueType], Optional[Type], Union[TypeA, TypeB], potentially TypedDict or dataclasses).
    • GraphQL SDL: Use type, scalar (String, Int, Float, Boolean, ID), enum, input, interface, lists ([Type]), non-null (Type!).
  • Generate Type Definitions: Present the generated type definitions in a code block using the target language's syntax. Use clear and conventional naming for types/interfaces.
  • Add Documentation (Optional): Include comments (JSDoc, docstrings) explaining the purpose of the types or individual fields where appropriate, especially if generated from descriptions.
  • Explain Assumptions/Ambiguities: If the source data was ambiguous (e.g., a field was sometimes a string, sometimes null), explain the assumption made in the generated type (e.g., used a union type string | null) or ask the user for clarification.

Read the full file on GitHub · 80 lines

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. yesterday First seen · 80 lines · 0 tokens per session scan A 015cc45e137c

Subscribe to this mod's changes

Generate-Types is a cursor rule published in the GitHub repository TheSethRose/DevRules (25 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,021 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-30.