Learn Claude Code: Harness Engineering for Real Agents
Go from 0 to 1 building a nano Claude Code–like agent harness that turns any trained model into a working agent product.
- Source repo
- shareAI-lab/learn-claude-code
- Stars
- ★ 81k
- Last updated
- 18d ago
- FARS reviewed
- Nov 07, 2026
- License
- MIT
- Primary language
- Python
- FA score
- 57/100 · Major gaps
At a glance
- How it runs
- Works with
- Platform-specificClaude API
- Cost
- Free software; you pay for model usage
- Setup effort
- Low · running in minutes
- You'll need
- Typical use
- Software engineers who want to understand what Claude Code actually does under the hood and build their own harness from scratch.
- Not a fit if
- Teams wanting production-ready deployment; full hook lifecycle, permission governance, and session resume are omitted
- Readers unwilling to work through 17 chapters; some Python and API familiarity is expected
- Website
- learn.shareai.run ↗ set on GitHub
- Maintenance
- Commits in the last 30 dayslast commit 2026-11-15+48.9 ★/day over 7 days
- Source review
- 57/100 · Major gaps
What does this agent do, and when should you use it?
This repository is a 0-to-1 harness engineering learning project: it shows how to build the operational environment around an agent model, where agency comes from model training and the product is Model + Harness. It delivers 20 progressive lessons (s01–s20), each adding one harness mechanism to a core agent loop: tool use, permission rules, hooks, todo planning, subagents, skill loading, context compaction, memory, error recovery, task persistence, background tasks, cron scheduling, multi-agent teams, worktree isolation, and MCP plugins. Every lesson includes a full narrative README, bilingual (Chinese/English/Japanese) translations, a runnable code.py, and diagrams. The loop itself never changes; only the harness mechanisms layer on. The repo is MIT licensed and offers a clear learning path, legacy track mapping, and pointers to production spinoffs like Kode CLI and the claw0 always-on assistant. It is aimed at developers who want to understand the machinery behind agent products and build their own. The core philosophy: build the harness well, and the model will do the rest.
Each chapter ships a standalone Python file (code.py) that implements one Agent Loop plus a specific harness feature. The main loop calls the Anthropic Messages API (client.messages.create), appends tool results, and continues until stop_reason is 'tool_use'. Tools are dispatched through a TOOL_HANDLERS mapping, starting with a single Bash tool. Mechanisms include permission handling (PermissionRule), pre/post tool hooks, TodoWrite as a planning aid, subagents that spawn fresh message contexts, on-demand skill loading via SkillManifest, multi-layer context compaction (snipCompact, microCompact, toolResultBudget, autoCompact), memory selection/extraction/consolidation, a system prompt assembler, retry logic, a disk-backed task system (TaskRecord, blockedBy), background threads, a cron scheduler, a message bus for agent teams, worktree isolation helpers, and an MCP plugin channel. The learner runs scripts like python s01_agent_loop/code.py, python s08_context_compact/code.py, or the endpoint python s20_comprehensive/code.py to observe each mechanism. The repo also includes a legacy 12-lesson track and a web app.
- Software engineers who want to understand what Claude Code actually does under the hood and build their own harness from scratch.
- Developers frustrated by drag-and-drop workflow builders or no-code agent platforms who want a principled, model-centric approach.
- Teams planning to embed agent capabilities into their products and considering the provided Kode SDK as a foundation.
- Educators and self-learners looking for a progressive, code-first curriculum with runnable examples and diagrams in multiple languages.
- Researchers exploring always-on assistant patterns beyond the use-and-discard model, using the OpenClaw/claw0 comparison.
Key setup facts
Pulled from the install and usage notes below. The project README has the current values.
- Environment variables
ANTHROPIC_API_KEY- Config files
.env.env.example
How do you install or deploy this agent?
- Clone the repo:
git clone https://github.com/shareAI-lab/learn-claude-code - Enter the directory: cd learn-claude-code
- Install Python dependencies:
pip install -r requirements.txt - Create your .env from .env.example and set ANTHROPIC_API_KEY (Anthropic API key).
How do you use this agent?
Work through the 20 lessons in order. Start with python s01_agent_loop/code.py to see the minimal agent loop with a single Bash tool, then run increasingly complex chapters such as python s08_context_compact/code.py, and finish with python s20_comprehensive/code.py to see all mechanisms combined. Each lesson's README.md (English/Chinese/Japanese) explains the concepts with inline code and diagrams. Alternatively, the legacy track (agents/*.py) and web app are available.
Safety boundaries, hardening & integrations
Operational blast radius, source-verified safety controls, and first-run hardening steps before connecting this agent to real workspaces.
Declared capability surface (blast radius)
Can run terminal commands; pair with approval gates or container/OS sandboxing.
What are this agent's strengths and limitations?
- Teaches harness engineering from first principles, with every lesson adding exactly one mechanism and providing a runnable example—very effective for learning.
- Strong conceptual clarity: separates 'training a model' (agency) from 'building a harness' (product), avoiding common over-engineering traps.
- High-quality multilingual documentation (EN/ZH/JA) with SVG diagrams and self-contained code for each chapter.
- Requires an Anthropic API key and thus locks you to a single provider; you cannot easily swap in a different model without code changes.
- Deliberately omits production-grade features (full hook lifecycle, rigorous permission governance, session resume, full MCP), so you must extend it for real deployment.
- Substantial time investment: 20 chapters with detailed reading; some entry-level Python and API familiarity expected.
How does this agent compare with similar options?
Compared to Claude Code itself, this repo is a teaching-grade minimal reimplementation—not a drop-in replacement. Compared to OpenClaw, this repo focuses on the use-and-discard harness, while OpenClaw demonstrates how heartbeat and cron transform an agent into an always-on assistant; both projects complement each other.
Key facts side by side with the most closely related agents.
| Agent | Source review | Form / cost | Stars | Updated | Language | Full support on |
|---|---|---|---|---|---|---|
| Learn Claude Code: Harness Engineering for Real Agents This agent | 57 · Major gaps | CLIFree + model costs | ★ 81k | 18d ago | Python | Claude API |
| Claude Code From Scratch | 62 · Some gaps | CLIFree + model costs | ★ 2.9k | 3d ago | HTML | OpenAI API · Claude API |
| Build Your Own OpenClaw | 38 · Major gaps | CLIFree + model costs | ★ 1.9k | 13d ago | Python | — |
| Donggua's AI Learning Notes: In-depth Pi-Agent SDK Tutorial | 49 · Major gaps | Web appFree | ★ 3.8k | 3mo ago | MDX | — |
How does FollowAgents rate this agent?
Why each dimension lost points
The README identifies permissions, sandboxing, and approval for destructive operations as Harness responsibilities; the course covers Permission, MCP, and Teams, and the supplied tests check text-tool boundaries across lessons. The sample does not show the permission implementation, path restrictions, or concrete approval rules, so least privilege is only partially evidenced. Quickstart requires an ANTHROPIC_API_KEY, but key storage and logging practices are not shown. Bash and MCP imply external effects, while concrete execution confirmation, recovery, and dependency review are not evidenced in the supplied files. The LICENSE and README attribute the project, but publisher identity is unverified and maintenance ownership and update path are unclear.
The README distinguishes the current 17-session track from the legacy 12-session migration path and clarifies the scope of s15, s16, and s17, resolving some potential structural ambiguity. Supplied tests cover UTF-8 text-tool boundaries across lessons and Teams runtime contracts; CI files specify Python smoke tests and a web build. Dependencies have installation instructions and a web lockfile workflow, but Python requirements use lower bounds, and the sample provides little evidence about availability or recovery from failures. Failure-message quality cannot be established from the supplied material.
The agent-builder skill names business, research, operations, and creative scenarios and recommends progressive capability growth. The course assigns topics to sessions and presents coding as an example of a pattern it says generalizes; however, the claim of applicability to any domain is broad and conditions and boundaries are thin. Quickstart covers Python API examples and a web platform, while still requiring the Anthropic API and local Python/Node environments.
The README provides a clear course index, learning path, repository layout, and mapping between legacy and current versions. Quickstart covers cloning, dependencies, environment variables, and entry commands, but the sample lacks comprehensive troubleshooting. Session naming is consistent and migration mapping is explicit, though maintaining both tracks increases navigation overhead. Executable code, diagrams, and skill references are described; a FAQ and a complete limitations section are not shown. The MIT license text is complete. Version status explains the course migration, but no changelog is provided; copyright attribution does not establish a maintainer or update path.
The README lays out 17 progressive Harness mechanisms, a core loop, and a practical learning path; the skill provides a design framework and links to templates. The lesson structure and boundary tests add value beyond a generic conceptual overview. The claimed cross-domain generality remains mostly a thesis, and the sample does not quantify the effort or benefits of the more complex mechanisms.
Course topics, the index, and tests can be compared, and the supplied tests give concrete examples of some tool boundaries and runtime contracts. The README also labels the two course tracks. This supports traceability for parts of the course, but main implementation files are not in the sample, and broad claims such as cross-domain generality and comparative product judgments lack independent support here. Fact and opinion are not always clearly separated.
- This is a static review of a limited file sample; implementation files not supplied here were not inspected, and no code or tests were run.
- The course presents bash, MCP, and automation as capabilities, but the sample does not establish concrete permission boundaries, secret handling, or recovery for external actions.
- The README claims the approach generalizes to several high-impact domains; treat those as course claims, not evidence of validated suitability for those settings.
FAQ
Do I need a separate agent framework to run the code?
Will I incur cost by playing with this?
Can I use this to build a production agent?
What is the relationship between the tutorial and the kode CLI / web app?
Thanks — we use this to improve the page.
Subscribe to the FollowAgents RSS feed, or save this agent to your browser shortlist to compare on your next visit.