Copilot Interface Generator
Added Apr 2, 2026
About This Prompt
This prompt generates a complete TypeScript type system for any domain, producing interfaces, DTOs, union types, utility types, type guards, and runtime validators in one cohesive output. A well-designed type system catches bugs at compile time, serves as living documentation, and makes refactoring safer. This prompt applies TypeScript best practices like branded types for IDs, discriminated unions for state, and Zod schemas for runtime validation. It is especially valuable when starting a new module, migrating from JavaScript to TypeScript, or cleaning up a codebase that overuses 'any' types.
Variables to Customize
[DOMAIN]
The business domain for the types
Example: e-commerce orders
[PROJECT_TYPE]
Type of application
Example: Next.js full-stack application
[FUNCTIONALITY]
What the module manages
Example: order creation, status tracking, payment processing, and fulfillment
[EXTERNAL_SYSTEMS]
External APIs and services involved
Example: Stripe payments API, warehouse fulfillment API, and email notification service
Tips for Best Results
- Use branded types for entity IDs to catch bugs where you accidentally pass a userId where an orderId is expected
- Generate Zod schemas alongside interfaces to get both compile-time and runtime type safety
- Export types from a central barrel file so imports stay clean throughout the project
Example Output
// types/order.ts
/** Branded type to prevent mixing Order IDs with other entity IDs */
type OrderId = string & { readonly __brand: 'OrderId' };
type UserId = string & { readonly __brand: 'UserId' };
/** All possible states an order can be in */
type OrderStatus = 'pending' | 'confirmed' | 'processing' | 'shipped' | 'delivered' | 'cancelled' | 'refunded';
/** Core order entity as stored in the database */
interface Order {
readonly id: OrderId;
readonly userId: UserId;
readonly items: readonly OrderItem[];
readonly status: OrderStatus;
readonly total: number;
readonly currency: string;
readonly createdAt: Date;
readonly updatedAt: Date;
}
/** Request DTO for creating a new order */
interface CreateOrderRequest {
items: Array<{ productId: string; quantity: number }>;
shippingAddress: Address;
paymentMethodId: string;
}
// Zod validation schema
const createOrderSchema = z.object({
items: z.array(z.object({ productId: z.string().uuid(), quantity: z.number().int().positive() })).min(1),
...