Quest:Epic CLI 工具(通过实际构建学习代码)
Source: Dev.to
我构建的内容
我构建了 Quest —— 一个 CLI 工具,通过让你真正动手写代码来教你编程,而不是仅仅阅读相关内容。
我曾在大型科技公司工作,主要负责维护代码仓库和开发小功能。没有机会参与 0‑to‑1 的产品开发,于是去年夏天我开始在业余时间玩一些个人项目。学习曲线真的很陡:我大部分时间都在向 GPT 提问、阅读文档、完成教程。
我一直在想:为什么不能在编码的同时学习这些东西呢? 就像在 IDE 里,一边真正构建项目,一边学习。
这就是 Quest。你可以挑选一个项目(或让它为你生成),它会一步步带你完成构建——自动检查你的代码,并在你卡住时提供 AI 提示。没有浏览器标签页,没有教程的无底洞。只需要你的编辑器和终端。
一个典型的会话
quest begin → Pick a quest (templates or AI‑generated)
quest next → See your current task
→ Write your code
quest check → Auto‑validate your implementation
quest check -a → AI code review with inline comments
quest explain → Get hints (they get more direct each time)
quest complete → Move on
quest summary → See where you’re at
循环
这是核心工作流。它故意非常简单:
任务模板
有 7 个内置模板,任务数量从 3 项快速任务到 20 项深度任务不等:
| 模板 | 难度 | 任务数 | 构建内容 |
|---|---|---|---|
go-web-api | 快速 | 3 | REST API 基础 — 处理器、JSON、测试 |
go-cli-tool | 快速 | 3 | 使用 Cobra 的 CLI — 子命令和标志 |
go-concurrency | 快速 | 3 | Goroutine、通道、工作池 |
go-fairy-garden | 普通 | 10 | 一个奇思妙想的工作服务 |
go-todo-api | 高级 | 15 | 完整的 CRUD API,带中间件 |
go-auth-system | 高级 | 19 | 认证系统 — JWT、会话等全部功能 |
go-isekai-server | 高级 | 20 | 分布式虚拟世界管理器 |
或者你可以完全跳过模板。 描述你想构建的内容,选择难度,Copilot CLI 将生成自定义任务计划:章节、任务、验证规则,全部内容。
演示
仓库:
go install github.com/jovanpet/quest@latest
开始任务
🧭 Quest
Choose your path:
> 🗡️ Pick a Legendary Path
🔨 Forge Your Own Quest
🎲 Seek a Mystery Quest
检查你的工作
🔍 Checking Task 1: Create a Hello World endpoint
✓ File exists main.go found
✓ Contains HTTP server code http.HandleFunc detected
🎉 All 2 checks passed!
→ Next step: quest complete
使用 quest check -a 的 AI 代码审查
-a 标志会将你的代码发送到 Copilot CLI,并将内联评论直接注入到源文件中:
// ✓ GOOD: Correct imports for HTTP server functionality
import (
"fmt"
"net/http"
)
func main() {
// TODO: What content type should the client expect from a JSON endpoint?
handler := func(w http.ResponseWriter, r *http.Request) {
// HINT: Plain text isn't structured JSON — what Go package helps encode structs?
fmt.Fprint(w, "Hello, World!")
// ✓ GOOD: Handler properly uses ResponseWriter to send response
}
}
使用 quest explain 的递进提示
提示系统会根据你的尝试次数进行适配:
Attempt 1 → Minimal hints ("Consider what happens if input is empty")
Attempt 2 → More specific ("Look into http.Error for error responses")
Attempt 3 → Direct code (partial code examples, since you’re clearly stuck)
我使用 GitHub Copilot CLI 的体验
Copilot CLI 在重构代码时提供了巨大的帮助,尤其是当我需要添加字段并更新所有模板时。它驱动了三个核心功能,否则实现起来会非常麻烦。
实际了解你代码的提示
当你运行 quest explain 时,Quest 会抓取你当前的任务并将其传递给 Copilot CLI。响应是结构化的注释,绑定到代码中的特定行。
知道你任务的代码审查员
自动检查 (quest check) 处理基础工作——文件是否存在?是否包含正确的模式?添加 -a 标志后,Copilot CLI 会进行真正的审查。它读取你的实际代码并写入类似以下的注释:
✓ GOOD: Using http.HandleFunc correctly✗ ERROR: Missing error handling on ListenAndServe⚠ WARNING: Consider adding Content‑Type header
这些注释直接注入到源文件中,位于相关行的上方。
生成完整的 quest 计划
与其挑选模板,你可以描述你想要的内容(例如 “I want to build a princess‑fairy scheduler worker”),选择难度,Copilot CLI 会生成完整的教学计划(JSON 格式)。我甚至创建了一个 go‑isekai‑server 模板,你可以在其中完成诸如玩家技能端点之类的 quest。
提交结束。
# Read Me
The big realization was that Copilot CLI isn't just an autocomplete tool; it's basically a programmable AI interface. I can pipe structured prompts to it and get structured output back. No API keys, no cloud hosting, no billing dashboards—just a binary that takes **stdin** and returns useful output. 