Websites, apps & code / Coding & debugging
Tidy up messy code
It works but is getting messy, and you fear breaking it.
1Fill in your details
Leave blank to use the example. Names are remembered for other prompts too (stored only on your device).
3Copy the prompt
Please help me tidy some code. Goal: Easier to add features and easier for others to read. Size: One file of about 200 lines Requirements: - first ask me to paste the code and remind me to back it up - behaviour and output must not change, only how it is written - change one kind of thing at a time (names, then repetition, then functions) and give steps - for each step tell me how to confirm nothing broke - do not add features I did not ask for - fit the kind of code - Pull repeated parts into functions and use readable names. - Use only the details I give you. Do not invent anything. If something is missing, leave it as [ ] or ask me. Output format: A tidy-up plan, then the code for each step. [Make it sound human] - Explain in plain words; no pleasantry openers or empty summaries. - Only necessary, short, practical code comments; the simplest working approach, no over-engineering. - Interface text (buttons, hints, error messages) should sound like a person wrote it; no "seamless", "empower", "unlock". [Quality] Code must run as is and handle common errors; tell me how to test it and confirm it works; ask first if a requirement is unclear; never put passwords or API keys in the code.
Paste it into ChatGPT, Gemini, Claude or Meta AI.
Test result
What we noticed
No code was provided, so it gave a backup routine and a 4-step plan, each with a way to confirm nothing broke. Nothing was changed.
See what the AI actually wrote
Please paste the 200 lines first (swap passwords and API keys for fake ones). I have no code, and I will not tidy anything out of thin air.
Back up before tidying:
- Copy the file, add "backup" to the name, and keep it elsewhere.
- If you use Git, commit once as a save point.
- Run it once now and record the current output (screenshot or text); after tidying it must match.
Tidy plan (adjusted to the real code once you paste it):
| Step | Changes only | How to confirm nothing broke |
|---|---|---|
| 1. Naming | Rename unclear variables and functions (a to totalPrice) | Run again; the output is identical to the backup |
| 2. Find repeats | Only mark the repeated parts and show you, no edits | You confirm they are really repeats |
| 3. Extract functions | Turn the repeated part into a function and call it | Run: same output; change one value on purpose and both places follow |
| 4. Split up | If still too long, split a large function into smaller ones | Same as above |
I change one kind of thing per step, give you the updated code and a list of changes, and move on only after you confirm nothing broke.
Rules:
- Behaviour and output must not change; only how it is written.
- No new features you did not ask for, no performance tuning on the side.
- Anything unclear gets "not sure here" and is left alone.
- Design choices you did not state (such as splitting into several files) stay as they are: one file.
Paste the code and I give the tidy plan first; you agree, then I do step 1.
AI tools that suit this
- ChatGPT Suggested tool Free plan
The most widely used AI chat, for writing, questions and images
- Claude Suggested tool Free plan
Strong at long documents, editing and code
- Claude Code Suggested tool Free plan
AI that writes code directly on your computer
Recommendations only, not sponsored. Check each site for what the free plan includes.
This site is made by FullMark Tech
Want your own website, or your shop spreadsheets automated? FullMark Tech builds business websites and custom Excel tools.