Module 13 • Advanced

Working with Files

Learn how OpenClaw reads, writes, edits, and organizes files safely with trash > rm and git safety rules.

📊 Module Progress

Complete objectives and quizzes to unlock your badge!
0/9 Tasks Completed

🎯 Learning Objectives

Read Files — View contents of text files and documents using the read tool.
Write Files — Create new files or overwrite existing files using the write tool.
Edit Files — Make targeted changes to existing files with the edit tool.
Organize Safely — Move, rename, and delete files safely using trash instead of rm.

📚 Theory

What OpenClaw Can Do with Files

OpenClaw can read, write, and edit files on your computer (with permission). This transforms it from a chat bot into a file management assistant.

1. Read Files

2. Write Files

3. Edit Files

4. Organize Files

⚠️ Safety First!

Danger Zone: Using rm (delete) is permanent on most systems. There's no "Recycle Bin."

Safe Zone: Using trash moves files to Recycle Bin/Trash. You can recover them!

File Operation Tools

OpenClaw uses these tools (you don't need to type these, JiXe uses them):

1. read

Read contents of a file.

Tool: read
Path: "C:\Users\User\notes.txt"
→ Returns file contents

2. write

Create a new file or overwrite existing.

Tool: write
Path: "C:\Users\User\new-file.txt"
Content: "Hello World!"
→ Creates file with that content

3. edit

Make targeted changes to a file.

Tool: edit
Path: "C:\Users\User\file.txt"
Old text: "Hello"
New text: "Hi"
→ Changes "Hello" to "Hi" in the file

Real-World Examples

Example 1: Reading a Config File
You: "Read my openclaw.json config." JiXe: uses read tool → shows the file contents in chat.

Example 2: Creating a Note
You: "Create a file called 'ideas.txt' with my project ideas." JiXe: uses write tool → "Done! Created ideas.txt."

Example 3: Fixing a Typo
You: "In TOOLS.md, change 'Brevo' to 'SendBlue'." JiXe: uses edit tool → "Fixed! Changed 'Brevo' to 'SendBlue'."

Example 4: Safe Deletion
You: "Delete old-notes.txt." JiXe: uses trash tool → "Moved old-notes.txt to Recycle Bin."

🔒 Git Safety Rules (Important!)

If you're working with code:

  1. ALWAYS check pwd (print working directory) before git operations
  2. NEVER run git reset --hard without confirming directory
  3. Use git status to see what's changed before committing

True story: On April 5, 2026, JiXe accidentally deleted the entire workspace with git reset --hard. Never again!

Key Takeaway

File operations make OpenClaw powerful — but with great power comes great responsibility. trash > rm, always verify paths, and be careful with git!

🧪 Hands-On Exercise

Practice file operations safely in a simulated environment.

Step 1: Read a File

You: "Read the file TOOLS.md and tell me what API keys are stored."

JiXe: uses read tool → "I found these API keys in TOOLS.md: Brevo, Gemini, Groq (expired), Brave Search..."

Step 2: Create a New File

You: "Create a file called 'my-ideas.txt' with content: 'Idea 1: Build an AI course. Idea 2: Learn coding.'"

JiXe: uses write tool → "Created my-ideas.txt with your ideas!"

Step 3: Edit the File

You: "Add 'Idea 3: Start a YouTube channel' to my-ideas.txt."

JiXe: reads file, then uses write tool to append → "Added Idea 3 to the file!"

Step 4: Safe Deletion

You: "Delete the file 'old-draft.txt'."

JiXe: uses trash tool → "Moved old-draft.txt to Recycle Bin. You can recover it if needed."

Step 5: Git Safety Check

Scenario: You're in a git repo and want to reset.

JiXe: "Before I do anything, let me check where we are." uses pwd → "We're in /workspace/projects/criticalyx/. Safe to proceed."

📝 Quiz: File Operations Mastery

Q1: Which command is safer for deleting files?

A
rm
B
trash
C
delete
D
shred

Q2: What does the read tool do?

A
Deletes files
B
Reads file contents
C
Writes new files
D
Edits images

Q3: What does the edit tool do?

A
Reads files
B
Makes targeted changes to existing files
C
Deletes files
D
Plays music

Q4: Before running git reset --hard, you should:

A
Just do it
B
Check current directory with pwd
C
Delete everything
D
Panic

Q5: What happened on April 5, 2026?

A
Nothing special
B
Workspace was accidentally deleted with git reset --hard
C
OpenClaw was born
D
Christmas came early
📁
Badge Earned!
File Manager 📁

You've completed all objectives and quizzes!