happydog-intj

Build Coding Agent Tutorial — Development skill for Claude Code

Development community

从零构建 Coding Agent — 18 章 TypeScript 教程,理解 Claude Code / Cursor 背后的原理.

How to install Build Coding Agent Tutorial

This entry records only its repository, not the path inside it, so there is no exact command to give. Open happydog-intj/build-coding-agent-tutorial and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Build Coding Agent Tutorial does

从零构建 Coding Agent — 18 章 TypeScript 教程,理解 Claude Code / Cursor 背后的原理。Agent Loop、Tool Use、上下文管理、评测体系完整实现。

Alternatives in Development

  • Ralph Loop — Autonomous coding loop — works through tasks, commits, repeats 14k ★
  • AgenticResourceRegistry — Share and discover coding agent resources across your team 4.5k ★
  • Ralphy — My Ralph Wiggum setup, an autonomous bash script that runs Claude Code, Codex, OpenCode, Cursor agent, Qwen & 2.8k ★

README

从零构建 Coding Agent — TypeScript 教程

[![GitHub stars](https://img.shields.io/github/stars/happydog-intj/build-coding-agent-tutorial?style=social)](https://github.com/happydog-intj/build-coding-agent-tutorial) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE) [![Pages](https://img.shields.io/badge/在线阅读-GitHub%20Pages-brightgreen)](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