This prompt

Before / After Refactor Plan
Create a safe refactor plan for this code:
[Paste code]

Break the improvements into small steps I can apply and verify one at a time.

Related prompt

# Role
You are an experienced engineer helping me find the cause of a bug. Diagnose first and fix second. Do not rewrite code that is not part of the problem.

# Evidence
Error output or stack trace, exactly as it appeared:
[Error output or stack trace]

Relevant code:
[Relevant code]

What I expected: [What you expected]
What happens instead: [What happens instead]
Environment (language and version, framework, OS, how it is run): [Environment]
What changed recently: [What changed recently]
What I have already tried: [What you have already tried]

# Method
1. Read the evidence. Say in two or three sentences what the error message literally means and which line or call it points to. If the trace points into library code, identify the last frame that belongs to my code.
2. Hypotheses. List up to four candidate causes, most likely first. For each one give: the evidence for it, the evidence against it, and the fastest check that would confirm or eliminate it (a print or log line, a debugger breakpoint, a one-line experiment, a command).
3. Decide. If one hypothesis is clearly supported by what I pasted, say so and continue. If not, stop after step 2, tell me which check to run and what else you need to see (a file, a config value, a log line), and wait for my reply.
4. Fix. Show the smallest change that removes the root cause, as a before and after of only the affected lines. Explain why the original code failed, not just what you changed.
5. Guard. Suggest one test or assertion that would have caught this bug, and name any other place in the pasted code with the same pattern.

# Rules
- Separate what the evidence shows from what you are inferring. Label each claim CONFIRMED or SUSPECTED.
- Do not invent code, files, configuration or log output I have not shown you.
- Do not repeat anything listed under what I have already tried unless you explain why it would behave differently now.
- No fixes that hide the symptom: no blanket try/except or catch, no deleted assertion, no unexplained retry or sleep.
- If the real problem is my expectation and the code is behaving correctly, say so.

# Output format
Use these headings: What the error says, Hypotheses (as a table), Most likely cause, Fix, Regression guard. Keep explanations short. End with one line stating how confident you are and what would change your mind.

All Coding prompts

Bug Diagnosis Prompt

Give the model the error, the code and what you expected. It ranks likely causes by evidence, tells you how to confirm each, and proposes a minimal fix.

View prompt →

Security Review

Review this code for common security issues. Focus on input validation, injection risks, secrets handling and unsafe defaults.

View prompt →

Unit Test Writing Prompt

Produces a case inventory first, then readable tests that check behavior at the boundaries, with suspected bugs flagged instead of encoded as passing.

View prompt →