เพิ่มคอมเมนต์ชัดเจนและข้อเสนอการตั้งชื่อให้โค้ดที่อ่านยาก
A ready-to-use “Programming” AI prompt template, designed and tested with Claude. Replace the (bracketed) parts below with your own needs.
Prompt template
ฉันรับช่วงโค้ดที่ไม่มีคอมเมนต์และตั้งชื่อตัวแปรลวก ๆ และอยากทำให้คนในอนาคต (รวมถึงตัวฉันเอง) เข้าใจได้ ภาษาโปรแกรม: () โค้ดนี้ทำอะไรคร่าว ๆ (ที่ฉันเดา): () โค้ด: (วางมา) โปรด: 1. สรุปในหนึ่งย่อหน้าด้วยภาษาที่เข้าใจง่ายว่าโค้ดนี้ทำอะไรจริง ๆ 2. โดยไม่เปลี่ยนตรรกะ เพิ่มคอมเมนต์ภาษาไทยในจุดสำคัญ (คอมเมนต์เฉพาะส่วนที่งง ไม่ใช่ทุกบรรทัด) 3. จัดรายการชื่อตัวแปร/ฟังก์ชันที่ไม่ชัดเจนและเสนอชื่อที่สื่อความหมายกว่า เป็นตารางเปรียบเทียบ 4. ชี้สิ่งที่ดูเหมือนอาจซ่อนบั๊กหรือดูแลรักษายากในภายหลัง แต่ละข้อพร้อมหมายเหตุหนึ่งบรรทัด
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