Claude Code Reference
Claude Code Reference
Terminal Agent AnthropicOverview
Claude Code เป็น AI coding agent ที่รันใน terminal ของ Anthropic — มันอ่าน/เขียนไฟล์, รันคำสั่ง, และทำงานหลายขั้นตอนให้เสร็จภายใน repository ของคุณ โดยใช้ Claude models
You → Claude Code CLI → files, commands, tests, gitWhen to Use
- งานที่ต้องแก้หลายไฟล์พร้อมกัน (multi-file refactor)
- งาน autonomous ที่ต้องรัน test / build / git เอง
- งานที่ต้องการ agentic loop (อ่าน → แก้ → verify → retry)
- งานที่ต้องการ integ/กับ MCP servers หรือ subagents
When NOT to Use:
- แค่ autocomplete สั้นๆ (ใช้ IDE inline completion ก็พอ)
- งานที่ต้อง transaction กับระบบภายนอกโดยไม่มีการ review
Key Features
| Feature | Description |
|---|---|
| Terminal-based | ทำงานใน CLI, ยึดกับ current directory (working directory) |
| File I/O | อ่าน/เขียนไฟล์ใน repo ได้โดยตรง |
| Command execution | รัน shell commands, tests, builds |
| Agentic loop | วางแผน → ลงมือ → ตรวจสอบ → retry เอง |
| MCP support | เชื่อมต่อ tools ภายนอกผ่าน Model Context Protocol |
| Subagents | เรียก agent ย่อยเฉพาะทาง (เช่น Explore, Plan) |
| Plan mode | วางแผนก่อนแก้ โดยไม่เขียน code จนกว่าจะ approve |
| Hooks | trigger scripts ตามเหตุการณ์ (pre-tool, post-tool, …) |
Basic Usage
# เริ่มใน directory ของโปรเจกต์claude
# รัน command เดียวแบบ non-interactiveclaude -p "Add a /health endpoint to the server"
# เปิดโหมด Plan (วางแผนก่อนแก้)claude --plan "Design the auth flow"Common Workflows
1. Fresh Task in a Repo
cd my-projectclaude# > Add error handling to the fetch wrapper2. Plan-First (recommended for big changes)
claude --plan "Add a dark-mode toggle"# Review the plan, then approve before any code is written3. Delegating to a Subagent
Use the Explore agent to find every place we read process.env,then propose a config module.4. Verify-Before-Trust
After generating the function, run the test suite and fix any failures.Quote the test output when you're done.Tips
- Be explicit about the working directory and scope — Claude Code acts on the current directory.
- Ask for verification output — instruct it to run
node test.js/ your gate and quote the result. - Use Plan mode for reversible decisions — approve before it mutates files.
- Guard verbs — “read X, change Y, run Z, stop” keeps the agent bounded.