How to Get Started with learn-claude-code: From Zero to AI Agent
I wanted to build an AI agent, but every tutorial I found led me straight into framework quicksand. LangChain this, CrewAI that, AutoGen everywhere. Twenty dependency installs later, I still didn’t understand what an agent actually does.
Then I found learn-claude-code. Twelve sessions. Each one adds exactly one concept. No framework magic, just raw Python showing you the harness mechanisms that make agents work.
Here’s how to get started.
The Setup Problem
I cloned the repo, installed dependencies, and ran the first agent:
git clone https://github.com/shareAI-lab/learn-claude-codecd learn-claude-codepip install -r requirements.txtpython agents/s01_agent_loop.pyI got an error immediately:
anthropic.AuthenticationError: Error code: 401 - {'error': {'type': 'authentication_error', 'message': 'Invalid API Key'}}Of course. I hadn’t configured my API key.
Configuration: What Actually Matters
The repository uses a .env file for configuration. Here’s what you need:
ANTHROPIC_API_KEY=sk-ant-your-key-hereMODEL_ID=claude-sonnet-4-6That’s it. Two environment variables. No complex config files, no service accounts, no cloud provisioning.
Copy the example file and add your key:
cp .env.example .env# Edit .env with your actual API keyThe .env.example file shows additional options for other providers (MiniMax, GLM/Zhipu, Kimi/Moonshot, DeepSeek), but if you’re using Anthropic directly, you just need the key.
Running Your First Agent
With the API key configured, I ran the first session again:
python agents/s01_agent_loop.pyThe agent started and waited for input. I typed:
Create a file called hello.py that prints "Hello, World!"The agent thought for a moment, then executed:
Created file: hello.pyI checked the file:
print("Hello, World!")It worked. A 30-line Python script had just created code for me.
Understanding What Just Happened
The s01_agent_loop.py file contains the minimal agent pattern. It’s not a framework, it’s a loop:
+-------------+ +-------------+ +-------------+| User | --> | Claude | --> | Tools || Input | | API | | (bash, || | | | | read, || | | | | write) |+-------------+ +-------------+ +-------------+ ^ | | v +--------------------+ Tool results feed back to ClaudeThe loop works like this:
- User input goes to Claude
- Claude decides: respond with text OR call a tool
- If tool called: execute it, send result back to Claude
- Repeat until Claude responds with text only
This is the core of every AI agent. Everything else (planning, subagents, teams) builds on this loop.
The Learning Path: Why 12 Sessions?
The repository is structured as 12 progressive sessions. Each session adds ONE mechanism:
| Phase | Sessions | What You Learn |
|---|---|---|
| THE LOOP | s01-s02 | Agent loop, tool use |
| PLANNING & KNOWLEDGE | s03-s06 | TodoWrite, subagents, skills, context compaction |
| PERSISTENCE | s07-s08 | Tasks, background tasks |
| TEAMS | s09-s12 | Agent teams, protocols, autonomous agents, worktree isolation |
I made the mistake of jumping to s12 first. Don’t do that. The sessions are cumulative:
- s01: 1 tool (the minimal loop)
- s02: 4 tools (add read/write/edit)
- s12: 16 tools (all mechanisms combined)
Each session is under 100 lines. You can read the whole thing in 5 minutes and understand exactly how it works.
Things to Try with s01
The minimal agent loop can already do useful work. Some examples I tested:
1. List all Python files in this directory2. What is the current git branch?3. Create a directory called test_output and write 3 files in it4. Read the README.md and summarize it in 3 bullet pointsThe key insight: s01 has only bash tool access. It can’t read or write files directly—it uses shell commands. Session s02 adds proper file tools.
When to Progress to Next Sessions
I stayed on s01 for a while, testing edge cases. Then I hit a limitation: I wanted the agent to read a file and analyze its contents.
s01 can do this via bash (cat file.txt), but s02 makes it cleaner with a dedicated read tool. The progression feels natural—each session solves a problem you encounter in the previous one.
Web Platform Alternative
If you prefer interactive learning over cloning the repo, the project also offers a web platform for hands-on practice. Check the documentation in docs/en/ for details.
The docs are also available in Chinese (docs/zh/) and Japanese (docs/ja/) if that helps.
What I Wish I Knew Earlier
-
Read the code, not just run it. Each session is tiny. Understanding the 30 lines of s01 will teach you more than running s12 blind.
-
The API costs money. Start with simple prompts.
claude-sonnet-4-6is reasonably priced, but complex operations add up. -
Tools are just functions. The “tool” abstraction is a Python function that returns a result. No magic.
-
The loop IS the agent. Frameworks add orchestration, memory, RAG, etc. But underneath, it’s always this loop.
Next Steps
After s01, I recommend this order:
python agents/s02_tool_use.py # Add file operationspython agents/s03_todowrite.py # Add planningpython agents/s04_subagents.py # Add task delegationpython agents/s05_skills.py # Add reusable skillspython agents/s06_context_compact.py # Add memory management# ... continue through s12Or jump around based on what you’re curious about. The sessions are independent enough that you can explore out of order.
Summary
learn-claude-code strips away framework complexity and shows the raw mechanisms of AI agents. Start with:
git clone https://github.com/shareAI-lab/learn-claude-codecd learn-claude-codepip install -r requirements.txtcp .env.example .env # Add your ANTHROPIC_API_KEYpython agents/s01_agent_loop.pyProgress through the 12 sessions. By the end, you’ll understand how production agents are architected—because you’ll have built each mechanism yourself.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments