Tag: Skill

  • Claude Code: รวมคู่มือและวิธีใช้ Claude Code สำหรับผู้เริ่มต้นและมืออาชีพ

    Claude Code: รวมคู่มือและวิธีใช้ Claude Code สำหรับผู้เริ่มต้นและมืออาชีพ

    Claude Code เป็น AI coding assistant สำหรับช่วยทำงานกับ code และไฟล์บนคอมพิวเตอร์ ผ่านการสั่งงานด้วยภาษาธรรมชาติ (natural language)

    แม้ว่า Claude Code จะช่วยให้เราสร้างผลงานได้โดยไม่จำเป็นต้องมีความรู้ในการเขียน code มาก่อน ถึงอย่างนั้น คุณภาพงานขึ้นอยู่กับฝีมือการใช้ Claude Code

    ในบทความชุดนี้ ผมจะพาทุกคนไปดูวิธีการใช้งาน Claude Code ที่ถูกต้อง ซึ่งไม่ว่ามือใหม่หรือมืออาชีพก็ใช้ได้

    บทความชุดนี้แบ่งเป็น 3 กลุ่ม:

    1. การเริ่มต้นใช้งาน Claude Code (2 บทความ)
    2. การจัดการ context ใน Claude Code (2 บทความ)
    3. การเพิ่มความสามารถให้ Claude Code (2 บทความ)

    อ่านบทความชุดนี้ได้ตามลิงก์ด้านล่าง 👇



    🧑‍💻 กลุ่มที่ 1. เริ่มต้นใช้งาน Claude Code

    .

    🌊 4 ขั้นตอนการใช้งาน Claude Code

    การสั่งให้ Claude เขียน code โดยไม่วางแผนหรือระบุความต้องการให้ชัดเจน อาจทำให้ผลลัพธ์ที่ได้ไม่ตรงกับสิ่งที่เราต้องการ

    ถ้าอยากได้ code แบบที่คาดหวังไว้ เราต้องมีขั้นตอนการทำงาน (process) กับ Claude Code ที่ถูกต้อง

    บทความนี้แนะนำ 4 ขั้นตอนการทำงานกับ Claude Code เพื่อให้ได้ code แบบที่เราต้องการ:

    Explore → Plan → Code → Commit

    👉 อ่านบทความ: 4 ขั้นตอนการใช้งาน Claude Code

    Claude Code

    .

    💻 30+ คำสั่ง Claude Code ที่ควรรู้

    Claude Code มีคำสั่งมากมายที่ช่วยลดเวลาในการทำงาน และช่วยสั่งงานได้ง่ายและเร็ว

    ตัวอย่าง:

    แทนที่เราจะสั่งให้ Claude เขียน CLAUDE.md ให้:

    เขียน CLAUDE.md ให้หน่อย

    เราสั่งงานด้วยคำสั่งสั้น ๆ อย่าง /init ได้

    ไปเรียนรู้คำสั่งนี้และอีก 30+ คำสั่งที่ควรรู้ในการทำงานกับ Claude Code ตั้งแต่:

    • คำสั่งพื้นฐาน
    • คำสั่งตั้งค่า Claude Code ให้เข้ามือ
    • คำสั่งขั้นสูงที่ทำให้ Claude Code ทำงานโดยอัตโนมัติ

    👉 อ่านบทความ: 30+ คำสั่ง Claude Code ที่ควรรู้

    Claude Code commands

    🧠 กลุ่มที่ 2. จัดการ Context ใน Claude Code

    .

    📖 5 วิธีจัดการ Context ใน Claude Code

    Context เป็นความจำที่ Claude ใช้ในการทำงาน

    เมื่อ context เต็ม Claude จะลืมข้อมูลหรือคำสั่งที่อยู่ช่วงต้นของ session และทำงานผิดพลาดได้

    ไปดู 5 วิธีจัดการ context เพื่อให้ Claude ทำงานได้อย่างมีประสิทธิภาพ ไม่ว่า session จะยาวขนาดไหนก็ตาม

    👉 อ่านบทความ: 5 วิธีจัดการ Context ใน Claude Code

    Claude Code context

    .

    📝 วิธีใช้ CLAUDE.md

    CLAUDE.md เป็นไฟล์ที่เก็บข้อมูลและแนวทางที่ Claude ควรรู้เกี่ยวกับการทำงาน ซึ่งช่วยลดการสั่งงาน Claude ใหม่ทุก ๆ session เช่น:

    • เป้าหมายของงาน
    • สไตล์การเขียน code
    • Tech stack ที่ต้องใช้

    ไปทำความรู้จักกับ CLAUDE.md และวิธีการใช้ CLAUDE.md อย่างมืออาชีพในบทความนี้

    👉 อ่านบทความ: วิธีสร้างและใช้งาน CLAUDE.md

    CLAUDE.md

    🦾 กลุ่มที่ 3. เพิ่มความสามารถให้ Claude Code

    .

    🛠️ วิธีใช้ Claude Code Skill

    Skill เป็นแนวทางการทำงานที่ Claude Code เรียกใช้งานได้เมื่อจำเป็น

    ไปดูวิธีการสร้างและใช้ skill เพื่อช่วยให้ Claude Code ทำงานได้อย่างมีประสิทธิภาพกัน

    👉 อ่านบทความ: วิธีสร้างและใช้งาน Claude Code skill

    Claude Code SKILL.md

    .

    🤖 วิธีใช้ Claude Code Subagent

    Subagent คือ AI agent ที่ Claude เรียกใช้เพื่อทำงานเฉพาะทาง โดยไม่รบกวน context หลัก เหมาะกับงานที่เราต้องการแค่ผลลัพธ์ ไม่ใช่กระบวนการทำงาน

    ไปดูวิธีการสร้างและใช้งาน subagent เพื่อช่วยให้ Claude Code ทำงานได้อย่างมีประสิทธิภาพกัน

    👉 อ่านบทความ: วิธีสร้างและใช้งาน Claude Code subagent

    Claude Code subagent
  • Claude Code Skill คืออะไร? วิธีสร้างและใช้งาน Skill อย่างมีประสิทธิภาพ

    Claude Code Skill คืออะไร? วิธีสร้างและใช้งาน Skill อย่างมีประสิทธิภาพ

    Claude Code เป็น AI coding assistant ที่ทำงานกับไฟล์บนเครื่องของเราได้โดยตรง ช่วยลดเวลาในการเปลี่ยนหน้าจอในการทำงาน และทุ่นแรงในการเขียนและรีวิว code ได้

    จุดเด่นหนึ่งของ Claude คือ skill ซึ่งช่วยให้ Claude ปรับตัวและทำงานที่มีความซับซ้อนและหลากหลายได้

    ในบทความนี้ ผมจะพาทุกคนไปรู้จักกับ skill ตั้งแต่ skill คืออะไร ใช้ยังไง ไปจนถึงเคล็ดลับในการใช้ skill อย่างมีประสิทธิภาพ

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



    🤨 Skill ใน Claude Code คืออะไร? ใช้เพื่ออะไร?

    Skill เป็นไฟล์ markdown ที่เก็บคำชี้แจง script และข้อมูลต่าง ๆ ที่ Claude เรียกใช้ได้เมื่อจำเป็น

    Skill ใช้แก้ปัญหา 2 อย่าง:

    1. ลดการพูดซ้ำ
    2. ใช้ทำงานย่อย ๆ หรืองานเฉพาะกิจ

    งานย่อย ๆ หรือสิ่งที่เรามักต้องพูดซ้ำกับ Claude (เช่น รีวิว code ยังไง, แก้ bug ยังไง, deploy บน production ยังไง) ให้เราสร้างเป็น skill เพื่อให้ Claude รู้ว่าต้องทำอะไรโดยที่เราไม่ต้องสั่งอีก


    🕰️ Skill จะใช้เมื่อไร?

    Claude จะเรียกใช้งาน skill โดยอัตโนมัติเมื่อ skill มีความเกี่ยวข้องกับงานตรงหน้า หรือเมื่อเราเรียกใช้งานเอง

    ตัวอย่างการเรียกใช้งานแบบอัตโนมัติ:

    รีวิว code ใน app.py ให้หน่อย

    ถ้า Claude มี skill สำหรับรีวิว code (เช่น code-review) Claude จะเรียกใช้งาน skill นี้โดยที่เราไม่ต้องบอกแต่แรก

    ตัวอย่างการเรียกใช้งานเอง:

    ใช้ /code-review รีวิว code ใน app.py ให้หน่อย

    ในกรณีนี้ Claude จะค้นหา skill ชื่อ code-review และเอามาใช้รีวิว code ตามคำสั่ง


    📎 สร้าง Skill ยังไง?

    เราสร้าง skill ได้ 3 วิธี:

    1. สั่งให้ Claude สร้างให้ (แนะนำ)
    2. เขียนเอง
    3. โหลด skill ที่มีคนสร้างไว้แล้ว

    ตัวอย่างการสั่งให้ Claude สร้างให้:

    สร้าง skill สำหรับรีวิว code ให้หน่อย

    📑 Skill หน้าตาเป็นยังไง?

    Skill จะถูกเก็บไว้ใน SKILL.md ซึ่งประกอบไปด้วย 5 ส่วน:

    1. name
    2. description
    3. allowed-tools (optional)
    4. model (optional)
    5. Instruction

    ตัวอย่าง SKILL.md:

    ---
    name: code-review
    description: Reviews code changes for bugs, style issues, and best practices. Use when the user asks for a code review, wants feedback on a diff or pull request, or asks "does this look right?" about recent changes.
    allowed-tools: Read, Grep, Glob, Bash(git diff:*)
    model: sonnet
    ---
    # Code Review
    Review the code changes in the current diff or specified files.
    ## Steps
    1. Run `git diff` (or read the specified files) to see what changed
    2. Check for:
    - Logic errors or edge cases the code doesn't handle
    - Inconsistent style with the rest of the codebase
    - Missing error handling
    - Unclear naming or missing comments where logic is non-obvious
    - Potential security issues (unsanitized input, hardcoded secrets)
    3. Skip nitpicks on formatting if a linter/formatter is already configured
    ## Output Format
    - Group feedback by file
    - Mark each issue as **Blocking**, **Suggestion**, or **Nit**
    - Keep comments specific — point to the line and explain *why*, not just *what*
    - End with a one-line summary verdict (e.g. "Ready to merge" / "Needs changes")

    .

    👉 ส่วนที่ 1. name

    ตัวอย่าง:

    name: code-review

    ใช้ระบุ skill และควรตั้งให้มีความเจาะจงเพื่อไม่ให้ซ้ำกัน เช่น:

    • code-review-for-security
    • code-review-for-rendering
    • code-review-for-general-functions

    .

    👉 ส่วนที่ 2. description

    ตัวอย่าง:

    description: Reviews code changes for bugs, style issues, and best practices. Use when the user asks for a code review, wants feedback on a diff or pull request, or asks "does this look right?" about recent changes.

    ใช้บอก Claude 2 อย่าง:

    1. What: skill นี้ทำอะไร
    2. When: เมื่อไรถึงจะเรียกใช้ skill นี้

    อย่างในตัวอย่างบอก Claude ว่า:

    1. What: ใช้รีวิว code เพื่อหา bug และแนะนำวิธีแก้
    2. When: ใช้เมื่อ user ต้องการรีวิว code หรือถามเกี่ยวกับ code

    .

    👉 ส่วนที่ 3. allowed-tools

    ตัวอย่าง:

    allowed-tools: Read, Grep, Glob, Bash(git diff:*)

    ใช้ระบุ action ที่ skill นี้ทำได้

    อย่างในตัวอย่าง เราเลือก:

    • Read: อ่านไฟล์
    • Grep: ค้นหาเนื้อหาในไฟล์
    • Glob: ค้นหาไฟล์
    • Bash: รัน shell command

    Note:

    • ดูตัวเลือก action ทั้งหมดได้ที่ Tools reference
    • เราสามารถเลือกไม่ระบุได้ โดย Claude จะเลือกใช้ค่า default ของระบบ

    .

    👉 ส่วนที่ 4. model

    ตัวอย่าง:

    model: sonnet

    ระบุ model ที่จะใช้งาน ซึ่งมี 3 ตัวเลือก:

    1. Haiku: เหมาะกับงานที่เน้นความเร็ว
    2. Opus: เหมาะกับงานที่เน้นการคิดวิเคราะห์
    3. Sonnet: งานที่เน้นความสมดุลระหว่างความเร็วและการวิเคราะห์

    เราเลือกที่จะไม่กำหนด model ได้ โดยในกรณีนั้น Claude จะใช้ model ที่ใช้งานอยู่ใน session นั้น ๆ

    .

    👉 ส่วนที่ 5. Instruction

    ตัวอย่าง:

    # Code Review
    Review the code changes in the current diff or specified files.
    ## Steps
    1. Run `git diff` (or read the specified files) to see what changed
    2. Check for:
    - Logic errors or edge cases the code doesn't handle
    - Inconsistent style with the rest of the codebase
    - Missing error handling
    - Unclear naming or missing comments where logic is non-obvious
    - Potential security issues (unsanitized input, hardcoded secrets)
    3. Skip nitpicks on formatting if a linter/formatter is already configured
    ## Output Format
    - Group feedback by file
    - Mark each issue as **Blocking**, **Suggestion**, or **Nit**
    - Keep comments specific — point to the line and explain *why*, not just *what*
    - End with a one-line summary verdict (e.g. "Ready to merge" / "Needs changes")

    เป็นคำชี้แจงในการทำงานให้กับ Claude

    อย่างในตัวอย่าง เราระบุ:

    1. ขั้นตอนการรีวิว code
    2. สิ่งที่จะต้องส่งกลับมา

    ✌️ ระดับและการจัดลำดับ Skill

    Skill แบ่งได้เป็น 4 ระดับ:

    1. Enterprise: skill ที่ใช้ร่วมกันทั้งองค์กร (เก็บอยู่ใน managed-settings.json)
    2. Personal: skill ที่ใช้ร่วมกันทุก project ที่เราทำงาน (เก็บอยู่ใน ~/.claude/skills)
    3. Project: skill ที่ใช้เฉพาะ project (เก็บอยู่ใน <project_folder>/.claude/skills)
    4. Plugin: skill ที่มาพร้อม plugin (เก็บอยู่ใน <project_folder>/.claude-plugins/skills)

    ในกรณีที่ skill มีชื่อซ้ำกันหรือทำงานเหมือนกัน Claude จะเลือกใช้ skill ตามลำดับนี้:

    Enterprise > Personal > Project > Plugin

    ตัวอย่าง:

    เรามี skill ชื่อ code-review ใน root directory (ระดับ Personal) ซึ่งซ้ำกับ code-review ใน managed-settings.json (ระดับ Enterprise) Claude จะเลือกใช้ code-review ใน managed-settings.json ก่อน


    🤫 เคล็ดลับการใช้ Skill

    .

    1️⃣ ข้อที่ 1. เขียน name และ description ให้ดี

    Claude เลือกใช้ skill โดยอ่านจาก name และ description

    ถ้าทั้ง name และ description ไม่สื่อความหมายที่เกี่ยวข้องกับงานตรงหน้า Claude จะไม่เรียกมาใช้งาน แม้ว่าเราต้องการให้ใช้ก็ตาม

    วิธีแก้ คือ เขียน name และ description ให้ดี:

    1. name ควรมีความเฉพาะเจาะจง ไม่ธรรมดาจนเกินไป
    2. description ควรบอกว่า skill ทำอะไร และควรใช้เมื่อไร

    .

    2️⃣ ข้อที่ 2. เขียน Instruction ให้กระชับ

    เมื่อ Claude เลือกใช้ skill ก็จะโหลด instruction ใน SKILL.md เข้ามาอ่าน ซึ่งจะทำให้ Claude มี context หรือความจำในการทำงานน้อยลง

    ดังนั้น เราควรเขียน instruction กระชับเพื่อประหยัดการใช้ context ของ Claude โดย SKILL.md ไม่ควรยาวเกิน 500 บรรทัด

    ในกรณีที่ instruction ยาว เราสามารถตัดแบ่งบางส่วนไปใส่ในไฟล์อื่น และเขียนอ้างอิงไว้ใน SKILL.md แทนได้

    ตัวอย่าง:

    ---
    name: api-integration
    description: Build and debug integrations with our internal API. Use when the user asks to add an endpoint, authenticate a request, or troubleshoot API errors.
    ---
    # API Integration
    This skill covers our internal API conventions. Keep this file as your starting point — don't guess at details covered in the linked files below; open them when the task needs that level of detail.
    ## Quick Reference
    - Base URL: `https://api.internal.example.com/v1`
    - Auth: Bearer token in `Authorization` header
    - All responses are JSON with a `data` and `error` envelope
    ## When You Need More Detail
    - **Authentication flows** (OAuth, token refresh, service accounts) → see [auth.md](auth.md)
    - **Full endpoint list and request/response schemas** → see [endpoints.md](endpoints.md)
    - **Error codes and retry behavior** → see [errors.md](errors.md)
    - **Example requests in curl, Python, and JS** → see [examples.md](examples.md)
    Only read the file(s) relevant to the current task. Don't load all of them upfront.

    เมื่อทำอย่างนี้ Claude จะโหลดข้อมูลจากไฟล์ที่เราอ้างอิงใน SKILL.md เมื่อจำเป็นเท่านั้น ทำให้เราประหยัดพื้นที่ใน context ไปได้

    .

    3️⃣ ข้อที่ 3. ใช้ Skill ใน Subagent

    Subagent เป็น agent ที่ Claude เรียกใช้งานเพื่อทำงานเฉพาะทางบางอย่างได้

    Subagent จะไม่สามารถใช้ skill ได้เองจนกว่าเราจะบอกว่าใช้ได้ โดยกำหนด skill ใน skills ในไฟล์ markdown ของ subagent

    ตัวอย่าง:

    ---
    name: api-developer
    description: Implement API endpoints following team conventions
    tools: Read, Write, Edit, Grep, Glob, Bash
    skills:
    - api-conventions
    - error-handling-patterns
    ---
    You are an API developer. Implement endpoints following the conventions
    and patterns from the preloaded skills above.

    เมื่อกำหนดแล้ว subagent จะเรียกใช้งาน skill ทุกครั้งที่ตัวเองถูกใช้งาน ซึ่งต่างจาก main agent ที่เลือกใช้ skill ได้ตามหน้างาน


    🫵 Your Turn

    หลังอ่านบทความนี้แล้ว ลองใช้มา Claude Code กันดูนะครับ:


    📃 References