y.y
Published on

从设计文档到代码:Groundhog AI 编程助手(以及新的 Cursor vibecoding 元技术)

从设计文档到代码:Groundhog AI 编程助手(以及新的 Cursor vibecoding 元技术)

Geoffrey Huntley

2025年3月3日

大家好,在"是的,Claude Code 可以反编译自己。这是源代码"博文中,我暗示了使用 Cursor 的一种新方法。这篇文章是下面这篇文章的后续。

You are using Cursor AI incorrectly...

I'm hesitant to give this advice away for free, but I'm gonna push past it and share it anyway. You're using Cursor incorrectly. Over the last few weeks I've been doing /zooms with software engineers - from entry level, to staff level and all the way up to principal level.

Geoffrey Huntley

当你将"/specs"(本文)方法与"stdlib"(上文)方法结合使用,同时使用具有编译器健全性(由良好的类型驱动)和编译器错误提示的编程语言时,结果令人难以置信。你可以在几小时内实现相当于同事数周工作量的输出。

今天,我将教授这种技术,同时宣布启动一个新的开源(是的,我将其作为纯开源项目,而不是我通常的专有许可)AI 无头代理编码助手,名为"groundhog"。

Groundhog 的主要目的是向人们教授 Cursor 和所有其他编码助手在底层的工作原理。如果你从第一原则理解这些编码助手的工作方式,那么你可以更有效地使用这些工具(或者也许创建自己的工具!)。

我们将一起构建它,逐步增量,作为一系列博客文章,所以不要急着去 GitHub 提出 XYZ 不工作的问题,因为我还没有决定项目周围的社区模式,免费提供客户支持并不在我的优先列表上。

GitHub - ghuntley/groundhog: Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then you can drive these tools harder (or perhaps make your own!).

Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then y…

GitHubghuntley

订阅、点赞并点击下方铃铛,以便在系列下一篇文章发布时收到通知。


Sign up for Geoffrey Huntley

I work remotely from a van that is slowly working its way around Australia. Follow me for the intersection of remote work, camping & #vanlife.

[Subscribe]

No spam. Unsubscribe anytime.


Groundhog 首先是一个教学工具。如果你现在想要一个功能完备的工具,可以查看"Goose"、"Roo/Cline"、"Aider"或"AllHands"。

你即将看到的所有代码都是使用这两种技术结合多个同时打开的 Cursor IDE 会话生成的,每个会话都在处理各自的规范领域。

什么是规范领域?

考虑一个标准的文件系统应用布局:

  • src/core - 这里是你的核心应用所在。
  • src/ai/mcp_tools - 这里是你的 MCP 工具所在。
  • src/ui - 这里是你的 UI 所在。

通过在一个实现会话中驱动 LLM 实现核心基础,然后是 src/ai/mcp_toolssrc/ui 来构建"应用的核心",你可以随后扩展并启动多个 Cursor 副本来处理应用中不重叠的部分。

Multi Boxing LLMs

Been doing heaps of thinking about how software is made after https://ghuntley.com/oh-fuck and the current design/UX approach by vendors of software assistants. IDEs since 1983 have been designed around an experience of a single plane of glass. Restricted by what an engineer can see on their

Geoffrey Huntley

如果你使用单一机器,使用 https://git-scm.com/docs/git-worktree 是让其工作的关键因素,因为你希望每个 Cursor("代理")拥有自己的工作目录。

首先编写一个"stdlib"规则,以自动进行 git 提交作为规范的增量,这也是关键。如果你想要高级一点,可以创建一个规则,在代理完成时自动创建拉取请求。

现在,你可能想知道如何处理合并冲突。你可以编写一个"stdlib"规则,驱动 Cursor 自动协调分支。

那么,什么是规范?

规范是你应用的核心;现在应用的内部实现重要性较低。只要你的测试通过,并且 LLM 实现了你在"stdlib"中定义的技术指导课程,那就足够了。

我首先承认,看到应用的 API 内部以快速速度大幅演变有点不安。软件工程师被教导要控制计算机;放手并建立对这个过程的信任需要一些时间。

我现在如何构建应用

我从与 LLM 进行关于我的产品需求(即规范)的长对话开始。对于 Groundhog,这些是我使用的提示:

We are going to create an AI coding assistant command line application in rust

The AI coding assistant is called "groundhog".

It uses the "tracing" crate for logging, metrics and telemetry. All operations have appropriate tracing on them that can be used to troubleshoot the application.

Use the clap cargo create for command line parsing.

The first operation is

"$ groundhogexplain"

When groundhog explain is invoked it prints hello world.

IMPORTANT: Write up the specifications into the "specs/" folder with each domain topic (including technical topic) as a seperate markdown file. Create a "SPECS.md" in the root of the directory which is an overview document that contains a table that links to all the specs.

几分钟后,会生成类似这样的内容。

在这个阶段,你需要做出决定。你可以手动更新每个文件,或者继续提示 LLM 更新规范库。让我们尝试一下。

继续这样做,直到你对应用的最小可行产品或增量感到满意。一开始不要过度复杂化。一旦你确定了规范,就该引入"stdlib"了。让我们从第一原则开始构建...

Create a Cursor IDE AI MDC rule in ".cursor/rules" which instructs Cursor to always create new MDC rules in that folder. Each rule should be a seperate file.

不错。好的,我们有了第一个基础规则。现在是时候创建更多的规则了,比如自动化 git 提交。

New Cursor IDE MDC rule.

After each change performed by Cursor automatically from Git commit.

Commit the changed files.

Use the "conventional git commit convention" for the title of the commit message Explain what was changed and why the files were changed from exploring the prompts used to generate the commit.

好的,很好,现在我们开始快速前进了。下一步是创建一个定义你的编码约定的 cursor 规则。由于 Groundhog 是用 Rust 编写的,让我们生成最佳实践并将其保存为规则。

Create a new Cursor MDC rule for all *.rs files (in all subdirectories)

You are an expert expert software engineer who knows rust. Infact you are the software engineer who created rust. Your task is to come up with technical recommendations in this rule which document best practices when authoring rust.

Split each concern about rust into seperate MDC rules.

Prefix each rule with the filename of "rust-$rulename.mdc"

Write these rules to disk

在生成这些规则后,你需要更加推动 LLM。要求它继续...

再进行几轮之后,手动审查你的新 Cursor 规则,这些规则指导 LLM 你期望的技术输出。如果你想加速这个过程,可以将新规则反馈给 LLM。

Look at the rust rules in @.cursor . What is missing? What does not follow best practice.

注意我们刚刚是如何让 LLM 自己反馈自己的?这是你将与新形成的规范和技术库一起使用的关键 LLM 提示。

反馈是关键工作流程

无需动手进行 vibe coding 的秘诀实际上就是这个提示,与 stdlib 和规范库结合使用...

Study @SPECS.md for functional specifications. Study @.cursor for technical requirements Implement what is not implemented Create tests Run a "cargo build" and verify the application works

几分钟后,Groundhog 将被生成。在此操作期间,Cursor 将超时或耗尽工具调用。

继续实现,直到完成

下一个秘诀实际上只是不断发出相同的提示:

Study @SPECS.md for functional specifications. Study @.cursor for technical requirements Implement what is not implemented Create tests Run "cargo build" and verify the application works Run "cargo clippy" and resolve linting errors

LLM 走错路了吗?重新开始一个新的聊天会话以清除 LLM 上下文窗口,并使用上述提示。继续这样做,直到所有内容都实现。

扩展规模

现在 src/core 已经实现。是时候转向其他规范领域,如 src/ai/mcp_toolssrc/ui 了。启动一个新的 Cursor 编辑窗口,重复我们在博客文章开始时所做的定义规范工作流程。

Look at specifications in

New requirement.

What should be implemented for MCP (model context protocol) registry? Include security best practices. What should be implemented for a new MCP (model context protocol) tool that can be invoked to list directory contents ("ls"). Include security best practices Provide a LLM system prompt for this MCP protocol tool.

Update with this guidance. Store them under "specs/mcp" with each technical topic as a seperate markdown file.

现在,对 src/ui 做同样的事情:

Look at specifications in @specs.

New requirement.

Create a basic "hello world" TUI user interface using the the "ratatui" create

Update @specs with this guidance. Store them under "specs/ui" with each UI Widget as a separate markdown file.

继续实现,直到完成

现在你面临一个决定。你可以同时启动多个 Cursor 会话,并要求每个副本同时处理 src/uisrc/core

Look at @specs Study @groundhog Implement what is not implemented Run "cargo build" Run "cargo clippy"

建议

这些 LLM 工作方式像"愚蠢的字符串查找服务",根本不理解编程语言。要使这一切正常工作,你需要一种良好的编程语言,它具有健全性,即如果它能编译,它就能工作(如 Rust/Haskell),以及一个坚实的基于属性的测试套件。Rust/Haskell 的独特之处在于它们提供了出色的编译器错误信息,可以反馈到 LLM 中以自动修复问题,直到它正确为止。

应用"stdlib"技术来引导 LLM 使用你的技术要求,并通过创建反馈循环(即测试和/或静态分析工具,如 sonarqube),你完全控制着产品/输出质量。

真的是天空才是极限 - 甚至可以将预先存在的安全扫描工具挂入反馈循环中...

结束语

对我来说,现在的限制因素实际上是我拥有多少屏幕空间。我很幸运在我的主工作站上有一个 59 英寸的显示器。我可以看到、感受到并体会到永远放弃 Cursor 的可能性...

Multi Boxing LLMs

Been doing heaps of thinking about how software is made after https://ghuntley.com/oh-fuck and the current design/UX approach by vendors of software assistants. IDEs since 1983 have been designed around an experience of a single plane of glass. Restricted by what an engineer can see on their

Geoffrey Huntley

计算机科学中编译器有一种方法叫"自举"。

Bootstrapping (compilers) - Wikipedia

Wikimedia Foundation, Inc.Contributors to Wikimedia projects

尽快自举,使 Groundhog 能构建 Groundhog 是我们将要建设的目标。如果你喜欢阅读,请考虑订阅通讯。我们离达到那里还有一段距离,所以系列的下一部分将解释"MCPs"到底是什么。


Sign up for Geoffrey Huntley

I work remotely from a van that is slowly working its way around Australia. Follow me for the intersection of remote work, camping & #vanlife.

[Subscribe]

No spam. Unsubscribe anytime.


Groundhog 的源代码(以及用于构建它的 stdlib + specs)可以在这里找到。给它一个星标。

GitHub - ghuntley/groundhog: Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then you can drive these tools harder (or perhaps make your own!).

Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then y…

GitHubghuntley

附:本博文的社交媒体链接如下

如果你喜欢阅读,请分享: