What I learned building a tiny Claude Code

Published by LEARN Desk with Ravenclip

Almost every software engineer has used Claude Code, Codex, or Cursor by now. I always wondered how the LLM navigates through my codebase, changes files, and investigates & reports things when prompted. Spoiler: it doesn't, it's just a loop and a few tools. So I've decided to build a lightweight Claude Code clone in TypeScript on top of the Anthropic API to learn the core principles. Then added custom subagents. The whole agentic loop is: send the conversation -> if the model's stop_reason is tool_use, run the requested tool, append the result, loop again -> stop when it's end_turn. That's it. "Reading a file" is just a view tool the model chooses to call. Tools execution happens on your local machine. A subagent isn't a new system - it's the same loop, called recursively, with a smaller toolset and its own prompt and often a model. I've implemented the "task" tool, which the main agent uses to delegate. Three bugs taugh

What the video says

Nearly every software engineer is now using AI coding tools, but the magic behind how they navigate codebases is surprisingly simple. A developer building a lightweight Claude code clone in TypeScript on the Anthropic API has demystified this process, revealing it is just a basic loop running local tools.

The loop simply sends the conversation, executes a local tool if the model requests it, appends the result, and repeats until the turn ends. Even complex subagents are not new systems but rather the same loop called recursively with smaller toolsets.

While building the clone, 3 specific bugs revealed that tool descriptions act as critical API surfaces and must be highly precise to avoid routing errors. The developer also discovered that prompts merely shift probability rather than strictly constraining a model's behavior.

Ultimately, this project proves that delegating tasks to AI agents relies on clear descriptions and probabilistic guidance rather than complex system architecture.

Create a channel like this

Pick your topic. Ravenclip makes and posts videos like this on autopilot.

Start my channel