Add clear comments and naming suggestions to hard-to-read code
A ready-to-use “Programming” AI prompt template, designed and tested with Claude. Replace the (bracketed) parts below with your own needs.
Prompt template
I inherited some code with no comments and careless variable naming, and want to make it understandable to future people (including myself). Programming language: () Roughly what this code does (my current guess): () Code: (paste it) Please: 1. Summarize in one plain-language paragraph what this code actually does 2. Without changing the logic, add Traditional Chinese comments at the key spots (only comment what's confusing, not every line) 3. List unclear variable/function names and give more expressive naming suggestions, as a comparison table 4. Point out anything that looks like it might hide a bug or be hard to maintain later, each with a one-line note.
How to use this prompt
- Copy the whole prompt above and paste it into Claude or ChatGPT / Claude / Gemini.
- Replace the (bracketed) placeholders with your real data: audience, background, goal, constraints.
- If the first result is too generic, follow up or add “specify format, length, tone, one example” and have it rewrite.
Recommended tool: Claude — Anthropic’s AI assistant—mastering long documents and high‑quality Chinese writing