Cheat sheet · Frontend · Agentic Workflow

Agentic Workflow กับ Claude Code — 5 ขั้น · prompt ที่ดี 6 หลัก แผ่นเดียวจบ

คู่กับ บทเรียน 86–89 · ทุกผลรันในหน้านี้ก็อปมาจากบทเรียน ซึ่งรันจริงบนโปรเจกต์ Next.js 16.3.5 · ไม่มีคำตอบของ AI สักบรรทัด

หน้านี้ไม่ได้เขียนไว้ให้อ่านรวดเดียว — เขียนไว้ให้เปิดตอนมือติดคีย์บอร์ด
กำลังจะกด Enter สั่งงาน Claude Code: ดูหัวข้อ 8 (checklist) แล้วก็อปแม่แบบหัวข้อ 6
agent บอกว่า “เสร็จแล้ว”: ดูหัวข้อ 4 (คำสั่งตรวจ) และหัวข้อ 9 (กับดักรวม)
เพิ่งติดตั้งครั้งแรก: หัวข้อ 1–2 — ดูโหมดสิทธิ์ก่อนพิมพ์อะไรทั้งนั้น

🧰 ตรวจด้วยอะไร เวอร์ชันไหน — ทุกบรรทัดผลรันในหน้านี้มาจาก

VS Code                     1.136.0   # code --version
Claude Code for VS Code     2.1.261   # code --list-extensions --show-versions
Next.js                     16.3.5    # Turbopack · โปรเจกต์ create-next-app + shadcn
react                       19.2.8
typescript                  5.9.3
eslint                      9.39.5
tailwindcss                 4.3.3
node                        v24.14.0
git                         2.51.0

ข้อมูลวิธีติดตั้งและระบบสิทธิ์มาจากเอกสารทางการ code.claude.com/docs ที่บทเรียนเปิดเมื่อ 15 ก.ย. 2026 · ทั้งกลุ่มไม่ได้ส่ง prompt ให้ Claude จริงเลยสักครั้ง เพราะคำตอบของ AI ไม่ซ้ำกันทุกรอบ — โค้ดที่ “แก้แล้ว” ในบทเรียนแก้ด้วยมือ เพื่อดูว่าคำสั่งตรวจคืนผลอะไร · Claude Code ออกเวอร์ชันใหม่ถี่มาก ถ้าหน้าจอไม่ตรง ให้เชื่อเอกสารทางการฉบับปัจจุบัน

สารบัญ

  1. Chat · Code · Cowork — งานแบบไหนใช้ตัวไหน
  2. โหมดสิทธิ์ — ดูก่อนพิมพ์
  3. ตาราง 5 ขั้น Explore → Commit
  4. คำสั่งตรวจในขั้น Evaluate / Commit
  5. ตาราง 6 หลักของ prompt
  6. แม่แบบ prompt สั่งงานโค้ด
  7. XML tag vs Markdown header
  8. checklist ก่อนกด Enter
  9. ตารางกับดักรวมทั้งกลุ่ม
  10. อ้างอิง

1 · Chat · Code · Cowork — งานแบบไหนใช้ตัวไหน

ทั้งสามตัวใช้โมเดล Claude คิดเหมือนกัน ที่ต่างคือมือของมันเอื้อมไปถึงอะไรได้บ้าง · กฎหยาบ ๆ: ผลลัพธ์เป็น “ความรู้” → Chat · ผลลัพธ์เป็น “ไฟล์ที่เปลี่ยน” หรือ “ผลรันคำสั่ง” → Code

ลักษณะงานตัวที่เหมาะเพราะอะไร
ถามแนวคิด · ขอคำอธิบาย · เทียบสองวิธีChatผลลัพธ์คือความเข้าใจ ไม่ต้องแตะไฟล์
ถามเรื่องโค้ดชิ้นเล็กที่ก็อปไปวางได้ทั้งก้อนChatบริบทพอดีกับที่วาง · ไม่มีอะไรในเครื่องเปลี่ยน
งานเขียนทั่วไป (อีเมล · สรุป · แปล)Chatไม่เกี่ยวกับโปรเจกต์
แก้ bug ที่ต้องไล่หลายไฟล์ · แก้ build / tsc / eslint errorCodeต้องค้นไฟล์จริงและรันคำสั่งตรวจซ้ำ
เพิ่ม feature · refactor ที่กระทบหลายไฟล์Codeแก้ได้ครบทุกจุดแล้วรัน build ยืนยันเอง · ก่อนสั่งควรมี git commit ไว้ย้อนกลับได้
ทำความเข้าใจโปรเจกต์ที่เพิ่งได้มาCode (โหมด Plan หรือ Manual)อ่านไฟล์จริงได้ทั้งโปรเจกต์ · ใช้โหมดที่ไม่แก้อะไรก่อน
งานหลายขั้นข้ามไฟล์และเครื่องมือ ผลงานเป็นเอกสาร (deck · spreadsheet · research) แล้วกลับมาตรวจทีหลังCowork ตามคำโปรยในสไลด์หน้า 7: ให้เป้าหมาย แล้วกลับมาตรวจงาน · สไลด์มีแค่ภาพหน้าเว็บภาพเดียว บทเรียนจึงไม่ลงรายละเอียดเกินนี้

วงจรที่ agent วนเองมีชื่อในเอกสารทางการว่า agentic loop: gather context (ค้นไฟล์ · อ่าน error) → take action (แก้ไฟล์ · รันคำสั่ง) → verify results (รัน build / test ซ้ำ) → ยังไม่เสร็จก็วนใหม่ · ทุกลูกศรคือการตัดสินใจของ AI ไม่ใช่ของคุณ — นี่คือเหตุผลที่ต้องมี workflow 5 ขั้น (หัวข้อ 3)

⚠ ติดตั้ง extension แล้ว พิมพ์ claude ใน terminal ไม่เจอ — ไม่ใช่ติดตั้งพัง
$ code --list-extensions --show-versions | grep anthropic
anthropic.claude-code@2.1.261
$ which claude; echo "rc=$?"
claude not found
rc=1

extension พก Claude Code สำเนาของตัวเองไว้ใช้กับแผงแชท แต่ไม่ได้ใส่ claude ไว้ใน PATH · อยากใช้ใน terminal ต้องติดตั้ง CLI แยกตามหน้า Quickstart · ตอนค้นใน Marketplace ให้เลือกผู้เผยแพร่ Anthropic ที่มีเครื่องหมายยืนยัน รหัส anthropic.claude-code · อย่ารัน curl … | bash จาก URL ที่ไม่ได้มาจากเอกสารทางการ

2 · โหมดสิทธิ์ — ดูก่อนพิมพ์

ใน VS Code เปลี่ยนที่ตัวบอกโหมดใต้ช่องพิมพ์ · ใน CLI กด Shift+Tab · คำถามที่ต้องถามตัวเองก่อนสั่งงานทุกครั้ง: “ตอนนี้อยู่โหมดไหน”

โหมด (ชื่อใน VS Code)ทำอะไรได้โดยไม่ถามเหมาะกับ
Planอ่าน · เขียนแผน แล้วไม่แก้ไฟล์โค้ดจนกว่าคุณจะอนุมัติแผน (ถ้าบัญชีใช้โหมด Auto ได้ คำสั่ง shell ที่ classifier อนุมัติก็รันได้เพื่อสำรวจ)สำรวจโปรเจกต์ก่อนแก้ · ใช้ครั้งแรก
Manualอ่านไฟล์ · ค้นหา · คำสั่งอ่านอย่างเดียวชุดหนึ่ง เช่น ls cat git status · แก้ไฟล์ · npm install · rm · curl · wget ต้องถามอยากเห็นทุกการกระทำ · โค้ดที่ไม่ไว้ใจ
Edit automaticallyแก้ไฟล์ได้เลย รวมคำสั่งจัดการไฟล์ mkdir touch mv cpคุณนั่งรีวิวโค้ดที่มันแก้ไปด้วย
Autoเกือบทุกอย่าง โดยมีโมเดลอีกตัว (classifier) ตรวจแทนและบล็อกสิ่งที่เห็นว่าไม่ปลอดภัยงานยาวที่ไม่อยากถูกถามบ่อย
⚠ สองเรื่องที่ต้องรู้ก่อนกดอนุญาตครั้งแรก

โหมดเริ่มต้นอาจไม่ใช่โหมดที่ถามก่อน — เอกสารระบุว่าบนแพ็กเกจ Pro · Max · Team โหมดเริ่มต้นคือ Auto · ลองครั้งแรกให้เปลี่ยนเป็น Plan หรือ Manual ก่อน

“Yes, and don't ask again” กับคำสั่ง shell = เขียนกฎถาวรลง .claude/settings.local.json ที่รากของ git repo (ต่อคำสั่ง ต่อ repo) ครั้งหน้าเปิดใหม่ก็ไม่ถาม · ส่วนอนุญาตแก้ไฟล์จำแค่จนจบ session · ดูและลบกฎได้ที่ /permissions · กฎตรวจตามลำดับ deny → ask → allow

3 · ตาราง 5 ขั้น Explore → Plan → Code → Evaluate → Commit

สไลด์หน้า 12 นิยาม agentic workflow ว่า “An AI-driven process where autonomous systems use reasoning, planning, and tool use to execute multi-step tasks dynamically” · เส้นประย้อนกลับของ diagram บอกว่า Evaluate ไม่ผ่าน → กลับไปขั้นที่เหมาะ (Plan หรือ Code) แล้ววนใหม่

ขั้นทำอะไร (ถอดจากสไลด์)ต้องตอบได้ก่อนไปขั้นถัดไปคำเตือน · ประโยคที่ใส่ใน prompt
1 · Explore
หน้า 14
Like a researcher, gather context before touching anything · อ่านไฟล์ที่เกี่ยว ค้นทั้งโปรเจกต์ เข้าใจ pattern · convention · dependency · เป้าหมายคือ mental model ยังไม่ใช่เขียนโค้ด ของที่จะแก้อยู่ไฟล์ไหน · ของคล้าย ๆ กันเขียนแบบไหน · มีของนี้อยู่แล้วหรือยัง · ใครใช้อยู่ (แก้แล้วกระทบใคร) · อ่าน package.json กับ AGENTS.md แล้วหรือยัง read … Do not edit anything yet. · ตัวอย่าง “Add dark mode” — โปรเจกต์ shadcn มีชุดสีโหมดมืดอยู่แล้วครึ่งทาง ข้าม Explore = สร้างซ้ำซ้อน
2 · Plan
หน้า 15
Decide the approach before implementing · แตกงานเป็นขั้น · ระบุไฟล์ที่เปลี่ยน · คาด edge case และ trade-off ไฟล์ไหนเปลี่ยน กี่ไฟล์ · ทางเลือกที่ตัดทิ้งเพราะอะไร · ตรวจยังไงว่าเสร็จ · คนอื่นอ่านจบในนาทีเดียวแล้วแย้งได้ไหม “A good plan is reviewable by someone who can catch a bad direction before written code.” · show me which files you will change … STOP and wait for my approval · งานเล็กที่อธิบาย diff ได้ประโยคเดียว ข้ามได้ (ตามเอกสาร Claude Code)
3 · Code
หน้า 16
Execute the plan · แก้ตาม convention ที่เจอตอน Explore diff ตรงกับแผนไหม · มีอะไรนอกแผนเข้ามาหรือเปล่า “Implement what was planned rather than improvising a new scope mid-stream.” · implement only the approved plan · เจอของที่อยากแก้ระหว่างทาง → จดเป็นงานถัดไป
4 · Evaluate
หน้า 17
Verify the work is CORRECT — Run tests, lint, type-check, execute the code, and review the diff. tsc · eslint · build ผ่านครบ · รันจริงแล้วเห็นผล · diff --stat ตรงแผน · ย้อนเทียบโจทย์ตั้งต้นทีละข้อแล้ว ⚠ “Should check the original requirements.” · “If FAILURES here should be loop back to Code” · แผนผิดตั้งแต่ต้น → กลับไป Plan · re-check every item in Requirements and Examples, one by one
5 · Commit
หน้า 18
Write a clear commit message describing the change, and record the work. ข้อความบอกว่าเปลี่ยนอะไรและตรวจด้วยอะไร · add เฉพาะไฟล์ที่ตั้งใจ ⚠ “Only reached after Eval passes.” — ไม่มีเครื่องมือไหนบังคับให้ เป็นวินัยล้วน ๆ · only after step 4 fully passes, commit …
✅ ตัวอย่างที่เดินครบ 5 ขั้นในบท 87 — เพิ่ม variant="success" ให้ Button
$ git diff --stat
 app/globals.css          | 6 ++++++
 app/page.tsx             | 2 ++
 components/ui/button.tsx | 1 +
 3 files changed, 9 insertions(+)

แผนบอก 3 ไฟล์ · --stat ขึ้น 3 ไฟล์ 9 บรรทัด = ตรงแผน · ถ้าเห็นไฟล์ที่ไม่อยู่ในแผนโผล่มา (เช่น package-lock.json ทั้งที่ไม่ได้ลงแพ็กเกจ) หยุดถามก่อน commit

4 · คำสั่งตรวจในขั้น Evaluate / Commit

ทุกคำสั่งในตารางนี้บท 87–89 รันจริง · โปรเจกต์นี้ package.json มีแค่ dev · build · start · lint — ไม่มี test ขั้น Evaluate จึงพึ่ง type-check · lint · build · และ “รันจริงแล้วดูผล”

อยากรู้อะไรพิมพ์ผ่านหน้าตาแบบไหน · ที่ต้องรู้
type ถูกไหม npx tsc --noEmit; echo "rc=$?" ผ่าน = ไม่พิมพ์อะไรเลย เหลือแค่ rc=0 · พัง = rc=2 · จับพิมพ์ชื่อ variant ผิดได้ พร้อมบอก Did you mean '"success"'?
tsc ฟ้อง LayoutProps ทั้งที่ไม่ได้แตะ npx next typegen ขึ้น ✓ Types generated successfully แล้ว error นั้นหาย · type นี้ Next.js สร้างไว้ใน .next/types/ ตอน dev/build · โปรเจกต์ที่เพิ่ง clone ยังไม่มี
แพตเทิร์นอันตราย / สไตล์ npx eslint .; echo "rc=$?" ผ่าน = rc=0 เงียบ ๆ · ไม่ได้ตรวจ type — ได้ rc=0 ทั้งตอนพิมพ์ "sucess" ผิด และตอนลืมใส่ HARD ใน Record<RecipeLevel, string>
ประกอบทั้งโปรเจกต์ได้จริง npx next build ผ่าน = จบด้วยตาราง Route (app) · อ่านจนบรรทัดสุดท้าย — ✓ Compiled successfully ขึ้นก่อน แล้วค่อยพังที่ Running TypeScript ... → Failed to type check.
รันจริงแล้วเห็นผลจริง npx next dev -p 387
curl -s http://localhost:387/ | grep -o '<button[^>]*>บันทึกแล้ว</button>'
ยืนยันว่า class bg-success อยู่บนปุ่มใน HTML ที่ server ส่งมาจริง
Tailwind สร้าง CSS ของ class นั้นจริงไหม grep -rho '\.bg-success[^{]*{[^}]*}' .next/static เจอ = .bg-success{background-color:var(--success)} · ลืมเพิ่ม token ใน globals.css → grep rc=1 ทั้งที่ tsc · eslint · build ได้ rc=0 หมด
แก้ไปกี่ไฟล์ ตรงแผนไหม · แตะไฟล์ต้องห้ามไหม git diff --stat ตัวเดียวในชุดที่จับ “แอบแก้ components/ui/” ได้ — ลองแก้ badge.tsx แล้ว tsc · eslint · build ผ่านหมด มีแค่ --stat ที่โชว์ components/ui/badge.tsx | 2 +-
หาคนที่ใช้ component อยู่ (เสี่ยง regression ไหม) grep -rn "components/ui/button" app components; echo "rc=$?" rc=1 = ไม่เจอเลย ยังไม่มีใคร import · เป็นคำสั่งของขั้น Explore ที่ใช้ประเมินผลกระทบ
commit เฉพาะที่ตั้งใจ git add app/globals.css app/page.tsx components/ui/button.tsx ระบุชื่อไฟล์ ไม่ใช่ git add . · git commit -am ใช้ได้เฉพาะหลังเพิ่งดู diff --stat ยืนยันแล้ว
ข้อความ commit สองชั้น git commit -m "feat(button): add success variant" -m "… checked: tsc --noEmit, eslint ., next build" บรรทัดแรกสั้น อ่านใน git log --oneline รู้เรื่อง · ย่อหน้าล่างบอกรายละเอียดและตรวจด้วยอะไร
⚠ รอบที่ 1 ของบท 87 — พิมพ์ variant="sucess" ผิดตัวเดียว
$ npx tsc --noEmit; echo "rc=$?"
app/page.tsx(58,19): error TS2820: Type '"sucess"' is not assignable to type '"link" | "default" | "outline" | "secondary" | "ghost" | "destructive" | "success" | null | undefined'. Did you mean '"success"'?
rc=2
$ npx eslint .; echo "rc=$?"
rc=0

lint ผ่าน type พัง — รันครบชุดทุกครั้ง และแก้แล้วรันใหม่ทั้งชุด ไม่ใช่รันแค่ตัวที่เคยพัง · และ git commit ของที่พังนี้ git รับไปเฉย ๆ ไม่มีคำเตือนสักคำ (ถ้าไม่ได้ตั้ง hook หรือ CI)

เทียบกับตอนเขียน Go

ตรวจอะไรฝั่ง Goฝั่ง Next.jsต่างกันตรงไหน
type ถูกไหมgo buildnpx tsc --noEmitTypeScript แยก “ตรวจ type” ออกจาก “รัน” ได้ ต้องสั่งตรวจเอง
แพตเทิร์นอันตราย / สไตล์go vetnpx eslint .ไม่ได้ตรวจ type ทั้งคู่ · eslint ของ Next มีกฎ React ด้วย
ประกอบทั้งโปรเจกต์go build ./...npx next buildรัน TypeScript ในตัว + สร้างหน้า static · ช้ากว่า tsc มาก
พฤติกรรมถูกไหมgo test ./...ยังไม่มีสคริปต์ test“next dev + curl” คือสิ่งที่ใกล้ test ที่สุดในโปรเจกต์นี้
แก้อะไรไปบ้างgit diffgit diffเหมือนกันทุกตัวอักษร

5 · ตาราง 6 หลักของ prompt (สไลด์หน้า 20)

สามข้อแรก (บท 88) ลดจำนวนสิ่งที่ AI ต้องเดา · สามข้อหลัง (บท 89) จัดวางเนื้อหา · กำหนดหน้าตาผลลัพธ์ · และทำอะไรต่อเมื่อยังไม่ตรง · ทุกคำถามที่คุณไม่ได้ตอบใน prompt AI ตอบแทนคุณ — และส่วนใหญ่ไม่ถามกลับ

#หลักใส่อะไรเพิ่มตัวอย่างสั้น (Bad → Good จากสไลด์)
1Be Clear and Specific
บท 88 · หน้า 22–23
task · scope · constraints (+ audience · tone ในงานเขียน) · งานโค้ด: ไฟล์ · พฤติกรรมที่ต้องการ · ข้อห้าม · วิธีตรวจ Write something about our new feature. → Write a 150-word announcement for our new dark-mode feature, aimed at existing users, …
2Give Example
บท 88 · หน้า 25–26
ตัวอย่าง input → output · positive (“do it like this”) และ negative (“avoid this”) · ครอบคลุมทุกคำตอบที่เป็นไปได้ รวมกรณีก้ำกึ่ง Classify these support tickets by urgency → เติม "App won't open, demo in 10 min" -> High. · "Typo on the About page" -> Low.
3Step-by-step Reasoning
บท 88 · หน้า 28–30
ไม่รู้ขั้น → สั่งให้คิดทีละขั้นก่อนสรุป · รู้ขั้นอยู่แล้ว → เขียนขั้นให้เองเป็น checklist ที่ต้องตอบทุกข้อ Work through it step by step, then give the original price. · Review this code and check each item. Mark ✅ or ❌ with a short note:
4Roles and Sections
บท 89 · หน้า 32–34
บทบาท (“You are a …”) · แยกคำสั่งออกจากข้อมูลด้วย XML tag หรือหัวข้อ Markdown · กรอบ 5 ช่อง Role · Context · Task · Constraints · Output Format Review this outline it's for a python course tell me whats wrong: … → You are an experienced instructional designer. + <task>…</task> <outline>…</outline>
5Specify Output Format
บท 89 · หน้า 36–37
ประเภท (ตาราง / list / JSON) · จำนวน · โครง (คอลัมน์) · ค่าที่ยอมรับ · ความยาวต่อช่อง Give me some marketing channel ideas. → List 5 marketing channels in a table with columns: Channel, Best for, Est. cost (Low/Med/High). One line per channel.
6Iterate and Refine
บท 89 · หน้า 39–40
ถือว่าผลแรกคือร่าง · บอก ส่วนที่ดี + อาการ + วิธีแก้ที่ตรวจได้ · งานโค้ดใช้ error จริงเป็น feedback (too formal) start over with a brand-new prompt. → Good draft, but too formal. Rewrite it warmer, cut the jargon, and shorten the intro to one sentence.

หลัก 6 — แปลงอาการเป็นประโยคที่ต้องพิมพ์ (สไลด์หน้า 39 + งานโค้ด)

อาการ (สไลด์)Action (สไลด์)ในงานโค้ดกับ Claude Code
Too formalAdjust tone and stylebutton labels should be short and casual, max 2 words
Missing detailsProvide context, goals, and specificsalso handle the case where no recipe matches
Wrong formatDefine the desired format clearlylist changed files only, one per line
Too longSet word or character limitslimit the change to RecipeList.tsx
Incomplete answerDefine depth and coverage neededrun tsc, eslint and next build, and fix any failures
⚠ แก้ต่อ หรือเริ่มใหม่ — รวมสไลด์หน้า 40 กับเอกสาร Claude Code เป็นกฎเดียว

ร่างแรกใกล้แล้ว ติดไม่กี่จุด → คุยต่อ แบบ Good Prompt หน้า 40 · แก้เรื่องเดิมเกินสองรอบใน session เดียวแล้วยังไม่ได้ → /clear แล้วเขียน prompt ใหม่ที่ใส่บทเรียนจากรอบก่อน (หัวข้อ Course-correct early and often) · Esc หยุดกลางทางโดย context ยังอยู่ · /rewind (หรือ Esc สองครั้ง) ย้อนบทสนทนาและโค้ด

6 · แม่แบบ prompt สั่งงานโค้ด

ถอดตรง ๆ จากเฉลยภารกิจบท 89 (ช่องค้นหาสูตรอาหาร + empty state ของแอป Wongnok) · เป็น prompt ที่บทเรียนเขียนเอง ไม่ใช่ผลลัพธ์ของ AI และไม่ได้ส่งให้ Claude Code รัน · ชื่อไฟล์อิงโค้ดบท 85 — เปลี่ยนเป็น path จริงของคุณ · หัวข้อที่ต้องเปลี่ยนเนื้อทุกครั้งคือ Context · Task · Requirements · Examples

# รอบที่ 1 — prompt แรก (หัวข้อ Markdown + ตัวอย่างในแท็ก XML)
# Role
You are a senior Next.js engineer who follows existing project conventions strictly.

# Context
- Next.js App Router project "Wongnok", TypeScript, Tailwind, shadcn/ui.
- `app/recipes/page.tsx` renders `RecipeList` from `containers/RecipeList/RecipeList.tsx`
  (a "use client" component), which maps over `RECIPES_MOCK_DATA` from `./recipes`
  and renders `RecipeCard` from `@/components/RecipeCard`.
- Convention: `components/` = pure presentational, `containers/` = stateful composition.

# Task
Add a "search by recipe name" input and an empty state to the All Recipes page.

# Requirements
- Filter while typing. Case-insensitive. Trim spaces before matching.
- Match on `name` only.
- Empty input shows all recipes.
- No match shows: No recipes match your search
- Keep `RecipeCard` presentational — put state and filtering in `RecipeList`.
- Do not change `RECIPES_MOCK_DATA`, `RecipeCard`'s props, or any other page.

# Examples
<examples>
input: ""            → all 8 recipes
input: "beef"        → only "Beef Wellington"
input: "  BEEF "     → same as "beef"
input: "pizza"       → empty state: No recipes match your search
</examples>

# Steps
1. Explore: read RecipeList.tsx, recipes.ts, RecipeCard, and app/recipes/page.tsx. Do not edit anything yet.
2. Plan: think step by step, then show me which files you will change, and why,
   plus any edge case you see. STOP and wait for my approval.
3. Code: implement only the approved plan.
4. Evaluate: run `npx tsc --noEmit`, `npx eslint .`, `npx next build`, and fix any failure.
   Then re-check every item in Requirements and Examples, one by one.
5. Commit: only after step 4 fully passes, commit with a clear conventional message.

# Output
When done, reply with exactly 3 sections:
1. Files changed — one line per file
2. Checks — tsc / eslint / build: pass or fail
3. Requirements — each requirement with ✅ or ❌
หลักอยู่ตรงไหนในแม่แบบ
① Clear# Requirements ตอบทุกคำถามที่โจทย์ปล่อยว่าง + บรรทัด Do not change … กำหนดขอบเขต
② Example<examples> 4 เคส รวมเคสเว้นวรรค+ตัวใหญ่ และเคสไม่เจอ — ตัวอย่าง = test case ของขั้น Evaluate
③ Step-by-stepขั้น Plan: think step by step, then show me …
④ Role / Sections# Role + หัวข้อ Markdown ทั้งหมด + ตัวอย่างในแท็ก XML (ผสมกันได้) · # Steps ทำให้ 5 ขั้นเห็นชัด
⑤ Output format# Output 3 หัวข้อตายตัว · ✅/❌ เป็นค่าที่เลือกได้จำกัด
⑥ Iterateจุด STOP หลัง Plan คือรอบแก้รอบแรก · และข้อความรอบที่ 2 ข้างล่าง

รอบที่ 2 — แผนมาเกือบถูก (เฉลยบท 89)

Good plan, but two changes before you code:
1. Keep the state in RecipeList, not page.tsx — page.tsx must stay a Server Component.
2. Do not add a prop to RecipeCard. Filtering happens before rendering the cards.
Show me the updated plan, then wait again.

รอบแก้ด้วย error จริง (ตัวอย่างบท 89)

tsc fails with the error below. Fix it by using the existing `name` field —
do not add a `title` field to the Recipe type. Then re-run tsc and eslint.
<tsc_output>
containers/RecipeList/RecipeList.tsx(11,12): error TS2339: Property 'title' does not exist on type 'Recipe'.
</tsc_output>

ถ้ารายงานตอนจบจะถูกสคริปต์อ่านต่อ ให้ขอเป็น JSON แล้ววางโครงให้ดู — โครงนี้บท 89 ตรวจแล้วว่าผ่าน JSON.parse (valid JSON, keys: summary, filesChanged, checks, openQuestions):

{
  "summary": "Added name search and an empty state to RecipeList",
  "filesChanged": ["containers/RecipeList/RecipeList.tsx"],
  "checks": { "tsc": "pass", "eslint": "pass", "build": "pass" },
  "openQuestions": []
}

7 · XML tag vs Markdown header — เลือกเมื่อไหร่

สไลด์บอกแค่ “with XML or Markdown” · ชื่อแท็ก ไม่ใช่คำพิเศษ ไม่มีรายการให้ท่อง — เอกสาร Anthropic แนะนำให้ตั้งชื่อที่สื่อความหมาย และใช้ชื่อเดิมให้สม่ำเสมอ (<requirements> · <error_log> ก็ได้)

สถานการณ์เลือกเพราะ
prompt สั้น พิมพ์เองในแชท มี 3–4 หัวข้อMarkdown # หัวข้อพิมพ์เร็ว คนอ่านง่าย · แม่แบบหัวข้อ 6 ใช้แบบนี้
📄 ต้องแปะของยาวปนกับคำสั่ง — โค้ด · error log · เอกสารXML <error_log>เอกสาร Anthropic: XML ช่วยแยก instructions · context · examples · inputs ออกจากกันชัด
ของที่แปะมี Markdown อยู่ในตัว — README.md · CLAUDE.md · ข้อความ PRXML <readme>…</readme># ของ prompt กับ ## ของเอกสารจะปนเป็นลำดับหัวข้อชุดเดียว · แท็กมีจุดปิดชัดเจน
ของหลายชิ้นประเภทเดียวกัน เช่น 3 ไฟล์XML ซ้อน<file path="…"> สามก้อนอยู่ใน <files>
📄 อยากได้คำตอบที่ไม่เป็น Markdown (เอาไปวางอีเมล)XML หรือไม่ใช้หัวข้อเลยเอกสาร Anthropic: รูปแบบของ prompt มีผลต่อรูปแบบของคำตอบ

เปลี่ยน XML เป็น Markdown ไม่ได้ทำให้ prompt ดีขึ้นเอง — Good Prompt หน้า 33 กับ 34 ต่างกันจริงสองจุด: below และ as a numbered list · สิ่งที่เปลี่ยนผลคือคำที่เพิ่มเข้ามา · จะทดลองว่าแบบไหนดีกว่า ต้องเปลี่ยนทีละอย่าง

8 · checklist ก่อนกด Enter

✓เช็คถ้าข้าม จะเจออะไร
☐ดูตัวบอกโหมดใต้ช่องพิมพ์ — ครั้งแรก / โค้ดไม่ไว้ใจ ใช้ Plan หรือ ManualPro · Max · Team เริ่มที่ Auto → แก้ไฟล์และรันคำสั่งโดยไม่ถาม
☐git status สะอาด · งานล่าสุด commit แล้วagent แก้หลายไฟล์แล้วแยกไม่ออกว่าอันไหนของคุณ · ย้อนกลับยาก
☐ระบุ path ไฟล์ ที่จะแก้ และของเดิมที่ต้องใช้ (@/components/ui/badge)มันค้นเอง · อาจเขียน component ใหม่แทนที่จะใช้ของเดิม
☐บอกพฤติกรรมที่ต้องการเป็นคำที่นับ/ตรวจได้ ไม่ใช่ “ดูดีขึ้น”“ดูดีขึ้น” กลายเป็นเปลี่ยนสี · เพิ่มไอคอน · จัด layout ใหม่ทั้งการ์ด
☐ตัวอย่าง input → output ครบทุกค่า — ทั้งกรณีปกติ กรณีว่าง และกรณีก้ำกึ่งตัวอย่างมีแค่สองขั้ว → ไม่รู้ว่ามีตรงกลางไหม · มีแค่กรณีว่าง → การ์ดปกติพังไม่มีใครจับ
☐ข้อห้าม: ไฟล์ที่ห้ามแตะ · ห้ามลง package · ห้ามเปลี่ยน type · “ถ้าจำเป็นต้องแก้ไฟล์อื่น ให้ถามก่อน”ทางลัดที่ “ได้ผลเหมือนกัน” เช่นแก้ Badge กลาง → ป้ายทั้งแอปเปลี่ยน
☐ข้อห้ามทุกข้อมีคำสั่งตรวจที่จับได้คู่กัน (ห้ามแตะไฟล์ ↔ git diff --stat)tsc · eslint · build ผ่านหมด ทั้งที่แอบแก้ components/ui/
☐สั่ง Explore ก่อน และ STOP and wait for my approval หลัง Plan (งานที่ไม่ใช่งานประโยคเดียว)กระโดดไปขั้น Code ทันที · ได้โค้ดที่แก้ปัญหาผิดข้อ
☐Evaluate: tsc --noEmit + eslint . + next build + วิธีพิสูจน์ว่าตัวอย่างทุกเคสทำงานจริง + เทียบ requirement ทีละข้อagent หยุดตอนที่ “ดูเสร็จ” · build ผ่านไม่ได้แปลว่าตรงโจทย์
☐ขอ output จริงของคำสั่งตรวจ ไม่ใช่คำว่า “ผ่านแล้ว”ไม่มีหลักฐานว่ามันรันจริง · คุณต้องรันตรวจเองทุกรอบ
☐บอกรูปแบบรายงานตอนจบ (ไฟล์ที่เปลี่ยน · ผลตรวจ · สิ่งที่สมมติเอง)ได้เรียงความยาวที่ต้องอ่านเองว่าแก้อะไรไป
☐Commit หลัง Evaluate ผ่านเท่านั้นgit รับ commit ที่พังไปเฉย ๆ · คน pull ต่อ build ไม่ผ่าน
☐golden rule: ยื่นให้เพื่อนที่ไม่เคยเห็นโค้ด เขาจะต้องถามกลับอะไร?ทุกคำถามที่เขาจะถาม คือจุดที่ AI จะเดาแทน

9 · ตารางกับดักรวมทั้งกลุ่ม

อาการสาเหตุทางแก้
ติดตั้ง extension แล้ว which claude ได้ claude not found extension ใช้สำเนาของตัวเอง ไม่ได้ใส่ claude ไว้ใน PATH ใช้ในแผง VS Code อย่างเดียวพอแล้ว · จะใช้ใน terminal ติดตั้ง CLI แยกตามหน้า Quickstart
ถามแค่ “อธิบายโครงโปรเจกต์” แล้วไม่มีการขออนุญาตโผล่เลย / มีไฟล์เปลี่ยน โหมดเริ่มต้นเป็น Auto (Pro · Max · Team) ไม่ใช่โหมดที่ถามก่อน ดูตัวบอกโหมดก่อนพิมพ์ · เปลี่ยนเป็น Plan / Manual · ปิดท้ายด้วย git status · (ถ้ารัน next dev ไว้ AGENTS.md อาจเปลี่ยนเองได้ ไม่ใช่ Claude)
ไม่ถูกถามอนุญาตคำสั่งหนึ่งอีกเลย แม้ปิด VS Code เปิดใหม่ เคยกด “Yes, and don't ask again” → กฎถาวรใน .claude/settings.local.json ดูและลบที่ /permissions
error TS2304: Cannot find name 'LayoutProps' ทั้งที่ไม่ได้แตะ layout.tsx โปรเจกต์ที่ยังไม่เคย dev/build ยังไม่มี type ใน .next/types/ npx next typegen · ใส่ใน prompt ว่า run npx next typegen before tsc ไม่งั้น agent อาจ “แก้” layout.tsx ที่ไม่ได้เสีย
eslint rc=0 แต่โค้ดผิด lint ตรวจแพตเทิร์นและสไตล์ ไม่ได้ตรวจ type รัน tsc --noEmit คู่กันเสมอ — เหมือน go vet กับ go build
เห็น ✓ Compiled successfully แล้วนึกว่า build ผ่าน ขั้น Running TypeScript มาทีหลัง แล้วจบด้วย Failed to type check. อ่านจนบรรทัดสุดท้าย หรือดู exit code
class bg-success อยู่บนปุ่ม แต่ปุ่มไม่มีสี · tsc / eslint / build rc=0 หมด ลืมเพิ่ม token --success ใน app/globals.css → Tailwind ไม่สร้าง CSS “execute the code”: grep -rho '\.bg-success[^{]*{[^}]*}' .next/static ต้องเจอ
แอบแก้ไฟล์ใน components/ui/ แต่ตรวจครบทุกตัวก็ผ่าน tsc · eslint · build ตรวจว่า “โค้ดพังไหม” ไม่ได้ตรวจว่า “แตะไฟล์ที่ห้ามไหม” git diff --stat ดูรายชื่อไฟล์ · ใส่ไว้ในเช็คลิสต์ของ prompt
tools ผ่านหมด แต่ปุ่มไปอยู่ผิดหน้า / ทำไม่ตรงโจทย์ ข้ามคำเตือนหน้า 17 “Should check the original requirements.” ท้าย Evaluate ไล่ requirement ทีละข้อ ✅/❌ · ขอให้ agent รายงานแบบนี้ใน # Output
commit ของที่ tsc ยังพัง แล้ว git ไม่เตือนเลย git เก็บ “ไฟล์หน้าตาแบบนี้” ไม่สนว่าโค้ดถูกไหม “Only reached after Eval passes” เป็นวินัย · สั่งใน prompt ให้ commit หลังขั้น 4 ผ่านเท่านั้น
diff บวมเป็นหลายสิบบรรทัด คนรีวิวหาบรรทัดสำคัญไม่เจอ scope creep — แก้ของนอกแผน (เช่นลบข้อความ “To get started…” ใน page.tsx) implement only the approved plan · list anything else you notice as follow-ups instead of doing it
สั่ง “Add dark mode” แล้วได้ระบบสีสองชุดตีกัน · build ผ่าน ข้าม Explore — โปรเจกต์ shadcn มี .dark { … } และ class dark: อยู่แล้ว สั่ง Explore ก่อน Do not edit anything yet. · งานจริงเหลือแค่ปุ่มสลับ class dark ที่ <html>
AI จัดระดับ ticket แปลก ๆ ตรงกลาง ตัวอย่างมีแค่ High กับ Low — prompt ไม่ได้บอกว่ามี Medium ไหม เติมตัวอย่างระดับกลาง หรือเขียนตรง ๆ ว่ามีระดับอะไรบ้าง · เอกสาร Anthropic แนะนำ 3–5 ตัวอย่างที่หลากหลาย
สคริปต์ parse JSON จาก AI แล้ว SyntaxError โครงตัวอย่างใน prompt มี trailing comma — AI เลียนแบบตัวอย่างที่พัง · Expected double-quoted property name in JSON at position 29 ตรวจโครงด้วย JSON.parse ก่อนใส่ prompt · ฝั่งโค้ดครอบ try/catch — รูปแบบใน prompt คือคำขอ ไม่ใช่การบังคับ
ผลลัพธ์เขียนว่า “verified” / “All constraints satisfied” แต่ตัวเลขผิด ข้อความ “verified” ไม่ใช่การ verify (ภาพสไลด์หน้า 28 เองก็คูณได้ $1,520 ที่จริงคือ $1,120) ขอให้แสดงวิธีคิดทีละขั้น แล้วตรวจเอง · วิธีคิดที่เขียนออกมาทำให้ตรวจได้ ไม่ได้ทำให้ไม่ต้องตรวจ
บอก You are a senior Next.js engineer แล้วยังเขียนผิดโปรเจกต์ บทบาทไม่ได้เพิ่มความรู้ ไม่ได้ทำให้รู้จักโค้ดของคุณ แค่เลือกมุมมอง ยังต้องสั่งให้อ่านไฟล์เอง (Explore) และใส่ Context
แก้เรื่องเดิมรอบที่สามก็ยังพังแบบเดิม ความพยายามที่ผิดค้างอยู่ใน context · session ยาวที่รกทำให้ผลแย่ลง /clear แล้วเริ่มด้วย prompt ที่ดีขึ้นซึ่งใส่สิ่งที่เรียนรู้ · ไม่ใช่ส่ง prompt เดิมซ้ำ หรือพิมพ์ตัวใหญ่เน้นเสียง
แผนมีจุดผิดเล็ก ๆ แต่กดอนุมัติไปก่อน “เดี๋ยวแก้โค้ดเอง” โค้ดที่เขียนต่อจากจุดนั้นพึ่งมันไปหลายที่แล้ว แก้ที่แผน: Good plan, but … Show the updated plan. — แก้ที่แผนถูกกว่าแก้ที่โค้ดเสมอ

10 · อ้างอิง