Skip to main content

LEARNCLAUDECODE

Build a Claude Code–style agent harness from scratch - a free 20-lesson course across 6 stages, with runnable code and English chapters.

The Core Pattern - every coding agent is one loop
while True:
    response = model(messages, tools)
    if response.stop_reason != "tool_use":
        return response.text
    results = execute(response.tool_calls)
    messages.append(results)

Every coding agent is this loop. The model calls tools until it is done — everything else in these 20 lessons is refinement around it.

topFDEjobs
Forward Deployed Engineer roles

Building with Claude? Get paid for it.

Forward Deployed Engineers ship AI agents inside real customer systems. Open roles at Anthropic, OpenAI, Cognizant and more.

Up to $325k Anthropic, OpenAI, more Updated daily
Browse FDE jobs
Browse FDE jobs on topFDEjobs
20 of 20 lessons

Stage 1: Let the Agent Act

Core capabilities

s01

Agent Loop

“One loop & Bash is all you need”

one tool + one loop = one agent

messageswhile Truetool_use
s02

Tool Use

“Adding a tool means adding one handler”

the loop stays untouched; new tools register into the dispatch map

TOOL_HANDLERSdispatch mapconcurrency
s03

Permission System

“Set boundaries first, then grant freedom”

check what can run, what must stop, and what needs approval

PermissionRuleapproval pipeline
s04

Hook System

“Hook around the loop, never rewrite the loop”

add extension points without changing the main loop

PreToolUsePostToolUseextension points

Stage 2: Handle Complex Work

Plan, delegate, make room

s05

TodoWrite

“An agent without a plan drifts”

list the steps before starting; completion rate doubles

TodoItemplan-then-execute
s08

Context Compact

“Context always fills up -- have a way to make room”

four compaction steps reduce tool results first, then summarize history when it remains over the limit

tool_result_budgetsnip_compactmicro_compactcompact_history

Stage 3: Remember & Recover

Memory and resilience

s09

Memory System

“Remember what matters, forget what doesn't”

three subsystems: selection, extraction, consolidation

selectionextractionconsolidation
s10

Task System

“Big goals break into small tasks, ordered, persisted to disk”

a file-backed task graph that lays the groundwork for multi-agent coordination

TaskRecordblockedBydisk persistence
s11

Background Tasks

“Slow ops go background, agent keeps thinking”

background threads run commands; notifications inject on completion

threaded executionnotification queue

Stage 4: Run Long Tasks

Persist, background, schedule

s12

Cron Scheduler

“Fire on schedule, no human kick needed”

trigger tasks automatically by time

durable schedulingsession-scoped triggers
s13

Agent Teams

“Too big for one agent -- let teammates divide the work”

persistent teammates coordinate, claim ready tasks, and use task-bound working directories

persistent teammatesatomic task claimstask-bound worktreestyped protocols
s14

MCP Plugin

“Not enough capability? Plug in more via MCP”

connect external tools into the same tool pool

tool discoverynamespaced toolstool pool assembly

Stage 5: Coordinate Many Agents

Teams and protocols

s15

Integrated Harness

“Many mechanisms, one loop”

the mechanisms used by the integrated example share one harness

tools, runtime context, tasks, teams, scheduling, and MCP around one loop
s16

Workflow Runtime

“When the orchestration shape is fixed, put it in code”

saved workflows with resumable journals

script orchestrationlifecycle eventsjournal resume
s17

Goal Loop

“A goal decides when the loop may stop”

an independent evaluator reviews each proposed stop; impossible, failed, or over-limit goals return control to the user

goal gateconversation evaluationautomatic continuation

Stage 6: Extend & Assemble

Skills, MCP, the full loop

s07

Skill Loading

“Load knowledge on demand, not upfront”

list skills first, expand them only when needed

SkillLoadercatalogon-demand injection
WebMCP Developers