Documentation
Coding Studio

Generate Tool

Create code from natural language requirements. Get type-safe, documented, and production-ready code with usage examples.

Keyboard shortcut: Cmd/Ctrl + 4

What It Does

The Generate tool creates code from your requirements, producing production-ready implementations with best practices:

Type-Safe Code

Generates properly typed code with interfaces, type annotations, and type guards where appropriate.

Documentation

Includes JSDoc/docstrings, inline comments explaining complex logic, and README-style usage instructions.

Usage Examples

Provides working examples showing how to use the generated code, including edge cases and error handling.

Multiple Files

For complex requirements, generates multiple files (types, utils, main code) organized in the Files tab.

Context Fields

The Generate tool uses a requirements field for your specifications:

FieldDescription
RequirementsNatural 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.

How to Use

1

Select Generate Tool

Click the Generate button (green icon) or pressCmd/Ctrl + 4.

2

Choose Target Language

Select the programming language you want the code generated in from the language dropdown.

3

Enter Requirements

In the Requirements field, describe what you want to build. Be as specific as possible about functionality, types, and constraints.

4

Optional: Add Context Code

If you have existing types, interfaces, or code that the generated code should integrate with, paste it in the code editor.

5

Click "Generate Code"

Run the generation. The tool balances quality with responsiveness for quick iteration.

6

Review and Download

Check the Result tab for the main code, and the Files tab for additional generated files that you can download.

Example Requirements

Here's an example of well-written requirements:

requirements.txt
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 documentation

This would generate:

validate-email.tsTypeScript
/**
 * 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,
  };
}

Writing Good Requirements

  • Be specific: "Parse JSON" vs "Parse JSON with error recovery and type validation"
  • Define types: Specify input/output types and shapes
  • List edge cases: Empty inputs, nulls, invalid data
  • Mention constraints: Performance needs, size limits, async requirements
  • Include context: Frameworks, libraries, or patterns to use

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.