Use this prompt when you need to produce a complete, structured reference for a data model, interface, or type definition in an SDK. The primary job-to-be-done is converting a raw source of truth—such as a JSON Schema, a protobuf definition, or a set of annotated source files—into a developer-facing document that describes every field, its type, nullability, default value, and relationship to other objects. The ideal user is an SDK engineer, a technical writer embedded in a platform team, or a developer relations engineer who must ensure that the public documentation surface is an exact and faithful representation of the serialization contract. This prompt is designed for a workflow where accuracy and completeness are non-negotiable because a missing field or incorrect type in the docs will cause integration bugs downstream.
Prompt
SDK Type Definition and Model Documentation Prompt

When to Use This Prompt
Define the job, reader, and constraints for generating structured SDK type and model documentation.
This prompt is not a general-purpose documentation writer. Do not use it for conceptual overviews, getting-started narratives, or architectural decision records. It is strictly for structured, reference-style type documentation. You should have the canonical schema or source code available as input; the prompt works best when it can reference a concrete artifact rather than generating a type definition from memory. The required context includes the raw type definition, the target language or serialization format, and any specific documentation conventions your team follows, such as how to mark deprecated fields or experimental features. The output is a predictable, machine-readable structure that can be rendered into HTML, MDX, or a PDF without manual reformatting.
Before using this prompt, confirm that you have a stable source of truth for the type. If the schema is still in flux, the generated documentation will drift immediately, creating a maintenance burden. Pair this prompt with a validation step that diffs the generated output against the source schema to catch omissions. For high-stakes APIs where a documentation error could cause data loss or a security incident, always require human review of the final output before publication. The next step after generating the reference is to integrate it into your CI pipeline so that every schema change triggers a documentation refresh and a review request.
Use Case Fit
Where this prompt works and where it does not. Use these cards to decide if the SDK Type Definition and Model Documentation Prompt is the right tool for your current documentation task.
Good Fit: Source-Annotated Codebases
Use when: you have TypeScript interfaces, JSDoc annotations, Python type hints with docstrings, or similar structured source annotations. The prompt excels at extracting field names, types, nullability, and descriptions directly from code. Guardrail: always provide the raw source file or annotated snippet as [INPUT]. Do not rely on the model's memory of a library's types.
Bad Fit: Undocumented Legacy Code
Avoid when: the codebase lacks type annotations, docstrings, or inline comments. The model will hallucinate field descriptions and miss implicit nullability rules. Guardrail: run a static analysis pass first to flag undocumented public surfaces. Use this prompt only after annotations are added or supplemented with a separate specification document.
Required Input: Serialization Behavior
Risk: type definitions alone miss critical runtime behavior such as JSON field name transformations (camelCase to snake_case), omit-empty policies, and custom encoders/decoders. Guardrail: always include a [SERIALIZATION_RULES] input block describing field name casing, null handling, and any custom transforms. Validate the generated docs against a round-trip encode-decode test.
Required Input: Enum Value Sources
Risk: the model may invent plausible enum values or miss recently added variants if only shown the type definition. Guardrail: provide the actual enum source of truth as [ENUM_DEFINITIONS], either from code or a canonical constants file. Add an eval check that every documented enum value exists in the source and no source values are omitted.
Operational Risk: Drift from Live API
Risk: documentation generated from SDK types can drift from the actual API contract if the SDK lags behind the API or includes client-side-only conveniences. Guardrail: cross-reference generated type docs against the OpenAPI spec or API reference as a validation step. Flag any field that appears in the API response but is missing from the documented SDK type, and vice versa.
Operational Risk: Nested Object Depth
Risk: deeply nested type hierarchies produce documentation that is hard to read and easy to get wrong. The model may flatten relationships or omit intermediate wrapper types. Guardrail: set a [MAX_DEPTH] constraint in the prompt and require the output to preserve the full nesting path. Use a structural diff against the source AST to verify no level was collapsed.
Copy-Ready Prompt Template
The reusable prompt template for generating structured SDK type and model documentation from source annotations, with square-bracket placeholders for adaptation.
This prompt template generates structured documentation for SDK data models, interfaces, and type definitions. It expects source annotations, type definitions, or implementation code as input and produces field-level reference documentation with descriptions, nullability, enum values, nested object relationships, and serialization notes. The template is designed to be wired into a documentation pipeline where consistency with actual serialization behavior matters.
textYou are an SDK documentation engineer. Generate structured type reference documentation from the provided source annotations and type definitions. ## INPUT [SOURCE_ANNOTATIONS] ## OUTPUT SCHEMA Return a JSON object with this exact structure: { "type_name": "string", "package_path": "string", "description": "string", "fields": [ { "name": "string", "type": "string", "required": boolean, "nullable": boolean, "description": "string", "default_value": "string or null", "enum_values": ["string"] or null, "deprecated": boolean, "deprecation_message": "string or null", "serialization_name": "string or null", "validation_constraints": "string or null" } ], "nested_types": [ { "name": "string", "fields": [/* same field structure */] } ] or null, "serialization_format": "json" | "form" | "multipart" | "custom", "deserialization_notes": "string or null", "example_json": "string or null" } ## CONSTRAINTS - Extract every public field from the source annotations, including inherited fields. - Mark fields as nullable only when the annotation explicitly allows null. - Include enum_values when the type is an enum or string union with known values. - Set serialization_name when the wire format name differs from the field name (e.g., snake_case vs camelCase). - Flag deprecated fields with deprecation_message from the annotation. - For nested object types, include them in nested_types with full field definitions. - Generate example_json that matches the serialization_format and includes all required fields. - If the source annotations are incomplete, note missing information in the relevant field description rather than omitting the field. - Do not invent types, fields, or constraints not present in the source. ## EXAMPLES [EXAMPLES] ## RISK LEVEL [RISK_LEVEL]
Adapt this template by replacing each square-bracket placeholder. [SOURCE_ANNOTATIONS] should contain the raw type definitions, JSDoc comments, docstrings, or annotation tags from source code. [EXAMPLES] should include one or two well-formed output examples showing the expected structure for your SDK's specific type patterns. Set [RISK_LEVEL] to low for internal documentation, medium for customer-facing docs where errors cause confusion, or high for types involved in billing, auth, or data integrity where mistakes have operational consequences. For high-risk types, add a human review step before publication and validate the generated output against actual serialization test fixtures.
Prompt Variables
Required and optional inputs for the SDK type definition and model documentation prompt. Validate each placeholder before wiring the prompt into a documentation generation pipeline.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[SOURCE_CODE] | Source file or class definition containing the type, interface, or model to document | src/models/Subscription.ts | Must parse without syntax errors. File extension must match expected language. Null allowed if [SOURCE_ANNOTATIONS] is provided. |
[SOURCE_ANNOTATIONS] | Structured annotations, docstrings, or JSDoc blocks extracted from source | {"class": "Subscription", "docstring": "Represents a recurring billing subscription.", "fields": [...]} | Must be valid JSON with class name and fields array. Each field requires name, type, and optional description. Null allowed if [SOURCE_CODE] is provided. |
[LANGUAGE] | Target programming language for the SDK being documented | TypeScript | Must match one of the supported SDK languages. Controls type syntax, nullability conventions, and example formatting. |
[SERIALIZATION_FORMAT] | Wire format used for serialization and deserialization | JSON | Must be a recognized format. Drives field name casing rules, enum representation, and nested object handling in documentation. |
[OUTPUT_SCHEMA] | Expected structure for the generated type reference documentation | {"type_name": "string", "description": "string", "fields": [{"name": "string", "type": "string", "required": "boolean", "nullable": "boolean", "description": "string", "enum_values": ["string"]}]} | Must be a valid JSON Schema or TypeScript interface definition. Every field in the output must map to a documented element. Missing output fields will cause downstream rendering failures. |
[ENUM_MAPPINGS] | Known enum definitions and their allowed values referenced by the type | {"BillingInterval": ["monthly", "annual"], "SubscriptionStatus": ["active", "paused", "canceled"]} | Must be a JSON object where keys are enum names and values are string arrays. Used to validate that documented enum fields list complete and correct values. Null allowed if type has no enum fields. |
[KNOWN_NULLABLE_FIELDS] | Explicit list of fields that permit null values in the serialized form | ["canceled_at", "trial_end"] | Must be a string array matching field names in the source. Null allowed. If provided, output must mark these fields as nullable. Mismatch between this list and source annotations is a validation failure. |
[CONSTRAINTS] | Additional documentation requirements or style rules | Include @deprecated tags. Use PascalCase for type names. Add see-also links to parent types. | Must be a non-empty string or null. Constraints are appended to the system prompt. Validate that constraints do not contradict the output schema. |
Implementation Harness Notes
How to wire the SDK type definition prompt into a documentation pipeline with validation, retries, and human review gates.
This prompt is designed to be called programmatically as part of a documentation generation pipeline, not as a one-off chat interaction. The typical integration point is a CI/CD workflow or a docs-platform backend that receives source code annotations, OpenAPI schemas, or protobuf definitions and produces structured type reference pages. The prompt expects a well-formed [INPUT] containing the raw type definition (interface, class, struct, or schema) and any available docstrings or annotations. The [OUTPUT_SCHEMA] placeholder should be replaced with a strict JSON schema that defines the exact structure you want: field name, type, description, required/optional, nullable, default value, enum members, and nested object relationships. Do not rely on the model to invent a consistent schema on its own—provide the target schema explicitly to ensure downstream consumers (static site generators, API reference renderers, IDE integrations) receive predictable output.
Wire the prompt into an application using a three-stage pipeline: generation, validation, and repair-or-escalate. In the generation stage, call the model with the prompt template and capture the raw output. In the validation stage, parse the output against your [OUTPUT_SCHEMA] using a JSON Schema validator. Common failures include missing required fields, incorrect enum value casing, and nested object flattening errors. If validation fails, invoke a repair prompt (from the Output Repair and Validation Prompts pillar) that provides the original input, the failed output, and the specific validation errors. Retry once. If the repair also fails, escalate to a human reviewer queue with the source type definition, both failed outputs, and the validation error log. For high-risk SDK surfaces (authentication, payments, data deletion), always require human approval before publishing, regardless of validation success.
Model choice matters here. Use a model with strong structured output capabilities and a large context window if your type definitions include deeply nested generics or extensive docstrings. For cost-sensitive pipelines processing hundreds of types, consider batching multiple type definitions into a single prompt call with clear delimiters, but be aware that larger batches increase the risk of field confusion between types. Log every generation attempt with the prompt version, model identifier, input hash, output hash, validation result, and reviewer decision. This audit trail is essential for debugging type reference drift when source code changes. Avoid wiring this prompt directly to a publish action—always insert a staging step where generated docs can be diffed against the previous version before going live.
Expected Output Contract
Each field the prompt must return, with its expected type, whether it is required, and the validation rule to apply before accepting the output into a documentation pipeline.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
type_name | string | Must match the exact type, interface, or class name from the source code. Case-sensitive exact match required. | |
description | string | Must be a single sentence between 10 and 200 characters. Must not repeat the type name as the first three words. | |
fields | array of objects | Array length must equal the number of public fields in the source type. Each object must contain name, type, required, nullable, and description keys. | |
fields[].name | string | Must match the exact field name from the source code. Case-sensitive. No trailing underscores or prefix variations allowed. | |
fields[].type | string | Must use the SDK language's idiomatic type notation. Primitives, union types, and nested references must match the serialized form in the actual SDK. | |
fields[].required | boolean | Must be true if the field is non-optional in the source type definition. Must be false if the field has a default value or is marked optional. | |
fields[].nullable | boolean | Must be true only if null is an explicitly allowed value in the source type. Must not be inferred from optionality alone. | |
fields[].description | string | Must describe the field's purpose and constraints. Must mention enum values or valid ranges if applicable. Must not exceed 300 characters. | |
fields[].enum_values | array of strings or null | If the field is an enum or string literal union, must list every allowed value. If not an enum, must be null. Array must not be empty when present. | |
nested_types | array of objects or null | If the type contains inline object definitions or nested interfaces, each must appear here with the same schema as the root type. Must be null if no nested types exist. | |
serialization_notes | string or null | If the type has non-obvious serialization behavior, must describe it. Must mention field name transformations, omitted nulls, or custom encoders. Must be null if standard serialization applies. | |
deprecation | object or null | If the type or any field is deprecated, must contain deprecated_field, deprecation_version, replacement, and removal_version. Must be null if nothing is deprecated. | |
source_reference | string | Must be a valid file path and line range from the source repository. Format: path/to/file.ext:Lstart-Lend. Must be verifiable against the current main branch. |
Common Failure Modes
When generating SDK type definitions and model documentation, these are the most common failure patterns that cause downstream integration errors, broken builds, and developer confusion.
Field Nullability Mismatch
What to watch: The prompt generates type definitions that mark fields as required when the API actually returns null, or vice versa. This causes runtime crashes when SDK consumers destructure optional fields without null guards. Guardrail: Require the prompt to reference actual API response samples or OpenAPI schemas. Add a validation step that compares generated nullability against at least three real response payloads before publishing.
Enum Value Drift from Source
What to watch: Generated enum types include values that are outdated, miss newly added variants, or use incorrect string casing. SDK consumers hit deserialization failures when the API returns an unlisted enum member. Guardrail: Ground enum generation in a machine-readable source of truth such as an OpenAPI spec or a constants file. Add a CI check that diffs generated enums against the live API's actual response values weekly.
Nested Object Depth Collapse
What to watch: The prompt flattens or omits deeply nested object relationships, producing a shallow type that compiles but fails to represent the actual data structure. Consumers lose access to nested fields or receive any types where strong types were expected. Guardrail: Include a schema traversal instruction in the prompt that explicitly requires documenting every nesting level. Validate output by comparing the depth of generated type trees against the source schema's maximum nesting depth.
Serialization Round-Trip Inconsistency
What to watch: Generated type definitions describe a structure that cannot survive a serialize-deserialize round-trip. Field names use camelCase in the type but snake_case in the wire format, or the type omits a custom serializer annotation the SDK requires. Guardrail: Add an eval harness that generates a sample object from the documented type, serializes it using the SDK's actual serializer, deserializes it back, and asserts structural equality. Flag any type that fails the round-trip.
Missing Deprecation Annotations
What to watch: The prompt documents fields and methods without marking deprecated surfaces, causing consumers to build against APIs scheduled for removal. Migration timelines are invisible in the generated reference. Guardrail: Require the prompt to scan source annotations, changelogs, or OpenAPI deprecated flags. Add a mandatory @deprecated tag and replacement guidance field to the output schema. Validate that every deprecated surface in the source appears in the generated docs.
Generic Type Erasure in Collections
What to watch: The prompt generates Array<object> or List<Map> instead of preserving the concrete element type for list responses, paginated results, or dictionary values. Consumers lose type safety on collection elements. Guardrail: Include explicit instructions to resolve generic type parameters through every level of indirection. Add a post-generation lint rule that rejects any object, any, or unparameterized generic appearing in a collection type position.
Evaluation Rubric
Use this rubric to evaluate the quality of generated SDK type definition and model documentation before shipping. Each criterion targets a specific failure mode common in structured documentation generation.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Field Completeness | Every public field from the source type definition appears in the output with a description | Missing fields; undocumented properties present in the source interface or class | Diff output fields against source AST or OpenAPI schema; flag any field in source not in output |
Type Accuracy | Each field's documented type matches the source type exactly, including generics, unions, and wrappers | Type mismatch between source and documentation; | Parse source type annotations and output type strings; compare normalized type representations |
Nullability Documentation | Every nullable or optional field is explicitly marked with nullability semantics and default behavior | Optional field documented as required; nullable field missing null handling description | Check each field for null/undefined indicators; verify presence of nullability column or inline notation |
Enum Value Completeness | All enum members are listed with their string or numeric values and a description of each variant's meaning | Missing enum members; undocumented variant values; placeholder descriptions like 'Other' for known variants | Extract enum definitions from source; compare member count and values against documented enum table |
Nested Object Expansion | Nested object types are fully expanded or linked with clear navigation; no opaque | Nested type documented as | Traverse output type tree; flag any leaf node typed as |
Serialization Behavior Notes | Documentation includes serialization format, field name transformations, and any custom serde logic | No mention of camelCase/snake_case conversion; missing notes on date formatting or byte encoding | Search output for serialization keywords; verify presence of format notes when source contains serde annotations |
Deprecation Flagging | All deprecated fields, types, or enum variants are clearly marked with deprecation version and replacement guidance | Deprecated field shown without warning; missing migration path; active and deprecated surfaces indistinguishable | Cross-reference source deprecation annotations against output; verify each deprecated item has a visible deprecation marker and replacement pointer |
Code Example Relevance | Each complex type includes a realistic instantiation example showing required fields, optional overrides, and nested objects | Examples missing for types with more than 5 fields; example uses invalid field values; example omits required fields | Extract code blocks from output; validate syntax; check that all required fields appear in each example |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a single language target and relaxed validation. Focus on getting the structure right before adding strict schema checks. Replace [LANGUAGE] with your target language and [SOURCE_ARTIFACT] with a single class or interface file.
Watch for
- Missing nullability annotations in generated output
- Enum values listed without their string or integer equivalents
- Nested object relationships described but not typed
- Overly broad instructions that produce prose instead of structured reference

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us