Build Coding Agent Tutorial
Description
从零构建 Coding Agent — 18 章 TypeScript 教程,理解 Claude Code / Cursor 背后的原理。Agent Loop、Tool Use、上下文管理、评测体系完整实现。
Installation
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open the source below and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
README
从零构建 Coding Agent — TypeScript 教程
[](https://github.com/happydog-intj/build-coding-agent-tutorial) [](./LICENSE) [](https://happydog-intj.github.io/build-coding-agent-tutorial/)
18 章渐进式教程 + 17 个可运行 Demo,理解 Claude Code / Cursor / Cline 背后的原理
📖 **[在线阅读](https://happydog-intj.github.io/build-coding-agent-tutorial/)** · 🪞 **[国内镜像](https://build-coding-agent-tutorial.vercel.app)** · 📥 **[下载 PDF](./releases/build-coding-agent-tutorial.pdf)** · 💬 **[FAQ](https://happydog-intj.github.io/build-coding-agent-tutorial/faq)**
用 TypeScript 从零实现一个完整的 AI Coding Agent(750 行),逐步讲解 Agent Loop、Tool Use、上下文管理、评测体系等核心原理。
快速开始
# 设置 API Key(二选一)
export ANTHROPIC_API_KEY=sk-ant-...
# 或
export OPENAI_API_KEY=sk-...
# 安装依赖
npm install
# 运行
npm start
# 指定模型
npm start -- --model=gpt-4o
架构概览
┌─────────────────────────────────────────────────────┐
│ index.ts (CLI 入口) │
│ readline 交互 + 流式输出 + 会话管理 │
├─────────────────────────────────────────────────────┤
│ agent-loop.ts (核心 Agent Loop) │
│ [用户消息] → LLM → 有 tool call? → 执行 → 重复 │
├─────────────────────────────────────────────────────┤
│ tools/ (4 个核心工具) │
│ read_file | write_file | edit_file | bash │
├─────────────────────────────────────────────────────┤
│ provider.ts (LLM Provider) │
│ pi-ai: 30+ provider 统一接口 │
├─────────────────────────────────────────────────────┤
│ session.ts (JSONL 持久化) │
│ 增量追加、崩溃安全、简单恢复 │
└─────────────────────────────────────────────────────┘
核心设计原则
这些原则来自 Pi 项目 5600+ 次迭代的经验:
1. LLM 调用永不 throw
Related Skills
Auto Update
Pull the latest ECC repo changes and reinstall the current managed targets.
Development Ecc Guide
Navigate ECC's current agents, skills, commands, hooks, install profiles, and docs from the live repository su
Development Epic Claim
Claim an epic issue, stamp coordination state, and sync local ownership.
Development Epic Publish
Publish a validated epic update back to the issue and local cache.
Development Epic Review
Mark epic review requested, approved, or changes requested.
Development Epic Unblock
Sweep blocked epic issues and reopen anything whose dependencies are closed.
Development Related Agents
Django Build Resolver
Django/Python build, migration, and dependency error resolution specialist. Fixes pip/Poetry errors, migration
Openai Codex CLI
(55.8k ⭐) - Lightweight coding agent that runs in your terminal.
src/agents/ — 11 Agent Definitions
**Generated:** 2026-04-11