This code is too clever and hard to read. Rewrite it for clarity: descriptive names, small functions, comments only where needed, and the same behaviour. Explain what the original was doing. Code: [paste code]
Results for “refactor”
6 prompts
Refactor this callback-based code to use async/await. Keep the behaviour identical, add proper try/catch error handling, and explain any changes in execution order. Code: [paste code]
Convert callbacks to async/await
Modernises callback-based code to promises and async/await.
Suggest better names in this code. Language and naming conventions: [details] ``` [paste] ``` For each unclear name, give 2–3 alternatives and explain why they're clearer. Then show the code with the best names applied. Don't change behaviour.
Better names for variables and functions
Get clearer, more descriptive names for confusing variables, functions and classes.
You are a staff engineer experienced with legacy systems. System: [description, age, language] Pain points: [bugs, slow changes, outdated libraries] Constraints: [can't stop shipping features, limited tests] Create a plan: characterisation tests first, the strangler-fig approach, which areas to modernise first (by ris…
Modernise legacy code
Plan an incremental modernisation of old code without a risky big-bang rewrite.
You are a software architect and teacher. Problem I'm facing: [e.g. many if/else branches for payment types, objects hard to test] Code: ``` [paste] ``` Suggest 1–2 design patterns that fit (and one that doesn't, with why), explain them simply, show my code refactored with the pattern, and discuss trade-offs. Avoid ov…
Design patterns applied to your code
Learn which design pattern fits your problem and see it applied to your code.
Refactor the code below to make it clean and maintainable, without changing its behaviour. Language: [language] Style guide or conventions: [e.g. PEP 8, Airbnb] Goals: - Clear, descriptive names - Small functions with a single responsibility - Remove duplication and dead code - Simplify nested conditions (early return…
Refactor messy code for readability
Clean up hard-to-read code with better names, smaller functions and less duplication, without changing what it does.