by shareAI-lab
Bash is all you need - A nano claude code–like 「agent harness」, built from 0 to 1
# Add to your Claude Code skills
git clone https://github.com/shareAI-lab/learn-claude-codeA teaching repository for implementers who want to build a high-completion coding-agent harness from scratch.
This repo does not try to mirror every product detail from a production codebase. It focuses on the mechanisms that actually decide whether an agent can work well:
The goal is simple:
understand the real design backbone well enough that you can rebuild it yourself.
One sentence first:
The model does the reasoning. The harness gives the model a working environment.
That working environment is made of a few cooperating parts:
Agent Loop: ask the model, run tools, append results, continueTools: the agent's handsPlanning: a small structure that keeps multi-step work from driftingContext Management: keep the active context small and coherentPermissions: do not let model intent turn into unsafe execution directlyHooks: extend behavior around the loop without rewriting the loopMemory: keep only durable facts that should survive sessionsNo comments yet. Be the first to share your thoughts!
Prompt Construction: assemble the model input from stable rules and runtime stateTasks / Teams / Worktree / MCP: grow the single-agent core into a larger working platformThis is the teaching promise of the repo:
This repo is not trying to preserve every detail that may exist in a real production system.
If a detail is not central to the agent's core operating model, it should not dominate the teaching line. That includes things like:
Those details may matter in production. They do not belong at the center of a 0-to-1 teaching path.
The assumed reader:
So the repo tries to keep a few strong teaching rules:
The English docs are intended to stand on their own. The chapter order, bridge docs, and mechanism map are aligned across locales, so you can stay inside one language while following the main learning path.
docs/en/s00-architecture-overview.mddocs/en/s00f-code-reading-order.mddocs/en/glossary.mddocs/en/teaching-scope.mddocs/en/data-structures.mdDo not open random chapters first.
The safest path is:
docs/en/s00-architecture-overview.md for the full system map.docs/en/s00d-chapter-order-rationale.md so the chapter order makes sense before you dive into mechanism detail.docs/en/s00f-code-reading-order.md so you know which local files to open first.s01-s06 -> s07-s11 -> s12-s14 -> s15-s19.If the middle and late chapters start to blur together, reset in this order:
docs/en/data-structures.mddocs/en/entity-map.mdIf you want a more visual way to understand the chapter order, stage boundaries, and chapter-to-chapter upgrades, run the built-in teaching site:
cd web
npm install
npm run dev
Then use these routes:
/en: the English entry page for choosing a reading path/en/timeline: the cleanest view of the full mainline/en/layers: the four-stage boundary map/en/compare: adjacent-step comparison and jump diagnosisFor a first pass, start with timeline.
If you are already in the middle and chapter boundaries are getting fuzzy, use layers and compare before you go deeper into source code.
These are not extra main chapters. They are bridge documents that make the middle and late system easier to understand:
docs/en/s00d-chapter-order-rationale.mddocs/en/s00f-code-reading-order.mddocs/en/s00e-reference-module-map.mddocs/en/s00a-query-control-plane.mddocs/en/s00b-one-request-lifecycle.mddocs/en/s00c-query-transition-model.mddocs/en/s02a-tool-control-plane.mddocs/en/s02b-tool-execution-runtime.mddocs/en/s10a-message-prompt-pipeline.mddocs/en/s13a-runtime-task-model.mddocs/en/s19a-mcp-capability-layers.mddocs/en/team-task-lane-model.mddocs/en/entity-map.mds01-s06: build a useful single-agent cores07-s11: add safety, extension points, memory, prompt assembly, and recoverys12-s14: turn temporary session planning into durable runtime works15-s19: move into teams, protocols, autonomy, isolated execution, and external capability routing| Chapter | Topic | What you get |
|---|---|---|
| s00 | Architecture Overview | the global map, key terms, and learning order |
| s01 | Agent Loop | the smallest working agent loop |
| s02 | Tool Use | a stable tool dispatch layer |
| s03 | Todo / Planning | a visible session plan |
| s04 | Subagent | fresh context per delegated subtask |
| s05 | Skills | load specialized knowledge only when needed |
| s06 | Context Compact | keep the active window small |
| s07 | Permission System | a safety gate before execution |
| s08 | Hook System | extension points around the loop |
| s09 | Memory System | durable cross-session knowledge |
| s10 | System Prompt | section-based prompt assembly |
| s11 | Error Recovery | continuation and retry branches |
| s12 | Task System | persistent task graph |
| s13 | Background Tasks | non-blocking execution |
| s14 | Cron Scheduler | time-based triggers |
| s15 | Agent Teams | persistent teammates |
| s16 | Team Protocols | shared coordination rules |
| s17 | Autonomous Agents | self-claiming and self-resume |
| s18 | Worktree Isolation | isolated execution lanes |
| s19 | MCP & Plugin | external capability routing |
git clone https://github.com/shareAI-lab/learn-claude-code
cd learn-claude-code
pip install -r requirements.txt
cp .env.example .env
Then configure ANTHROPIC_API_KEY or a compatible endpoint in .env, and run:
python agents/s01_agent_loop.py
python agents/s18_worktree_task_isolation.py
python agents/s19_mcp_plugin.py
python agents/s_full.py
Suggested order:
s01 and make sure the minimal loop really works.s00, then move through s01 -> s11 in order.s12 -> s19.s_full.py last, after the mechanisms already make sense separately.Each chapter is easier to absorb if you keep the same reading rhythm:
If you keep asking:
go back to:
learn-claude-code/
├── agents/ # runnable Python reference implementations per chapter
├── docs/zh/ # Chinese mainline docs
├── docs/en/ # English docs
├── docs/ja/ # Japanese docs
├── skills/ # skill files used in s05
├── web/ # web teaching platform
└── requirements.txt
Chinese is still the canonical teaching line and the fastest-moving version.
zh: most reviewed and most completeen: main chapters plus the major bridge docs are available