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
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 อย่าง:
What: skill นี้ทำอะไร
When: เมื่อไรถึงจะเรียกใช้ skill นี้
อย่างในตัวอย่างบอก Claude ว่า:
What: ใช้รีวิว code เพื่อหา bug และแนะนำวิธีแก้
When: ใช้เมื่อ user ต้องการรีวิว code หรือถามเกี่ยวกับ code
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 เรียกใช้งานเพื่อทำงานเฉพาะทางบางอย่างได้
Document(id=7fe87ca8e57420adb9ed47866809d38424003dd43b4eefdf6b1a400eb3709677, content: ' Quarterly profits at US media giant TimeWarner jumped 76% to $1.13bn (£600m) for the three months t...', meta: {'title': 'Ad sales boost Time Warner profit', 'category': 'business', 'filename': '001.txt'})
เริ่มจากสร้าง function สำหรับเรียกใช้งาน pipeline เพื่อให้ง่ายต่อการเรียกใช้:
Python
# Create the function
defrun_query(query: str):
# Run the pipeline
result=querying_pipeline.run(
{
"question_embedder": {
"text": query
},
"prompt_builder": {
"question": query
}
}
)
# Return the result
returnresult["generator"]["replies"][0].text
จากนั้น เรียกใช้งานโดยถามเกี่ยวกับข่าวที่อยู่ใน BBC News Archive เช่น:
Python
# Set the question
my_question="What concerns did users raise about Google’s AutoLink feature?"
# Run the query
query_result=run_query(query=my_question)
# Display the result
print(query_result)
ผลลัพธ์:
Users raised several concerns about Google’s AutoLink feature:
* It directs people to pre-selected commercial websites [1].
* Google's dominant market position could give a competitive edge to firms like Amazon [1].
* It creates links based on webpage information without the publisher's permission [1].
* Online libraries and other websites might direct users to commercial sites like Amazon or rival services against their will or in conflict with their own advertising [4].
* Some users felt it would only be fair if websites had to opt-in or receive revenue for "click throughs" to commercial sites [2].
* Concerns were raised about user choice, transparency regarding Google's payments, and the ability to substitute preferred companies for those chosen by Google [3].
* There was an objection to users being forced or tricked into using the service [3].
* The feature was compared to Microsoft's Smart Tags, which was widely criticised [2].
Claude Code เป็น AI coding assistant ที่กำลังได้รับความนิยม ด้วยความสามารถในการประมวลผลคำสั่ง และความสามารถในการทำงานกับไฟล์บนคอมพิวเตอร์ได้โดยตรง ช่วยลดเวลาในการ copy-paste code ไปมาระหว่าง Claude และไฟล์
แม้ Claude Code จะสามารถเขียน code ได้ดี แต่ก็ไม่ได้หมายความว่า เราจะได้ code ที่ตอบโจทย์ทุกครั้ง
เช่น เราสั่งให้ Claude Code สร้างเว็บ chatbot ทั้งหน้าตา การทำงาน และการเก็บข้อมูลอาจไม่ได้เป็นไปตามที่เราคาดหวัง ทำให้เราต้องเวลาเพิ่มขึ้นเพื่อสั่งให้ Claude แก้ไขงาน
ในบทความนี้ ผมจะมาแนะนำ 4 ขั้นตอนในการทำงานกับ Claude Code เพื่อให้ได้ code ที่ตอบโจทย์
Claude Code เป็น AI ช่วยเขียน code ที่ช่วยเราวางแผน เขียน และแก้ไข code บนคอมพิวเตอร์ได้ผ่านคำสั่งภาษาธรรมชาติ (natural language)
หนึ่งในสิ่งที่ทำให้ Claude Code ทำงานได้อย่างมีประสิทธิภาพ คือ context
ถ้าไม่มี context, Claude จะขาดบริบทในการทำงาน และไม่สามารถเขียน code ได้อย่างมีประสิทธิภาพได้
ในบทความนี้ เราจะมาทำความรู้จักกับ context และวิธีใช้งาน context ใน Claude Code อย่างถูกวิธีกัน
บทความนี้แบ่งเป็น 2 ส่วน:
ความหมายของ context
วิธีจัดการ context ที่ถูกต้อง
ถ้าพร้อมแล้ว ไปเริ่มกันเลย
🤨 Context ใน Claude Code คืออะไร? และสำคัญยังไง?
Context คือ ความจำในการทำงานของ Claude (working memory)
Context เก็บประวัติการพูดคุยระหว่างเรากับ Claude รวมถึงการทำงานของ Claude เช่น การอ่านไฟล์และการแก้ไขไฟล์ ซึ่งช่วยให้ Claude มีข้อมูลบริบทในการทำงาน
เมื่อ context เต็ม Claude จะลืมการพูดคุยช่วงต้น และมีโอกาสทำงานผิดพลาดมากขึ้น
เช่น ตอนต้น session เราบอกให้ Claude เขียน comment กำกับ code ทุกครั้ง พอ context เต็ม Claude จะลืมคำสั่งนี้ และไม่ comment code ตามที่เราต้องการ
ดังนั้น เราควรจะจัดการ context ให้ดี เพื่อให้ Claude ทำงานได้อย่างมีประสิทธิภาพมากที่สุด
👍 วิธีจัดการ Context ที่ถูกต้อง
5 วิธีในการจัดการ context ไม่ให้เต็มเร็ว:
เขียน prompt ให้เจาะจง
ใช้ CLAUDE.md
ปิดใช้งาน skills and MCPs
ใช้ subagent
ลบหรือสรุปข้อมูล
.
✏️ วิธีที่ 1. เขียน Prompt ให้เจาะจง
เขียน prompt ให้ชัดเจนและเจาะจง เพื่อที่ Claude จะไม่ต้องคิดทบทวนคำสั่งหลายรอบ
❌ ตัวอย่าง prompt ที่เปลือง context:
แก้ code ให้หน่อย
เพราะ Claude จะต้องคิดก่อนลงมือทำ:
มองหาจุดไหนที่ต้องแก้
คิดว่าแก้เพื่ออะไร
คิดว่าแก้ยังไง
ลงมือแก้
ทำให้เปลือง context โดยไม่จำเป็น
✅ ตัวอย่าง prompt ที่ประหยัด context:
แก้ calculate_sum() ในไฟล์ @calculator.py
เพื่อ handle data type ที่ไม่ใช่ int หรือ float
เพราะ Claude สามารถคิดและลงมือแก้ได้เลย โดยตีกรอบบริบทว่าอะไรที่ต้องแก้บ้าง
.
📑 วิธีที่ 2. ใช้ CLAUDE.md
ใส่บริบทและสิ่งที่ Claude ควรรู้ไว้ใน CLAUDE.md ซึ่งเป็นไฟล์กำกับการทำงานของ Claude เพื่อที่ Claude จะได้เข้าใจบริบทในการทำงานได้โดยไม่ต้องอ่าน code ทั้งหมดใหม่ทุกครั้ง
ไม่มี CLAUDE.md
มี CLAUDE.md
อ่าน code ทั้งหมดเพื่อเข้าใจบริบท
อ่านแค่ CLAUDE.md
2 วิธีในการสร้าง CLAUDE.md:
สั่งให้ Claude สร้างให้ ด้วยคำสั่ง /init (แนะนำ)
สร้างเองใน text editor
ตัวอย่าง CLAUDE.md:
# Project: My To-Do App
## What this is
A simple to-do list app.
Frontend only, no backend yet.
Built with HTML, CSS, and vanilla JavaScript.
## Do
- Keep the code in plain JavaScript
- Explain any code changes in plain English before making them
- Always test in the browser before marking tasks as complete
## Don't
- Don't use React, Vue, or any framework
- Don't rewrite the whole file for a small fix
- Don't delete comments that explain "why", only "what"
Claude Code เป็น AI coding assistant ที่เราใช้ช่วยเขียน code ลงบนคอมพิวเตอร์ได้โดยตรง
แม้ว่า Claude Code จะรองรับการทำงานกับภาษาธรรมชาติ (natural language) แต่เราสามารถสั่งงาน Claude ผ่าน command line หรือคำสั่งลัดใน Terminal ได้ด้วยเช่นกัน
ในบทความนี้ ผมจะพาไปดู 30+ คำสั่งที่ทุกคนควรรู้สำหรับการใช้งาน Claude Code ให้ได้อย่างมืออาชีพกัน
ทั้ง 30+ คำสั่งแบ่งได้เป็น 3 ส่วน:
Basic: คำสั่งพื้นฐานในการทำงานกับ Claude (14 คำสั่ง)
Intermediate: คำสั่งที่ช่วยให้ Claude ตอบโจทย์เรามากขึ้น (12 คำสั่ง)
Advanced: คำสั่งที่ทำให้ Claude ทำงานโดยอัตโนมัติ (8 คำสั่ง)