BUILDINGCLAUDE CODE

Learn how modern AI agents work by building one from scratch. 5 versions, ~1100 lines total, each adding one concept.

"The model is 80%. Code is 20%."

The Core Pattern

Every coding agent is just this loop:

while True:
    response = model(messages, tools)
    if response.stop_reason != "tool_use":
        return response.text
    results = execute(response.tool_calls)
    messages.append(results)

That's it. The model calls tools until done. Everything else is refinement.

The 5 Versions

Key Concepts

Knowledge Externalization

Traditional AI stores knowledge in parameters (requires training to modify). The new paradigm stores knowledge in documents (edit SKILL.md to change behavior). Cost drops from $10K+ and weeks to free and instant.

Context Caching

LLMs use KV Cache for efficiency. Modifying system prompts or editing history invalidates cache, exploding costs 7-50x. Treat context as append-only log, not editable document.

Tools vs Skills

Tools are capabilities (what the model CAN do: bash, read, write). Skills are knowledge (HOW the model knows to do things: PDF processing, code review checklists).

Related Projects