Skip to content

About

Hands-on learn to build claude code workshop material for building real AI and web apps.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build your own coding agent

Objective

By the end, you have built a small coding agent in Python, one idea at a time. You will know what Claude Code does inside: the loop, the tools, the plan, the helper agents, the memory tricks and the teams.

There are twelve modules. Each one is a single agent.py file you can run. Each one adds one idea to the one before.

Who it is for

  • Mid and senior engineers who use Claude Code and want to know how it works inside.
  • People who want to build their own agent without a framework.
  • You read Python and you are at home in a terminal.

Not for you if you want a finished product to ship. These agents are teaching code. They run shell commands on your computer, so run them in a folder you do not mind losing.

Before you start

  • uv, which installs Python 3.11 and the packages for you.
  • An Anthropic API key from the Claude Console. Or a key for another provider, see "Switch provider".
  • git, for module 12.

Run it

  1. Get the code.
git clone https://github.com/learnwithparam/learn-to-build-claude-code.git
cd learn-to-build-claude-code

Expect: a new folder with the modules 01-agent-loop to 12-worktree-isolation.

  1. Install the packages and make your settings file.
make setup

Expect: uv installs the packages, then Made .env. Paste your ANTHROPIC_API_KEY into it.

  1. Open .env and paste your key after ANTHROPIC_API_KEY=.

Expect: one line such as ANTHROPIC_API_KEY=sk-ant-... with your own key.

  1. Run the offline tests. They use a fake model, so they need no key.
make test

Expect: a list of ok lines, then tests: all passed.

  1. Run the first agent and give it a task.
make run

Expect: 01 agent loop in <your folder>. Type q to quit. Type list the files here and you see yellow $ ls lines, then a short answer.

  1. Go through the modules in order. Each folder has a README.md to start with.
make 02-bash-agent

Expect: the same kind of prompt, now from module 02. Type q to leave.

The picture

The agent loop: your task goes to the model, the model asks for tools, your code runs them and sends the results back

Every module runs the loop in the picture. You give a task. The model answers with text, or it asks for tools. Your code runs the tools and sends the results back. The loop stops when the model asks for no more tools.

The modules grow that loop step by step.

flowchart LR
  A["01 Agent loop"] --> B["02 Bash agent"] --> C["03 Tool design"]
  C --> D["04 Structured planning"] --> E["05 Subagents and skills"]
  E --> F["06 Context compaction"] --> G["07 Task system"] --> H["08 Background tasks"]
  H --> I["09 Agent teams"] --> J["10 Team protocols"] --> K["11 Autonomous agents"]
  K --> L["12 Worktree isolation"]
Loading

All model calls go through one file, llm.py. It sends the request, counts the cost and stops a run at a spend cap. Each module still runs its own loop, so you can read it.

A real run of module 03. The agent asks before it deletes a file, and the user says no.

A real run of module 03. The agent asks before it deletes a file, and the user says no

Lessons

# Module What it adds Key idea
01 The agent loop One bash tool and a loop The loop is the agent
02 Bash agent Clean structure, and a helper mode where the agent calls itself Structure and recursion
03 Tool design Four tools: bash, read, write, edit. A gate that asks before risky commands The model picks, your code checks
04 Structured planning A to-do list the model keeps up to date A plan you can see
05 Subagents and skills Helper agents with a fresh chat, and skills loaded on demand Split the work, load what you need
06 Context compaction Three ways to shrink a long chat Forget on purpose
07 Task system Tasks saved as files, with "blocked by" links Keep state outside the chat
08 Background tasks Slow commands run in a thread and report back Do not wait
09 Agent teams Teammates in threads, with an inbox each Talk to each other
10 Team protocols Shutdown and plan approval, matched by request id Agree before you act
11 Autonomous agents Teammates that find and claim open tasks Find your own work
12 Worktree isolation One git worktree per task Keep edits apart

Each module folder holds the same files.

File What it is for
agent.py The agent you run
README.md What it adds, how to run it, and what to watch
GUIDE.md A slower walk through the code
EXERCISES.md Things to try and change

The skills/ folder holds the sample skills that module 05 loads.

Switch provider

The agents use Claude Haiku by default. You can use any model that LiteLLM supports and that can call tools. Set it in .env.

LITELLM_MODEL=openrouter/nvidia/nemotron-3.5-lightning
OPENROUTER_API_KEY=

Expect: the next run uses the new model. env.example lists more examples, such as gemini/<model id> with GEMINI_API_KEY.

To try the stronger default, set LITELLM_MODEL=anthropic/claude-sonnet-5-5. The model names live only in llm.py, so you never edit a module to switch.

make check checks the writing and the settings. make verify runs every module on a real model and writes the cost to docs/runs/. It spends real money, a cap of one US dollar by default.

Where to go next

Read the free course page at learnwithparam.com.

Then open Claude Code in a project of your own. Look for the ideas you built here: the tool calls, the to-do list, the helper agents, the skills and /compact. The Claude Code docs explain each one.

About

Hands-on learn to build claude code workshop material for building real AI and web apps.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages