# Build Your Own AI Coding Agent From Scratch

A step-by-step, chapter-based tutorial that builds an AI coding agent from scratch in TypeScript, covering the agent loop, tools, file editing, context, permissions, subagents and streaming.

This tutorial takes a reader from zero to a working AI coding agent using only TypeScript and an LLM API, with no framework in between. Each of its fourteen chapters introduces one concept, explains why it is designed that way, and comes with a runnable example, using Claude and the Anthropic SDK while noting that the same architecture works with any LLM that supports tool use.

By the end, the reader has built a CLI tool that reads, searches and edits files and runs commands, and has added streaming, permissions, subagents, context compression and concurrent tool execution -- the same core ideas behind tools such as Claude Code and Cursor. It assumes basic TypeScript knowledge, Node.js 18 or newer, and an Anthropic API key, and is aimed at developers who learn best by building rather than only reading.

Website: https://github.com/nauvalazhar/build-your-own-ai-coding-agent
