Agentic Coding 完整工作流(AI-native 工程体系)

你现在要建立的,不是:

AI 帮我写代码

而是:

AI 驱动的软件工程系统

这两者差距非常大。

真正成熟的 Agentic Coding,不是 Prompt Engineering,而是 System Engineering(系统工程)。


一、Agentic Coding 的本质

传统开发:

人类:
定义需求 -> 写代码 -> 测试 -> 修复

Agentic Coding:

人类:
定义系统边界与协议

AI:
规划 -> 拆解 -> 实现 -> 测试 -> Review -> Refactor

所以,在 Agentic Coding 中,职责分工发生了根本变化。

人类负责

  • 目标

  • 边界

  • 约束

  • 哲学

  • Contract

AI 负责

  • 实现

  • 重复工程

  • boilerplate

  • schema propagation

  • 测试

  • review


二、完整 Agentic Workflow

成熟的 Agentic Coding 工作流通常分为 10 个阶段。

Phase 1 — Product Definition

产品定义阶段。

目标

定义:

  • 产品目标

  • 用户是谁

  • 核心工作流

  • AI Agent 行为

本阶段要输出什么

例如:

# Product Vision

这是一个 AI Agent 平台。

用户可以:

- 创建 Agent
- 配置工具
- 执行 Workflow
- 查看 Execution 历史
- 实时观察 Agent 推理过程

本阶段 AI 的角色

AI 不写代码。

AI 负责:

  • challenge 你的想法

  • 补全遗漏

  • 风险分析

Phase 2 — Domain Modeling

领域建模阶段。

这是最核心阶段。

目标

定义系统世界观。

本阶段要输出什么

例如:

User
Workspace
Agent
Execution
Memory
Tool
Workflow
Event

以及它们之间的关系:

Workspace has many Agents
Agent has many Executions
Execution emits Events

为什么最重要

因为:

  • API

  • DB

  • 权限

  • 状态流

全部来自 Domain Model。

推荐 Prompt

Please design the domain model for this Agent platform.

Focus on:
- entity boundaries
- ownership
- lifecycle
- multi-tenant architecture
- extensibility

中文注释:

请设计整个 Agent 平台的领域模型,
重点关注:
- 实体边界
- 数据归属
- 生命周期
- 多租户
- 扩展性

Phase 3 — State Machine Design

状态机设计阶段。

Agent 产品的核心之一是状态流转。

目标

定义系统如何流动。

Execution 状态示例

idle
queued
planning
tool_calling
waiting_human
streaming
completed
failed
cancelled

需要定义

  • 哪些状态允许跳转

  • 哪些状态可恢复

  • 哪些状态支持 retry

  • websocket 如何同步

推荐 Prompt

Design the execution lifecycle state machine.

Include:
- transitions
- retry logic
- cancellation
- streaming behavior
- frontend synchronization

中文注释:

设计 Execution 生命周期状态机,
包括:
- 状态转换
- 重试逻辑
- 取消机制
- streaming 行为
- 前端同步方式

Phase 4 — Event Architecture

事件架构阶段。

Agent 系统本质上是 Event-driven。

本阶段要输出什么

例如:

ExecutionStarted
TokenStreamDelta
ToolCallRequested
ToolCallCompleted
ExecutionFailed

Event Schema 示例

type ExecutionEvent = {
  id: string
  type: string
  executionId: string
  timestamp: string
  payload: unknown
}

推荐 Prompt

Design an event-driven architecture for the Agent runtime.

Include:
- event taxonomy
- streaming protocol
- ordering guarantees
- retry semantics

中文注释:

为 Agent Runtime 设计事件驱动架构,
包括:
- 事件分类
- streaming 协议
- 顺序保证
- 重试语义

Phase 5 — API Contract Design

接口契约设计阶段。

核心思想

Contract First。

不是:

先写 API

而是:

先定义协议

本阶段要输出什么

  • OpenAPI

  • GraphQL schema

  • protobuf

  • error schema

  • pagination rules

API 示例

POST /executions
GET /executions/:id/events
POST /executions/:id/cancel

推荐 Prompt

Design the API contract for the Agent platform.

Requirements:
- OpenAPI-first
- typed schemas
- standardized errors
- cursor pagination
- streaming support

中文注释:

设计 Agent 平台 API Contract,
要求:
- OpenAPI 优先
- 类型安全
- 标准化错误
- cursor 分页
- streaming 支持

Phase 6 — Frontend/Backend Boundary

前后端边界设计阶段。

目标

定义:

  • 谁负责状态

  • 谁负责缓存

  • 谁负责 streaming

  • 谁负责 optimistic update

职责划分示例

Frontend:
- UI state
- cache
- optimistic updates

Backend:
- source of truth
- event ordering
- permissions

推荐 Prompt

Define frontend/backend responsibilities.

Focus on:
- cache ownership
- event synchronization
- optimistic updates
- websocket responsibilities

中文注释:

定义前后端职责边界,
重点:
- cache 所有权
- event 同步
- optimistic update
- websocket 职责

Phase 7 — Architecture Decomposition

系统拆分阶段。

目标

拆分 Service。

Service 示例

frontend-app
api-service
execution-engine
memory-service
tool-runtime
event-bus
gateway

推荐 Prompt

Decompose the platform into services.

Define:
- service boundaries
- ownership
- communication protocol
- scaling concerns

中文注释:

拆分系统服务,
定义:
- 服务边界
- ownership
- 通信协议
- 扩展问题

Phase 8 — Code Generation

代码生成阶段。

现在才开始写代码。

AI 负责

  • boilerplate

  • schema propagation

  • CRUD

  • tests

  • SDK

  • types

推荐 Prompt

Implement the execution service based on the approved architecture.

Requirements:
- typed schemas
- service layer
- repository pattern
- event emission
- unit tests

中文注释:

基于已确认架构实现 execution service,
要求:
- 类型安全
- service layer
- repository pattern
- event emission
- 单元测试

Phase 9 — AI Review

AI Review 阶段。

这是高级玩法:不让 AI 只写代码,还要让 AI Review 自己。

示例 Prompt

Review the current architecture.

Focus on:
- scalability
- websocket bottlenecks
- event consistency
- retry behavior
- observability
- multi-agent extensibility

中文注释:

Review 当前架构,
重点:
- 扩展性
- websocket 瓶颈
- event consistency
- retry 行为
- 可观测性
- 多 Agent 扩展性

Phase 10 — Continuous Evolution

持续演化阶段。

AI-native 系统不是:

写完结束

而是:

持续演化

AI 持续负责

  • refactor

  • schema migration

  • performance optimization

  • observability

  • test generation

  • dead code detection


三、Agentic Coding 的核心文件

1. AGENTS.md

最重要。

用于定义:

  • 工程哲学

  • 规则

  • coding constraints

示例

# Engineering Rules

- OpenAPI-first
- typed everywhere
- async-first
- event-driven
- no business logic in controllers

中文注释:

工程规则:
- OpenAPI 优先
- 全类型安全
- async-first
- event-driven
- controller 禁止业务逻辑

2. architecture.md

用于定义:

  • service boundary

  • event flow

  • state machine

3. api-schema.yaml

用于定义 OpenAPI contract。

4. event-schema.ts

用于定义 streaming event contract。


四、真正成熟的 Agentic Engineering 思维

核心不是:

让 AI 写代码

而是:

让 AI 维护系统协议


五、未来真正重要的人

不是:

会写 CRUD 的人

而是会定义以下内容的人:

  • Domain

  • State

  • Event

  • Contract

  • Boundary


六、你现在真正应该做的事

建立你自己的 AI Engineering Operating System。

包括:

  • architecture prompts

  • contract prompts

  • review prompts

  • AGENTS.md

  • event schema templates

  • RFC templates


七、一句话总结

传统开发:

Human writes implementation.

中文:

人类写实现。

Agentic Coding:

Human defines systems.
AI implements systems.

中文:

人类定义系统,
AI 实现系统。

3 个赞