Claude Code Agent from Scratch
An autonomous coding assistant that reads files, makes edits, and runs commands to solve tasks
Architectural Overview & Engineering Deep Dive
What is the Coding Agent?
It is a command-line developer assistant. You give it a task (like "Find where user authentication happens and add a check for expired sessions"), and it autonomously searches your files, reads the relevant code, makes the necessary edits, and runs tests to verify the fix.
Demystifying AI Agents
Commercial tools like Claude Code or Cursor often seem magical or overly complex. This project was built from first principles to show how an effective agent actually works under the hood without bloated frameworks:
- The Think-and-Act loop: The agent receives your goal, chooses an action (like reading a file or running a bash command), inspects the result, and repeats until the task is complete.
- Safe tool suite:
Read: Inspects files with line limits so it doesn't overwhelm memory.Write: Writes clean file updates safely.Bash: Spawns terminal commands with timeout safety so runaway scripts don't hang your machine.
- Works online or offline: Can connect to cloud models like Claude or run completely locally with free, private models via Ollama.
Architecture & Highlights
- Autonomous coding loop that plans actions, runs tools, and iterates to complete tasks
- Deterministic file tools: safe file reading, editing, and terminal command execution
- Works with local private models (via Ollama) or cloud frontier models
- Built from scratch in TypeScript on Bun without heavy agent frameworks
Technologies
Bun 1.3TypeScriptOpenAI SDKNode child processes
Changelog & Milestones
Releases & Major Commits
Architectural overhauls, major commits, and versioned release notes for Claude Code Agent from Scratch.