How to build your own Agentic Code Editor
Sep 11, 2025

How to build your own Agentic Code Editor (Step by Step)
Build a tiny terminal coding agent in Python that chats with Claude and can read, list, and edit files. It’s fast to set up and easy to extend. You’ll go from zero to working in minutes.
What you will build
- A minimal chatbot with Anthropic’s Claude main.py
- A basic agent loop that lets Claude edit code locally. run.py
- We will use three tools: read_file
, list_files
, and edit_file
.
Prerequisites
Step 1: Minimal terminal chatbot
The Anthropic messages API is stateless. This loop keeps your own conversation
, sends it each turn, and prints text blocks. We will build on this basic chatbot and extend it.
Step 2: Add tool plumbing (registry + execution loop)
We add a tiny tool registry and a loop that detects tool_use
blocks, runs the tool locally, and replies with tool_result
blocks. This mirrors the standard pattern in Anthropic’s docs.
The model emits tool_use
. You reply with tool_result
blocks in a user message, then call the API again. It's a while loop under the hood you execute the tools that the model is responding back to use. They are eager to use tools as their training datasets produce a model that "knows" how to use tools.
Step 3: Add the read_file
tool
Step 4: Add the list_files
tool
This is recursive and adds a trailing /
for directories.