Skip to content
AIRepoHub

learn-claude-code

by shareAI-lab

Educational project that shows how to build a small agent harness like Claude Code from the ground up.

Coding AssistantsAI AgentsPythonMIT license
Stars
80,862
stars
Forks
13k
forks
Last push
10 days ago
Activity
Active
learn-claude-code: quick start
# 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.py

Commands 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

Based on official documentation

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

    Clone and install

    Shell
    git clone https://github.com/shareAI-lab/learn-claude-codecd learn-claude-codepip install -r requirements.txt
  2. 2

    Add your API key

    Set ANTHROPIC_API_KEY in .env.

    Shell
    cp .env.example .env
  3. 3

    Run the first lesson

    Shell
    python s01_agent_loop/code.py
  1. 1

    Start the web app

    Opens at http://localhost:3000.

    Shell
    cd web && npm install && npm run dev

Configuration and API keys

SettingWhat it's for
ANTHROPIC_API_KEYRequiredYour Anthropic API key, set in .env.

First run

  1. 1

    Run the one-loop-plus-bash agent

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

    Read s01_agent_loop/README.md

    The motto: one loop and bash is all you need.

  2. 2

    Run the code

    Shell
    python s01_agent_loop/code.py
  3. 3

    Move on to context compaction

    Shell
    python s08_context_compact/code.py
  4. 4

    Finish with the goal loop

    Shell
    python 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.

Source: README.md

Lessons fail to call the model

Copy .env.example to .env and set ANTHROPIC_API_KEY.

Source: README.md

Where to start

Begin at s01_agent_loop in the root-level track.

Source: README.md

Alternatives

Similar AI repositories