Week 2 of 12 🔧

Core Tools: Read, Write & Edit

เครื่องมือหลัก: Read, Write และ Edit

核心工具:Read、Write 和 Edit

Core Tools: Read, Write & Edit

1. Introduction / บทนำ / 简介

Claude Code มาพร้อมกับเครื่องมือในตัวที่ทรงพลังสำหรับการทำงานกับไฟล์ เครื่องมือสำคัญที่สุดสามตัวคือ Read (ดูเนื้อหาไฟล์), Write (สร้างไฟล์ใหม่) และ Edit (แก้ไขไฟล์ที่มีอยู่) เครื่องมือเหล่านี้ให้ Claude เข้าใจและเปลี่ยนแปลงโค้ดของคุณ
Claude Code 自带强大的内置文件工具。最重要的三个是 Read(查看文件内容)、Write(创建新文件)和 Edit(修改现有文件)。这些工具让 Claude 能够理解并修改你的代码。
Claude Code comes with powerful built-in tools for working with files. The three most important are Read (view file contents), Write (create new files), and Edit (modify existing files). These tools let Claude understand and change your code.

Fun Facts / ข้อเท็จจริงที่น่าสนใจ / 趣味知识

  • The Read tool can view images and PDFs too!
  • Edit only sends the changed part, not the whole file.
  • Write will ask for permission before creating files.
Close-up of an Adler typewriter keyboard
Before Edit existed: on a typewriter, every change meant retyping the whole page. — Photo: Maksym Kozlenko, CC BY-SA 4.0, via Wikimedia Commons

2. Vocabulary / คำศัพท์ / 词汇

Click a card to flip it. คลิกการ์ดเพื่อพลิก 点击卡片翻面。

read
อ่าน
读取
To view the contents of a file
write
เขียน
写入
To create a new file with content
edit
แก้ไข
编辑
To change part of an existing file
file
ไฟล์
文件
A document stored on a computer
path
พาธ / เส้นทาง
路径
The location of a file in a directory
content
เนื้อหา
内容
The text or data inside a file
line
บรรทัด
A single row of text in a file
replace
แทนที่
替换
To put new text in place of old text
create
สร้าง
创建
To make something new
overwrite
เขียนทับ
覆盖
To replace a file completely
permission
สิทธิ์
权限
Authorization to perform an action
tool
เครื่องมือ
工具
A feature used to perform a task

3. Grammar Focus / ไวยากรณ์ / 语法焦点

Present Simple for Descriptions (It reads... It writes...) / Present Simple สำหรับการอธิบาย (It reads... It writes...) / 用于描述的一般现在时(It reads... It writes...)

Thai:
Present Simple อธิบายสิ่งที่เกิดขึ้นเป็นประจำหรือถาวร สำหรับบุรุษที่สาม (he/she/it) เติม -s หรือ -es ตัวอย่าง: 'It reads the file.' 'The tool writes new content.'
中文:
一般现在时描述某物经常做或一直做的事情。第三人称(he/she/it)要在动词后加 -s 或 -es。例如:'It reads the file.'(它读取文件。)'The tool writes new content.'(这个工具写入新内容。)
English:
Present Simple describes what something does regularly or permanently. For third person (he/she/it), add -s or -es. Example: 'It reads the file.' 'The tool writes new content.'
เครื่องมือ Read แสดงเนื้อหาไฟล์
Read 工具显示文件内容。
The Read tool displays file contents.
Claude เขียนโค้ดลงในไฟล์ใหม่
Claude 把代码写入一个新文件。
Claude writes the code to a new file.
เครื่องมือ Edit แทนที่ข้อความเก่าด้วยข้อความใหม่
Edit 工具用新文本替换旧文本。
The Edit tool replaces old text with new text.

Section Check 1

Which tool creates a new file?

เครื่องมือใดสร้างไฟล์ใหม่?

哪个工具可以创建新文件?

Section Check 2

What does 'It reads the file' use?

'It reads the file' ใช้ tense อะไร?

'It reads the file' 用的是什么时态?

Section Check 3

Which tool needs permission?

เครื่องมือใดต้องการสิทธิ์?

哪个工具需要权限?

4. Tutorial Steps / ขั้นตอนการเรียนรู้ / 教程步骤

1
Ask Claude to read a file / ขอให้ Claude อ่านไฟล์ / 让 Claude 读取文件
Say: 'Read the file at src/index.js' — Claude uses the Read tool to show you the contents.

How to do it

  • Just describe it in plain English: Read the file at src/index.js. There is no special syntax.
  • Claude runs its Read tool and shows the file with line numbers.
  • No path? Say the file name only — Claude will search for it first.
2
Ask Claude to create a file / ขอให้ Claude สร้างไฟล์ / 让 Claude 创建文件
Say: 'Create a file called hello.py with a print statement' — Claude uses Write.

How to do it

  • Say what you want and where: Create a file called hello.py with a print statement.
  • Claude shows the exact content it plans to write before anything happens.
  • The file is only created after you approve.
3
Ask Claude to edit a file / ขอให้ Claude แก้ไขไฟล์ / 让 Claude 编辑文件
Say: 'Change the function name from foo to bar in utils.js' — Claude uses Edit to make the change.

How to do it

  • Describe the change: Change the function name from foo to bar in utils.js.
  • Claude shows a diff: red lines are removed, green lines are added.
  • Only the shown lines change — the rest of the file stays exactly the same.
4
Check permissions / ตรวจสอบสิทธิ์ / 检查权限
Read is automatic. Write and Edit require your approval before making changes.

How to do it

  • Read never asks — looking at a file changes nothing.
  • Write and Edit always pause and wait for your answer first.
  • This is the safety model: nothing on your disk changes without your approval.
5
Review changes / ตรวจสอบการเปลี่ยนแปลง / 审查更改
Claude shows you what will change. Type 'y' to approve or 'n' to reject.

How to do it

  • Read the diff carefully — you are the reviewer.
  • Press y to approve, n to reject. You can also choose "don't ask again" for this session.
  • Rejecting is free: Claude simply tries another way or asks you what you want.

5. Hands-On Activity / กิจกรรมลงมือทำ / 动手练习

แบบฝึกหัด: ขอให้ Claude สร้างไฟล์ชื่อ 'greeting.txt' พร้อมข้อความทักทาย จากนั้นขอให้แก้ไขไฟล์เพื่อเพิ่มบรรทัดที่สอง
练习:让 Claude 创建一个名为 'greeting.txt' 的文件,写入一句问候语。然后让它编辑文件,添加第二行。
Practice: Ask Claude to create a file called 'greeting.txt' with a hello message. Then ask it to edit the file to add a second line.

Step by step

  1. Start claude in a test folder (make one with mkdir test && cd test).
  2. Say: Create a file called greeting.txt with a hello message — approve with y.
  3. Say: Add a second line to greeting.txt that says goodbye — check the diff, approve.
  4. Say: Read greeting.txt to see the final file.

✓ You did it right if: greeting.txt shows two lines — your hello and your goodbye.

📜 A complete Read / Write / Edit session / ตัวอย่างคำตอบ / 示例答案
> Create a file called greeting.txt with a hello message
* Write(greeting.txt)
    1  Hello from Chiang Mai!
  Allow? (y/n) > y
  Created greeting.txt

> Add a second line to greeting.txt that says goodbye
* Edit(greeting.txt)
    Hello from Chiang Mai!
  + Goodbye, see you tomorrow!
  Allow? (y/n) > y
  Edited greeting.txt - only the shown lines changed

> Read greeting.txt
    1  Hello from Chiang Mai!
    2  Goodbye, see you tomorrow!

6. Reference Table / ตารางอ้างอิง / 参考表

Command / ToolEnglishภาษาไทย中文
ReadView file contents (up to 2000 lines)ดูเนื้อหาไฟล์ (สูงสุด 2000 บรรทัด)查看文件内容(最多 2000 行)
WriteCreate or overwrite a fileสร้างหรือเขียนทับไฟล์创建或覆盖文件
EditReplace specific text in a fileแทนที่ข้อความเฉพาะในไฟล์替换文件中的特定文本
BashRun shell commandsรันคำสั่งเชลล์运行 shell 命令

7. Interactive Lab / ห้องทดลอง / 互动实验室

Drive the Read / Write / Edit loop yourself — including the diff and the y/n gate. / ลองใช้ Read / Write / Edit ด้วยตัวเอง / 亲手试试 Read / Write / Edit 工具

The file on disk: greeting.txt

Read shows the file instantly. Edit shows a diff and waits for your y / n — nothing changes until you approve.

8. Summary / สรุป / 总结

เครื่องมือไฟล์หลักของ Claude Code คือ Read, Write และ Edit Read ดูไฟล์ Write สร้างไฟล์ และ Edit แก้ไขส่วนเฉพาะ Present Simple (เติม -s สำหรับ he/she/it) อธิบายสิ่งที่เครื่องมือทำ
Claude Code 的核心文件工具是 Read、Write 和 Edit。Read 查看文件,Write 创建文件,Edit 修改特定部分。一般现在时(he/she/it 加 -s)用来描述工具的功能。
Claude Code's core file tools are Read, Write, and Edit. Read views files, Write creates them, and Edit changes specific parts. Present Simple (adds -s for he/she/it) describes what tools do.

Homework / การบ้าน / 作业

1. ใช้ Claude อ่านไฟล์สามประเภทที่แตกต่างกัน
2. สร้างไฟล์ Python ใหม่ด้วย Claude
3. เขียน 5 ประโยคโดยใช้ Present Simple เกี่ยวกับเครื่องมือของ Claude
1. 用 Claude 读取三种不同类型的文件。
2. 和 Claude 一起创建一个新的 Python 文件。
3. 用一般现在时写 5 个关于 Claude 工具的句子。
1. Use Claude to read three different file types.
2. Create a new Python file with Claude.
3. Write 5 sentences using Present Simple about Claude's tools.