Create code from natural language requirements. Get type-safe, documented, and production-ready code with usage examples.
The Generate tool creates code from your requirements, producing production-ready implementations with best practices:
Generates properly typed code with interfaces, type annotations, and type guards where appropriate.
Includes JSDoc/docstrings, inline comments explaining complex logic, and README-style usage instructions.
Provides working examples showing how to use the generated code, including edge cases and error handling.
For complex requirements, generates multiple files (types, utils, main code) organized in the Files tab.
The Generate tool uses a requirements field for your specifications:
| Field | Description |
|---|---|
| Requirements | Natural language description of what you want to build |
Be Specific
The more detailed your requirements, the better the generated code. Include input/output types, error handling needs, and any constraints.
Click the Generate button (green icon) or pressCmd/Ctrl + 4.
Select the programming language you want the code generated in from the language dropdown.
In the Requirements field, describe what you want to build. Be as specific as possible about functionality, types, and constraints.
If you have existing types, interfaces, or code that the generated code should integrate with, paste it in the code editor.
Run the generation. The tool balances quality with responsiveness for quick iteration.
Check the Result tab for the main code, and the Files tab for additional generated files that you can download.
Here's an example of well-written requirements:
Create a TypeScript function that:
1. Validates email addresses
2. Accepts a string input
3. Returns an object with:
- isValid: boolean
- errors: string[] (empty if valid)
4. Checks for:
- Non-empty input
- Valid email format (RFC 5322)
- Maximum length of 254 characters
- No consecutive dots
5. Should be pure function with no side effects
6. Include comprehensive JSDoc documentationThis would generate:
/**
* Validates an email address according to RFC 5322 standards.
*
* @param email - The email address to validate
* @returns Validation result with isValid flag and error messages
*
* @example
* const result = validateEmail('user@example.com');
* // { isValid: true, errors: [] }
*
* @example
* const result = validateEmail('invalid..email@test.com');
* // { isValid: false, errors: ['Email contains consecutive dots'] }
*/
export interface ValidationResult {
isValid: boolean;
errors: string[];
}
const EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
const MAX_EMAIL_LENGTH = 254;
export function validateEmail(email: string): ValidationResult {
const errors: string[] = [];
// Check for empty input
if (!email || email.trim().length === 0) {
errors.push('Email address is required');
return { isValid: false, errors };
}
// Check maximum length
if (email.length > MAX_EMAIL_LENGTH) {
errors.push(`Email exceeds maximum length of ${MAX_EMAIL_LENGTH} characters`);
}
// Check for consecutive dots
if (email.includes('..')) {
errors.push('Email contains consecutive dots');
}
// Check email format
if (!EMAIL_REGEX.test(email)) {
errors.push('Invalid email format');
}
return {
isValid: errors.length === 0,
errors,
};
}Iterative Generation
You can iterate on generated code by pasting it back into the editor with updated requirements. The tool will refine based on your feedback.