Build AI Apps with Python: File System Tools — AI That Reads and Writes Files | Episode 9

Опубликовано: 30 Март 2026
на канале: Taught by Celeste AI - AI Coding Coach
5
0

Claude can now read, write, and list files on your computer! In this episode, we build three file system tools that
let AI interact with the real world — not just answer questions, but actually create and manage files.

A workspace directory keeps everything safe. All file operations happen inside it. Three questions test the full
workflow: create a file, list the workspace, read the file back. Claude picks the right tool every time.

Student code: https://github.com/GoCelesteAI/build-...

Every keystroke is shown on screen with 3-second pauses so you can follow along at your own pace.

What You'll Learn:
• Building read_file, write_file, and list_directory tools
• The os module for file system operations
• Workspace directory pattern for safe file access
• os.path.join for secure path construction
• os.path.exists for safety checks before reading
• os.makedirs with exist_ok for directory creation
• Same dispatch pattern from Episodes 7-8
• Tool schemas for file operations
• Three-question workflow: write → list → read
• Running Python scripts with :!python %

Timestamps:
0:00 - Introduction
0:12 - AI That Can Touch Files (Preview)
0:44 - Creating file_tools.py
1:00 - Imports (new: os module)
1:58 - Workspace directory — safe file access
2:25 - Tool 1: read_file — see inside any file
4:10 - Tool 2: write_file — create and overwrite files
5:40 - Tool 3: list_directory — see what exists
7:02 - Save progress
7:15 - Dispatch dictionary — three file tools
8:15 - Tool definitions — three JSON schemas
12:15 - Save tool definitions
12:28 - The ask() function
14:12 - Tool handling and dispatch
15:55 - Sending results back to Claude
18:12 - Three questions: write, list, read
19:12 - Save and run
19:18 - Claude manages files — write, list, read!
21:38 - Code review
21:58 - Recap: 3 Key Takeaways
22:30 - End Screen