I built a coding agent from scratch to see what's inside
Description and use
The author built a 565‑line Python agent to reveal that coding agents loop by sending prompts to a model, executing requested tools locally, and repeating until the model answers directly.
Problem
The author could not explain what coding agents do between the prompt and the file edit, so they built one to understand the internal loop.
Outcome
The author discovered that coding agents operate by sending the conversation to a model, executing tools requested by the model, and looping until the model provides a direct answer. The model never edits files; the local machine performs all file operations.
Workflow
- 1. Define tools (Read, Write, Bash) and give them to the model.
- 2. Run the agent loop: send conversation to model, execute requested tools, return results, repeat until model answers directly.
- 3. Validate tool calls with Pydantic.
- 4. Implement skills, slash commands, and arguments.
- 5. Create Skill tool and subagents with their own conversations.
- 6. Test each stage with tagged commits and a command that proves it works (e.g.,
just stage 4 cd .stages/04 just run "How many carrots does the rabbit eat per day, according to rabbit.py?").
Evidence
Claude Code, Cursor and Codex all run the same loop: send the conversation to a model, run the tools it asks for, send back the results, repeat until the model just answers.
The model never touches your files. It only asks, and your machine does the work.
petite is that loop, written from scratch in 565 lines of Python.
Every stage is a tagged commit that runs on its own. The site gives you a task for each one, keeps the solution folded until you want it, and has a command that proves it works:
- Record date: 2026-10-04T23:56:02.440Z