<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-does-claude-code-actually-work-let-s-make-our-own-0paeeuy8e" -->

---
title: How Does Claude Code Actually Work? Let's Make Our Own
description: A breakdown of how Claude Code works under the hood, covering the five core building blocks of an AI coding agent: the LLM model, tools, memory, context...
canonical: https://daily.dev/posts/how-does-claude-code-actually-work-let-s-make-our-own-0paeeuy8e
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How Does Claude Code Actually Work? Let's Make Our Own | daily.dev
og:description: A breakdown of how Claude Code works under the hood, covering the five core building blocks of an AI coding agent: the LLM model, tools, memory, context...
og:url: https://daily.dev/posts/how-does-claude-code-actually-work-let-s-make-our-own-0paeeuy8e
og:image: https://api.daily.dev/og/posts/0pAEeuY8E.png
og:image:alt: How Does Claude Code Actually Work? Let's Make Our Own
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How Does Claude Code Actually Work? Let's Make Our Own

**[Tech With Tim](https://daily.dev/sources/TechWithTim)** · 31 min read · 4 upvotes · 0 comments

## Summary

A breakdown of how Claude Code works under the hood, covering the five core building blocks of an AI coding agent: the LLM model, tools, memory, context window, and guardrails. The LLM is demystified as a stateless text predictor that outputs structured tool-call requests, while the agentic harness handles the actual execution loop. Memory is implemented as files injected into the context, and guardrails are simple software-level if-statements requiring human approval for destructive actions. A minimal working clone is built in ~300 lines of Python using the Anthropic SDK, demonstrating the model file, context assembly, tool definitions vs. implementations, and the agent loop.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=vp6Dlx5aHDU>

## Questions this post answers

### How does Claude Code decide when to stop calling tools and give a final answer?

The model itself signals when to stop by returning plain text output instead of a tool call. If the model's response contains no tool-use request, the harness treats that as the end of the turn and terminates the loop rather than triggering another model call, since it means the model is not waiting on any tool result.

_Developers building or debugging agent loops can dig deeper into harness design patterns on daily.dev._

### How does an AI coding agent like Claude Code actually call tools if the model can only output text?

The model never executes anything itself; it only predicts text, and when it wants to use a tool it outputs structured JSON specifying a tool name and arguments. Separate software called the harness parses that JSON, runs the actual tool implementation (like reading a file or executing bash), and feeds the result back into the model's context so it can continue.

_Anyone building an agent harness can compare implementation approaches on daily.dev._

### How does memory work in Claude Code if the underlying LLM has no memory between turns?

The model itself is stateless and remembers nothing between calls; persistent memory is implemented as files, such as a CLAUDE.md file that is always loaded into the prompt, plus a memory folder and skill markdown files that get read into context only when needed. Anything the agent 'remembers' had to be re-injected into the context window on every call.

_Developers designing agent memory systems can track these architecture patterns on daily.dev._

## Similar posts on daily.dev

- [Components of A Coding Agent](https://daily.dev/posts/components-of-a-coding-agent-owpdoz5b4) · Sebastian Raschka · 2 upvotes · 0 comments
- [The Emperor Has No Clothes: How to Code Claude Code in 200 Lines of Code](https://daily.dev/posts/the-emperor-has-no-clothes-how-to-code-claude-code-in-200-lines-of-code-ip0liwwaj) · Hacker News · 1 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#llm](https://daily.dev/tags/llm), [#ai-agents](https://daily.dev/tags/ai-agents), [#claude-code](https://daily.dev/tags/claude-code)

[View this post on daily.dev](https://daily.dev/posts/how-does-claude-code-actually-work-let-s-make-our-own-0paeeuy8e)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How Does Claude Code Actually Work? Let's Make Our Own","url":"https://daily.dev/posts/how-does-claude-code-actually-work-let-s-make-our-own-0paeeuy8e","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-does-claude-code-actually-work-let-s-make-our-own-0paeeuy8e"},"datePublished":"2026-07-30T12:49:09.768Z","dateModified":"2026-09-13T18:41:57.126Z","description":"A breakdown of how Claude Code works under the hood, covering the five core building blocks of an AI coding agent: the LLM model, tools, memory, context...","image":"https://i.ytimg.com/vi/vp6Dlx5aHDU/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/vp6Dlx5aHDU/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Tech With Tim","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Tech With Tim","logo":"https://media.daily.dev/image/upload/s--6vVIDfU0--/f_auto/v1711726146/logos/TechWithTim","url":"https://daily.dev/sources/TechWithTim"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-does-claude-code-actually-work-let-s-make-our-own-0paeeuy8e","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":4},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python,llm,ai-agents,claude-code","timeRequired":"PT31M","video":{"@type":"VideoObject","name":"How Does Claude Code Actually Work? Let's Make Our Own","description":"A breakdown of how Claude Code works under the hood, covering the five core building blocks of an AI coding agent: the LLM model, tools, memory, context...","thumbnailUrl":"https://i.ytimg.com/vi/vp6Dlx5aHDU/sddefault.jpg","uploadDate":"2026-07-30T12:49:09.768Z","duration":"PT31M","url":"https://api.daily.dev/r/0pAEeuY8E","embedUrl":"https://www.youtube.com/embed/vp6Dlx5aHDU"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Tech With Tim","item":"https://daily.dev/sources/TechWithTim"},{"@type":"ListItem","position":3,"name":"How Does Claude Code Actually Work? Let's Make Our Own"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-does-claude-code-actually-work-let-s-make-our-own-0paeeuy8e#faq","mainEntity":[{"@type":"Question","name":"How does Claude Code decide when to stop calling tools and give a final answer?","acceptedAnswer":{"@type":"Answer","text":"The model itself signals when to stop by returning plain text output instead of a tool call. If the model's response contains no tool-use request, the harness treats that as the end of the turn and terminates the loop rather than triggering another model call, since it means the model is not waiting on any tool result. Developers building or debugging agent loops can dig deeper into harness design patterns on daily.dev."}},{"@type":"Question","name":"How does an AI coding agent like Claude Code actually call tools if the model can only output text?","acceptedAnswer":{"@type":"Answer","text":"The model never executes anything itself; it only predicts text, and when it wants to use a tool it outputs structured JSON specifying a tool name and arguments. Separate software called the harness parses that JSON, runs the actual tool implementation (like reading a file or executing bash), and feeds the result back into the model's context so it can continue. Anyone building an agent harness can compare implementation approaches on daily.dev."}},{"@type":"Question","name":"How does memory work in Claude Code if the underlying LLM has no memory between turns?","acceptedAnswer":{"@type":"Answer","text":"The model itself is stateless and remembers nothing between calls; persistent memory is implemented as files, such as a CLAUDE.md file that is always loaded into the prompt, plus a memory folder and skill markdown files that get read into context only when needed. Anything the agent 'remembers' had to be re-injected into the context window on every call. Developers designing agent memory systems can track these architecture patterns on daily.dev."}}]}
```

