Skip to content

Commit 1aa71fb

Browse files
xkcodingclaude
andcommitted
feat: 新增博客文章「从 Vibe 到 Spec」及 GitHub Alerts 支持
- 新增博客文章:从 Vibe 到 Spec:我的 AI Coding 工作流 - 添加 remark-github-blockquote-alert 插件支持 GitHub 风格提示框 - 添加 GitHub Alerts 样式(支持亮色/暗色主题) - 调整封面图 object-fit 为 contain 避免裁切 - 更新 .gitignore 忽略图片资源目录 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c5604d5 commit 1aa71fb

8 files changed

Lines changed: 398 additions & 3 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ scripts/migrate-images/reports/
4343
# ossutil output
4444
ossutil_output/
4545

46+
cover-image/
4647
xhs-images/
48+
illustrations/

astro.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import tailwindcss from "@tailwindcss/vite";
33
import sitemap from "@astrojs/sitemap";
44
import remarkToc from "remark-toc";
55
import remarkCollapse from "remark-collapse";
6+
import remarkGithubBlockquoteAlert from "remark-github-blockquote-alert";
67
import {
78
transformerNotationDiff,
89
transformerNotationHighlight,
@@ -26,7 +27,11 @@ export default defineConfig({
2627
}),
2728
],
2829
markdown: {
29-
remarkPlugins: [remarkToc, [remarkCollapse, { test: "Table of contents" }]],
30+
remarkPlugins: [
31+
remarkToc,
32+
[remarkCollapse, { test: "Table of contents" }],
33+
remarkGithubBlockquoteAlert,
34+
],
3035
shikiConfig: {
3136
// For more themes, visit https://shiki.style/themes
3237
themes: { light: "min-light", dark: "night-owl" },

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"dayjs": "^1.11.19",
2323
"lodash.kebabcase": "^4.1.1",
2424
"remark-collapse": "^0.1.2",
25+
"remark-github-blockquote-alert": "^2.0.1",
2526
"remark-toc": "^9.0.0",
2627
"satori": "^0.18.3",
2728
"sharp": "^0.34.5",

pnpm-lock.yaml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/data/blog/2026-01-17.extend-claude-code-with-slash-command.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pubDatetime: 2026-01-17T00:00:00.000Z
55
slug: extend-claude-code-with-slash-command
66
featured: true
77
draft: false
8-
ogImage: https://cdn.xkcoding.com/blog/2026-01-19-cover.png?x-oss-process=style/tag_compress
8+
ogImage: https://cdn.xkcoding.com/blog/2026-01-22-2026-01-19-cover.webp?x-oss-process=style/tag_compress
99
tags:
1010
- ai
1111
- claude-code
Lines changed: 311 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,311 @@
1+
---
2+
title: "从 Vibe 到 Spec:我的 AI Coding 工作流"
3+
author: xkcoding
4+
pubDatetime: 2026-01-22T00:00:00.000Z
5+
ogImage: https://cdn.xkcoding.com/blog/2026-01-22-cover-sketch-16x9.webp?x-oss-process=style/tag_compress
6+
slug: vibe-to-spec-ai-coding-workflow
7+
featured: true
8+
draft: false
9+
tags:
10+
- ai-coding
11+
- vibe-coding
12+
- sdd
13+
- openspec
14+
- methodology
15+
description: "Vibe Coding 快速验证想法确实爽,做复杂功能就翻车——AI 总爱过度设计,简单需求给你整复杂,方向错了代码写再多也白搭。这篇分享我摸索出的工作流:用 Gemini 探讨方向出 Deep Research 报告,再用 OpenSpec 管理 SDD 流程,proposal → review → apply → archive 四步循环。Vibe 负责发散,Spec 负责落地,两阶段配合避免返工。"
16+
---
17+
18+
## 写在前面
19+
20+
2025 年初,Andrej Karpathy 在 [X 上提出了 "Vibe Coding"](https://x.com/karpathy/status/1886192184808149383) 这个概念:
21+
22+
> "There's a new kind of coding I call 'vibe coding', where you fully give in to the vibes, embrace exponentials, and forget that the code even exists."
23+
>
24+
> "I 'Accept All' always, I don't read the diffs anymore. When I get error messages I just copy paste them in with no comment."
25+
26+
说白了就是:完全信任 AI,不看代码,不读 diff,报错就贴,能跑就行。
27+
28+
用这种方式快速验证想法确实爽。但做稍微复杂点的东西,问题很快就来了:
29+
30+
- 对话长了,AI 开始"失忆",之前的需求细节全忘了
31+
- AI 自信地写出根本不存在的 API
32+
- 改了 A 功能,B 功能莫名其妙挂了
33+
34+
这些是业内公认的问题。
35+
36+
但让我更头疼的是另一类情况——**方向错了**
37+
38+
- 让 AI 做消息通知,它设计了 Kafka + ZooKeeper + 死信队列。我日活 100 人,一张表 + 轮询就够了
39+
- 让 AI 做数据导出,它造了异步任务 + 5 张表。我只想导个 Excel
40+
41+
代码能跑,但方向错了,写得再多也是白写。
42+
43+
有了 AI 能力之后,我的时间不该花在反复调教、改 BUG 上。我想要的很简单:**快速完成满意的功能**
44+
45+
折腾了一段时间后,我摸索出一套工作流。用 Vibe 的方式探索方向,用 Spec 的方式保证质量。
46+
47+
这篇文章分享一下我的做法。
48+
49+
---
50+
51+
## 整体思路
52+
53+
我的做法分两个阶段:**Vibe 发散****SDD 落地**
54+
55+
![Vibe to Spec 工作流](https://cdn.xkcoding.com/blog/2026-01-22-illustration-workflow-overview-sketch.webp?x-oss-process=style/tag_compress)
56+
57+
> [!IMPORTANT]
58+
> 核心逻辑:**先用 Vibe 的方式把方向聊对,再用 Spec 的方式把代码写对**
59+
>
60+
> Vibe 阶段产出的研究报告,就是 SDD 阶段的输入。报告里定好了做什么、用什么技术、大致怎么拆分,后面写代码就不容易跑偏。
61+
62+
**Vibe 阶段**用来探索方向。idea 还不清晰的时候,跟 AI 聊,找可行性,定技术栈。这个阶段不写代码,只输出一份研究报告。
63+
64+
**SDD 阶段**用来保证质量。拿着研究报告进入 Coding Agent,用 OpenSpec 管理开发流程。先出 proposal,review 通过再写代码。
65+
66+
两个阶段的分工:**Vibe 负责方向,SDD 负责执行**
67+
68+
### 用什么工具
69+
70+
这套流程可复制,工具可以换。
71+
72+
**Vibe 阶段**,我用 Gemini。你也可以用 ChatGPT、Claude 或其他擅长探讨的模型。
73+
74+
**SDD 阶段**,工具有几个选择:
75+
76+
- [OpenSpec](https://github.com/Fission-AI/OpenSpec):我在用的,轻量、流程清晰
77+
- [Spec-Kit](https://github.com/github/spec-kit):GitHub 出的,64k stars,支持的 Coding Agent 更多
78+
- 还有 Kiro、Tessl 等,可以参考 [Martin Fowler 的对比文章](https://martinfowler.com/articles/exploring-gen-ai/sdd-3-tools.html)
79+
80+
这些工具思路差不多,选一个顺手的就行。
81+
82+
**Coding Agent 层面**,Cursor、Claude Code、Codex、Gemini CLI 都能配合 SDD 工具用。
83+
84+
> [!WARNING]
85+
> 有一点要说清楚:**基座模型的质量直接决定产出质量**。同样的流程,用 Claude 和用一个普通模型,效果差很多。我选 Claude Code 不是因为工具好用,而是因为 Claude 的代码能力目前最强。工具可以换,模型质量不能妥协。
86+
87+
---
88+
89+
## 先聊方向
90+
91+
这个阶段要做的是把模糊的 idea 变成一份清晰的研究报告。不写代码,只聊方向。
92+
93+
### 两种聊法
94+
95+
跟 AI 探讨的时候,我发现自己有两种状态:
96+
97+
**探路者模式**。脑子里就一个模糊的想法,能不能做、怎么做都不知道。这时候主要是让 AI 帮我找可行性、选技术栈。聊着聊着,某个方案让我眼前一亮,差不多就可以往下走了。
98+
99+
**细化者模式**。方向大概有了,但细节还没想清楚。这时候主要是让 AI 帮我细化方案、确认技术点。关键技术点都聊到了、实现路径也大致清晰了,就可以进入下一步。
100+
101+
![两种聊法](https://cdn.xkcoding.com/blog/2026-01-22-illustration-two-modes.webp?x-oss-process=style/tag_compress)
102+
103+
两种模式的结束信号不一样,但目标一样:**输出一份足够清晰的研究报告**
104+
105+
### 为什么用 Gemini
106+
107+
Vibe 阶段,我用 Gemini。
108+
109+
选它的原因是:Gemini 是 Google 家的,搜索能力原生集成。聊技术方案的时候,给的信息更贴近最新潮流,不容易查到过时的东西。
110+
111+
模型的选择也有讲究。我的优先级是 **2.5 Pro > 2.5 Flash Thinking > 2.5 Flash**。Pro 的推理能力最强,探讨复杂方案的时候更靠谱。Flash 系列速度快,简单问题用它就够了。
112+
113+
这个阶段不写代码,只需要聊清楚"做什么"和"怎么做"。信息检索能力比代码能力更重要。
114+
115+
### 聊完怎么出报告
116+
117+
探讨到位之后,别急着写代码。先让 Gemini 输出一份深度研究报告。
118+
119+
我的做法:
120+
121+
1. 让 Gemini 总结一下讨论结果
122+
2. 自己过一遍,确认没遗漏重要的点
123+
3. 让 Gemini 生成一个 Deep Research 的提示词
124+
4. 新开一个 Gemini Deep Research 会话,把提示词贴进去
125+
5. 拿到深度研究报告
126+
127+
这份报告就是进入 SDD 阶段的输入。我一般保存成 `idea.md``report.md`,后面初始化 proposal 的时候会用到。
128+
129+
如果你发现报告里有明显遗漏或者方向偏了,多半是前面探讨阶段聊得不够透。回去补几轮再出报告,别硬往下走。
130+
131+
---
132+
133+
## 再动手做
134+
135+
拿到研究报告之后,就进入 SDD 阶段了。这个阶段要做的是把报告变成可运行的代码,而且要保证质量。
136+
137+
### SDD 是什么
138+
139+
SDD 是 Spec-Driven Development,核心思想是:**先写规范,再写代码**
140+
141+
不是拿到需求就让 AI 开干,而是先让 AI 出一份 proposal,描述要做什么、怎么做、分几步。人 review 通过之后,再按 proposal 写代码。
142+
143+
> [!TIP]
144+
> 好处很直接:问题在 review 阶段发现成本低,代码写完之后发现成本高。
145+
146+
市面上 SDD 工具不少,我选 [OpenSpec](https://github.com/Fission-AI/OpenSpec)。选它的原因:
147+
148+
- **轻量**:就是一套目录结构 + 几个命令,没有复杂的配置
149+
- **工具无关**:支持 Cursor、Claude Code、Codex、Gemini CLI 等主流 Coding Agent
150+
- **流程清晰**:proposal → review → apply → archive,四步循环
151+
152+
跑一下 `openspec init` 就能用,不需要学很多东西。
153+
154+
### 怎么跑起来
155+
156+
拿着 Vibe 阶段产出的 `idea.md``report.md`,开始 SDD 流程。
157+
158+
**第一步:初始化项目**
159+
160+
```bash
161+
mkdir my-project && cd my-project
162+
openspec init
163+
```
164+
165+
初始化之后,项目里会多一个 `openspec/` 目录:
166+
167+
```
168+
openspec/
169+
├── specs/ # 当前规范(系统的"记忆")
170+
├── changes/ # 进行中的变更(proposal + tasks)
171+
└── archive/ # 已完成的变更(可追溯)
172+
```
173+
174+
**第二步:初始化 proposal**
175+
176+
打开 Coding Agent(我用 Claude Code),执行:
177+
178+
```
179+
/openspec:proposal 帮我初始化一个 proposal 用于实现原始想法 @idea.md 的功能,具体可以参考 @report.md ultrathink
180+
```
181+
182+
这条命令做了三件事:
183+
184+
- 引用 `idea.md``report.md`,把 Vibe 阶段的产出带进来
185+
- 让 AI 生成 proposal.md + design.md + tasks.md
186+
- `ultrathink` 触发深度思考模式,确保方案考虑周全
187+
188+
**第三步:review**
189+
190+
AI 生成完之后,别急着往下走。打开 proposal.md、design.md、tasks.md,逐个过一遍:
191+
192+
- 方案是不是你想要的?
193+
- 技术选型对不对?
194+
- 任务拆解合理吗?
195+
196+
有问题就让 AI 改,改到满意为止。这一步多花点时间,后面能省很多事。
197+
198+
**第四步:apply**
199+
200+
review 通过之后,让 AI 按 tasks.md 逐步实现:
201+
202+
```
203+
/openspec:apply
204+
```
205+
206+
AI 会边做边更新 task 进度。做完一个 task,就标记一个完成。
207+
208+
**第五步:archive**
209+
210+
全部完成之后,归档这次变更:
211+
212+
```
213+
/openspec:archive
214+
```
215+
216+
归档会把 proposal 移到 `archive/` 目录,保持 `changes/` 干净。下次新功能,再起一个新的 proposal。
217+
218+
这就是一轮完整的 SDD 循环。
219+
220+
![SDD 开发循环](https://cdn.xkcoding.com/blog/2026-01-22-illustration-sdd-cycle.webp?x-oss-process=style/tag_compress)
221+
222+
---
223+
224+
## 一些经验
225+
226+
SDD 流程跑起来之后,踩了一些坑,下面有几个实践经验值得分享一下。
227+
228+
### 一个 spec 做一件事
229+
230+
一个项目不可能一个 proposal 就做完。我的做法是:**渐进式堆砌**
231+
232+
两种情况:
233+
234+
**主动规划**。一开始就知道功能很大,拆成多个 spec。先做 MVP 核心功能,跑通了再加其他的。比如做一个内容管理系统,第一个 spec 只做"文章增删改查",第二个 spec 再加"分类标签",第三个 spec 加"搜索"。
235+
236+
**做着发现**。做的过程中发现"如果加个这个功能体验会更好"。这时候别直接改当前 spec,新开一个 spec 来做。保持每个 spec 边界清晰。
237+
238+
不管哪种情况,核心原则是:**一个 spec 只做一件事**
239+
240+
### 出错了怎么办
241+
242+
用这套流程,错误会少很多。但也会出错。出错的时候,处理方式分两种:
243+
244+
**需求或设计不匹配**。比如做着做着发现,当初设计的方案根本行不通,或者需求理解有偏差。这种情况别硬撑,直接回溯。回到 proposal 阶段重新来,该改设计改设计,该补探讨补探讨。
245+
246+
**设计正确但实现出错**。方向没问题,就是代码写错了。这种情况不用推翻重来。把报错信息和对应的 task 引用告诉 AI,让它定点修复。比如:
247+
248+
```
249+
task 3.2 的实现有问题,报错信息如下:xxx。请修复。
250+
```
251+
252+
AI 有了上下文,纠错效果会好很多。
253+
254+
### 什么时候让 AI 慢下来
255+
256+
前面提到 `ultrathink` 可以触发深度思考模式。不是每次都要用,但有几个场景建议用:
257+
258+
**奠基的时候**。初始化 proposal 是整个项目的基础,方案想不清楚后面全是坑。这时候主动触发深度思考。
259+
260+
**卡壳的时候**。AI 来回修改同一个问题,改了几轮还是不对。这时候让它慢下来想想,别一直快速试错。
261+
262+
**失焦的时候**。你说了好几遍需求,AI 还是理解不对。这时候触发深度思考,让它重新梳理一遍上下文。
263+
264+
判断标准很简单:**如果你觉得 AI 在瞎忙,就让它慢下来**
265+
266+
---
267+
268+
## 什么时候用
269+
270+
这套流程不是万能的,也不是所有场景都要走全套。
271+
272+
我按变更规模分三层:
273+
274+
![什么时候用](https://cdn.xkcoding.com/blog/2026-01-22-illustration-when-to-use.webp?x-oss-process=style/tag_compress)
275+
276+
**大重构 / 大 feature / 探索性功能**。走完整流程:Vibe 阶段探讨 + Deep Research,SDD 阶段 proposal → review → apply → archive。初始化 proposal 的时候触发深度思考。
277+
278+
**小体验优化**。不需要回 Gemini 探讨,直接在 Coding Agent 里起一个轻量 spec。proposal 简单写写,task 列几条,review 一下就开干。
279+
280+
**很小的改动**。改个文案、调个样式、修个明显的 bug。直接改,不用起 spec。
281+
282+
判断原则:**流程是为了控制复杂度,不是为了增加仪式感**
283+
284+
如果一个改动你闭着眼睛都知道怎么做,就没必要走流程。
285+
286+
---
287+
288+
## 最后
289+
290+
总结一下这套工作流的核心:
291+
292+
- **Vibe 阶段**:跟 Gemini 探讨方向,输出 Deep Research 报告
293+
- **SDD 阶段**:用 OpenSpec 管理开发,proposal → review → apply → archive
294+
295+
Vibe 负责"做什么",SDD 负责"做对"。两个阶段配合,既保留了 AI Coding 的发散探索能力,又避免了方向跑偏和反复返工。
296+
297+
这套流程我在 0→1 的新项目和老项目迭代新功能上都验证过,效果不错。不敢说是最优解,但至少比纯 Vibe Coding 可控很多。
298+
299+
工具会不断迭代,模型会越来越强。但"先想清楚再动手"这个道理,应该不会过时。
300+
301+
希望对你有帮助。
302+
303+
---
304+
305+
## 参考资料
306+
307+
- [GitHub - Fission-AI/OpenSpec](https://github.com/Fission-AI/OpenSpec)
308+
- [OpenSpec Deep Dive - redreamality](https://redreamality.com/garden/notes/openspec-guide/)
309+
- [The End of Vibe Coding - DEV Community](https://dev.to/gara501/the-end-of-vibe-coding-why-spec-driven-development-is-the-future-3hpa)
310+
- [Spec-driven development with AI - GitHub Blog](https://github.blog/ai-and-ml/generative-ai/spec-driven-development-with-ai-get-started-with-a-new-open-source-toolkit/)
311+
- [Martin Fowler - Understanding SDD](https://martinfowler.com/articles/exploring-gen-ai/sdd-3-tools.html)

src/layouts/PostDetails.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const nextPost =
110110
<img
111111
src={coverImageUrl}
112112
alt={title}
113-
class="h-auto max-h-[250px] w-full object-cover transition-transform duration-300 group-hover/cover:scale-[1.02] sm:max-h-[400px]"
113+
class="h-auto max-h-[250px] w-full object-contain transition-transform duration-300 group-hover/cover:scale-[1.02] sm:max-h-[500px]"
114114
loading="lazy"
115115
decoding="async"
116116
/>

0 commit comments

Comments
 (0)