Claude Code: คู่มือ Tools

🇹🇭 Thai claude-codetoolsreferencethai
📋 Table of Contents (14 sections)
  1. คู่มือ Tools
  2. ภาพรวม
  3. File System Tools
  4. Shell & Execution Tools
  5. Agent & Orchestration Tools
  6. Task Management Tools
  7. Web Tools
  8. MCP (Model Context Protocol) Tools
  9. Integration Tools
  10. Scheduling & Triggers
  11. Utility Tools
  12. Permission Model
  13. Tool Presets
  14. ดูเพิ่มเติม

คู่มือ Tools

Catalog ครบถ้วนของ agent tools ทั้ง ~40 รายการใน Claude Code


ภาพรวม

ทุก tool อยู่ใน src/tools/<ToolName>/ เป็น module ที่มีความสมบูรณ์ในตัวเอง แต่ละ tool นิยาม:

  • Input schema — พารามิเตอร์ที่ validate ด้วย Zod
  • Permission model — สิ่งที่ต้องการการอนุมัติจาก user
  • Execution logic — การ implement ของ tool
  • UI components — การ render ใน terminal สำหรับการเรียกใช้และผลลัพธ์
  • Concurrency safety — สามารถทำงานพร้อมกันได้หรือไม่

Tools ลงทะเบียนใน src/tools.ts และถูกเรียกใช้โดย Query Engine ระหว่าง LLM tool-call loops

รูปแบบการนิยาม Tool

export const MyTool = buildTool({
  name: 'MyTool',
  aliases: ['my_tool'],
  description: 'สิ่งที่ tool นี้ทำ',
  inputSchema: z.object({
    param: z.string(),
  }),
  async call(args, context, canUseTool, parentMessage, onProgress) {
    // Execute และคืนค่า { data: result, newMessages?: [...] }
  },
  async checkPermissions(input, context) { /* Permission checks */ },
  isConcurrencySafe(input) { /* ทำงานพร้อมกันได้? */ },
  isReadOnly(input) { /* ไม่ทำลายข้อมูล? */ },
  prompt(options) { /* System prompt injection */ },
  renderToolUseMessage(input, options) { /* UI สำหรับการเรียกใช้ */ },
  renderToolResultMessage(content, progressMessages, options) { /* UI สำหรับผลลัพธ์ */ },
})

โครงสร้างไดเรกทอรีต่อ tool:

src/tools/MyTool/
├── MyTool.ts        # การ implement หลัก
├── UI.tsx           # Terminal rendering
├── prompt.ts        # System prompt contribution
└── utils.ts         # Helper เฉพาะ tool

File System Tools

ToolคำอธิบายRead-Only
FileReadToolอ่านเนื้อหาไฟล์ (text, images, PDFs, notebooks) รองรับ line rangesใช่
FileWriteToolสร้างหรือเขียนทับไฟล์ไม่
FileEditToolแก้ไขไฟล์บางส่วนผ่าน string replacementไม่
GlobToolค้นหาไฟล์ที่ตรงกับ glob patterns (เช่น **/*.ts)ใช่
GrepToolค้นหาเนื้อหาด้วย ripgrep (รองรับ regex)ใช่
NotebookEditToolแก้ไข Jupyter notebook cellsไม่
TodoWriteToolเขียนไปยัง structured todo/task fileไม่

Shell & Execution Tools

ToolคำอธิบายRead-Only
BashToolExecute shell commands ใน bashไม่
PowerShellToolExecute PowerShell commands (Windows)ไม่
REPLToolรัน code ใน REPL session (Python, Node ฯลฯ)ไม่

Agent & Orchestration Tools

ToolคำอธิบายRead-Only
AgentToolSpawn sub-agent สำหรับงานที่ซับซ้อนไม่
SendMessageToolส่ง messages ระหว่าง agentsไม่
TeamCreateToolสร้างทีม parallel agentsไม่
TeamDeleteToolลบ team agentไม่
EnterPlanModeToolสลับเป็น planning mode (ไม่ execute)ไม่
ExitPlanModeToolออกจาก planning mode กลับสู่ executionไม่
EnterWorktreeToolแยกงานใน git worktreeไม่
ExitWorktreeToolออกจาก worktree isolationไม่
SleepToolหยุดชั่วคราว (proactive mode)ใช่
SyntheticOutputToolสร้าง structured outputใช่

Task Management Tools

ToolคำอธิบายRead-Only
TaskCreateToolสร้าง background task ใหม่ไม่
TaskUpdateToolอัปเดตสถานะหรือรายละเอียดของ taskไม่
TaskGetToolดูรายละเอียดของ task เฉพาะใช่
TaskListToolแสดงรายการ tasks ทั้งหมดใช่
TaskOutputToolดู output จาก task ที่เสร็จสิ้นใช่
TaskStopToolหยุด task ที่กำลังทำงานไม่

Web Tools

ToolคำอธิบายRead-Only
WebFetchToolดึงเนื้อหาจาก URLใช่
WebSearchToolค้นหาในเว็บใช่

MCP (Model Context Protocol) Tools

ToolคำอธิบายRead-Only
MCPToolเรียกใช้ tools บน MCP servers ที่เชื่อมต่อขึ้นอยู่กับ
ListMcpResourcesToolแสดง resources ที่ MCP servers เปิดเผยใช่
ReadMcpResourceToolอ่าน MCP resource เฉพาะใช่
McpAuthToolจัดการ MCP server authenticationไม่
ToolSearchToolค้นพบ deferred/dynamic tools จาก MCP serversใช่

Integration Tools

ToolคำอธิบายRead-Only
LSPToolLanguage Server Protocol operations (go-to-definition, find references ฯลฯ)ใช่
SkillToolExecute skill ที่ลงทะเบียนไว้ขึ้นอยู่กับ

Scheduling & Triggers

ToolคำอธิบายRead-Only
ScheduleCronToolสร้าง scheduled cron triggerไม่
RemoteTriggerToolเรียก remote triggerไม่

Utility Tools

ToolคำอธิบายRead-Only
AskUserQuestionToolขอข้อมูลจาก user ระหว่างการ executeใช่
BriefToolสร้าง brief/summaryใช่
ConfigToolอ่านหรือแก้ไข Claude Code configurationไม่

Permission Model

ทุก tool invocation ผ่านระบบ permission (src/hooks/toolPermission/) โหมด permission:

โหมดพฤติกรรม
defaultแจ้งให้ user อนุมัติสำหรับแต่ละ operation ที่อาจทำลายข้อมูล
planแสดง plan ทั้งหมด ขออนุมัติครั้งเดียว
bypassPermissionsอนุมัติทุกอย่างอัตโนมัติ (อันตราย)
autoML-based classifier ตัดสินใจ

Permission rules ใช้ wildcard patterns:

Bash(git *)           # อนุญาต git commands ทั้งหมด
FileEdit(/src/*)      # อนุญาตแก้ไขทุกอย่างใน src/
FileRead(*)           # อนุญาตอ่านทุกไฟล์

แต่ละ tool implement checkPermissions() คืนค่า { granted: boolean, reason?, prompt? }


Tool Presets

Tools ถูกจัดกลุ่มเป็น presets ใน src/tools.ts สำหรับ context ต่างๆ (เช่น read-only tools สำหรับ code review, full toolset สำหรับการพัฒนา)


ดูเพิ่มเติม

  • Architecture — วิธีที่ tools ใช้งานร่วมกับ overall pipeline
  • Subsystems Guide — MCP, permissions และ subsystems ที่เกี่ยวข้องกับ tool
  • Exploration Guide — วิธีอ่าน tool source code
← Back to claudecodeanalysis