# learn-claude-code — Build an Agent Harness > learn-claude-code teaches agent harness engineering: tool dispatch, worktrees, context compression, and teams. Clone, set API key, run the demo scripts. ## Install Copy the content below into your project: ## Quick Use 1. Install the verified entrypoint: ```bash git clone https://github.com/shareAI-lab/learn-claude-code && cd learn-claude-code && pip install -r requirements.txt ``` 2. Run a first local check: ```bash cp .env.example .env && python agents/s01_agent_loop.py ``` 3. Add a repeatable verification step: ```bash python agents/s12_worktree_task_isolation.py ``` --- ## Intro learn-claude-code is a verified GitHub-backed asset sourced from `shareAI-lab/learn-claude-code` with 59,755 stars and a MIT license snapshot. Best for: engineers building agent products who need a concrete, runnable reference harness rather than high-level blog posts. Works with: Python + pip; optional web UI (npm) for visualizations. Setup time: 12 minutes. ### Quantitative notes - Multiple runnable stages (s01 → s12, repo) - Setup time ~12 minutes --- ## Deep Dive ### What it solves Use this when you need a **repeatable, team-shareable workflow** instead of one-off agent prompts. The goal is to make installation, first-run validation, and rollback **predictable**. ### Minimal mental model - Treat the GitHub repo as the source of truth: install instructions, configs, and upgrade paths live there. - Keep your first run small: one command, one verification, one rollback plan. - Capture a baseline: setup time, first successful run, and one real task completed end-to-end. ### Safe rollout checklist 1. **Verify source**: confirm repo URL, stars, and license match what you expect. 2. **Install** using the Quick Use commands above. 3. **Prove it works** with the verification command; save the output in a note or issue. 4. **Operationalize**: document owner, upgrade command, and rollback command. ### Troubleshooting (common) - **Install succeeds but nothing shows up** - Likely cause: the tool needs a restart/reload (CLI/IDE) or a config file in the right path. - Fix: restart the client, then re-run the verification step. - **Works on one machine, fails on another** - Likely cause: Node/Python/Docker versions differ or missing system dependencies. - Fix: pin versions (Node/Python), and copy a minimal known-good config. - **Token cost or latency is worse than expected** - Likely cause: tool schemas or verbose outputs get injected into context. - Fix: prefer smaller steps, cache results, and keep tool responses concise when possible. --- ### FAQ **Q: Is this a production implementation?** A: The README frames it as a teaching repo; use it to learn patterns, then harden the pieces you need. **Q: What should I run first?** A: Start with s01 to see a minimal loop, then progress to the later stages for worktrees, teams, and persistence. **Q: How do I keep it safe?** A: Use a dedicated API key with quotas, and run demos in a sandbox repo or throwaway project. --- ## Source & Thanks > GitHub: https://github.com/shareAI-lab/learn-claude-code > Owner avatar: https://avatars.githubusercontent.com/u/189210346?v=4 > License (SPDX): MIT > Stars (verified via `api.github.com/repos/shareAI-lab/learn-claude-code`): 59,755 --- # learn-claude-code——从零搭建 Agent Harness > learn-claude-code 是 0→1 的 agent harness 教学项目:工具调度、worktree 任务隔离、上下文压缩与团队协议。clone 后配置 ANTHROPIC_API_KEY,运行示例脚本即可逐章复现与调试。 ## 快速使用 1. 安装(以仓库为准): ```bash git clone https://github.com/shareAI-lab/learn-claude-code && cd learn-claude-code && pip install -r requirements.txt ``` 2. 首次运行/检查: ```bash cp .env.example .env && python agents/s01_agent_loop.py ``` 3. 可重复验证: ```bash python agents/s12_worktree_task_isolation.py ``` --- ## 简介 learn-claude-code 已核验来源于 `shareAI-lab/learn-claude-code`(59,755 stars,许可证 MIT)。适合:在做 agent 产品、需要“可运行的参考实现”而不是泛泛文章的工程师。兼容:Python + pip;可选 web UI(npm)用于可视化与文档浏览。装机时间:12 分钟。 ### 量化信息 - 多阶段可运行脚本(s01→s12,仓库) - 装机约 12 分钟 --- ## 深度说明 ### 解决什么问题 把“找到项目 → 安装 → 首次验证 → 回滚/升级”变成可复用流程,避免只靠一次性提示词或截图操作。 ### 最小心智模型 - GitHub 仓库是事实来源:安装、配置、升级、已知问题都以它为准。 - 第一次只做最小闭环:一个命令安装、一个命令验证、一个可回滚方案。 - 记录基线:装机耗时、首次成功输出、完成 1 个真实任务的证据。 ### 安全推广清单 1. **核验来源**:确认仓库 URL / stars / license 与预期一致。 2. 按“快速使用”完成安装与首次检查。 3. 跑通“验证命令”,把输出留档。 4. 标注 owner,并写清升级/回滚步骤。 ### 常见排障 - **装了但看不到效果** - 常见原因:需要重启 CLI/IDE 或配置文件路径不对。 - 处理:重启后再跑一遍“验证命令”。 - **一台机器能跑,另一台不行** - 常见原因:Node/Python/Docker 版本差异或缺少系统依赖。 - 处理:固定版本,并拷贝最小可用配置。 - **token 成本/延迟超预期** - 常见原因:工具 schema 或输出过长被塞进上下文。 - 处理:拆小步骤、缓存结果、尽量让工具输出更短。 --- ### FAQ **Q: 这是生产级实现吗?** A: README 明确它是教学仓库;用来理解机制,再把你需要的部分做权限、观测和错误处理加固。 **Q: 先跑哪个最合适?** A: 从 s01 看最小 loop,再逐步跑到后面的 worktree、teams 与 persistence 章节。 **Q: 怎么更安全地实验?** A: 用独立额度的 API key,并在 sandbox/一次性项目里跑,避免污染真实仓库。 --- ## 来源与感谢 > GitHub:https://github.com/shareAI-lab/learn-claude-code > Owner avatar:https://avatars.githubusercontent.com/u/189210346?v=4 > 许可证(SPDX):MIT > GitHub stars(已通过 `api.github.com/repos/shareAI-lab/learn-claude-code` 核验):59,755 --- Source: https://tokrepo.com/en/workflows/learn-claude-code-build-an-agent-harness Author: Agent Toolkit