learn-claude-code
by shareAI-lab
Educational project that shows how to build a small agent harness like Claude Code from the ground up.
- Stars
- 80,862 stars
- Forks
- 13k forks
- Last push
- 10 days ago
- Activity
- Active
# Get the course$ git clone https://github.com/shareAI-lab/learn-claude-code
cd learn-claude-code
pip install -r requirements.txt# Run the first lesson$ python s01_agent_loop/code.pyCommands from the project's README. Run them after installing (see below).
Overview
Understand learn-claude-code in 60 seconds
- What it does
- Learn Claude Code is a hands-on course in harness engineering: building the code around a language model that turns it into a working coding agent, using Claude Code's design as the model. It has 17 lessons, each adding one mechanism with runnable Python.
- The problem it solves
- Many agent tutorials wire LLM calls into rigid workflows. This course argues that the model provides the intelligence and your job is the harness (tools, knowledge, context, permissions), and teaches each part step by step from a single agent loop.
- Why choose it
- Choose it to understand agent harnesses from first principles with small runnable examples. It uses the Anthropic API, so running the code needs an API key.
- Who should use it
- Developers building their own coding agents
- Engineers curious how Claude Code works inside
- Python programmers learning tool use and agent loops
- Readers of English, Chinese or Japanese
- Setup difficulty
You'll need:
- Python with pip
- Git
- An Anthropic API key
- Optional: Node.js for the web platform
How learn-claude-code works
The course starts from one loop: send messages to the model, run any tools it asks for, append the results and repeat until it stops. Each lesson then adds one mechanism around that loop without rewriting it.
The 17 lessons cover the agent loop, tool use, permissions, hooks, planning with a todo list, subagents, on-demand skill loading, context compaction, memory, a file-backed task system, background tasks, a cron scheduler, agent teams with task-bound worktrees, MCP plugins, an integrated harness, a workflow runtime and a goal loop with an independent evaluator.
Each chapter folder has an English README with Chinese and Japanese translations, a standalone code.py and diagrams. A web platform lets you read lessons with source, simulator and architecture views. An older 12-lesson track is kept in docs/ and agents/ for existing links.
Features
Key features
17 progressive lessons
Each adds one harness mechanism to the same loop.
Runnable code
A standalone code.py in every chapter.
Claude Code's design
Subagents, skills, compaction, tasks, teams and MCP explained.
Web platform
Read lessons with source, simulator and architecture views.
Three languages
English, Chinese and Japanese READMEs.
Goal loop
An evaluator decides when the agent may stop.
Strengths
- Clear, minimal examples
- Builds up from a single loop
- Covers advanced topics like teams and compaction
- MIT licensed
Limitations
- Educational code, not a production agent
- Needs an Anthropic API key, which costs money per use
- Two tracks exist; don't mix chapter numbers between them
- Strongly opinionated about what counts as an agent
Practical use cases
Learn agent internals
Work through s01 to s17 in order.
Build your own harness
Reuse the patterns for a domain-specific agent.
Teach a team
Use the web platform's simulator to explain agent loops.
Installation
Install learn-claude-code
Commands come from Learn Claude Code's README. AIRepoHub hasn't run them yet. View source
Prerequisites
- Python and pip
- An Anthropic API key
Supported systems
- Windows
- macOS
- Linux
- 1
Clone and install
Shellgit clone https://github.com/shareAI-lab/learn-claude-codecd learn-claude-codepip install -r requirements.txt - 2
Add your API key
Set ANTHROPIC_API_KEY in .env.
Shellcp .env.example .env - 3
Run the first lesson
Shellpython s01_agent_loop/code.py
- 1
Start the web app
Opens at http://localhost:3000.
Shellcd web && npm install && npm run dev
Configuration and API keys
| Setting | What it's for |
|---|---|
ANTHROPIC_API_KEYRequired | Your Anthropic API key, set in .env. |
First run
- 1
Run the one-loop-plus-bash agent
Shellpython s01_agent_loop/code.py
learn-claude-code's documentation doesn't include sample output, so we don't show any. Expect the results in your terminal.
Your first project
Run your first agent loop
See a minimal coding agent work with one loop and a bash tool.
Before you start
- The repository cloned and requirements installed
- ANTHROPIC_API_KEY set in .env
- 1
Read s01_agent_loop/README.md
The motto: one loop and bash is all you need.
- 2
Run the code
Shellpython s01_agent_loop/code.py - 3
Move on to context compaction
Shellpython s08_context_compact/code.py - 4
Finish with the goal loop
Shellpython s17_goal_loop/code.py
What to expect
A small agent that calls the model, runs bash commands it asks for and loops until it is done.
Next steps
- Add tools in s02
- Add permissions and hooks in s03 and s04
- Study the integrated harness in s15
Costs and requirements
What it costs to run
- License
- MIT. Free to use, modify and use commercially.Free
- Course
- Free.Free
- Anthropic API
- Running the lessons calls the API, billed per token.Paid
Troubleshooting
Common setup issues
Chapter numbers don't match an old link
The legacy 12-lesson track uses different numbers; see the mapping table in the README.
Lessons fail to call the model
Copy .env.example to .env and set ANTHROPIC_API_KEY.
Where to start
Begin at s01_agent_loop in the root-level track.
Alternatives
Similar AI repositories
hermes-agent
NousResearch
Personal AI agent from Nous Research that learns and improves the more you use it.
ui-ux-pro-max-skill
nextlevelbuilder
AI agent skill that gives coding assistants design guidance for building polished user interfaces.
graphify
Graphify-Labs
Agent skill that turns a codebase and its docs into a searchable knowledge graph for Claude Code, Cursor, Codex and Gemini CLI.
spec-kit
github
GitHub toolkit for spec-driven development, where you write a specification first and let an AI coding agent build from it.