AI工具 Skill技能库 关于道场
Python AI工具 开源 ai ai-agent anthropic build-from-scratch claude claude-code coding-agent llm tutorial typescript

ClaudeCodeFromScratch:你的代码从代码开源了万行代码读不动从零复现核心架构

GitHub |2026-07-04

Build 你的 own Claude 代码从 scratch. 🔍 Claude 代码 开源了 50 万行代码,读不动?用 ~4000 行 TypeScript / Python 从零复现核心架构,11 章分步教程带你理解 coding agent 精髓GitHub 2,075 ⭐ / 467 Fork,主要使用 Python 开发。标签:ai,ai-agent,anthropic,build-from-scratch,claude。访问项目:https://github.com/Windy3f3f3f3f/claude-code-from-scratch

项目介绍

Build 你的 own Claude 代码从 scratch. 🔍 Claude 代码 开源了 50 万行代码,读不动?用 ~4000 行 TypeScript / Python 从零复现核心架构,11 章分步教程带你理解 coding agent 精髓

核心功能

- Agent 循环:自动调用工具、处理结果、持续迭代,直到任务完成 - 13 个工具:读写编辑文件(mtime 防护)、搜索、Shell、WebFetch、ToolSearch(延迟加载)、技能、子 Agent、Plan Mode - 流式输出:逐字实时显示,Anthropic + OpenAI 双后端,streaming 工具早期执行 - 并行工具执行:只读工具(read_file、grep_search 等)自动并发,2-3x 加速 - 4 层上下文压缩:budget 截断 → stale snip → microcompact → auto-compact + 大结果持久化(>30KB 写磁盘) - 权限系统:5 种模式 + `.claude/settings.json` 声明式 allow/deny 规则 + 16 个危险命令正则

使用指南

npm install && npm run build ```

Python 版(需要 Python 3.11+,[详细说明](./python/README.md))

``` cd python pip install -e . mini-claude-py # 命令行入口(避免与 TS 版 mini-claude 冲突) python -m mini_claude # 或用 python -m 方式运行 ```

配置 API

支持两种后端,通过环境变量自动识别:(支持自定义base url)

方式一:Anthropic 格式(推荐)

``` export ANTHROPIC_API_KEY="sk-ant-xxx"

项目信息

项目信息
项目名称Windy3f3f3f3f/claude-code-from-scratch
Star 数2,075
Fork 数467
编程语言Python
开源协议MIT
创建时间2026-03-31
最近更新2026-07-03
主题标签ai、ai-agent、anthropic、build-from-scratch、claude

项目地址

GitHub 仓库:<https://github.com/Windy3f3f3f3f/claude-code-from-scratch>

> 完整 URL:[https://github.com/Windy3f3f3f3f/claude-code-from-scratch](https://github.com/Windy3f3f3f3f/claude-code-from-scratch)

如需查看完整源码、安装命令、使用示例、API 文档,请直接访问上方项目地址。所有信息均以 GitHub 仓库为准。