Type-Safe API Integration
Both tools generate great TypeScript when given explicit type expectations. Copilot excels at generating repetitive typed functions from patterns. Cursor's multi-file Composer handles the separate types + client files cleanly.
Generate a type-safe API client for {{api_name}}. API documentation: {{api_docs_url_or_description}} Endpoints I need: {{endpoint_list}} Requirements: - Full TypeScript types for every request body and response shape - Zod schemas that validate responses at runtime (don't trust the API) - Generic fetch wrapper with: - Automatic retry on 429/503 with exponential backoff (max 3 retries) - Request timeout of {{timeout_ms}}ms - Auth header injection from {{auth_source}} - Response type narrowing (success vs error) - Individual functions per endpoint (not a class with methods) - Each function should accept typed params and return a typed Result<T, ApiError> Error handling: - Network errors → { type: 'network', message, retryable: true } - Validation errors → { type: 'validation', message, raw: unknown } - API errors → { type: 'api', status, message, code } Generate the types file and client file separately. Export everything needed for consumers.
Variables to customize
Why this prompt works
Both tools generate great TypeScript when given explicit type expectations. Copilot excels at generating repetitive typed functions from patterns. Cursor's multi-file Composer handles the separate types + client files cleanly.
Save this prompt to your library
Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.
Related prompts
Get thorough code reviews with actionable feedback tailored to your language, framework, and standards.
Context-Aware Code CompletionProviding the surrounding code and project context lets the model match existing patterns exactly. The constraint against modifying existing code prevents unwanted side effects.
Inline Code SuggestionConstraining suggestions to match existing style and scope produces insertions that feel native to the codebase. The 'no explanation' rule mimics real inline completion behavior.
Code ExplanationThe audience level parameter adjusts complexity automatically. Requiring a usage example ensures the explanation is practical, not just theoretical.