Latest / AI Fire Daily / #656 Neil: How I Built A Karpathy Clone With Claude Code In 5 Steps
Transcript
- 0:00What if you could actually bottle a genius mind?
- 0:02Imagine keeping them right there on your desktop
- 0:05as a mentor. That is kind of the ultimate dream,
- 0:07right? Welcome to the Deep Dive. Today, you and
- 0:10I are unpacking a truly fascinating AI experiment.
- 0:13Yeah, it's a really good one. A developer built
- 0:15a highly customized Claude code agent entirely
- 0:17from scratch. They wanted to perfectly clone
- 0:20the teaching style of Andre Karpathy. It is a
- 0:23profoundly interesting concept to explore. Karpathy
- 0:26is obviously a towering figure in our industry.
- 0:28I mean, he was one of the founding members of
- 0:30OpenAI. He previously led the autopilot engineering
- 0:33team over at Tesla. And now he is building his
- 0:37own company called Eureka Labs. He is incredibly
- 0:39famous for his educational tutorials online.
- 0:42Oh, absolutely. His Zero to Hero neural network
- 0:45series is basically legendary now. Yeah, he literally
- 0:49teaches you how to build AI from absolute scratch.
- 0:52Right. He never just throws complicated ideas
- 0:53at you blindly. He actually writes the code right
- 0:56there on the screen. Exactly. He explains every
- 0:59single mechanical step of the process very clearly.
- 1:02He even shows you exactly what happens when things
- 1:05inevitably break. But, you know, you obviously
- 1:08can't just message him when your code breaks.
- 1:10No, you definitely can't expect a personal lesson
- 1:12from a busy founder. Yeah, he's a little too
- 1:14busy for that. So this developer had a slightly
- 1:17crazy, highly ambitious idea. They decided to
- 1:21structurally build their own André Carpathy clone.
- 1:25They wanted a digital mentor that actually checks
- 1:27its own work. Right. Instead of an AI confidently
- 1:31handing you broken, hallucinated Python code.
- 1:33Which happens way too often. We are going to
- 1:36explore this entire architectural process today.
- 1:39We will look at how they systematically gathered
- 1:40the right data. And we'll structure an AI brain
- 1:43from the ground up together. We will encode specific
- 1:46behavioral rules for the autonomous agent. We
- 1:49will force the AI to rigorously verify its own
- 1:52work. And finally, we will test the finished
- 1:54clone in reality. It is a remarkable technical
- 1:58journey. Let's start with gathering the foundational
- 2:01brain itself. You clearly can't just tell an
- 2:03AI to act like Harpathi. No, you can't just feed
- 2:06it a few random technical articles. If you do
- 2:09that, you just get a superficial chatbot. Right.
- 2:11It will just hallucinate the specific technical
- 2:13details immediately. To build a true clone, you
- 2:17need his actual literal words. The developer
- 2:20systematically collected over 700 ,000 words
- 2:24initially. And that massive data set eventually
- 2:27grew to over 1 million words. Wow. They pulled
- 2:31from four primary public sources across the internet.
- 2:34They grabbed his YouTube lectures and his detailed
- 2:37educational tutorials. They also pulled his Twitter
- 2:40post dating all the way back to 2023. They collected
- 2:44long -form technical articles from his personal
- 2:46blog, and they meticulously downloaded his public
- 2:50GitHub software repositories. It is basically
- 2:53like packing a massive suitcase. You stuff it
- 2:56with every book, lecture, and note he has ever
- 2:59written before a long trip. That is a great analogy.
- 3:02They deployed some very specific technical tools
- 3:04for this collection phase. They used YouTube
- 3:07-Transcript -API to pull the precise video captions.
- 3:11They used YT -DLP to grab the necessary metadata
- 3:14and formatting. And they also leveraged TwitterAPI
- 3:17.io to systematically archive his social media
- 3:20posts. Exactly. But they didn't manually download
- 3:23all of this data themselves. Clodcode actually
- 3:27built the source collection pipeline on its own.
- 3:29Wait, really? No. It autonomously pulled the
- 3:32data and stored it cleanly for use. Yeah. It
- 3:35generated a specific project folder named Carpathy
- 3:38-Brain. Inside that architecture, it established
- 3:41a dedicated raw data directory. So the AI wrote
- 3:45a Python script to gather everything entirely
- 3:48automatically. It is an incredibly efficient
- 3:50way to handle data ingestion. But scraping a
- 3:53million words from the internet can be incredibly
- 3:55messy. I mean, you might pull the same exact
- 3:58YouTube transcript three different times. That
- 4:01is exactly why they created a CriticalManifest
- 4:03.json file. Ah, okay. This specific manifest
- 4:07file acts as a strict inventory control system.
- 4:10It rigorously tracks the exact word counts for
- 4:13every single document. It completely prevents
- 4:16any duplicate files from corrupting the dataset.
- 4:18Wait, does it just scrape everything blindly
- 4:21and guess the missing parts? No. The strict manifest
- 4:24prevents the AI from inventing missing data.
- 4:27So it acts like a strict bouncer for incoming
- 4:30files. Got it. It is a crucial safeguard for
- 4:32data integrity. So we have a million words sitting
- 4:38on a hard drive now. But raw data is basically
- 4:42just a chaotic, messy pile. Yeah, it's pretty
- 4:44much useless in that state. To make it genuinely
- 4:47useful, the AI needs rigid, underlying structure.
- 4:51It needs to know how to logically connect the
- 4:53conceptual dots. Exactly. It is like stacking
- 4:57Lego blocks of data into a perfectly organized
- 5:00library. You cannot just dump raw text files
- 5:03into an AI prompt. The developer converted everything
- 5:06into an interconnected markdown wiki. This architecture
- 5:10was actually directly inspired by Karpathy's
- 5:12own wiki framework. It was. The wiki meticulously
- 5:16grouped the raw data by its underlying meaning.
- 5:18So it deliberately linked related technical concepts
- 5:21together on specific internal pages. Right, and
- 5:24it cleanly grouped various debugging approaches
- 5:26and broad engineering principles together. They
- 5:30also established a very important project level
- 5:32memory file. Yeah, a configuration file specifically
- 5:35called Claude .md. This file effectively establishes
- 5:38the fundamental rules of engagement here. It
- 5:41essentially tells the AI exactly how to navigate
- 5:43the library. The rules explicitly force the AI
- 5:46to read quick summaries first. These brief summaries
- 5:50are stored in a file called hot .md. It also
- 5:53rigorously forces the AI to trace factual claims
- 5:56back. It absolutely must link its statements
- 5:58back to the raw sources. Right, and it strictly
- 6:01separates documented facts from its own interpretations.
- 6:04That is huge. The agent cannot pretend an inferred
- 6:08opinion is a documented historical fact. It has
- 6:10to clearly state whenever it is making an educated
- 6:13guess. It even maintains a special directory
- 6:16just for uncertain findings. If concrete evidence
- 6:19is missing, it marks the claim as unverified.
- 6:23It is a deeply scientific approach to personal
- 6:26knowledge management. It fundamentally prevents
- 6:28the AI from making sweeping, unverified technical
- 6:31assumptions. Wait, if it is just reading Markdown,
- 6:34how does it handle contradicting sources over
- 6:37time? It preserves the disagreements and highlights
- 6:40the original publication dates. So it treats
- 6:43changing opinions like a historical timeline.
- 6:46Makes sense. Yeah. Human experts constantly evolve
- 6:49their technical opinions over time. So with the
- 6:52comprehensive library built, we need a competent
- 6:54librarian. We need an autonomous AI that actually
- 6:58thinks like the master. We need to explicitly
- 7:00give it his personality and specific skills.
- 7:03The developer cleverly used Claude code for this
- 7:06critical next step. They specifically instructed
- 7:08it to extract seven distinct thinking rules.
- 7:11It pulled these behavioral rules directly from
- 7:14the compiled Markdown Wiki. These extracted rules
- 7:16include several classic Karpathy educational
- 7:19stables. Like, you always build small examples
- 7:22to truly understand complex concepts. You absolutely
- 7:25must predict results before running any new code.
- 7:28You also deliberately show failures to explain
- 7:30why they actually happen. You must verify all
- 7:33technical claims using evidence and real tests.
- 7:37And you should always prefer simple solutions
- 7:39over unnecessary structural complexity. We just
- 7:42easier said than done, obviously. I mean, I still
- 7:44wrestle with prompt drift myself, honestly. Oh,
- 7:47we all do. It's a huge problem. So locking in
- 7:50these specific behavioral rules at the system
- 7:52level is brilliant. It physically stops the AI
- 7:55from wandering off into generic answers. It keeps
- 7:57the autonomous aging incredibly focused and highly
- 8:00disciplined, structurally. This extraction process
- 8:04resulted in a dedicated Claude code sub agent.
- 8:08A sub agent is basically a highly specialized
- 8:11tightly -focused AI assistant. Exactly. It also
- 8:15created a reusable internal skill called slash
- 8:18carpathy dash teach. That specific command lets
- 8:22the user summon the personalized clone anytime.
- 8:25But the sub -agent is strictly instructed regarding
- 8:27its own internal identity. It absolutely must
- 8:30identify itself as being merely carpathy -inspired.
- 8:33It can never falsely claim to be the actual human
- 8:36being. It is a functional clone, but it inherently
- 8:39knows it is a clone. It is explicitly programmed
- 8:42to be entirely transparent about its artificial
- 8:44nature. Can this agent access unrelated projects
- 8:48on my local machine? No. All project operations
- 8:51remain entirely local and strictly contained.
- 8:54Good. So it won't rummage through my personal
- 8:57folders. Reassuring. Security and isolation are
- 8:59built directly into the agent workflow. They
- 9:03might write an entire script without checking
- 9:05if it works. Yeah. They might write an entire
- 9:07script without checking if it works. How do we
- 9:11physically force it to be academically rigorous?
- 9:14Well, we have to make it physically prove its
- 9:16work every time. This specific mechanism acts
- 9:19as a firm blocker for the AI. If the agent writes
- 9:22or modifies any actual code files, it cannot
- 9:25complete the designated task until it literally
- 9:28runs it. If it stubbornly tries to bypass this
- 9:30mandatory testing step, the software hook actively
- 9:33blocks it with a very specific message. The system
- 9:36message strictly says, Run it before you say
- 9:40it works. It is an incredibly powerful concept
- 9:43for personal software development. Whoa. Imagine
- 9:46having an automated mentor that forces you to
- 9:49be rigorous at 2am. It changes everything. Human
- 9:52developers naturally get fatigued and start skipping
- 9:55vital testing steps. This structural hook forces
- 9:58a very specific, unbreakable workflow on the
- 10:01AI. The mandatory sequence is predict, build,
- 10:05run, compare, and then explain. So it fundamentally
- 10:08must guess the output before it executes the
- 10:11script. Right. It cannot just run the code and
- 10:14act surprised by errors. It has to explicitly
- 10:16state its underlying hypothesis beforehand. The
- 10:19developer carefully ran 16 simulation tests on
- 10:22this specific hook. They desperately wanted to
- 10:24ensure it wouldn't create infinite automated
- 10:27loops. Yeah. You definitely don't want the AI
- 10:30endlessly retrying deeply broken code, burning
- 10:32through API tokens while stuck in an inescapable
- 10:35logic loop. The simulation's happily proved it
- 10:37handles failed tests safely. It inherently knows
- 10:40when to stop trying and simply ask for help.
- 10:43It clearly reports the unresolved technical problems
- 10:46back to the human user. Which is great. What
- 10:48happens if I just ask a conceptual question without
- 10:51writing code? The hook simply ignores it and
- 10:53allows the agent to answer normally. The blocker
- 10:56only triggers when actual code is modified, elegantly
- 10:59designed. It doesn't get in the way of a normal
- 11:01conversation unnecessarily. The strict rules
- 11:05are set and the data is heavily verified. The
- 11:07execution stop hook is actively running in the
- 11:10background. It is finally time for the ultimate
- 11:12comprehensive final test. The developer directly
- 11:16prompted the slash carpathy dash teach skill
- 11:19in their terminal. They asked it to independently
- 11:22build a small BPE tokenizer. They specifically
- 11:25wanted it built entirely from scratch in Python.
- 11:28And let's quickly clarify that term for a moment.
- 11:30A tokenizer chops text into small pieces an AI
- 11:33can read. Right. It is a completely fundamental
- 11:36part of modern large language models. Byte Pair
- 11:39Encoding is how they actually process our human
- 11:42language. The autonomous agent followed Carpathy's
- 11:45exact documented methods perfectly. It initially
- 11:48explained the basic underlying idea in highly
- 11:50beginner -friendly language. Then it clearly
- 11:53defined what a successful tokenizer should actually
- 11:56functionally do. It strategically built the absolute
- 11:59smallest working implementation first. It clearly
- 12:02predicted the exact text output before running
- 12:04the new code. Then it actively ran the code and
- 12:07compared the actual real results. It flawlessly
- 12:10passed 8 out of 8 required technical tests successfully.
- 12:14It successfully handled basic English text and
- 12:17highly complex Unicode characters. It even correctly
- 12:20processed visual emojis without throwing any
- 12:23unexpected errors. It also deliberately showed
- 12:26a highly meaningful failure case during testing.
- 12:29It explicitly explained what went wrong and exactly
- 12:31how to fix it. It properly cited relevant educational
- 12:34sources from the compiled Karpathy knowledge
- 12:36base. Right, and the stop hook actively worked
- 12:39in a real interactive session. The agent lazily
- 12:42tried to finish without testing its code exactly
- 12:44once. The background hook instantly blocked it
- 12:47and forced it to run tests. This completely validates
- 12:50the entire crazy experiment for me, conceptually.
- 12:52The digital clone actually functions exactly
- 12:54as they originally intended. It strictly follows
- 12:57the rules and actively catches its own programming
- 12:59mistakes. It conclusively proves the underlying
- 13:01software architecture is solid and highly reliable.
- 13:05Can you easily update the clone when Carpathi
- 13:08releases a new video? Yes, you just feed the
- 13:10new content into the existing pipeline. It digests
- 13:12the new material and keeps on growing. Fascinating.
- 13:15It effectively acts as a continuously evolving
- 13:17digital brain. We will explore what this means
- 13:21for the future shortly, sponsor. We have covered
- 13:25a tremendous amount of conceptual ground today.
- 13:27Let's take a moment to step back and look at
- 13:29the big picture. We really need to carefully
- 13:31distill the core insight here. This deeply fascinating
- 13:35experiment isn't just about cloning Andrej Karpathy
- 13:38specifically. It is fundamentally about a replicable,
- 13:42scalable framework for artificial AI mentorship.
- 13:46You meticulously combine a highly curated knowledge
- 13:49base like the Markdown Wiki. You structurally
- 13:52add strict behavioral principles via the dedicated
- 13:55Claude sub -agent. You rigorously enforce academic
- 13:59integrity with a mandatory execution stop hook.
- 14:02Literally anyone can build an autonomous AI clone
- 14:04of their favorite expert. You simply need their
- 14:07public data and their deeply documented methods.
- 14:11It can fundamentally act as a highly personalized,
- 14:14endlessly patient mentor. Seriously, think about
- 14:17whose specific brain you would want to download.
- 14:20Who would you actively turn into a custom, personalized
- 14:24clot agent? It could dramatically change how
- 14:27we learn complex technical skills forever. You
- 14:30are simply no longer limited by your geographic
- 14:34access to experts. If we can mathematically clone
- 14:37the methodologies of our professional heroes,
- 14:39what actually happens when we use these same
- 14:42software tools on ourselves? That is wild to
- 14:45think about. Could you eventually pair program
- 14:47with an idealized, perfectly rigorous version
- 14:50of yourself? Imagine seamlessly pair programming
- 14:53with a highly focused version of yourself. A
- 14:56perfectly rigorous version that literally never
- 14:58gets tired or lazy. That is definitely something
- 15:03to deeply mull over tonight. Thank you for joining
- 15:06us on this deep dive. Keep questioning everything
- 15:09around you.