-[](https://github.com/catlog22/Claude-Code-Workflow/releases)
+[](https://github.com/catlog22/Claude-Code-Workflow/releases)
[](LICENSE)
[]()
[](https://github.com/modelcontextprotocol)
@@ -15,7 +15,7 @@
**Claude Code Workflow (CCW)** is a next-generation multi-agent automation framework that orchestrates complex software development tasks through intelligent workflow management and autonomous execution.
-> **🎉 Latest: v3.0.1** - Documentation optimization and brainstorming role updates. See [CHANGELOG.md](CHANGELOG.md) for details.
+> **🎉 Latest: v3.1.0** - TDD Workflow Support with Red-Green-Refactor cycle enforcement. See [CHANGELOG.md](CHANGELOG.md) for details.
>
> **v3.0.0**: Introduced **unified CLI command structure**. The `/cli:*` commands consolidate all tool interactions (Gemini, Qwen, Codex) using a `--tool` flag for selection.
@@ -23,13 +23,15 @@
## ✨ Key Features
-- **🤖 Multi-Agent System**: Specialized agents for planning, coding, testing, and reviewing.
-- **🔄 End-to-End Workflow Automation**: From brainstorming (`/workflow:brainstorm`) to deployment.
-- **🎯 JSON-First Architecture**: Uses JSON as the single source of truth for tasks, ensuring consistency.
-- **🧪 Automated Test Generation**: Creates comprehensive test suites based on implementation analysis.
+- **🎯 Context-First Architecture**: Pre-defined context gathering eliminates execution uncertainty and error accumulation.
+- **🤖 Multi-Agent System**: Specialized agents (`@code-developer`, `@code-review-test-agent`) with tech-stack awareness.
+- **🔄 End-to-End Workflow Automation**: From brainstorming to deployment with multi-phase orchestration.
+- **📋 JSON-First Task Model**: Structured task definitions with `pre_analysis` steps for deterministic execution.
+- **🧪 TDD Workflow Support**: Complete Test-Driven Development with Red-Green-Refactor cycle enforcement.
+- **🧠 Multi-Model Orchestration**: Leverages Gemini (analysis), Qwen (architecture), and Codex (implementation) strengths.
- **✅ Pre-execution Verification**: Validates plans with both strategic (Gemini) and technical (Codex) analysis.
- **🔧 Unified CLI**: A single, powerful `/cli:*` command set for interacting with various AI tools.
-- **🧠 Smart Context Management**: Automatically manages and updates project documentation (`CLAUDE.md`).
+- **📦 Smart Context Package**: `context-package.json` links tasks to relevant codebase files and external examples.
---
@@ -55,27 +57,74 @@ After installation, run the following command to ensure CCW is working:
---
-## 🚀 Getting Started: A Simple Workflow
+## 🚀 Getting Started
-1. **Start a new workflow session:**
- ```bash
- /workflow:session:start "Create a new user authentication feature"
- ```
+### Complete Development Workflow
-2. **Generate an implementation plan:**
- ```bash
- /workflow:plan "Implement JWT-based user authentication"
- ```
+**Phase 1: Brainstorming & Conceptual Planning**
+```bash
+# Multi-perspective brainstorming with role-based agents
+/workflow:brainstorm:auto-parallel "Build a user authentication system"
-3. **Execute the plan with AI agents:**
- ```bash
- /workflow:execute
- ```
+# Review and refine specific aspects (optional)
+/workflow:brainstorm:ui-designer "authentication flows"
+/workflow:brainstorm:synthesis # Generate consolidated specification
+```
-4. **Check the status:**
- ```bash
- /workflow:status
- ```
+**Phase 2: Action Planning**
+```bash
+# Create executable implementation plan
+/workflow:plan "Implement JWT-based authentication system"
+
+# OR for TDD approach
+/workflow:tdd-plan "Implement authentication with test-first development"
+```
+
+**Phase 3: Execution**
+```bash
+# Execute tasks with AI agents
+/workflow:execute
+
+# Monitor progress
+/workflow:status
+```
+
+**Phase 4: Testing & Quality Assurance**
+```bash
+# Generate comprehensive test suite (standard workflow)
+/workflow:test-gen
+/workflow:execute
+
+# OR verify TDD compliance (TDD workflow)
+/workflow:tdd-verify
+
+# Final quality review
+/workflow:review
+```
+
+### Quick Start for Simple Tasks
+
+**Feature Development:**
+```bash
+/workflow:session:start "Add password reset feature"
+/workflow:plan "Email-based password reset with token expiry"
+/workflow:execute
+```
+
+**Bug Fixing:**
+```bash
+# Interactive analysis with CLI tools
+/cli:mode:bug-index --tool gemini "Login timeout on mobile devices"
+
+# Execute the suggested fix
+/workflow:execute
+```
+
+**Code Analysis:**
+```bash
+# Deep codebase analysis
+/cli:mode:code-analysis --tool qwen "Analyze authentication module architecture"
+```
---
@@ -101,9 +150,11 @@ After installation, run the following command to ensure CCW is working:
| `/workflow:session:*` | Manage development sessions (`start`, `pause`, `resume`, `list`, `switch`, `complete`). |
| `/workflow:brainstorm:*` | Use role-based agents for multi-perspective planning. |
| `/workflow:plan` | Create a detailed, executable plan from a description. |
+| `/workflow:tdd-plan` | Create a Test-Driven Development workflow with Red-Green-Refactor cycles. |
| `/workflow:execute` | Execute the current workflow plan autonomously. |
| `/workflow:status` | Display the current status of the workflow. |
| `/workflow:test-gen` | Automatically generate a test plan from the implementation. |
+| `/workflow:tdd-verify` | Verify TDD compliance and generate quality report. |
| `/workflow:review` | Initiate a quality assurance review of the completed work. |
### **Task & Memory Commands**
@@ -167,6 +218,162 @@ MCP (Model Context Protocol) tools provide advanced codebase analysis. **Complet
---
+## 🧩 How It Works: Design Philosophy
+
+### The Core Problem
+
+Traditional AI coding workflows face a fundamental challenge: **execution uncertainty leads to error accumulation**.
+
+**Example:**
+```bash
+# Prompt 1: "Develop XX feature"
+# Prompt 2: "Review XX architecture in file Y, then develop XX feature"
+```
+
+While Prompt 1 might succeed for simple tasks, in complex workflows:
+- The AI may examine different files each time
+- Small deviations compound across multiple steps
+- Final output drifts from the intended goal
+
+> **CCW's Mission**: Solve the "1-to-N" problem — building upon existing codebases with precision, not just "0-to-1" greenfield development.
+
+---
+
+### The CCW Solution: Context-First Architecture
+
+#### 1. **Pre-defined Context Gathering**
+
+Instead of letting agents randomly explore, CCW uses structured context packages:
+
+**`context-package.json`** created during planning:
+```json
+{
+ "metadata": {
+ "task_description": "...",
+ "tech_stack": {"frontend": [...], "backend": [...]},
+ "complexity": "high"
+ },
+ "assets": [
+ {
+ "path": "synthesis-specification.md",
+ "priority": "critical",
+ "sections": ["Backend Module Structure"]
+ }
+ ],
+ "implementation_guidance": {
+ "start_with": ["Step 1", "Step 2"],
+ "critical_security_items": [...]
+ }
+}
+```
+
+#### 2. **JSON-First Task Model**
+
+Each task includes a `flow_control.pre_analysis` section:
+
+```json
+{
+ "id": "IMPL-1",
+ "flow_control": {
+ "pre_analysis": [
+ {
+ "step": "load_architecture",
+ "commands": ["Read(architecture.md)", "grep 'auth' src/"],
+ "output_to": "arch_context",
+ "on_error": "fail"
+ }
+ ],
+ "implementation_approach": {
+ "modification_points": ["..."],
+ "logic_flow": ["..."]
+ },
+ "target_files": ["src/auth/index.ts"]
+ }
+}
+```
+
+**Key Innovation**: The `pre_analysis` steps are **executed before implementation**, ensuring agents always have the correct context.
+
+#### 3. **Multi-Phase Orchestration**
+
+CCW workflows are orchestrators that coordinate slash commands:
+
+**Planning Phase** (`/workflow:plan`):
+```
+Phase 1: session:start → Create session
+Phase 2: context-gather → Build context-package.json
+Phase 3: concept-enhanced → CLI analysis (Gemini/Qwen)
+Phase 4: task-generate → Generate task JSONs with pre_analysis
+```
+
+**Execution Phase** (`/workflow:execute`):
+```
+For each task:
+ 1. Execute pre_analysis steps → Load context
+ 2. Apply implementation_approach → Make changes
+ 3. Validate acceptance criteria → Verify success
+ 4. Generate summary → Track progress
+```
+
+#### 4. **Multi-Model Orchestration**
+
+Each AI model serves its strength:
+
+| Model | Role | Use Cases |
+|-------|------|-----------|
+| **Gemini** | Analysis & Understanding | Long-context analysis, architecture review, bug investigation |
+| **Qwen** | Architecture & Design | System design, code generation, architectural planning |
+| **Codex** | Implementation | Feature development, testing, autonomous execution |
+
+**Example:**
+```bash
+# Gemini analyzes the problem space
+/cli:mode:code-analysis --tool gemini "Analyze auth module"
+
+# Qwen designs the solution
+/cli:analyze --tool qwen "Design scalable auth architecture"
+
+# Codex implements the code
+/workflow:execute # Uses @code-developer with Codex
+```
+
+---
+
+### From 0-to-1 vs 1-to-N Development
+
+| Scenario | Traditional Workflow | CCW Approach |
+|----------|---------------------|--------------|
+| **Greenfield (0→1)** | ✅ Works well | ✅ Adds structured planning |
+| **Feature Addition (1→2)** | ⚠️ Context uncertainty | ✅ Context-package links to existing code |
+| **Bug Fixing (N→N+1)** | ⚠️ May miss related code | ✅ Pre-analysis finds dependencies |
+| **Refactoring** | ⚠️ Unpredictable scope | ✅ CLI analysis + structured tasks |
+
+---
+
+### Key Workflows
+
+#### **Complete Development (Brainstorm → Deploy)**
+```
+Brainstorm (8 roles) → Synthesis → Plan (4 phases) → Execute → Test → Review
+```
+
+#### **Quick Feature Development**
+```
+session:start → plan → execute → test-gen → execute
+```
+
+#### **TDD Workflow**
+```
+tdd-plan (TEST→IMPL→REFACTOR chains) → execute → tdd-verify
+```
+
+#### **Bug Fixing**
+```
+cli:mode:bug-index (analyze) → execute (fix) → test-gen (verify)
+```
+
+---
+
## 🤝 Contributing & Support
- **Repository**: [GitHub - Claude-Code-Workflow](https://github.com/catlog22/Claude-Code-Workflow)
diff --git a/README_CN.md b/README_CN.md
index 43cde900..a3836b7c 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -2,7 +2,7 @@
-[](https://github.com/catlog22/Claude-Code-Workflow/releases)
+[](https://github.com/catlog22/Claude-Code-Workflow/releases)
[](LICENSE)
[]()
[](https://github.com/modelcontextprotocol)
@@ -15,7 +15,7 @@
**Claude Code Workflow (CCW)** 是一个新一代的多智能体自动化开发框架,通过智能工作流管理和自主执行来协调复杂的软件开发任务。
-> **🎉 最新版本: v3.0.1** - 文档优化和头脑风暴角色更新。详见 [CHANGELOG.md](CHANGELOG.md)。
+> **🎉 最新版本: v3.1.0** - TDD 工作流支持,包含 Red-Green-Refactor 循环强制执行。详见 [CHANGELOG.md](CHANGELOG.md)。
>
> **v3.0.0 版本**: 引入了**统一的 CLI 命令结构**。`/cli:*` 命令通过 `--tool` 标志整合了所有工具(Gemini, Qwen, Codex)的交互。
@@ -23,13 +23,15 @@
## ✨ 核心特性
-- **🤖 多智能体系统**: 用于规划、编码、测试和审查的专用智能体。
-- **🔄 端到端工作流自动化**: 从头脑风暴 (`/workflow:brainstorm`) 到部署的完整流程。
-- **🎯 JSON 优先架构**: 使用 JSON 作为任务的唯一真实数据源,确保一致性。
-- **🧪 自动测试生成**: 基于实现分析创建全面的测试套件。
+- **🎯 上下文优先架构**: 预定义上下文收集消除执行不确定性和误差累积。
+- **🤖 多智能体系统**: 专用智能体(`@code-developer`、`@code-review-test-agent`)具备技术栈感知能力。
+- **🔄 端到端工作流自动化**: 从头脑风暴到部署的多阶段编排。
+- **📋 JSON 优先任务模型**: 结构化任务定义,包含 `pre_analysis` 步骤实现确定性执行。
+- **🧪 TDD 工作流支持**: 完整的测试驱动开发,包含 Red-Green-Refactor 循环强制执行。
+- **🧠 多模型编排**: 发挥 Gemini(分析)、Qwen(架构)和 Codex(实现)各自优势。
- **✅ 执行前验证**: 通过战略(Gemini)和技术(Codex)双重分析验证计划。
- **🔧 统一 CLI**: 一个强大、统一的 `/cli:*` 命令集,用于与各种 AI 工具交互。
-- **🧠 智能上下文管理**: 自动管理和更新项目文档 (`CLAUDE.md`)。
+- **📦 智能上下文包**: `context-package.json` 将任务链接到相关代码库文件和外部示例。
---
@@ -55,27 +57,74 @@ bash <(curl -fsSL https://raw.githubusercontent.com/catlog22/Claude-Code-Workflo
---
-## 🚀 快速入门:一个简单的工作流
+## 🚀 快速入门
-1. **启动一个新的工作流会话:**
- ```bash
- /workflow:session:start "创建一个新的用户认证功能"
- ```
+### 完整开发工作流
-2. **生成一个实现计划:**
- ```bash
- /workflow:plan "实现基于JWT的用户认证"
- ```
+**阶段 1:头脑风暴与概念规划**
+```bash
+# 多视角头脑风暴,使用基于角色的智能体
+/workflow:brainstorm:auto-parallel "构建用户认证系统"
-3. **使用 AI 智能体执行计划:**
- ```bash
- /workflow:execute
- ```
+# 审查和优化特定方面(可选)
+/workflow:brainstorm:ui-designer "认证流程"
+/workflow:brainstorm:synthesis # 生成综合规范
+```
-4. **检查状态:**
- ```bash
- /workflow:status
- ```
+**阶段 2:行动规划**
+```bash
+# 创建可执行的实现计划
+/workflow:plan "实现基于 JWT 的认证系统"
+
+# 或使用 TDD 方法
+/workflow:tdd-plan "使用测试优先开发实现认证"
+```
+
+**阶段 3:执行**
+```bash
+# 使用 AI 智能体执行任务
+/workflow:execute
+
+# 监控进度
+/workflow:status
+```
+
+**阶段 4:测试与质量保证**
+```bash
+# 生成全面测试套件(标准工作流)
+/workflow:test-gen
+/workflow:execute
+
+# 或验证 TDD 合规性(TDD 工作流)
+/workflow:tdd-verify
+
+# 最终质量审查
+/workflow:review
+```
+
+### 简单任务快速入门
+
+**功能开发:**
+```bash
+/workflow:session:start "添加密码重置功能"
+/workflow:plan "基于邮件的密码重置,带令牌过期"
+/workflow:execute
+```
+
+**Bug 修复:**
+```bash
+# 使用 CLI 工具进行交互式分析
+/cli:mode:bug-index --tool gemini "移动设备上登录超时"
+
+# 执行建议的修复
+/workflow:execute
+```
+
+**代码分析:**
+```bash
+# 深度代码库分析
+/cli:mode:code-analysis --tool qwen "分析认证模块架构"
+```
---
@@ -101,9 +150,11 @@ bash <(curl -fsSL https://raw.githubusercontent.com/catlog22/Claude-Code-Workflo
| `/workflow:session:*` | 管理开发会话(`start`, `pause`, `resume`, `list`, `switch`, `complete`)。 |
| `/workflow:brainstorm:*` | 使用基于角色的智能体进行多视角规划。 |
| `/workflow:plan` | 从描述创建详细、可执行的计划。 |
+| `/workflow:tdd-plan` | 创建测试驱动开发工作流,包含 Red-Green-Refactor 循环。 |
| `/workflow:execute` | 自主执行当前的工作流计划。 |
| `/workflow:status` | 显示工作流的当前状态。 |
| `/workflow:test-gen` | 从实现中自动生成测试计划。 |
+| `/workflow:tdd-verify` | 验证 TDD 合规性并生成质量报告。 |
| `/workflow:review` | 对已完成的工作启动质量保证审查。 |
### **任务与内存命令**
@@ -167,6 +218,162 @@ MCP (模型上下文协议) 工具提供高级代码库分析。**完全可选**
---
+## 🧩 工作原理:设计理念
+
+### 核心问题
+
+传统的 AI 编码工作流面临一个根本性挑战:**执行不确定性导致误差累积**。
+
+**示例:**
+```bash
+# 提示词1:"开发XX功能"
+# 提示词2:"查看XX文件中架构设计,开发XX功能"
+```
+
+虽然提示词1对简单任务可能成功,但在复杂工作流中:
+- AI 每次可能检查不同的文件
+- 小偏差在多个步骤中累积
+- 最终输出偏离预期目标
+
+> **CCW 的使命**:解决"1到N"的问题 — 精确地在现有代码库基础上开发,而不仅仅是"0到1"的全新项目开发。
+
+---
+
+### CCW 解决方案:上下文优先架构
+
+#### 1. **预定义上下文收集**
+
+CCW 使用结构化上下文包,而不是让智能体随机探索:
+
+**规划阶段创建的 `context-package.json`**:
+```json
+{
+ "metadata": {
+ "task_description": "...",
+ "tech_stack": {"frontend": [...], "backend": [...]},
+ "complexity": "high"
+ },
+ "assets": [
+ {
+ "path": "synthesis-specification.md",
+ "priority": "critical",
+ "sections": ["后端模块结构"]
+ }
+ ],
+ "implementation_guidance": {
+ "start_with": ["步骤1", "步骤2"],
+ "critical_security_items": [...]
+ }
+}
+```
+
+#### 2. **JSON 优先任务模型**
+
+每个任务包含 `flow_control.pre_analysis` 部分:
+
+```json
+{
+ "id": "IMPL-1",
+ "flow_control": {
+ "pre_analysis": [
+ {
+ "step": "load_architecture",
+ "commands": ["Read(architecture.md)", "grep 'auth' src/"],
+ "output_to": "arch_context",
+ "on_error": "fail"
+ }
+ ],
+ "implementation_approach": {
+ "modification_points": ["..."],
+ "logic_flow": ["..."]
+ },
+ "target_files": ["src/auth/index.ts"]
+ }
+}
+```
+
+**核心创新**:`pre_analysis` 步骤在实现**之前执行**,确保智能体始终拥有正确的上下文。
+
+#### 3. **多阶段编排**
+
+CCW 工作流是协调斜杠命令的编排器:
+
+**规划阶段** (`/workflow:plan`):
+```
+阶段1: session:start → 创建会话
+阶段2: context-gather → 构建 context-package.json
+阶段3: concept-enhanced → CLI 分析(Gemini/Qwen)
+阶段4: task-generate → 生成带 pre_analysis 的任务 JSON
+```
+
+**执行阶段** (`/workflow:execute`):
+```
+对于每个任务:
+ 1. 执行 pre_analysis 步骤 → 加载上下文
+ 2. 应用 implementation_approach → 进行更改
+ 3. 验证验收标准 → 验证成功
+ 4. 生成摘要 → 跟踪进度
+```
+
+#### 4. **多模型编排**
+
+每个 AI 模型发挥各自优势:
+
+| 模型 | 角色 | 使用场景 |
+|------|------|----------|
+| **Gemini** | 分析与理解 | 长上下文分析、架构审查、bug 调查 |
+| **Qwen** | 架构与设计 | 系统设计、代码生成、架构规划 |
+| **Codex** | 实现 | 功能开发、测试、自主执行 |
+
+**示例:**
+```bash
+# Gemini 分析问题空间
+/cli:mode:code-analysis --tool gemini "分析认证模块"
+
+# Qwen 设计解决方案
+/cli:analyze --tool qwen "设计可扩展的认证架构"
+
+# Codex 实现代码
+/workflow:execute # 使用带 Codex 的 @code-developer
+```
+
+---
+
+### 0到1 vs 1到N 开发
+
+| 场景 | 传统工作流 | CCW 方法 |
+|------|-----------|----------|
+| **全新项目(0→1)** | ✅ 效果良好 | ✅ 增加结构化规划 |
+| **功能添加(1→2)** | ⚠️ 上下文不确定 | ✅ context-package 链接现有代码 |
+| **Bug 修复(N→N+1)** | ⚠️ 可能遗漏相关代码 | ✅ pre_analysis 查找依赖 |
+| **重构** | ⚠️ 范围不可预测 | ✅ CLI 分析 + 结构化任务 |
+
+---
+
+### 核心工作流
+
+#### **完整开发(头脑风暴 → 部署)**
+```
+头脑风暴(8个角色)→ 综合 → 规划(4阶段)→ 执行 → 测试 → 审查
+```
+
+#### **快速功能开发**
+```
+session:start → plan → execute → test-gen → execute
+```
+
+#### **TDD 工作流**
+```
+tdd-plan (TEST→IMPL→REFACTOR 链) → execute → tdd-verify
+```
+
+#### **Bug 修复**
+```
+cli:mode:bug-index(分析)→ execute(修复)→ test-gen(验证)
+```
+
+---
+
## 🤝 贡献与支持
- **仓库**: [GitHub - Claude-Code-Workflow](https://github.com/catlog22/Claude-Code-Workflow)