30+ คำสั่งสำหรับทำงานกับ Claude Code—ไม่ว่ามือใหม่หรือมืออาชีพก็ใช้ได้

Claude Code เป็น AI ช่วยเขียน code ที่สามารถอ่านและเขียน code ลงบนเครื่องได้โดยตรง ช่วยทุ่นแรงและประหยัดเวลาให้กับทั้ง developer และคนที่เขียน code ไม่เป็น

Claude Code สามารถใช้งานได้ผ่าน Terminal และสั่งงานได้ผ่านทั้งภาษาธรรมชาติ (natural language) และคำสั่งแบบ command line

ในบทความนี้ ผมจะพาทุกคนไปดู 30+ คำสั่งในการทำงานกับ Claude Code โดยบทความแบ่งออกเป็น 3 กลุ่มใหญ่:

  1. Basic: 12 คำสั่งเบื้องต้นสำหรับเริ่มใช้งาน Claude Code
  2. Intermediate: 12 คำสั่งสำหรับทำงานกับ Claude Code ได้เข้ามือมากขึ้น
  3. Advanced: 8 คำสั่งสำหรับให้ Claude Code ทำงานอัตโนมัติ

ถ้าพร้อมแล้ว ไปเริ่มกันเลย


  1. 1️⃣ Part 1. Basic
    1. 🏁 Group 1. Getting Started
    2. 💻 Group 2. Execution
    3. 🧐 Group 3. Review
    4. 😣 Group 4. Getting Help
  2. 2️⃣ Part 2. Intermediate
    1. 🗣️ Group 1. Session Management
    2. 💭 Group 2. Context Management
    3. 🦾 Group 3. Customising Claude Code
    4. 🪙 Group 4. Usage Tracking
  3. 3️⃣ Part 3. Advanced
    1. Group 1. Multi-Tasking
    2. Group 2. Troubleshooting
  4. 💪 Summary
  5. 📃 References

1️⃣ Part 1. Basic

ใน part แรก ไปดู 12 คำสั่งสำหรับเริ่มใช้งาน Claude Code ซึ่งจัดได้เป็น 4 กลุ่มกัน:

  1. Getting started: เริ่มใช้งาน Claude Code
  2. Execution: เขียน code
  3. Review: ตรวจสอบงาน
  4. Getting help: ดูคู่มือการใช้งาน Claude Code
Getting started
Execution
Review
Getting help

.

🏁 Group 1. Getting Started

กลุ่มแรกมี 5 คำสั่งสำหรับเริ่มทำงานกับ Claude Code:

  1. claude: เริ่ม session หรือห้องเพื่อคุยกับ Claude Code
  2. ! <command>: รัน shell command ระหว่างใช้ Claude Code (เช่น ! cd /new_folder)
  3. @<file>: ชี้ไฟล์ให้กับ Claude Code (เช่น @app.py เพื่อบอกให้ไปที่ไฟล์ app.py)
  4. /model: เลือก model สำหรับใช้งาน
  5. /exit: ออกจาก session

.

💻 Group 2. Execution

กลุ่มที่ 2 มี 4 คำสั่งสำหรับเขียน code กับ Claude Code:

  1. /plan: เข้าโหมดวางแผน เพื่อให้ Claude Code ออกแบบก่อนเขียน
  2. /init: สั่งให้ Claude Code สร้าง CLAUDE.md ที่ใช้กำหนดบริบทและการเขียน code
  3. /memory: แก้ไข CLAUDE.md
  4. /btw: คุยกับ Claude Code ในระหว่างที่ Claude Code ยังเขียน code อยู่

.

🧐 Group 3. Review

กลุ่มที่ 3 มี 2 คำสั่งสำหรับตรวจงาน:

  1. /diff: ดูการเปลี่ยนแปลง code แบบบรรทัดต่อบรรทัด
  2. /review: สั่งให้ Claude Code ตรวจ code ให้

.

😣 Group 4. Getting Help

กลุ่มสุดท้ายมี 1 คำสั่งสำหรับดูคู่มือการใช้งาน:

  1. /help: ดูคำสั่งทั้งหมดที่ใช้ได้ใน Claude Code

2️⃣ Part 2. Intermediate

ใน part 2 ไปดู 12 คำสั่งที่ให้เราใช้ Claude Code ได้เข้ามือมากขึ้นกัน:

  1. Session management: จัดการ session
  2. Context management: จัดการ context
  3. Customising Claude Code: ตั้งค่า Claude Code ให้ตอบโจทย์
  4. Usage tracking: ติดตามการใช้งาน

.

🗣️ Group 1. Session Management

Session เป็นเหมือนห้องคุยกับ Claude Code

แต่ละ session มี context หรือความจำในการทำงานแยกจากกัน ทำให้การคุยแต่ละ session ไม่ผสมกัน

เรามี 3 คำสั่งสำหรับจัดการ session ใน Claude Code:

  1. claude -c: กลับไปใช้งาน session ล่าสุด
  2. /resume: เลือก session ที่จะกลับไปใช้งานต่อ
  3. /rename: เปลี่ยนชื่อ session เพื่อให้หา session ได้ง่ายขึ้น

.

💭 Group 2. Context Management

Context คือ ความจำในการทำงานของ Claude Code ซึ่งมีอยู่อย่างจำกัดในแต่ละ session

Context จะถูกใช้ไปเรื่อย ๆ ตามคำสั่งของเราและการทำงานของ Claude Code และเมื่อ context เต็ม Claude Code จะลืมข้อมูลเก่า ๆ และทำงานผิดพลาดได้

เช่น ตอนแรก เราสั่ง Claude Code สร้างเว็บไซต์สีขาวแดง พอ context เต็ม เว็บไซต์อาจจะมีสีอื่นแทรก เพราะ Claude Code ลืมคำสั่งเรื่องสีที่เราบอกไว้ตั้งแต่ต้น

เรามี 3 คำสั่งสำหรับจัดการ context:

  1. /context: เปิดดู context ที่ถูกใช้ไปใน session ที่ใช้อยู่
  2. /compact: ย่อข้อมูลใน context ด้วยการสรุป เพื่อเพิ่มพื้นที่ใน context ในขณะที่ยังเก็บข้อมูลการทำงานให้กับ Claude Code อยู่
  3. /clear: ลบข้อมูลใน context ของ session นั้นออกทั้งหมด

.

🦾 Group 3. Customising Claude Code

ในกลุ่มที่ 3 เรามี 4 คำสั่งสำหรับตั้งค่า Claude Code ให้ทำงานได้มีประสิทธิภาพมากขึ้น:

  1. /skills: ตั้งค่า skill ที่ Claude Code ใช้งานได้
  2. /mcp: ตั้งค่า MCP ที่ Claude Code ใช้งานได้
  3. /agents: ตั้งค่า subagent ที่ Claude Code ใช้งานได้
  4. /plugin: ตั้งค่า plugin ที่ Claude Code ใช้งานได้

.

🪙 Group 4. Usage Tracking

ในกลุ่มสุดท้าย เรามี 2 คำสั่งสำหรับดูการใช้งาน Claude Code:

  1. /usage: ดูจำนวนข้อความคงเหลือที่ยังใช้ได้
  2. /cost: ดูจำนวนเงินที่ใช้ไป

3️⃣ Part 3. Advanced

ใน part สุดท้าย เราไปดู 8 คำสั่งสำหรับ:

  1. Multi-tasking: สั่งให้ Claude Code ทำงานเอง
  2. Troubleshooting: แก้ปัญหาการทำงานของ Claude Code

.

Group 1. Multi-Tasking

ในกลุ่มนี้ เรามี 6 คำสั่งสำหรับให้ Claude Code ทำงานเอง:

  1. /goal: กำหนดเป้าหมายที่ต้องการ โดย Claude Code จะทำงานไปเรื่อย ๆ จนกว่าเป้าหมายนี้จะสำเร็จ
  2. /batch: สั่งให้ Claude Code แตกงานขนาดใหญ่ให้เป็นก้อนเล็ก ๆ และรันงานขนานกันไป เหมาะสำหรับการแก้ code หลายจุดพร้อมกัน
  3. /schedule: ตั้งเวลาที่จะให้ Claude Code ทำงานบางอย่าง (เช่น ทดสอบ code ทุก 10 โมงเช้า)
  4. /loop: สั่งให้ Claude Code ทำงานตามช่วงเวลาที่กำหนด (เช่น ทดสอบ code ทุก ๆ 1 ชั่วโมง)
  5. /background: ย้าย session ไปอยู่ใน background ซึ่งจะทำให้เราใช้ Terminal ได้ในขณะที่ Claude Code ยังทำงานอยู่
  6. /tasks: เปิดดูรายการ session ที่รันอยู่ใน background

.

Group 2. Troubleshooting

ในกลุ่มสุดท้าย เรามี 2 คำสั่งสำหรับแก้ปัญหาเวลาทำงานกับ Claude Code:

  1. /doctor: ตรวจสอบการตั้งค่า Claude Code เวลามีปัญหา
  2. /debug: สั่งให้ Claude Code ค้นหาและอธิบายเหตุของปัญหา

💪 Summary

สรุป 30+ คำสั่งในการทำงานกับ Claude Code:

1️⃣ Part 1. Basic

  • Group 1. Getting started
    • claude
    • ! <command>
    • @<file>
    • /model
    • /exit
  • Group 2. Execution
    • /plan
    • /init
    • /memory
    • /btw
  • Group 3. Review
    • /diff
    • /review
  • Group 4. Getting help
    • /help

2️⃣ Part 2. Intermediate

  • Group 1. Session management
    • claude -c
    • /resume
    • /rename
  • Group 2. Context Management
    • /context
    • /compact
    • /clear
  • Group 3. Customising Claude
    • /skills
    • /mcp
    • /agents
    • /plugin
  • Group 4. Usage Tracking
    • /usage
    • /cost

3️⃣ Part 3. Advanced

  • Group 1. Multi-tasking
    • /goal
    • /batch
    • /schedule
    • /loop
    • /background
    • /tasks
  • Group 2. Troubleshooting
    • /doctor
    • /debug

📃 References

Comments

Leave a comment