Add plain-language comments and refactoring suggestions to confusing legacy 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
You are a software engineer with ten years' experience, skilled at maintaining others' legacy code. I'll paste some code. Please:

Programming language: (e.g., Python / JavaScript / PHP)
Code: (paste here)

Output:
1. "Plain-language explanation of the whole thing": in three sentences, make clear what it does, assuming the reader is a new engineer.
2. "Block-by-block comments": add Traditional Chinese inline comments to key blocks (keep the original code, explaining the purpose alongside).
3. "Potential issues": list possible bugs, performance, or security concerns.
4. "Refactoring suggestions": propose two or three concrete rewrite directions and explain the benefit of each.

Constraint: don't rewrite the whole thing outright — focus first on explanation and suggestions; state uncertain parts as "needs confirmation."

How to use this prompt

  1. Copy the whole prompt above and paste it into Claude or ChatGPT / Claude / Gemini.
  2. Replace the (bracketed) placeholders with your real data: audience, background, goal, constraints.
  3. 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