<>
There’s a category of software that feels magical until you understand how it works, and then it feels inevitable. AI coding agents are like that. You watch Claude Code or similar tools read files, run commands, and edit code based on a natural language description — and it looks like sorcery.
It’s not. Under the hood, it’s a loop: call an LLM, check if it wants to use tools, execute those tools, feed the results back, and repeat until the model is satisfied. The complexity is in the details — streaming, tool definitions, permissions, state management, and the terminal UI that stitches it all together.
This guide walks through building a terminal-based SWE agent in 10 iterations. You’ll go from bun init to a working agent with streaming AI responses, tool execution, slash commands, permissions, and state management. The target audience is React engineers who haven’t built AI agents before.
The full implementation runs about 15,000-20,000 lines of TypeScript and takes roughly 2-3 months of full-time work.
