Skip to content

Generate prompt

--generate-prompt

Generate a prompt for consulting LLMs about CLI options.

Outputs a formatted prompt containing your current options, all available options by category, and full help text. Pipe to CLI LLM tools or copy to clipboard for web-based LLM chats.

Use --output-format json when an LLM agent or tool should consume structured option metadata instead of Markdown. Use --output-format-json-schema generate-prompt when the agent needs the JSON Schema for that structured payload, such as when defining a tool contract.

See also: LLM Integration for detailed usage examples

For LLM agents

See LLM Integration: If You Are an LLM Agent for workflow guidance.

Usage

datamodel-codegen --generate-prompt # (1)!
datamodel-codegen --generate-prompt "How do I generate strict types?" # (2)!
datamodel-codegen --generate-prompt --output-format json # (3)!
datamodel-codegen --output-format-json-schema generate-prompt # (4)!
  1. --generate-prompt - generate prompt without a question
  2. Include a specific question in the prompt
  3. Emit structured JSON for LLM/tool ingestion
  4. Emit JSON Schema for structured prompt JSON
Quick Examples

Pipe to CLI tools:

datamodel-codegen --generate-prompt | claude -p    # Claude Code
datamodel-codegen --generate-prompt | codex exec   # OpenAI Codex
datamodel-codegen --generate-prompt --output-format json | codex exec

Copy to clipboard:

datamodel-codegen --generate-prompt | pbcopy      # macOS
datamodel-codegen --generate-prompt | xclip -selection clipboard  # Linux
datamodel-codegen --generate-prompt | clip.exe    # WSL2

Ask about an existing OpenAPI command:

datamodel-codegen \
    --input openapi.yaml \
    --input-file-type openapi \
    --output models.py \
    --output-model-type pydantic_v2.BaseModel \
    --target-python-version 3.12 \
    --generate-prompt "Find the minimal options for strict API response models." \
    | claude -p

Review a command with current options:

datamodel-codegen \
    --input schema.json \
    --output models.py \
    --output-model-type pydantic_v2.BaseModel \
    --generate-prompt "Review this command for stable generated output in CI." \
    | claude -p