shareai-lab/learn-claude-code

Bash is all you need!write a claude code with only 16 line code

15.3K stars3.4K forksUpdated Jan 24, 2026
npx skills add shareai-lab/learn-claude-code

README

Learn Claude Code - Bash is all you & agent need

Python 3.10+ Tests License: MIT

Disclaimer: This is an independent educational project by shareAI Lab. It is not affiliated with, endorsed by, or sponsored by Anthropic. "Claude Code" is a trademark of Anthropic.

Learn how modern AI agents work by building one from scratch.

Chinese / 中文 | Japanese / 日本語


Why This Repository?

We created this repository out of admiration for Claude Code - what we believe to be the most capable AI coding agent in the world. Initially, we attempted to reverse-engineer its design through behavioral observation and speculation. The analysis we published was riddled with inaccuracies, unfounded guesses, and technical errors. We deeply apologize to the Claude Code team and anyone who was misled by that content.

Over the past six months, through building and iterating on real agent systems, our understanding of "what makes a true AI agent" has been fundamentally reshaped. We'd like to share these insights with you. All previous speculative content has been removed and replaced with original educational material.


Works with Kode CLI, Claude Code, Cursor, and any agent supporting the Agent Skills Spec.

demo

What You'll Learn

After completing this tutorial, you will understand:

  • The Agent Loop - The surprisingly simple pattern behind all AI coding agents
  • Tool Design - How to give AI models the ability to interact with the real world
  • Explicit Planning - Using constraints to make AI behavior predictable
  • Context Management - Keeping agent memory clean through subagent isolation
  • Knowledge Injection - Loading domain expertise on-demand without retraining

Learning Path

Start Here
    |
    v
[v0: Bash Agent] -----> "One tool is enough"
    |                    16-50 lines
    v
[v1: Basic Agent] ----> "The complete agent pattern"
    |                    4 tools, ~200 lines
    v
[v2: Todo Agent] -----> "Make plans explicit"
    |                    +TodoManager, ~300 lines
    v
[v3: Subagent] -------> "Divide and conquer"
    |                    +Task tool, ~450 lines
    v
[v4: Skills Agent] ---> "Domain expertise on-demand"
                         +Skill tool, ~550 lines

Recommended approach:

  1. Read and run v0 first - understand the core loop
  2. Compare v0 and v1 - see how tools evolve
  3. Study v2 for planning patterns
  4. Explore v3 for complex task decomposition
  5. Master v4 for building extensible agents

Quick Start

# Clone the repository
git clone https://github.com/shareAI-lab/learn-claude-code
cd learn-claude-code

# Install dependencies
pip install -r requirements.txt

# Configure API key
cp .env.example .env
# Edit .env with your ANTHROPIC_API_KEY

# Run any version
python v0_bash_agent.py      # Minimal (start here!)
python v1_basic_agent.py     # Core agent loop
python v2_todo_agent.py      # + Todo planning
python v3_subagent.py        # + Subagents
python v4_skills_agent.py    # + Skills

The Core Pattern

Every coding agent is just this loop:

while True:
    response = model(messages, tools)
    if response.stop_reason != "tool_use":
        return response.text
    results = execute(response.tool_calls)
    messages.append(results)

That's it. The model calls tools until done. Everything else is refinement.

Version Comparison

VersionLinesToolsCore AdditionKey Insight
v0~50bashRecursive subagentsOne tool is enough
v1~200bash, read, write, editCore loopModel as Agent
v2~300+TodoWriteExplicit planningConstraints enable complexity
v3~450+TaskContext isolationClean context = better results
v4~550+SkillKnowledge loadingExpertise without retraining

File Structure

learn-claude-code/
├── v0_bash_agent.py       # ~50 lines: 1 tool, recursive subagents
├── v0_bash_agent_mini.py  # ~16 lines: extreme compression
├── v1_basic_agent.py      # ~200 lines: 4 tools, core loop
├── v2_todo_agent.py       # ~300 lines: + TodoManager
├── v3_subagent.py         # ~450 lines: + Task tool, agent registry
├── v4_skills_agent.py     # ~550 lines: + Skill tool, SkillLoa

...
Read full README

Publisher

shareai-labshareai-lab

Statistics

Stars15.3K
Forks3.4K
Open Issues5
LicenseMIT License
CreatedJun 29, 2025