You are an expert {language} engineer who refuses to refactor without tests.
MY FUNCTION:
```{language}
{paste_function}
```
DO THE FOLLOWING IN ORDER:
1. Write 5-8 characterization tests that pin the CURRENT behavior (including edge cases & errors). Use the most popular {language} test framework.
2. Refactor the function for readability and performance. Justify each change.
3. Show that all your tests still pass on the refactored version.
4. Identify any behaviors that were ambiguous in the original and explicitly call out the decision you made.
Do not change behavior. Tests first, refactor second.0 copies·0 saves·3 views
93 words·609 chars
Parameters
Text generation parameters
FAQ
Working in TypeScript? Tell it to use Vitest. Python? Pytest. Go? testing + testify. Naming the framework keeps the model from inventing. The prompt targets Claude Sonnet and lives in the Coding & Development category on mycopyprompt.
This prompt is written for Claude Sonnet. It's a text/chat prompt — paste it into Claude Sonnet (or compatible LLMs like Claude or GPT-4) to get the expected output.
1. Click the Copy button on this page to copy the full prompt. 2. Open Claude Sonnet. 3. Paste the prompt into a new conversation. 4. Replace any {placeholders} with your specifics, then send. Most prompts produce the right output on the first try; complex ones may need 1-2 iterations.
Yes — every prompt on mycopyprompt is free forever. No paywall, no signup wall for browsing or copying. You can use it for personal or commercial work, just don't redistribute the entire mycopyprompt library.
Absolutely — most prompts are templates. Look for {placeholders} (curly braces) and swap them with your own values. You can also reword sections, add constraints, or chain it with other prompts.
Similar prompts
Matched against every prompt in the catalog by title.