Files
Claude-Code-Workflow/docs/zh/guide/first-workflow.md
catlog22 ee4dc367d9 docs: fix 404 errors - add missing zh guide files and fix zh-CN config [IDAW-002]
- Add docs/zh/guide/first-workflow.md (Chinese translation)
- Add docs/zh/guide/cli-tools.md (Chinese translation)
- Fix zh-CN locale config to only show existing files (dashboard, terminal, queue)
- Remove non-existent zh-CN sidebar entries that caused 404 errors
2026-03-01 20:34:11 +08:00

94 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 第一个工作流:构建简单 API
在 30 分钟内完成你的第一个 CCW 工作流。我们将从规范到实现构建一个简单的 REST API。
## 我们要构建什么
一个简单的用户 API包含
- GET /users - 获取所有用户
- GET /users/:id - 根据 ID 获取用户
- POST /users - 创建新用户
- PUT /users/:id - 更新用户
- DELETE /users/:id - 删除用户
## 前提条件
- 已安装 CCW[安装指南](./installation.md)
- Node.js >= 18.0.0
- 代码编辑器(推荐 VS Code
## 步骤 1创建项目5 分钟)
```bash
# 创建项目目录
mkdir user-api
cd user-api
# 初始化 npm 项目
npm init -y
# 安装依赖
npm install express
npm install --save-dev typescript @types/node @types/express
```
## 步骤 2生成规范5 分钟)
```bash
# 使用 CCW 生成 API 规范
ccw cli -p "为用户资源的 CRUD 操作生成 REST API 规范" --mode analysis
```
CCW 将分析你的请求并生成规范文档。
## 步骤 3实现 API15 分钟)
```bash
# 实现 API
ccw cli -p "使用 Express 和 TypeScript 按照规范实现用户 API" --mode write
```
CCW 将:
1. 创建项目结构
2. 实现路由
3. 添加类型定义
4. 包含错误处理
## 步骤 4审查代码5 分钟)
```bash
# 审查实现
ccw cli -p "审查用户 API 代码的质量、安全性和最佳实践" --mode analysis
```
## 步骤 5测试和运行
```bash
# 编译 TypeScript
npx tsc
# 运行服务器
node dist/index.js
# 测试 API
curl http://localhost:3000/users
```
## 预期结果
你应该拥有:
- `src/index.ts` - 主服务器文件
- `src/routes/users.ts` - 用户路由
- `src/types/user.ts` - 用户类型
- `src/middleware/error.ts` - 错误处理
## 下一步
- [CLI 参考](../cli/commands.md) - 学习所有 CLI 命令
- [技能库](../skills/core-skills.md) - 探索内置技能
- [工作流系统](../workflows/4-level.md) - 理解工作流编排
::: tip 恭喜!🎉
你已经完成了第一个 CCW 工作流。现在你可以将 CCW 用于更复杂的项目。
:::