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 ที่ตอบโจทย์
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 คำสั่ง)
Full-time employees receive health insurance after completing probation.
The company provides annual health checkups once per year.
Employees can claim up to 2,000 THB per month for wellness activities such as fitness memberships, yoga classes, or mental health support.
Employees are also eligible for learning support. The company reimburses up to 10,000 THB per year for approved online courses, books, or professional certificates.
Full-time employees receive health insurance after completing probation.
The company provides annual health checkups once per year.
Employees can claim up to 2,000 THB per month for wellness activities such as fitness memberships, yoga classes, or mental health support.
Employees are also eligible for learning support. The company reimburses up to 10,000 THB per year for approved online courses, books, or professional certificates.
[SystemMessage(content='You are an expert curator of mental models across science, philosophy, and applied reasoning.\\n\\nYour task is to explain mental models clearly and accurately using a fixed schema.\\n\\nIf the origin of a model is unclear or debated, state that explicitly.\\n\\nDo not invent historical sources. Be concise and concrete.', additional_kwargs={}, response_metadata={}),
HumanMessage(content='Explain the following mental model: Pareto Princinple', additional_kwargs={}, response_metadata={})]
"origin": "Finance, Mathematics; concept dates back to ancient times, formalized in the Renaissance.",
"description": "Compound interest is the interest on a loan or deposit calculated based on both the initial principal and the accumulated interest from previous periods. It is often called 'interest on interest' and leads to exponential growth over time, making it a powerful force in finance for both wealth creation and debt accumulation.",
"example": "If you invest $1,000 at an annual interest rate of 5% compounded annually, after the first year you'll have $1,050. In the second year, the 5% interest is calculated on $1,050, not just the original $1,000, leading to a balance of $1,102.50. This snowball effect accelerates over decades, significantly increasing the total return compared to simple interest.",
"origin": "Often attributed to Aristotle; popularized in modern business by Elon Musk.",
"description": "First Principles Thinking involves breaking down complex problems into their most basic, fundamental truths or 'first principles,' rather than reasoning by analogy or conventional wisdom. It matters because it allows for innovative solutions by challenging assumptions and building new knowledge from the ground up.",
"example": "Instead of accepting the high cost of batteries for electric cars, Elon Musk famously broke down a battery into its constituent raw materials (cobalt, nickel, lithium, etc.) to understand their actual cost, then sought ways to procure and assemble them more efficiently, leading to significant cost reductions and innovation.",
"tags": [
"Problem-solving",
"Innovation",
"Critical Thinking",
"Decision-making"
]
}
👉 Query 2:
{
"model_name": "Occam's Razor",
"origin": "William of Ockham (14th-century philosopher and theologian)",
"description": "Occam's Razor is a problem-solving principle stating that among competing hypotheses that explain an event or phenomenon equally well, the simplest solution is most likely the correct one. It advocates for parsimony, suggesting that one should not multiply entities beyond necessity, thereby favoring theories with fewer assumptions.",
"example": "If you hear hoofbeats outside, it is more likely to be horses than zebras, assuming you are in a location where horses are common and zebras are not. The 'horse' explanation is simpler and requires fewer extraordinary assumptions.",
"tags": [
"Philosophy",
"Decision-making",
"Problem-solving",
"Critical thinking",
"Science"
]
}
👉 Query 3:
{
"model_name": "Confirmation Bias",
"origin": "Psychology; early concepts traced to Francis Bacon's Novum Organum (1620)",
"description": "Confirmation bias is the tendency to search for, interpret, favor, and recall information in a way that confirms one's pre-existing beliefs or hypotheses. It matters because it can lead to flawed reasoning, poor decision-making, and resistance to new or contradictory evidence, hindering objective analysis.",
"example": "A person who believes a certain stock will perform well might selectively read news articles and analyst reports that support this positive outlook, while ignoring or downplaying any negative news or warnings about the company.",
การที่ AI พัฒนาเร็วขึ้นเรื่อย ๆ ทำให้เรามีเวลาปรับตัวน้อยลงเรื่อย ๆ
และตอนนี้ เราเหมือนอยู่ที่ทางแยกที่เราจะต้องเลือกว่า เราจะเรียนรู้การใช้ AI ให้เป็นและอยู่รอดในยุคของ AI หรือเราจะใช้ AI แบบเดิม ๆ และถูกทิ้งไว้ข้างหลัง
The people who will come out of this well won’t be the ones who mastered one tool. They’ll be the ones who got comfortable with the pace of change itself. — Matt Shumer
💼 Part II. Working With AI
.
ข้อ 9. Maslow’s hammer
I suppose it is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail. — Abraham Maslow
Maslow’s hammer เป็น mental model ที่บอกว่า เครื่องมือสามารถจำกัดมุมมองของเราได้
เช่น ถ้าเรามีค้อน เราจะมองทุกอย่างเป็นตะปู
ในยุคของ AI เราอาจมองว่าทุกอย่างแก้ได้ด้วย AI:
ทำงานเร็วขึ้น
ผิดพลาดน้อยลง
มีเวลามากขึ้น
แต่ไม่ใช่ทุกปัญหาจะแก้ได้ด้วย AI เพราะ AI ไม่ใช่เครื่องมือสำหรับแก้ทุกอย่าง
ถ้าเราอยากตอกตะปู เราจะต้องใช้ค้อน ไม่ใช่ AI
การใช้ AI ที่ถูกต้อง คือ เริ่มต้นจากปัญหาและความต้องการของเรา แล้วเลือกเครื่องมือที่ตอบโจทย์ ซึ่งเครื่องมือนั้นอาจจะเป็น AI หรือไม่ก็ได้
.
ข้อ 10. AI is built in man’s image
AI เกิดจากการ train model ด้วยข้อมูลจากอินเทอร์เน็ตซึ่งมาจากมนุษย์
Human -> Data -> Train -> AI
เพราะ AI ถูกสร้างจากข้อมูลของมนุษย์ และเรามองได้ว่า AI เป็นเหมือนเป็นมนุษย์คนหนึ่ง
.
ข้อ 11. AI as capable but junior assistant
ถ้าเรามอง AI เป็นคน AI จะเป็นเหมือนผู้ช่วยที่มีความรู้รอบด้านและมีศักยภาพสูง
แต่สิ่งเดียวที่ผู้ช่วยคนนี้ยังขาดไป คือ ทิศทาง
.
ข้อ 12. Even a fried egg is hard to get right
การทำงานกับ AI ก็เหมือนสั่งไข่ดาว แม้จะดูง่าย แต่ก็ไม่ง่ายอย่างที่คิด
บางครั้ง เราอยากกินไข่ไม่สุก แต่ได้แบบสุกมาแทน
บางครั้ง เราอยากให้ AI สร้างรูปในแบบที่เราคิด แต่ไม่เคยได้ภาพนั้นสักที
ถ้าสิ่งที่ AI ส่งกลับมาไม่ตรงใจ เราควรจะบอก AI ว่าอะไรที่ยังไม่ถูกใจ เพื่อให้ AI ปรับผลลัพธ์และส่งกลับมาให้เราเช็กจนกว่าเราจะพอใจกับงานของ AI
.
ข้อ 16. Be accountable
เราควรจะเช็กงานของ AI ทุกครั้ง เพราะถ้าเราไม่รับผิดชอบกับงานของ AI เราอาจจะเป็นเหมือนทนายความจากออสเตรเลียที่ถูกตรวจสอบ หลังจากศาลพบว่าเอกสารที่ทนายนำส่งเป็นข้อมูลที่ไม่มีอยู่จริง
แม้ทนายจะอ้างว่ารู้เท่าไม่ถึงการณ์ว่า AI ที่บริษัทให้ใช้สามารถสร้างข้อมูลที่ไม่มีอยู่จริงได้ และตัวเองควรตรวจสอบข้อมูลจาก AI ก่อน ศาลยังสั่งให้ทนายงดว่าความด้วยตัวเองเป็นเวลา 2 ปี โดยในระยะเวลานี้จะต้องทำงานเป็นลูกจ้างของคนอื่น และต้องรายงานต่อศาลทุกไตรมาส
ดังนั้น ไม่ว่างานของ AI จะดูดีขนาดไหน เราควรจะตรวจสอบด้วยตัวเองก่อนที่จะนำงานไปใช้จริง