♻️
Promise Chain to Async/Await Migration
Convert nested promise chains to clean async/await syntax
prompt template
Convert this promise-based code to async/await: ``` [PASTE_PROMISE_CHAIN_CODE] ``` Requirements: 1. **Direct conversion** — maintain identical behavior and error handling 2. **Error handling** — convert .catch() to try/catch, preserve error types 3. **Parallel operations** — use Promise.all() where promises are independent 4. **Sequential operations** — use await for dependent operations 5. **Error propagation** — ensure errors bubble up the same way 6. **TypeScript types** — add return types to async functions 7. **Edge cases** — handle Promise.race, Promise.allSettled if present Show before/after with comments explaining each transformation. Flag any behavior changes that the conversion might introduce.
How to Use This Prompt
- 1Copy the prompt template above
- 2Paste into Claude, ChatGPT, or Cursor
- 3Replace [bracketed placeholders] with your specific project details
- 4Iterate on the AI output to refine and customize the results
More Refactoring Prompts
Related refactoring templates from the vault
♻️
Switch Statement to Strategy Pattern
Use this prompt to switch statement to strategy pattern with AI assistance
Beginnerrefactoringstrategy-pattern
♻️
Code Review Prompt
Get a thorough code review with actionable feedback
Beginnercode-reviewquality
♻️
Code Smell Detector and Fixer
Identify code smells in existing code and get refactored versions
Intermediaterefactoringcode-review
♻️
Nested Conditionals Flattener
Use this prompt to nested conditionals flattener with AI assistance
Intermediaterefactoringconditionals
You Might Also Like
Prompts from other categories that share similar tags
⚙️
Backend
TypeScript Type Wizard
Get help with complex TypeScript types, generics, and utility types
Shared:typescript
🔌
API Design
API Error Response Standard
Define a consistent error response format across all API endpoints
Shared:typescript
🔌
API DesignPRO
OpenAPI Specification Generator
Generate a complete OpenAPI 3.1 specification from existing API routes
Shared:typescript
📝
Documentation
Code Documentation with JSDoc
Add comprehensive JSDoc documentation to existing code
Shared:typescript
Keep Exploring the Vault