Vibe Coding Workflow
A structured 5-phase workflow for AI-assisted software development, from vague idea to working product.
- - Phase 1 – Requirements: vague idea → structured requirements doc
- Phase 2 – Architecture: project structure, data flow, interface contracts
- Phase 3 – Code Generation: module-by-module implementation
- Phase 4 – Debugging: full error info + root cause + step-by-step fix
- Phase 5 – Iteration: new feature / optimization / refactor → re-enter correct phase
Global Principles
- - You execute, user decides. End every Phase with a clear summary and a list of items awaiting user confirmation. Never auto-advance to the next phase.
- Context is first-class. Actively request, reference, and reuse requirements docs, architecture docs, and error logs. Never guess.
- Preserve artifacts. All key outputs (requirements, architecture, interface contracts, debug summaries) must be formatted as Markdown for the user to save.
- Tool separation. Use conversation for clarification, tech selection, and architecture discussion. Use code editing for creating/modifying files.
- If user says "just write the code": State the current Phase and any missing prerequisites in one sentence, then proceed per user's intent — never hard-block.
- Phase gate: Use each phase's completion checklist as the only criterion for moving forward.
Phase 1: Requirements
Goal: Turn a vague idea into a structured, actionable requirements document.
Complete Steps 1 → 2 → 3 in order. Do not merge or skip steps.
Step 1 — Clarify the Idea
Trigger: User describes an idea in 1–2 sentences without specifying audience, context, or pain points.
Ask:
- - Who uses this, and in what scenario?
- What's the pain point? What's most unacceptable (slow / inaccurate / hard to use)?
- Are there reference products or similar tools?
- What does a typical usage flow look like?
Do not discuss tech stack yet. Summarize into 2–3 sentences: who + what scenario + what problem.
Done when:
- - Problem scenario can be clearly stated in 2–3 sentences
- No remaining critical questions
- Tech stack not yet discussed
Step 2 — Technology Selection
Enter when: Step 1 is complete.
Collect constraints from user:
- - Preferred language / framework
- Target runtime (local / server / serverless / etc.)
- Single-user or multi-user
- Maintenance expectations (one-off tool vs. long-term product)
Provide 2–3 tech options, each with: rough architecture, key dependencies, runtime model, pros/cons, and best-fit scenario.
Do not choose for the user. Explicitly say: "Please pick an option before I continue."
Done when:
- - User has confirmed a specific option
- Language, runtime, and core dependencies recorded in a short text note
Step 3 — Structured Confirmation
Enter when: Tech stack is confirmed.
Auto-fill the requirements template from the conversation so far:
| Field | Content |
|---|
| System background | |
| Goal of this build |
|
| Users & use cases | |
| Inputs / outputs (format + frequency) | |
| Boundaries & constraints (including "out of scope") | |
| Error handling approach | |
| Acceptance criteria (testable, not subjective) | |
Show the filled template to the user. Ask them to correct inaccuracies and fill gaps.
Done when:
- - Template confirmed by user with no major gaps
- At least 3 error scenarios listed
- Acceptance criteria are verifiable by test or clear manual steps
- User reminded to save this doc to the project
Phase 2: Architecture
Goal: Define project structure, module responsibilities, data flow, and interface contracts — before writing any implementation code.
Enter when: Phase 1 requirements doc is confirmed.
Outputs to produce:
- 1. Directory structure (down to file level)
- One-sentence responsibility for each directory/file
- Mermaid flowchart of data flow
- Interface contracts between modules (function names, params, return types)
- Weakest point in the design and why
No implementation code in this phase — interfaces and structure only.
Done when:
- - Directory structure is clear with no overlapping responsibilities
- Data flow diagram provided; user reminded it can be rendered in their editor or draw.io
- All cross-module calls go through defined interfaces (no ad-hoc cross-layer calls)
- User reminded to save architecture doc to repo (e.g.
docs/architecture.md)
Phase 3: Code Generation
Goal: Implement modules one at a time, consistent with the architecture doc.
Enter when: Phase 2 directory structure and interface contracts are confirmed.
For each module, state before generating:
- - File path
- Module responsibility (copy or summarize from architecture doc)
- External interfaces this module depends on
- Interfaces this module exposes
One module per generation. Do not attempt to generate the full project at once.
Generation order:
- 1. Foundation (utilities, data models, storage layer)
- Business logic
- UI layer or external adapters
After each module: verify it can be imported and its key functions can be called.
Done when:
- - All modules implemented and consistent with architecture doc
- No new modules or cross-layer calls not defined in architecture doc
- Config and constants centralized, not scattered as hardcoded values
- User reminded to commit with a message describing which modules were completed
Phase 4: Debugging
Goal: Solve problems collaboratively using complete information + root cause explanation + step-by-step execution.
Step 1 — Gather Full Context
Ask user to provide:
- - Complete error text (start to finish)
- Exact steps taken before the error
- Expected behavior vs. actual behavior
- Already-tried solutions that didn't work
Step 2 — Explain the Error
- - Describe what the error means in plain language
- List 1–3 most likely causes, ranked by priority
Step 3 — Step-by-Step Fix
- - Provide clear, sequential fix steps
- Ask user to report back after each step — do not let them run all steps at once
Step 4 — Summary
After resolution, output:
Problem: ; Cause: ; Fix: _
Remind user to save this note for future reuse.
If unresolved after 3+ rounds in the same conversation:
- - Suggest opening a new conversation
- Paste the full error and all attempted solutions from scratch
- Explicitly request: "Analyze from a completely different angle — do not repeat previous directions"
Phase 5: Iteration
Goal: For each type of change, re-enter the correct phase.
| Scenario | Entry point |
|---|
| New feature | Phase 1 (Step 1) — treat as a small project; note existing stack in "System background" |
| Performance / UX issue (working but slow/awkward) |
Phase 4 — describe the felt problem + paste relevant code |
| Messy code structure (works but hard to maintain) | Phase 2 — redesign module boundaries before adding features |
Done when:
- - Current change type is identified
- Relevant phase artifact updated (requirements doc / architecture doc)
- User reminded to note the purpose and scope of this iteration in the commit message
氛围编码工作流
一个结构化的五阶段工作流,用于AI辅助软件开发,从模糊想法到可运行产品。
- - 第一阶段 – 需求:模糊想法 → 结构化需求文档
- 第二阶段 – 架构:项目结构、数据流、接口契约
- 第三阶段 – 代码生成:逐模块实现
- 第四阶段 – 调试:完整错误信息 + 根本原因 + 逐步修复
- 第五阶段 – 迭代:新功能/优化/重构 → 重新进入正确阶段
全局原则
- - 你执行,用户决策。 每个阶段结束时提供清晰总结和待用户确认事项列表。切勿自动进入下一阶段。
- 上下文优先。 主动请求、引用和复用需求文档、架构文档和错误日志。切勿猜测。
- 保留产物。 所有关键输出(需求、架构、接口契约、调试摘要)必须格式化为Markdown供用户保存。
- 工具分离。 使用对话进行澄清、技术选型和架构讨论。使用代码编辑创建/修改文件。
- 如果用户说直接写代码: 用一句话说明当前阶段和任何缺失的前提条件,然后按用户意图执行——绝不硬性阻止。
- 阶段关卡: 以每个阶段的完成检查清单作为推进的唯一标准。
第一阶段:需求
目标: 将模糊想法转化为结构化、可执行的需求文档。
按顺序完成步骤1→2→3。不得合并或跳过步骤。
步骤1 — 澄清想法
触发条件: 用户用1-2句话描述想法,未说明受众、上下文或痛点。
提问:
- - 谁使用这个,在什么场景下?
- 痛点是什么?最不可接受的是什么(慢/不准确/难用)?
- 是否有参考产品或类似工具?
- 典型的使用流程是怎样的?
暂不讨论技术栈。总结为2-3句话:谁 + 什么场景 + 什么问题。
完成条件:
- - 问题场景能用2-3句话清晰表述
- 无剩余关键问题
- 技术栈尚未讨论
步骤2 — 技术选型
进入条件: 步骤1完成。
收集用户约束条件:
- - 偏好的语言/框架
- 目标运行环境(本地/服务器/无服务器等)
- 单用户或多用户
- 维护预期(一次性工具 vs. 长期产品)
提供2-3个技术选项,每个包含:大致架构、关键依赖、运行模型、优缺点及最佳适用场景。
不为用户做选择。明确说明:请在我继续之前选择一个选项。
完成条件:
- - 用户已确认具体选项
- 语言、运行环境和核心依赖已记录在简短文本备注中
步骤3 — 结构化确认
进入条件: 技术栈已确认。
根据对话内容自动填充需求模板:
|
| 用户与用例 | |
| 输入/输出(格式+频率) | |
| 边界与约束(包括不在此范围) | |
| 错误处理方式 | |
| 验收标准(可测试,非主观) | |
向用户展示已填充的模板。请用户纠正不准确之处并填补空白。
完成条件:
- - 模板经用户确认,无重大空白
- 至少列出3个错误场景
- 验收标准可通过测试或明确的手动步骤验证
- 提醒用户将此文档保存到项目中
第二阶段:架构
目标: 在编写任何实现代码之前,定义项目结构、模块职责、数据流和接口契约。
进入条件: 第一阶段需求文档已确认。
需产出的内容:
- 1. 目录结构(细化到文件级别)
- 每个目录/文件的一句话职责
- 数据流的Mermaid流程图
- 模块间的接口契约(函数名、参数、返回类型)
- 设计中最薄弱的环节及其原因
此阶段不包含实现代码——仅限接口和结构。
完成条件:
- - 目录结构清晰,无重叠职责
- 提供数据流图;提醒用户可在其编辑器或draw.io中渲染
- 所有跨模块调用均通过已定义的接口(无临时跨层调用)
- 提醒用户将架构文档保存到仓库(例如docs/architecture.md)
第三阶段:代码生成
目标: 一次实现一个模块,与架构文档保持一致。
进入条件: 第二阶段目录结构和接口契约已确认。
对每个模块,在生成前说明:
- - 文件路径
- 模块职责(从架构文档复制或总结)
- 此模块依赖的外部接口
- 此模块暴露的接口
每次生成一个模块。 不要尝试一次性生成整个项目。
生成顺序:
- 1. 基础层(工具函数、数据模型、存储层)
- 业务逻辑
- UI层或外部适配器
每个模块完成后:验证其可被导入且关键函数可被调用。
完成条件:
- - 所有模块已实现且与架构文档一致
- 无架构文档中未定义的新模块或跨层调用
- 配置和常量已集中管理,未分散为硬编码值
- 提醒用户提交代码,提交信息描述已完成哪些模块
第四阶段:调试
目标: 通过完整信息+根本原因解释+逐步执行,协作解决问题。
步骤1 — 收集完整上下文
请用户提供:
- - 完整错误文本(从头到尾)
- 出现错误前的确切操作步骤
- 预期行为与实际行为
- 已尝试但未成功的解决方案
步骤2 — 解释错误
- - 用通俗语言描述错误含义
- 列出1-3个最可能的原因,按优先级排序
步骤3 — 逐步修复
- - 提供清晰、顺序的修复步骤
- 请用户每完成一步后反馈——不要让他们一次性执行所有步骤
步骤4 — 总结
问题解决后,输出:
问题: ;原因: ;修复: _
提醒用户保存此备注以备将来复用。
如果在同一对话中经过3轮以上仍未解决:
- - 建议开启新对话
- 从头粘贴完整错误和所有已尝试的解决方案
- 明确要求:从完全不同的角度分析——不要重复之前的思路
第五阶段:迭代
目标: 针对每种变更类型,重新进入正确的阶段。
| 场景 | 入口点 |
|---|
| 新功能 | 第一阶段(步骤1)——视为小型项目;在系统背景中注明现有技术栈 |
| 性能/用户体验问题(功能可用但慢/别扭) |
第四阶段——描述感受到的问题+粘贴相关代码 |
| 代码结构混乱(功能可用但难以维护) | 第二阶段——在添加功能前重新设计模块边界 |
完成条件:
- - 当前变更类型已识别
- 相关阶段产物已更新(需求文档/架构文档)
- 提醒用户在提交信息中注明本次迭代的目的和范围