跳过主要内容
工作流是包含可重用指令的 Markdown 文件,您可以使用斜杠命令按需调用它们。可以把它们想象成“需要时调用的规则”,而不是始终激活的指导方针。

什么是工作流?

工作流与规则相似,但有一个关键区别

规则

始终激活开启后自动应用于每个任务示例:编码标准、风格指南

工作流

按需调用仅在您使用斜杠命令时调用示例:部署清单、审查流程
工作流只是 Markdown 文件,无需复杂的配置!

快速示例

这是一个简单的部署工作流: 文件:.clinerules/workflows/deploy.md
# Deployment Workflow

Before deploying to production, ensure:

## Pre-Deployment Checklist
1. All tests passing (unit, integration, e2e)
2. Code review approved by 2+ engineers
3. Staging environment tested successfully
4. Database migrations reviewed
5. Rollback plan documented

## Deployment Steps
1. Create deployment branch from main
2. Run final test suite
3. Deploy to production
4. Monitor error rates for 30 minutes
5. Verify key user flows

## Post-Deployment
1. Update deployment log
2. Notify team in #deployments channel
3. Monitor metrics for 24 hours
用法
/deploy

I'm ready to deploy the new authentication feature
调用时,Cline 会将工作流指令添加到该特定任务的上下文中。

创建工作流

.clinerules/workflows/ 目录中创建工作流文件
  1. 在您的存储库根目录中创建 .clinerules/workflows/
  2. 添加包含工作流指令的 Markdown 文件
  3. 使用与斜杠命令匹配的描述性名称
文件结构
your-repo/
├── .clinerules/
│   └── workflows/
│       ├── deploy.md
│       ├── code-review.md
│       └── bug-triage.md
└── src/

使用工作流

调用工作流

只需输入 / 后跟工作流文件名(不带 .md
/deploy
/code-review  
/bug-triage
工作流指令仅添加到当前任务的 Cline 上下文中。

工作流命名

  • 使用小写字母和连字符:deploy.md, code-review.md
  • 保持名称简短且易记
  • 名称应指示工作流的目的
工作流文件名成为斜杠命令,因此选择易于输入和记住的名称。

全局工作流 vs 工作区工作流

工作区工作流

位置:存储库中的 .clinerules/workflows/范围:特定于该项目用途:项目特定的流程和清单

全局工作流

位置:Documents/Cline/Workflows/ 目录范围:您所有的项目用途:适用于所有地方的个人工作流
优先级:如果本地工作流与全局工作流同名,则本地工作流会覆盖全局工作流。

管理工作流

切换工作流

您可以启用或禁用工作流
  1. 单击 Cline 界面中的规则图标
  2. 切换到“工作流”选项卡
  3. 根据需要开启/关闭工作流
禁用工作流会阻止其被调用,但文件会保持不变。斜杠命令将无法使用,直到您重新启用它。

企业版远程工作流

企业部署可以配置对所有团队成员都可用的远程全局工作流。这些通过您的基础设施配置进行管理。有关远程工作流的详细信息,请参阅自托管配置

示例工作流

# Code Review Workflow

## Pre-Review Checklist
- [ ] Code follows project style guide
- [ ] All tests pass locally
- [ ] No console.log or debugging code
- [ ] Comments explain "why" not "what"
- [ ] PR description is clear and complete

## Review Focus Areas
1. **Architecture**: Does this fit our existing patterns?
2. **Security**: Any potential vulnerabilities?
3. **Performance**: Any obvious bottlenecks?
4. **Testing**: Are edge cases covered?
5. **Documentation**: Is it clear how to use new features?

## Review Response
- Address all feedback within 24 hours
- Mark conversations as resolved when addressed
- Re-request review after major changes
# Bug Triage Workflow

## Information Gathering
1. Reproduce the bug in local environment
2. Identify affected versions/environments
3. Check if similar issues exist
4. Gather error logs and stack traces

## Priority Assessment
**P0 (Critical)**: Production down, data loss, security breach
**P1 (High)**: Major feature broken, significant user impact
**P2 (Medium)**: Minor feature broken, workaround available
**P3 (Low)**: Cosmetic issue, minimal impact

## Create Ticket
- Use template: "Bug Report"
- Add reproduction steps
- Include screenshots/videos if applicable
- Tag with affected component
- Assign priority label

## Next Steps
- P0/P1: Immediate fix required
- P2: Schedule for current sprint
- P3: Add to backlog
# Feature Planning Workflow

## Requirements Gathering
1. Define the user problem we're solving
2. List success criteria (measurable)
3. Identify edge cases and constraints
4. Document technical dependencies

## Design Considerations
1. How does this fit existing architecture?
2. What data models are needed?
3. What API changes are required?
4. How will this impact performance?

## Implementation Plan
1. Break into smaller, shippable pieces
2. Identify which pieces can be done in parallel
3. Note any feature flags needed
4. Plan for backwards compatibility

## Testing Strategy
1. What unit tests are needed?
2. What integration tests are needed?
3. How will we test edge cases?
4. What manual testing is required?

最佳实践

工作流应包含可操作的步骤,而非一般建议
  • ✅ “运行 npm test 并验证所有测试通过”
  • ❌ “确保测试做得彻底”
尽可能将工作流格式化为清单
  • 易于按步骤操作
  • 清晰的进度跟踪
  • 减少遗漏步骤
添加每个步骤背后的原因
1. Check staging environment first
   (Catching issues in staging prevents production incidents)
工作流位于您的存储库中
  • 在 git 中跟踪更改
  • 在 PR 中审查更新
  • 维护流程演变历史

工作流 vs 规则:何时使用

何时使用规则何时使用工作流
指导应应用于每个任务流程偶尔才被调用
很少更改的标准特定场景的清单
始终开启的编码约定按需部署流程
通用编码风格具体的审查程序
示例
  • 规则:“使用 TypeScript 严格模式和显式返回类型”
  • 工作流:“部署到生产环境时遵循这 10 个步骤”

后续步骤