Skip to content

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:

My first attempt
git clone https://github.com/shareAI-lab/learn-claude-code
cd learn-claude-code
pip install -r requirements.txt
python agents/s01_agent_loop.py

I got an error immediately:

The inevitable error
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:

.env file contents
ANTHROPIC_API_KEY=sk-ant-your-key-here
MODEL_ID=claude-sonnet-4-6

That’s it. Two environment variables. No complex config files, no service accounts, no cloud provisioning.

Copy the example file and add your key:

Setup steps
cp .env.example .env
# Edit .env with your actual API key

The .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:

Running the minimal agent loop
python agents/s01_agent_loop.py

The 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:

Agent action
Created file: hello.py

I checked the file:

hello.py
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 Claude

The loop works like this:

  1. User input goes to Claude
  2. Claude decides: respond with text OR call a tool
  3. If tool called: execute it, send result back to Claude
  4. 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:

PhaseSessionsWhat You Learn
THE LOOPs01-s02Agent loop, tool use
PLANNING & KNOWLEDGEs03-s06TodoWrite, subagents, skills, context compaction
PERSISTENCEs07-s08Tasks, background tasks
TEAMSs09-s12Agent 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:

Sample prompts to try
1. List all Python files in this directory
2. What is the current git branch?
3. Create a directory called test_output and write 3 files in it
4. Read the README.md and summarize it in 3 bullet points

The 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

  1. 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.

  2. The API costs money. Start with simple prompts. claude-sonnet-4-6 is reasonably priced, but complex operations add up.

  3. Tools are just functions. The “tool” abstraction is a Python function that returns a result. No magic.

  4. 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:

Recommended progression
python agents/s02_tool_use.py # Add file operations
python agents/s03_todowrite.py # Add planning
python agents/s04_subagents.py # Add task delegation
python agents/s05_skills.py # Add reusable skills
python agents/s06_context_compact.py # Add memory management
# ... continue through s12

Or 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:

Quick start commands
git clone https://github.com/shareAI-lab/learn-claude-code
cd learn-claude-code
pip install -r requirements.txt
cp .env.example .env # Add your ANTHROPIC_API_KEY
python agents/s01_agent_loop.py

Progress 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