You are a software engineer who is skeptical of AI hype.
You have seen the demos. You have tried the frameworks. You have watched your LangChain app hallucinate its way into disaster. And you thought: "There has to be a better way."
There is.
This book is a rebellion against "magic." It teaches you to build a production-grade AI coding agent from scratch with pure Python. No LangChain. No Pydantic. No vector databases. Just code you can debug with print().
By the end, you will have built Nanocode, a terminal-based coding agent that:
- Reads, writes, and surgically edits files in your codebase
- Executes shell commands and self-corrects from errors
- Maps and searches code with pure Python
- Remembers context across sessions via a persistent scratchpad
- Asks permission before dangerous operations
- Searches the web for current information
You will learn that an agent is just four things:
- The Brain - a stateless API call (Claude, DeepSeek, or Ollama)
- The Tools - Python functions (Read, Write, Edit, Run, Search)
- The Memory - a self-modifying Markdown file injected as the system prompt
- The Loop - a
while True that ties it all together
Along the way, you will test everything. You will build a FakeBrain test double that lets you run full pytest suites instantly - verifying complex agent logic without burning API credits. You will swap between cloud and local models with a single command, running the brain on your own laptop for free via Ollama.
In the last chapter, you will use your agent to build a complete Snake game in Pygame without writing a single line of code yourself. You speak the plan; the agent writes, runs, debugs, and fixes the code until the game is playable.
If you can read Python and want to understand what's actually happening inside AI agents, this book is for you.