Skip to main content

driven/workflows/
builtin.rs

1//! Built-in Workflow Definitions
2//!
3//! Provides 30+ guided workflows matching BMAD-METHOD capabilities.
4
5use super::{Workflow, WorkflowPhase, WorkflowStep};
6
7/// Get all built-in workflows
8pub fn all_workflows() -> Vec<Workflow> {
9    let mut workflows = Vec::new();
10
11    // Analysis Phase (4)
12    workflows.extend(analysis_workflows());
13
14    // Planning Phase (4)
15    workflows.extend(planning_workflows());
16
17    // Solutioning Phase (4)
18    workflows.extend(solutioning_workflows());
19
20    // Implementation Phase (5)
21    workflows.extend(implementation_workflows());
22
23    // Quick Flow (3)
24    workflows.extend(quick_flow_workflows());
25
26    // Testing (3)
27    workflows.extend(testing_workflows());
28
29    // Documentation (2)
30    workflows.extend(documentation_workflows());
31
32    // DevOps (2)
33    workflows.extend(devops_workflows());
34
35    // Additional workflows (7+)
36    workflows.extend(additional_workflows());
37
38    workflows
39}
40
41/// Analysis phase workflows
42pub fn analysis_workflows() -> Vec<Workflow> {
43    vec![
44        brainstorming(),
45        research(),
46        product_brief(),
47        competitive_analysis(),
48    ]
49}
50
51/// Planning phase workflows
52pub fn planning_workflows() -> Vec<Workflow> {
53    vec![prd(), ux_design(), tech_spec(), api_design()]
54}
55
56/// Solutioning phase workflows
57pub fn solutioning_workflows() -> Vec<Workflow> {
58    vec![
59        architecture(),
60        epics_and_stories(),
61        implementation_readiness(),
62        data_model(),
63    ]
64}
65
66/// Implementation phase workflows
67pub fn implementation_workflows() -> Vec<Workflow> {
68    vec![
69        sprint_planning(),
70        dev_story(),
71        code_review(),
72        retrospective(),
73        sprint_status(),
74    ]
75}
76
77/// Quick Flow workflows
78pub fn quick_flow_workflows() -> Vec<Workflow> {
79    vec![quick_bug_fix(), quick_feature(), quick_refactor()]
80}
81
82/// Testing workflows
83pub fn testing_workflows() -> Vec<Workflow> {
84    vec![test_design(), test_automation(), test_review()]
85}
86
87/// Documentation workflows
88pub fn documentation_workflows() -> Vec<Workflow> {
89    vec![document_project(), api_documentation()]
90}
91
92/// DevOps workflows
93pub fn devops_workflows() -> Vec<Workflow> {
94    vec![ci_setup(), deployment()]
95}
96
97/// Additional workflows
98pub fn additional_workflows() -> Vec<Workflow> {
99    vec![
100        security_review(),
101        performance_review(),
102        onboarding(),
103        tech_debt(),
104        migration(),
105        incident_response(),
106        release_planning(),
107    ]
108}
109
110// ============ Analysis Phase ============
111
112pub fn brainstorming() -> Workflow {
113    Workflow::new(
114        "brainstorming",
115        "Brainstorming",
116        WorkflowPhase::Analysis,
117        "Generate and explore ideas for a new feature or product",
118    )
119    .with_step(
120        WorkflowStep::new(
121            "define-problem",
122            "Define the Problem",
123            "Clearly articulate the problem to solve",
124            "analyst",
125        )
126        .with_actions(vec![
127            "Identify the core problem".to_string(),
128            "Define success criteria".to_string(),
129            "List constraints and assumptions".to_string(),
130        ]),
131    )
132    .with_step(
133        WorkflowStep::new(
134            "generate-ideas",
135            "Generate Ideas",
136            "Brainstorm potential solutions",
137            "analyst",
138        )
139        .with_actions(vec![
140            "List all possible solutions".to_string(),
141            "Encourage wild ideas".to_string(),
142            "Build on others' ideas".to_string(),
143        ]),
144    )
145    .with_step(
146        WorkflowStep::new(
147            "evaluate-ideas",
148            "Evaluate Ideas",
149            "Assess and prioritize ideas",
150            "analyst",
151        )
152        .with_actions(vec![
153            "Score ideas against criteria".to_string(),
154            "Identify pros and cons".to_string(),
155            "Select top candidates".to_string(),
156        ])
157        .as_checkpoint(),
158    )
159    .as_builtin()
160}
161
162pub fn research() -> Workflow {
163    Workflow::new(
164        "research",
165        "Research",
166        WorkflowPhase::Analysis,
167        "Conduct research to inform product decisions",
168    )
169    .with_step(
170        WorkflowStep::new(
171            "define-questions",
172            "Define Research Questions",
173            "Identify what we need to learn",
174            "analyst",
175        )
176        .with_actions(vec![
177            "List key questions".to_string(),
178            "Prioritize by impact".to_string(),
179            "Define research methods".to_string(),
180        ]),
181    )
182    .with_step(
183        WorkflowStep::new(
184            "gather-data",
185            "Gather Data",
186            "Collect relevant information",
187            "analyst",
188        )
189        .with_actions(vec![
190            "Review existing documentation".to_string(),
191            "Analyze competitors".to_string(),
192            "Interview stakeholders".to_string(),
193        ]),
194    )
195    .with_step(
196        WorkflowStep::new(
197            "synthesize",
198            "Synthesize Findings",
199            "Analyze and summarize research",
200            "analyst",
201        )
202        .with_actions(vec![
203            "Identify patterns and themes".to_string(),
204            "Draw conclusions".to_string(),
205            "Make recommendations".to_string(),
206        ])
207        .as_checkpoint(),
208    )
209    .as_builtin()
210}
211
212pub fn product_brief() -> Workflow {
213    Workflow::new(
214        "product-brief",
215        "Product Brief",
216        WorkflowPhase::Analysis,
217        "Create a concise product brief",
218    )
219    .with_step(
220        WorkflowStep::new(
221            "vision",
222            "Define Vision",
223            "Articulate the product vision",
224            "pm",
225        )
226        .with_actions(vec![
227            "Write vision statement".to_string(),
228            "Define target users".to_string(),
229            "Identify key benefits".to_string(),
230        ]),
231    )
232    .with_step(
233        WorkflowStep::new(
234            "scope",
235            "Define Scope",
236            "Outline what's in and out of scope",
237            "pm",
238        )
239        .with_actions(vec![
240            "List core features".to_string(),
241            "Define MVP boundaries".to_string(),
242            "Identify future phases".to_string(),
243        ]),
244    )
245    .with_step(
246        WorkflowStep::new(
247            "success-metrics",
248            "Define Success Metrics",
249            "How we'll measure success",
250            "pm",
251        )
252        .with_actions(vec![
253            "Define KPIs".to_string(),
254            "Set targets".to_string(),
255            "Plan measurement approach".to_string(),
256        ])
257        .as_checkpoint(),
258    )
259    .as_builtin()
260}
261
262pub fn competitive_analysis() -> Workflow {
263    Workflow::new(
264        "competitive-analysis",
265        "Competitive Analysis",
266        WorkflowPhase::Analysis,
267        "Analyze competitors and market positioning",
268    )
269    .with_step(
270        WorkflowStep::new(
271            "identify-competitors",
272            "Identify Competitors",
273            "List direct and indirect competitors",
274            "analyst",
275        )
276        .with_actions(vec![
277            "Research market landscape".to_string(),
278            "Categorize competitors".to_string(),
279            "Prioritize for analysis".to_string(),
280        ]),
281    )
282    .with_step(
283        WorkflowStep::new(
284            "analyze-features",
285            "Analyze Features",
286            "Compare feature sets",
287            "analyst",
288        )
289        .with_actions(vec![
290            "Create feature matrix".to_string(),
291            "Identify gaps and opportunities".to_string(),
292            "Note unique differentiators".to_string(),
293        ]),
294    )
295    .with_step(
296        WorkflowStep::new(
297            "positioning",
298            "Define Positioning",
299            "Determine market positioning",
300            "pm",
301        )
302        .with_actions(vec![
303            "Identify unique value proposition".to_string(),
304            "Define competitive advantages".to_string(),
305            "Create positioning statement".to_string(),
306        ])
307        .as_checkpoint(),
308    )
309    .as_builtin()
310}
311
312// ============ Planning Phase ============
313
314pub fn prd() -> Workflow {
315    Workflow::new(
316        "prd",
317        "Product Requirements Document",
318        WorkflowPhase::Planning,
319        "Create a comprehensive PRD",
320    )
321    .with_step(
322        WorkflowStep::new(
323            "overview",
324            "Write Overview",
325            "Document product overview",
326            "pm",
327        )
328        .with_actions(vec![
329            "Write executive summary".to_string(),
330            "Define problem statement".to_string(),
331            "List objectives".to_string(),
332        ]),
333    )
334    .with_step(
335        WorkflowStep::new(
336            "requirements",
337            "Define Requirements",
338            "Document functional requirements",
339            "pm",
340        )
341        .with_actions(vec![
342            "Write user stories".to_string(),
343            "Define acceptance criteria".to_string(),
344            "Prioritize requirements".to_string(),
345        ]),
346    )
347    .with_step(
348        WorkflowStep::new(
349            "non-functional",
350            "Non-Functional Requirements",
351            "Document NFRs",
352            "architect",
353        )
354        .with_actions(vec![
355            "Define performance requirements".to_string(),
356            "Define security requirements".to_string(),
357            "Define scalability requirements".to_string(),
358        ]),
359    )
360    .with_step(
361        WorkflowStep::new("review", "Review PRD", "Get stakeholder approval", "pm")
362            .with_actions(vec![
363                "Share with stakeholders".to_string(),
364                "Collect feedback".to_string(),
365                "Finalize document".to_string(),
366            ])
367            .as_checkpoint(),
368    )
369    .as_builtin()
370}
371
372pub fn ux_design() -> Workflow {
373    Workflow::new(
374        "ux-design",
375        "UX Design",
376        WorkflowPhase::Planning,
377        "Design user experience and interface",
378    )
379    .with_step(
380        WorkflowStep::new(
381            "user-research",
382            "User Research",
383            "Understand user needs",
384            "ux-designer",
385        )
386        .with_actions(vec![
387            "Create user personas".to_string(),
388            "Map user journeys".to_string(),
389            "Identify pain points".to_string(),
390        ]),
391    )
392    .with_step(
393        WorkflowStep::new(
394            "wireframes",
395            "Create Wireframes",
396            "Design low-fidelity wireframes",
397            "ux-designer",
398        )
399        .with_actions(vec![
400            "Sketch key screens".to_string(),
401            "Define information architecture".to_string(),
402            "Plan navigation flow".to_string(),
403        ]),
404    )
405    .with_step(
406        WorkflowStep::new(
407            "prototype",
408            "Build Prototype",
409            "Create interactive prototype",
410            "ux-designer",
411        )
412        .with_actions(vec![
413            "Build clickable prototype".to_string(),
414            "Add interactions".to_string(),
415            "Prepare for testing".to_string(),
416        ]),
417    )
418    .with_step(
419        WorkflowStep::new(
420            "validate",
421            "Validate Design",
422            "Test with users",
423            "ux-designer",
424        )
425        .with_actions(vec![
426            "Conduct usability testing".to_string(),
427            "Gather feedback".to_string(),
428            "Iterate on design".to_string(),
429        ])
430        .as_checkpoint(),
431    )
432    .as_builtin()
433}
434
435pub fn tech_spec() -> Workflow {
436    Workflow::new(
437        "tech-spec",
438        "Technical Specification",
439        WorkflowPhase::Planning,
440        "Create detailed technical specification",
441    )
442    .with_step(
443        WorkflowStep::new(
444            "overview",
445            "Technical Overview",
446            "Document technical approach",
447            "architect",
448        )
449        .with_actions(vec![
450            "Describe solution approach".to_string(),
451            "List technologies".to_string(),
452            "Identify dependencies".to_string(),
453        ]),
454    )
455    .with_step(
456        WorkflowStep::new(
457            "design",
458            "Detailed Design",
459            "Document component design",
460            "architect",
461        )
462        .with_actions(vec![
463            "Design components".to_string(),
464            "Define interfaces".to_string(),
465            "Document data flow".to_string(),
466        ]),
467    )
468    .with_step(
469        WorkflowStep::new(
470            "risks",
471            "Risk Assessment",
472            "Identify and mitigate risks",
473            "architect",
474        )
475        .with_actions(vec![
476            "List technical risks".to_string(),
477            "Define mitigation strategies".to_string(),
478            "Plan contingencies".to_string(),
479        ]),
480    )
481    .with_step(
482        WorkflowStep::new(
483            "review",
484            "Technical Review",
485            "Get technical approval",
486            "architect",
487        )
488        .with_actions(vec![
489            "Review with team".to_string(),
490            "Address concerns".to_string(),
491            "Finalize spec".to_string(),
492        ])
493        .as_checkpoint(),
494    )
495    .as_builtin()
496}
497
498pub fn api_design() -> Workflow {
499    Workflow::new(
500        "api-design",
501        "API Design",
502        WorkflowPhase::Planning,
503        "Design RESTful or GraphQL API",
504    )
505    .with_step(
506        WorkflowStep::new(
507            "resources",
508            "Define Resources",
509            "Identify API resources",
510            "architect",
511        )
512        .with_actions(vec![
513            "List resources".to_string(),
514            "Define relationships".to_string(),
515            "Plan URL structure".to_string(),
516        ]),
517    )
518    .with_step(
519        WorkflowStep::new(
520            "endpoints",
521            "Design Endpoints",
522            "Define API endpoints",
523            "architect",
524        )
525        .with_actions(vec![
526            "Define CRUD operations".to_string(),
527            "Specify request/response formats".to_string(),
528            "Document error handling".to_string(),
529        ]),
530    )
531    .with_step(
532        WorkflowStep::new(
533            "security",
534            "Security Design",
535            "Plan API security",
536            "security",
537        )
538        .with_actions(vec![
539            "Define authentication".to_string(),
540            "Plan authorization".to_string(),
541            "Document rate limiting".to_string(),
542        ]),
543    )
544    .with_step(
545        WorkflowStep::new(
546            "documentation",
547            "API Documentation",
548            "Create API docs",
549            "tech-writer",
550        )
551        .with_actions(vec![
552            "Write OpenAPI spec".to_string(),
553            "Add examples".to_string(),
554            "Generate documentation".to_string(),
555        ])
556        .as_checkpoint(),
557    )
558    .as_builtin()
559}
560
561// ============ Solutioning Phase ============
562
563pub fn architecture() -> Workflow {
564    Workflow::new(
565        "architecture",
566        "Architecture Design",
567        WorkflowPhase::Solutioning,
568        "Design system architecture",
569    )
570    .with_step(
571        WorkflowStep::new(
572            "context",
573            "System Context",
574            "Define system boundaries",
575            "architect",
576        )
577        .with_actions(vec![
578            "Identify external systems".to_string(),
579            "Define integration points".to_string(),
580            "Document data flows".to_string(),
581        ]),
582    )
583    .with_step(
584        WorkflowStep::new(
585            "containers",
586            "Container Design",
587            "Design high-level components",
588            "architect",
589        )
590        .with_actions(vec![
591            "Identify containers".to_string(),
592            "Define responsibilities".to_string(),
593            "Plan communication".to_string(),
594        ]),
595    )
596    .with_step(
597        WorkflowStep::new(
598            "components",
599            "Component Design",
600            "Design internal components",
601            "architect",
602        )
603        .with_actions(vec![
604            "Break down containers".to_string(),
605            "Define interfaces".to_string(),
606            "Plan dependencies".to_string(),
607        ]),
608    )
609    .with_step(
610        WorkflowStep::new(
611            "decisions",
612            "Architecture Decisions",
613            "Document ADRs",
614            "architect",
615        )
616        .with_actions(vec![
617            "Document key decisions".to_string(),
618            "Explain rationale".to_string(),
619            "Note alternatives considered".to_string(),
620        ])
621        .as_checkpoint(),
622    )
623    .as_builtin()
624}
625
626pub fn epics_and_stories() -> Workflow {
627    Workflow::new(
628        "epics-and-stories",
629        "Epics and Stories",
630        WorkflowPhase::Solutioning,
631        "Break down work into epics and user stories",
632    )
633    .with_step(
634        WorkflowStep::new("epics", "Define Epics", "Create high-level epics", "pm").with_actions(
635            vec![
636                "Identify major features".to_string(),
637                "Group related functionality".to_string(),
638                "Prioritize epics".to_string(),
639            ],
640        ),
641    )
642    .with_step(
643        WorkflowStep::new(
644            "stories",
645            "Write User Stories",
646            "Break epics into stories",
647            "pm",
648        )
649        .with_actions(vec![
650            "Write user stories".to_string(),
651            "Define acceptance criteria".to_string(),
652            "Estimate complexity".to_string(),
653        ]),
654    )
655    .with_step(
656        WorkflowStep::new(
657            "refine",
658            "Refine Backlog",
659            "Groom and prioritize",
660            "scrum-master",
661        )
662        .with_actions(vec![
663            "Review with team".to_string(),
664            "Clarify requirements".to_string(),
665            "Update estimates".to_string(),
666        ])
667        .as_checkpoint(),
668    )
669    .as_builtin()
670}
671
672pub fn implementation_readiness() -> Workflow {
673    Workflow::new(
674        "implementation-readiness",
675        "Implementation Readiness",
676        WorkflowPhase::Solutioning,
677        "Ensure team is ready to implement",
678    )
679    .with_step(
680        WorkflowStep::new(
681            "checklist",
682            "Readiness Checklist",
683            "Verify prerequisites",
684            "scrum-master",
685        )
686        .with_actions(vec![
687            "Check requirements clarity".to_string(),
688            "Verify design completeness".to_string(),
689            "Confirm resource availability".to_string(),
690        ]),
691    )
692    .with_step(
693        WorkflowStep::new(
694            "environment",
695            "Environment Setup",
696            "Prepare development environment",
697            "devops",
698        )
699        .with_actions(vec![
700            "Set up repositories".to_string(),
701            "Configure CI/CD".to_string(),
702            "Prepare test environments".to_string(),
703        ]),
704    )
705    .with_step(
706        WorkflowStep::new(
707            "kickoff",
708            "Sprint Kickoff",
709            "Start implementation",
710            "scrum-master",
711        )
712        .with_actions(vec![
713            "Review sprint goals".to_string(),
714            "Assign initial tasks".to_string(),
715            "Set communication cadence".to_string(),
716        ])
717        .as_checkpoint(),
718    )
719    .as_builtin()
720}
721
722pub fn data_model() -> Workflow {
723    Workflow::new(
724        "data-model",
725        "Data Model Design",
726        WorkflowPhase::Solutioning,
727        "Design database schema and data model",
728    )
729    .with_step(
730        WorkflowStep::new(
731            "entities",
732            "Define Entities",
733            "Identify data entities",
734            "data-engineer",
735        )
736        .with_actions(vec![
737            "List entities".to_string(),
738            "Define attributes".to_string(),
739            "Identify relationships".to_string(),
740        ]),
741    )
742    .with_step(
743        WorkflowStep::new(
744            "schema",
745            "Design Schema",
746            "Create database schema",
747            "data-engineer",
748        )
749        .with_actions(vec![
750            "Design tables".to_string(),
751            "Define indexes".to_string(),
752            "Plan partitioning".to_string(),
753        ]),
754    )
755    .with_step(
756        WorkflowStep::new(
757            "migration",
758            "Migration Strategy",
759            "Plan data migration",
760            "data-engineer",
761        )
762        .with_actions(vec![
763            "Design migration scripts".to_string(),
764            "Plan rollback strategy".to_string(),
765            "Test migration".to_string(),
766        ])
767        .as_checkpoint(),
768    )
769    .as_builtin()
770}
771
772// ============ Implementation Phase ============
773
774pub fn sprint_planning() -> Workflow {
775    Workflow::new(
776        "sprint-planning",
777        "Sprint Planning",
778        WorkflowPhase::Implementation,
779        "Plan sprint work and commitments",
780    )
781    .with_step(
782        WorkflowStep::new(
783            "review-backlog",
784            "Review Backlog",
785            "Review prioritized backlog",
786            "scrum-master",
787        )
788        .with_actions(vec![
789            "Review sprint goal".to_string(),
790            "Discuss top priorities".to_string(),
791            "Clarify requirements".to_string(),
792        ]),
793    )
794    .with_step(
795        WorkflowStep::new(
796            "capacity",
797            "Assess Capacity",
798            "Determine team capacity",
799            "scrum-master",
800        )
801        .with_actions(vec![
802            "Calculate available hours".to_string(),
803            "Account for meetings".to_string(),
804            "Consider PTO".to_string(),
805        ]),
806    )
807    .with_step(
808        WorkflowStep::new(
809            "commit",
810            "Sprint Commitment",
811            "Commit to sprint work",
812            "scrum-master",
813        )
814        .with_actions(vec![
815            "Select stories".to_string(),
816            "Break into tasks".to_string(),
817            "Confirm commitment".to_string(),
818        ])
819        .as_checkpoint(),
820    )
821    .as_builtin()
822}
823
824pub fn dev_story() -> Workflow {
825    Workflow::new(
826        "dev-story",
827        "Development Story",
828        WorkflowPhase::Implementation,
829        "Implement a user story",
830    )
831    .with_step(
832        WorkflowStep::new(
833            "understand",
834            "Understand Story",
835            "Review requirements",
836            "developer",
837        )
838        .with_actions(vec![
839            "Read acceptance criteria".to_string(),
840            "Ask clarifying questions".to_string(),
841            "Plan approach".to_string(),
842        ]),
843    )
844    .with_step(
845        WorkflowStep::new("implement", "Implement", "Write code", "developer").with_actions(vec![
846            "Create feature branch".to_string(),
847            "Write implementation".to_string(),
848            "Write tests".to_string(),
849        ]),
850    )
851    .with_step(
852        WorkflowStep::new("test", "Test", "Verify implementation", "developer").with_actions(vec![
853            "Run unit tests".to_string(),
854            "Manual testing".to_string(),
855            "Fix issues".to_string(),
856        ]),
857    )
858    .with_step(
859        WorkflowStep::new("pr", "Create PR", "Submit for review", "developer")
860            .with_actions(vec![
861                "Create pull request".to_string(),
862                "Add description".to_string(),
863                "Request review".to_string(),
864            ])
865            .as_checkpoint(),
866    )
867    .as_builtin()
868}
869
870pub fn code_review() -> Workflow {
871    Workflow::new(
872        "code-review",
873        "Code Review",
874        WorkflowPhase::Implementation,
875        "Review code changes",
876    )
877    .with_step(
878        WorkflowStep::new(
879            "context",
880            "Understand Context",
881            "Review PR description",
882            "reviewer",
883        )
884        .with_actions(vec![
885            "Read PR description".to_string(),
886            "Check linked issues".to_string(),
887            "Understand goal".to_string(),
888        ]),
889    )
890    .with_step(
891        WorkflowStep::new("review", "Review Code", "Examine changes", "reviewer").with_actions(
892            vec![
893                "Check correctness".to_string(),
894                "Check security".to_string(),
895                "Check performance".to_string(),
896                "Check readability".to_string(),
897            ],
898        ),
899    )
900    .with_step(
901        WorkflowStep::new(
902            "feedback",
903            "Provide Feedback",
904            "Give constructive feedback",
905            "reviewer",
906        )
907        .with_actions(vec![
908            "Praise good patterns".to_string(),
909            "Suggest improvements".to_string(),
910            "Approve or request changes".to_string(),
911        ])
912        .as_checkpoint(),
913    )
914    .as_builtin()
915}
916
917pub fn retrospective() -> Workflow {
918    Workflow::new(
919        "retrospective",
920        "Sprint Retrospective",
921        WorkflowPhase::Implementation,
922        "Reflect on sprint and improve",
923    )
924    .with_step(
925        WorkflowStep::new(
926            "gather",
927            "Gather Feedback",
928            "Collect team input",
929            "scrum-master",
930        )
931        .with_actions(vec![
932            "What went well".to_string(),
933            "What didn't go well".to_string(),
934            "What to improve".to_string(),
935        ]),
936    )
937    .with_step(
938        WorkflowStep::new("discuss", "Discuss", "Analyze feedback", "scrum-master").with_actions(
939            vec![
940                "Group similar items".to_string(),
941                "Identify root causes".to_string(),
942                "Prioritize issues".to_string(),
943            ],
944        ),
945    )
946    .with_step(
947        WorkflowStep::new(
948            "actions",
949            "Define Actions",
950            "Create improvement actions",
951            "scrum-master",
952        )
953        .with_actions(vec![
954            "Define action items".to_string(),
955            "Assign owners".to_string(),
956            "Set deadlines".to_string(),
957        ])
958        .as_checkpoint(),
959    )
960    .as_builtin()
961}
962
963pub fn sprint_status() -> Workflow {
964    Workflow::new(
965        "sprint-status",
966        "Sprint Status",
967        WorkflowPhase::Implementation,
968        "Report sprint progress",
969    )
970    .with_step(
971        WorkflowStep::new(
972            "metrics",
973            "Gather Metrics",
974            "Collect sprint data",
975            "scrum-master",
976        )
977        .with_actions(vec![
978            "Calculate velocity".to_string(),
979            "Track burndown".to_string(),
980            "Note blockers".to_string(),
981        ]),
982    )
983    .with_step(
984        WorkflowStep::new(
985            "report",
986            "Create Report",
987            "Summarize status",
988            "scrum-master",
989        )
990        .with_actions(vec![
991            "Write summary".to_string(),
992            "Highlight risks".to_string(),
993            "Note achievements".to_string(),
994        ])
995        .as_checkpoint(),
996    )
997    .as_builtin()
998}
999
1000// ============ Quick Flow ============
1001
1002pub fn quick_bug_fix() -> Workflow {
1003    Workflow::new(
1004        "quick-bug-fix",
1005        "Quick Bug Fix",
1006        WorkflowPhase::QuickFlow,
1007        "Rapidly fix a bug",
1008    )
1009    .with_step(
1010        WorkflowStep::new("reproduce", "Reproduce", "Confirm the bug", "developer").with_actions(
1011            vec![
1012                "Read bug report".to_string(),
1013                "Reproduce issue".to_string(),
1014                "Identify root cause".to_string(),
1015            ],
1016        ),
1017    )
1018    .with_step(
1019        WorkflowStep::new("fix", "Fix", "Implement fix", "developer").with_actions(vec![
1020            "Write failing test".to_string(),
1021            "Implement fix".to_string(),
1022            "Verify test passes".to_string(),
1023        ]),
1024    )
1025    .with_step(
1026        WorkflowStep::new("verify", "Verify", "Confirm fix works", "developer")
1027            .with_actions(vec![
1028                "Run all tests".to_string(),
1029                "Manual verification".to_string(),
1030                "Create PR".to_string(),
1031            ])
1032            .as_checkpoint(),
1033    )
1034    .as_builtin()
1035}
1036
1037pub fn quick_feature() -> Workflow {
1038    Workflow::new(
1039        "quick-feature",
1040        "Quick Feature",
1041        WorkflowPhase::QuickFlow,
1042        "Rapidly implement a small feature",
1043    )
1044    .with_step(
1045        WorkflowStep::new(
1046            "understand",
1047            "Understand",
1048            "Clarify requirements",
1049            "developer",
1050        )
1051        .with_actions(vec![
1052            "Review requirements".to_string(),
1053            "Ask questions".to_string(),
1054            "Plan approach".to_string(),
1055        ]),
1056    )
1057    .with_step(
1058        WorkflowStep::new("implement", "Implement", "Build feature", "developer").with_actions(
1059            vec![
1060                "Write code".to_string(),
1061                "Write tests".to_string(),
1062                "Update docs".to_string(),
1063            ],
1064        ),
1065    )
1066    .with_step(
1067        WorkflowStep::new("ship", "Ship", "Deploy feature", "developer")
1068            .with_actions(vec![
1069                "Create PR".to_string(),
1070                "Get review".to_string(),
1071                "Merge and deploy".to_string(),
1072            ])
1073            .as_checkpoint(),
1074    )
1075    .as_builtin()
1076}
1077
1078pub fn quick_refactor() -> Workflow {
1079    Workflow::new(
1080        "quick-refactor",
1081        "Quick Refactor",
1082        WorkflowPhase::QuickFlow,
1083        "Safely refactor code",
1084    )
1085    .with_step(
1086        WorkflowStep::new("tests", "Ensure Tests", "Verify test coverage", "developer")
1087            .with_actions(vec![
1088                "Check coverage".to_string(),
1089                "Add missing tests".to_string(),
1090                "Run baseline".to_string(),
1091            ]),
1092    )
1093    .with_step(
1094        WorkflowStep::new("refactor", "Refactor", "Make changes", "developer").with_actions(vec![
1095            "Small incremental changes".to_string(),
1096            "Run tests after each".to_string(),
1097            "Commit frequently".to_string(),
1098        ]),
1099    )
1100    .with_step(
1101        WorkflowStep::new(
1102            "verify",
1103            "Verify",
1104            "Confirm behavior unchanged",
1105            "developer",
1106        )
1107        .with_actions(vec![
1108            "Run all tests".to_string(),
1109            "Compare before/after".to_string(),
1110            "Create PR".to_string(),
1111        ])
1112        .as_checkpoint(),
1113    )
1114    .as_builtin()
1115}
1116
1117// ============ Testing ============
1118
1119pub fn test_design() -> Workflow {
1120    Workflow::new(
1121        "test-design",
1122        "Test Design",
1123        WorkflowPhase::Testing,
1124        "Design test strategy and cases",
1125    )
1126    .with_step(
1127        WorkflowStep::new(
1128            "strategy",
1129            "Test Strategy",
1130            "Define testing approach",
1131            "test-architect",
1132        )
1133        .with_actions(vec![
1134            "Define test levels".to_string(),
1135            "Identify test types".to_string(),
1136            "Plan coverage".to_string(),
1137        ]),
1138    )
1139    .with_step(
1140        WorkflowStep::new("cases", "Test Cases", "Write test cases", "test-architect")
1141            .with_actions(vec![
1142                "Write test scenarios".to_string(),
1143                "Define test data".to_string(),
1144                "Prioritize tests".to_string(),
1145            ])
1146            .as_checkpoint(),
1147    )
1148    .as_builtin()
1149}
1150
1151pub fn test_automation() -> Workflow {
1152    Workflow::new(
1153        "test-automation",
1154        "Test Automation",
1155        WorkflowPhase::Testing,
1156        "Automate test execution",
1157    )
1158    .with_step(
1159        WorkflowStep::new(
1160            "framework",
1161            "Setup Framework",
1162            "Configure test framework",
1163            "test-architect",
1164        )
1165        .with_actions(vec![
1166            "Select framework".to_string(),
1167            "Configure environment".to_string(),
1168            "Set up CI integration".to_string(),
1169        ]),
1170    )
1171    .with_step(
1172        WorkflowStep::new(
1173            "implement",
1174            "Implement Tests",
1175            "Write automated tests",
1176            "developer",
1177        )
1178        .with_actions(vec![
1179            "Write unit tests".to_string(),
1180            "Write integration tests".to_string(),
1181            "Write e2e tests".to_string(),
1182        ]),
1183    )
1184    .with_step(
1185        WorkflowStep::new(
1186            "maintain",
1187            "Maintain",
1188            "Keep tests healthy",
1189            "test-architect",
1190        )
1191        .with_actions(vec![
1192            "Fix flaky tests".to_string(),
1193            "Update test data".to_string(),
1194            "Improve coverage".to_string(),
1195        ])
1196        .as_checkpoint(),
1197    )
1198    .as_builtin()
1199}
1200
1201pub fn test_review() -> Workflow {
1202    Workflow::new(
1203        "test-review",
1204        "Test Review",
1205        WorkflowPhase::Testing,
1206        "Review test quality and coverage",
1207    )
1208    .with_step(
1209        WorkflowStep::new(
1210            "coverage",
1211            "Review Coverage",
1212            "Analyze test coverage",
1213            "test-architect",
1214        )
1215        .with_actions(vec![
1216            "Generate coverage report".to_string(),
1217            "Identify gaps".to_string(),
1218            "Prioritize additions".to_string(),
1219        ]),
1220    )
1221    .with_step(
1222        WorkflowStep::new(
1223            "quality",
1224            "Review Quality",
1225            "Assess test quality",
1226            "test-architect",
1227        )
1228        .with_actions(vec![
1229            "Check test isolation".to_string(),
1230            "Review assertions".to_string(),
1231            "Identify improvements".to_string(),
1232        ])
1233        .as_checkpoint(),
1234    )
1235    .as_builtin()
1236}
1237
1238// ============ Documentation ============
1239
1240pub fn document_project() -> Workflow {
1241    Workflow::new(
1242        "document-project",
1243        "Document Project",
1244        WorkflowPhase::Documentation,
1245        "Create project documentation",
1246    )
1247    .with_step(
1248        WorkflowStep::new("readme", "README", "Write project README", "tech-writer").with_actions(
1249            vec![
1250                "Write overview".to_string(),
1251                "Add installation".to_string(),
1252                "Include examples".to_string(),
1253            ],
1254        ),
1255    )
1256    .with_step(
1257        WorkflowStep::new(
1258            "guides",
1259            "User Guides",
1260            "Write user documentation",
1261            "tech-writer",
1262        )
1263        .with_actions(vec![
1264            "Write getting started".to_string(),
1265            "Document features".to_string(),
1266            "Add tutorials".to_string(),
1267        ]),
1268    )
1269    .with_step(
1270        WorkflowStep::new(
1271            "reference",
1272            "Reference",
1273            "Write reference docs",
1274            "tech-writer",
1275        )
1276        .with_actions(vec![
1277            "Document APIs".to_string(),
1278            "Add configuration".to_string(),
1279            "Include troubleshooting".to_string(),
1280        ])
1281        .as_checkpoint(),
1282    )
1283    .as_builtin()
1284}
1285
1286pub fn api_documentation() -> Workflow {
1287    Workflow::new(
1288        "api-documentation",
1289        "API Documentation",
1290        WorkflowPhase::Documentation,
1291        "Document API endpoints",
1292    )
1293    .with_step(
1294        WorkflowStep::new("spec", "API Spec", "Write OpenAPI spec", "tech-writer").with_actions(
1295            vec![
1296                "Document endpoints".to_string(),
1297                "Define schemas".to_string(),
1298                "Add examples".to_string(),
1299            ],
1300        ),
1301    )
1302    .with_step(
1303        WorkflowStep::new(
1304            "generate",
1305            "Generate Docs",
1306            "Generate documentation",
1307            "tech-writer",
1308        )
1309        .with_actions(vec![
1310            "Generate from spec".to_string(),
1311            "Add descriptions".to_string(),
1312            "Include code samples".to_string(),
1313        ])
1314        .as_checkpoint(),
1315    )
1316    .as_builtin()
1317}
1318
1319// ============ DevOps ============
1320
1321pub fn ci_setup() -> Workflow {
1322    Workflow::new(
1323        "ci-setup",
1324        "CI Setup",
1325        WorkflowPhase::DevOps,
1326        "Set up continuous integration",
1327    )
1328    .with_step(
1329        WorkflowStep::new(
1330            "pipeline",
1331            "Define Pipeline",
1332            "Create CI pipeline",
1333            "devops",
1334        )
1335        .with_actions(vec![
1336            "Define stages".to_string(),
1337            "Configure triggers".to_string(),
1338            "Set up caching".to_string(),
1339        ]),
1340    )
1341    .with_step(
1342        WorkflowStep::new("quality", "Quality Gates", "Add quality checks", "devops").with_actions(
1343            vec![
1344                "Add linting".to_string(),
1345                "Add testing".to_string(),
1346                "Add security scans".to_string(),
1347            ],
1348        ),
1349    )
1350    .with_step(
1351        WorkflowStep::new("artifacts", "Artifacts", "Configure artifacts", "devops")
1352            .with_actions(vec![
1353                "Build artifacts".to_string(),
1354                "Store artifacts".to_string(),
1355                "Version artifacts".to_string(),
1356            ])
1357            .as_checkpoint(),
1358    )
1359    .as_builtin()
1360}
1361
1362pub fn deployment() -> Workflow {
1363    Workflow::new(
1364        "deployment",
1365        "Deployment",
1366        WorkflowPhase::DevOps,
1367        "Deploy to production",
1368    )
1369    .with_step(
1370        WorkflowStep::new("prepare", "Prepare", "Prepare for deployment", "devops").with_actions(
1371            vec![
1372                "Verify build".to_string(),
1373                "Check dependencies".to_string(),
1374                "Review changes".to_string(),
1375            ],
1376        ),
1377    )
1378    .with_step(
1379        WorkflowStep::new("deploy", "Deploy", "Execute deployment", "devops").with_actions(vec![
1380            "Deploy to staging".to_string(),
1381            "Run smoke tests".to_string(),
1382            "Deploy to production".to_string(),
1383        ]),
1384    )
1385    .with_step(
1386        WorkflowStep::new("verify", "Verify", "Verify deployment", "devops")
1387            .with_actions(vec![
1388                "Check health".to_string(),
1389                "Monitor metrics".to_string(),
1390                "Confirm success".to_string(),
1391            ])
1392            .as_checkpoint(),
1393    )
1394    .as_builtin()
1395}
1396
1397// ============ Additional ============
1398
1399pub fn security_review() -> Workflow {
1400    Workflow::new(
1401        "security-review",
1402        "Security Review",
1403        WorkflowPhase::Implementation,
1404        "Review code for security issues",
1405    )
1406    .with_step(
1407        WorkflowStep::new("scan", "Security Scan", "Run security scanners", "security")
1408            .with_actions(vec![
1409                "Run SAST".to_string(),
1410                "Run dependency scan".to_string(),
1411                "Check secrets".to_string(),
1412            ]),
1413    )
1414    .with_step(
1415        WorkflowStep::new("review", "Manual Review", "Review findings", "security").with_actions(
1416            vec![
1417                "Triage findings".to_string(),
1418                "Verify vulnerabilities".to_string(),
1419                "Prioritize fixes".to_string(),
1420            ],
1421        ),
1422    )
1423    .with_step(
1424        WorkflowStep::new("remediate", "Remediate", "Fix issues", "developer")
1425            .with_actions(vec![
1426                "Fix vulnerabilities".to_string(),
1427                "Update dependencies".to_string(),
1428                "Verify fixes".to_string(),
1429            ])
1430            .as_checkpoint(),
1431    )
1432    .as_builtin()
1433}
1434
1435pub fn performance_review() -> Workflow {
1436    Workflow::new(
1437        "performance-review",
1438        "Performance Review",
1439        WorkflowPhase::Implementation,
1440        "Review and optimize performance",
1441    )
1442    .with_step(
1443        WorkflowStep::new("profile", "Profile", "Profile application", "performance").with_actions(
1444            vec![
1445                "Run profiler".to_string(),
1446                "Identify hotspots".to_string(),
1447                "Measure baselines".to_string(),
1448            ],
1449        ),
1450    )
1451    .with_step(
1452        WorkflowStep::new(
1453            "optimize",
1454            "Optimize",
1455            "Implement optimizations",
1456            "performance",
1457        )
1458        .with_actions(vec![
1459            "Optimize algorithms".to_string(),
1460            "Reduce allocations".to_string(),
1461            "Improve caching".to_string(),
1462        ]),
1463    )
1464    .with_step(
1465        WorkflowStep::new("verify", "Verify", "Verify improvements", "performance")
1466            .with_actions(vec![
1467                "Run benchmarks".to_string(),
1468                "Compare results".to_string(),
1469                "Document changes".to_string(),
1470            ])
1471            .as_checkpoint(),
1472    )
1473    .as_builtin()
1474}
1475
1476pub fn onboarding() -> Workflow {
1477    Workflow::new(
1478        "onboarding",
1479        "Developer Onboarding",
1480        WorkflowPhase::Documentation,
1481        "Onboard new team members",
1482    )
1483    .with_step(
1484        WorkflowStep::new(
1485            "setup",
1486            "Environment Setup",
1487            "Set up development environment",
1488            "mentor",
1489        )
1490        .with_actions(vec![
1491            "Install tools".to_string(),
1492            "Clone repositories".to_string(),
1493            "Configure IDE".to_string(),
1494        ]),
1495    )
1496    .with_step(
1497        WorkflowStep::new(
1498            "overview",
1499            "Project Overview",
1500            "Learn the codebase",
1501            "mentor",
1502        )
1503        .with_actions(vec![
1504            "Architecture overview".to_string(),
1505            "Key components".to_string(),
1506            "Development workflow".to_string(),
1507        ]),
1508    )
1509    .with_step(
1510        WorkflowStep::new(
1511            "first-task",
1512            "First Task",
1513            "Complete first contribution",
1514            "mentor",
1515        )
1516        .with_actions(vec![
1517            "Pick starter task".to_string(),
1518            "Implement with guidance".to_string(),
1519            "Submit PR".to_string(),
1520        ])
1521        .as_checkpoint(),
1522    )
1523    .as_builtin()
1524}
1525
1526pub fn tech_debt() -> Workflow {
1527    Workflow::new(
1528        "tech-debt",
1529        "Tech Debt Reduction",
1530        WorkflowPhase::Implementation,
1531        "Address technical debt",
1532    )
1533    .with_step(
1534        WorkflowStep::new(
1535            "identify",
1536            "Identify Debt",
1537            "Find technical debt",
1538            "architect",
1539        )
1540        .with_actions(vec![
1541            "Review code quality".to_string(),
1542            "Check dependencies".to_string(),
1543            "Assess architecture".to_string(),
1544        ]),
1545    )
1546    .with_step(
1547        WorkflowStep::new("prioritize", "Prioritize", "Rank debt items", "architect").with_actions(
1548            vec![
1549                "Assess impact".to_string(),
1550                "Estimate effort".to_string(),
1551                "Create backlog".to_string(),
1552            ],
1553        ),
1554    )
1555    .with_step(
1556        WorkflowStep::new("address", "Address Debt", "Fix debt items", "developer")
1557            .with_actions(vec![
1558                "Refactor code".to_string(),
1559                "Update dependencies".to_string(),
1560                "Improve tests".to_string(),
1561            ])
1562            .as_checkpoint(),
1563    )
1564    .as_builtin()
1565}
1566
1567pub fn migration() -> Workflow {
1568    Workflow::new(
1569        "migration",
1570        "System Migration",
1571        WorkflowPhase::Implementation,
1572        "Migrate to new system or version",
1573    )
1574    .with_step(
1575        WorkflowStep::new(
1576            "plan",
1577            "Plan Migration",
1578            "Create migration plan",
1579            "architect",
1580        )
1581        .with_actions(vec![
1582            "Assess current state".to_string(),
1583            "Define target state".to_string(),
1584            "Plan phases".to_string(),
1585        ]),
1586    )
1587    .with_step(
1588        WorkflowStep::new(
1589            "execute",
1590            "Execute Migration",
1591            "Perform migration",
1592            "developer",
1593        )
1594        .with_actions(vec![
1595            "Migrate data".to_string(),
1596            "Update code".to_string(),
1597            "Test thoroughly".to_string(),
1598        ]),
1599    )
1600    .with_step(
1601        WorkflowStep::new(
1602            "validate",
1603            "Validate",
1604            "Verify migration success",
1605            "test-architect",
1606        )
1607        .with_actions(vec![
1608            "Run validation tests".to_string(),
1609            "Compare data".to_string(),
1610            "Confirm functionality".to_string(),
1611        ])
1612        .as_checkpoint(),
1613    )
1614    .as_builtin()
1615}
1616
1617pub fn incident_response() -> Workflow {
1618    Workflow::new(
1619        "incident-response",
1620        "Incident Response",
1621        WorkflowPhase::DevOps,
1622        "Respond to production incidents",
1623    )
1624    .with_step(
1625        WorkflowStep::new("triage", "Triage", "Assess incident severity", "devops").with_actions(
1626            vec![
1627                "Identify impact".to_string(),
1628                "Assign severity".to_string(),
1629                "Notify stakeholders".to_string(),
1630            ],
1631        ),
1632    )
1633    .with_step(
1634        WorkflowStep::new("mitigate", "Mitigate", "Reduce impact", "devops").with_actions(vec![
1635            "Implement workaround".to_string(),
1636            "Scale resources".to_string(),
1637            "Communicate status".to_string(),
1638        ]),
1639    )
1640    .with_step(
1641        WorkflowStep::new("resolve", "Resolve", "Fix root cause", "developer").with_actions(vec![
1642            "Identify root cause".to_string(),
1643            "Implement fix".to_string(),
1644            "Deploy fix".to_string(),
1645        ]),
1646    )
1647    .with_step(
1648        WorkflowStep::new(
1649            "postmortem",
1650            "Postmortem",
1651            "Learn from incident",
1652            "scrum-master",
1653        )
1654        .with_actions(vec![
1655            "Document timeline".to_string(),
1656            "Identify improvements".to_string(),
1657            "Create action items".to_string(),
1658        ])
1659        .as_checkpoint(),
1660    )
1661    .as_builtin()
1662}
1663
1664pub fn release_planning() -> Workflow {
1665    Workflow::new(
1666        "release-planning",
1667        "Release Planning",
1668        WorkflowPhase::Planning,
1669        "Plan product release",
1670    )
1671    .with_step(
1672        WorkflowStep::new("scope", "Define Scope", "Determine release scope", "pm").with_actions(
1673            vec![
1674                "Review backlog".to_string(),
1675                "Select features".to_string(),
1676                "Define milestones".to_string(),
1677            ],
1678        ),
1679    )
1680    .with_step(
1681        WorkflowStep::new("schedule", "Create Schedule", "Plan release timeline", "pm")
1682            .with_actions(vec![
1683                "Set release date".to_string(),
1684                "Plan sprints".to_string(),
1685                "Identify dependencies".to_string(),
1686            ]),
1687    )
1688    .with_step(
1689        WorkflowStep::new("communicate", "Communicate", "Share release plan", "pm")
1690            .with_actions(vec![
1691                "Create release notes".to_string(),
1692                "Notify stakeholders".to_string(),
1693                "Update roadmap".to_string(),
1694            ])
1695            .as_checkpoint(),
1696    )
1697    .as_builtin()
1698}
1699
1700#[cfg(test)]
1701mod tests {
1702    use super::*;
1703
1704    #[test]
1705    fn test_all_workflows_count() {
1706        let workflows = all_workflows();
1707        assert!(
1708            workflows.len() >= 30,
1709            "Expected at least 30 workflows, got {}",
1710            workflows.len()
1711        );
1712    }
1713
1714    #[test]
1715    fn test_all_workflows_have_unique_ids() {
1716        let workflows = all_workflows();
1717        let mut ids: Vec<&str> = workflows.iter().map(|w| w.id.as_str()).collect();
1718        ids.sort();
1719        let original_len = ids.len();
1720        ids.dedup();
1721        assert_eq!(ids.len(), original_len, "Duplicate workflow IDs found");
1722    }
1723
1724    #[test]
1725    fn test_all_workflows_are_builtin() {
1726        let workflows = all_workflows();
1727        for workflow in workflows {
1728            assert!(
1729                workflow.builtin,
1730                "Workflow {} should be marked as builtin",
1731                workflow.id
1732            );
1733        }
1734    }
1735
1736    #[test]
1737    fn test_all_workflows_have_steps() {
1738        let workflows = all_workflows();
1739        for workflow in workflows {
1740            assert!(
1741                !workflow.steps.is_empty(),
1742                "Workflow {} has no steps",
1743                workflow.id
1744            );
1745        }
1746    }
1747
1748    #[test]
1749    fn test_all_workflows_have_checkpoints() {
1750        let workflows = all_workflows();
1751        for workflow in workflows {
1752            assert!(
1753                !workflow.checkpoints.is_empty(),
1754                "Workflow {} has no checkpoints",
1755                workflow.id
1756            );
1757        }
1758    }
1759}