Andrej Karpathy 65 Lines Instructions คืออะไร ทำไม SKILL นี้ช่วยให้ AI ที่คุณใช้ เก่งขึ้น ทำงานได้ดีขึ้น
Andrej Karpathy เป็นนักวิจัยและนักการศึกษาด้านปัญญาประดิษฐ์ เขาเป็นหนึ่งในสมาชิกผู้ก่อตั้ง OpenAI และต่อมาดำรงตำแหน่งผู้อำนวยการฝ่ายปัญญาประดิษฐ์ที่ Tesla ซึ่งเขาเป็นผู้นำทีมคอมพิวเตอร์วิชั่นของระบบ Autopilot ในระหว่างที่ศึกษาปริญญาเอกที่ Stanford เขาเป็นผู้ริเริ่มและอาจารย์ผู้สอนหลักของหลักสูตรการเรียนรู้เชิงลึกหลักสูตรแรกที่ Stanford (CS231n) ซึ่งกลายเป็นหนึ่งในหลักสูตรยอดนิยมที่สุดของมหาวิทยาลัย
Andrej Karpathy 65 Lines Instructions คืออะไร?
จริง ๆ แล้ว "Andrej Karpathy 65 Lines Instructions" ไม่ใช่เอกสารที่ Andrej Karpathy เป็นผู้เขียนโดยตรง แต่เป็นไฟล์ CLAUDE.md ความยาวประมาณ 65 บรรทัด ที่สร้างขึ้นโดย Forrest Chang จากแนวคิดและข้อสังเกตของ Andrej Karpathy เกี่ยวกับข้อผิดพลาดที่ AI มักทำเวลาเขียนโค้ด แล้วนำมาสรุปเป็นกฎการทำงานสำหรับ AI Coding Assistant เช่น Claude Code, Cursor และเครื่องมืออื่น ๆ (GitHub)
หลักการสำคัญ 4 ข้อ
1. Think Before Coding
AI ต้องคิดก่อนลงมือเขียนโค้ด
- อย่าเดา
- ถ้าไม่แน่ใจให้ถาม
- เปิดเผยสมมติฐานที่กำลังใช้
- ถ้ามีหลายทางเลือก ให้บอกทุกทางเลือก
- ถ้ามีวิธีที่ง่ายกว่า ให้เสนอ
แนวคิดคือ "อย่าให้ AI ตัดสินใจแทนผู้ใช้แบบเงียบ ๆ" (GitHub)
2. Simplicity First
เขียนให้น้อยที่สุดที่แก้ปัญหาได้
- ไม่เพิ่ม Feature ที่ไม่ได้สั่ง
- ไม่สร้าง Architecture เกินจำเป็น
- ไม่เขียน 300 บรรทัด ทั้งที่ 30 บรรทัดก็พอ
หลักการคือ
Minimum code that solves the problem. (GitHub)
3. Surgical Changes
แก้เฉพาะจุดที่ร้องขอ
- ไม่ Refactor ทั้งโปรเจกต์
- ไม่ลบโค้ดที่ยังไม่เข้าใจ
- ไม่แก้ Style ของไฟล์อื่น
- ไม่ "ทำความสะอาด" โค้ดโดยพลการ
เปรียบเหมือนศัลยแพทย์ที่ผ่าตรงตำแหน่ง ไม่ใช่รื้อทั้งระบบ (GitHub)
4. Goal-Driven Execution
เริ่มจากนิยามความสำเร็จ
เช่น
- เขียน Test ก่อน
- กำหนดว่า "เสร็จ" คืออะไร
- ตรวจสอบว่าทำได้ตามเป้าหมายจริง
AI ไม่ควรเดาว่า "น่าจะเสร็จแล้ว" แต่ต้องพิสูจน์ได้ (GitHub)
ทำไมถึงดังมาก
ไฟล์นี้ได้รับความนิยม เพราะแก้ปัญหาที่คนใช้ AI เขียนโค้ดเจอบ่อย เช่น
- AI ชอบเดา
- AI ชอบเขียนเกินความจำเป็น
- AI แอบแก้ไฟล์อื่น
- AI ไม่ถามเมื่อข้อมูลไม่ครบ
- AI พยายามเอาใจผู้ใช้ แม้คำสั่งจะไม่เหมาะสม
จึงช่วยให้ผลลัพธ์มีความแม่นยำและควบคุมได้มากขึ้น โดยเฉพาะเมื่อใช้กับ AI Coding Agent (LinkedIn)
นำไปใช้กับ ChatGPT ได้หรือไม่
ได้ แม้ไฟล์นี้จะออกแบบมาสำหรับ Claude Code แต่แนวคิดเดียวกันสามารถนำไปใช้เป็น System Prompt, Custom Instructions หรือ Project Instructions ของ ChatGPT, Codex, Gemini หรือ AI Agent อื่น ๆ ได้ เพราะเป็นหลักการด้าน "พฤติกรรม" มากกว่าการผูกกับเครื่องมือใดเครื่องมือหนึ่ง (GitHub)
ถ้าคุณทำงานด้าน AI Automation
จากลักษณะงานของคุณที่ออกแบบระบบ AI, Dashboard, SaaS และ Workflow จำนวนมาก หลักการนี้สามารถขยายจาก "การเขียนโค้ด" ไปเป็น "กฎการทำงานของ AI ทุกประเภท" ได้ เช่น
- ห้ามเดา ให้ถามเมื่อข้อมูลไม่ครบ
- ทำเฉพาะสิ่งที่ได้รับมอบหมาย
- เลือกวิธีที่ง่ายที่สุดก่อน
- ระบุสมมติฐานทุกครั้ง
- กำหนดเกณฑ์ความสำเร็จก่อนเริ่มงาน
- สรุปสิ่งที่แก้ไขและสิ่งที่ไม่ได้แก้ไขทุกครั้ง
แนวทางนี้ช่วยให้ AI Agent มีความน่าเชื่อถือมากขึ้น ไม่ว่าจะใช้กับการเขียนโปรแกรม การวิเคราะห์ข้อมูล การตลาด หรือการสร้างเอกสาร
CLAUDE.md
Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.
Tradeoff: These guidelines bias toward caution over speed. For trivial tasks, use judgment.
1. Think Before Coding
Don't assume. Don't hide confusion. Surface tradeoffs.
Before implementing:
- State your assumptions explicitly. If uncertain, ask.
- If multiple interpretations exist, present them - don't pick silently.
- If a simpler approach exists, say so. Push back when warranted.
- If something is unclear, stop. Name what's confusing. Ask.
2. Simplicity First
Minimum code that solves the problem. Nothing speculative.
- No features beyond what was asked.
- No abstractions for single-use code.
- No "flexibility" or "configurability" that wasn't requested.
- No error handling for impossible scenarios.
- If you write 200 lines and it could be 50, rewrite it.
Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
3. Surgical Changes
Touch only what you must. Clean up only your own mess.
When editing existing code:
- Don't "improve" adjacent code, comments, or formatting.
- Don't refactor things that aren't broken.
- Match existing style, even if you'd do it differently.
- If you notice unrelated dead code, mention it - don't delete it.
When your changes create orphans:
- Remove imports/variables/functions that YOUR changes made unused.
- Don't remove pre-existing dead code unless asked.
The test: Every changed line should trace directly to the user's request.
4. Goal-Driven Execution
Define success criteria. Loop until verified.
Transform tasks into verifiable goals:
- "Add validation" → "Write tests for invalid inputs, then make them pass"
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
- "Refactor X" → "Ensure tests pass before and after"
For multi-step tasks, state a brief plan:
1. [Step] → verify: [check] 2. [Step] → verify: [check] 3. [Step] → verify: [check]
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
These guidelines are working if: fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.