Initial commit: Brachnha Insight project setup

- Next.js 14+ with App Router and TypeScript
- Tailwind CSS and ShadCN UI styling
- Zustand state management
- Dexie.js for IndexedDB (local-first data)
- Auth.js v5 for authentication
- BMAD framework integration

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Max
2026-01-26 12:28:43 +07:00
commit 3fbbb1a93b
812 changed files with 150531 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
---
stepsCompleted: []
lastStep: ''
date: ''
user_name: ''
project_name: ''
---
# {{document_title}}
[Content will be progressively appended by workflow steps]

View File

@@ -0,0 +1,241 @@
# BMAD Continuable Step 01 Init Template
This template provides the standard structure for step-01-init files that support workflow continuation. It includes logic to detect existing workflows and route to step-01b-continue.md for resumption.
Use this template when creating workflows that generate output documents and might take multiple sessions to complete.
<!-- TEMPLATE START -->
---
name: 'step-01-init'
description: 'Initialize the [workflow-type] workflow by detecting continuation state and creating output document'
<!-- Path Definitions -->
workflow\*path: `{project-root}/_bmad/[module-path]/workflows/[workflow-name]`
# File References (all use {variable} format in file)
thisStepFile: `./step-01-init.md`
nextStepFile: `./step-02-[step-name].md`
workflowFile: `{workflow_path}/workflow.md`
outputFile: `{output_folder}/[output-file-name]-{project_name}.md`
continueFile: `./step-01b-continue.md`
templateFile: `{workflow_path}/templates/[main-template].md`
# Template References
# This step doesn't use content templates, only the main template
---
# Step 1: Workflow Initialization
## MANDATORY EXECUTION RULES (READ FIRST):
### Universal Rules:
- 🛑 NEVER generate content without user input
- 📖 CRITICAL: Read the complete step file before taking any action
- 🔄 CRITICAL: When loading next step with 'C', ensure entire file is read
- 📋 YOU ARE A FACILITATOR, not a content generator
### Role Reinforcement:
- ✅ You are a [specific role, e.g., "business analyst" or "technical architect"]
- ✅ We engage in collaborative dialogue, not command-response
- ✅ You bring [your expertise], user brings [their expertise], and together we produce something better than we could on our own
- ✅ Maintain collaborative [adjective] tone throughout
### Step-Specific Rules:
- 🎯 Focus ONLY on initialization and setup
- 🚫 FORBIDDEN to look ahead to future steps
- 💬 Handle initialization professionally
- 🚪 DETECT existing workflow state and handle continuation properly
## EXECUTION PROTOCOLS:
- 🎯 Show analysis before taking any action
- 💾 Initialize document and update frontmatter
- 📖 Set up frontmatter `stepsCompleted: [1]` before loading next step
- 🚫 FORBIDDEN to load next step until setup is complete
## CONTEXT BOUNDARIES:
- Variables from workflow.md are available in memory
- Previous context = what's in output document + frontmatter
- Don't assume knowledge from other steps
- Input document discovery happens in this step
## STEP GOAL:
To initialize the [workflow-type] workflow by detecting continuation state, creating the output document, and preparing for the first collaborative session.
## INITIALIZATION SEQUENCE:
### 1. Check for Existing Workflow
First, check if the output document already exists:
- Look for file at `{output_folder}/[output-file-name]-{project_name}.md`
- If exists, read the complete file including frontmatter
- If not exists, this is a fresh workflow
### 2. Handle Continuation (If Document Exists)
If the document exists and has frontmatter with `stepsCompleted`:
- **STOP here** and load `./step-01b-continue.md` immediately
- Do not proceed with any initialization tasks
- Let step-01b handle the continuation logic
### 3. Handle Completed Workflow
If the document exists AND all steps are marked complete in `stepsCompleted`:
- Ask user: "I found an existing [workflow-output] from [date]. Would you like to:
1. Create a new [workflow-output]
2. Update/modify the existing [workflow-output]"
- If option 1: Create new document with timestamp suffix
- If option 2: Load step-01b-continue.md
### 4. Fresh Workflow Setup (If No Document)
If no document exists or no `stepsCompleted` in frontmatter:
#### A. Input Document Discovery
This workflow requires [describe input documents if any]:
**[Document Type] Documents (Optional):**
- Look for: `{output_folder}/*[pattern1]*.md`
- Look for: `{output_folder}/*[pattern2]*.md`
- If found, load completely and add to `inputDocuments` frontmatter
#### B. Create Initial Document
Copy the template from `{templateFile}` to `{output_folder}/[output-file-name]-{project_name}.md`
Initialize frontmatter with:
```yaml
---
stepsCompleted: [1]
lastStep: 'init'
inputDocuments: []
date: [current date]
user_name: { user_name }
[additional workflow-specific fields]
---
```
#### C. Show Welcome Message
"[Welcome message appropriate for workflow type]
Let's begin by [brief description of first activity]."
## ✅ SUCCESS METRICS:
- Document created from template (for fresh workflows)
- Frontmatter initialized with step 1 marked complete
- User welcomed to the process
- Ready to proceed to step 2
- OR continuation properly routed to step-01b-continue.md
## ❌ FAILURE MODES TO AVOID:
- Proceeding with step 2 without document initialization
- Not checking for existing documents properly
- Creating duplicate documents
- Skipping welcome message
- Not routing to step-01b-continue.md when needed
### 5. Present MENU OPTIONS
Display: **Proceeding to [next step description]...**
#### EXECUTION RULES:
- This is an initialization step with no user choices
- Proceed directly to next step after setup
- Use menu handling logic section below
#### Menu Handling Logic:
- After setup completion, immediately load, read entire file, then execute `{nextStepFile}` to begin [next step description]
---
## 🚨 SYSTEM SUCCESS/FAILURE METRICS
### ✅ SUCCESS:
- Document created from template (for fresh workflows)
- update frontmatter `stepsCompleted` to add 1 at the end of the array before loading next step
- Frontmatter initialized with `stepsCompleted: [1]`
- User welcomed to the process
- Ready to proceed to step 2
- OR existing workflow properly routed to step-01b-continue.md
### ❌ SYSTEM FAILURE:
- Proceeding with step 2 without document initialization
- Not checking for existing documents properly
- Creating duplicate documents
- Skipping welcome message
- Not routing to step-01b-continue.md when appropriate
**Master Rule:** Skipping steps, optimizing sequences, or not following exact instructions is FORBIDDEN and constitutes SYSTEM FAILURE.
## CRITICAL STEP COMPLETION NOTE
ONLY WHEN initialization setup is complete and document is created (OR continuation is properly routed), will you then immediately load, read entire file, then execute `{nextStepFile}` to begin [next step description].
<!-- TEMPLATE END -->
## Customization Guidelines
When adapting this template for your specific workflow:
### 1. Update Placeholders
Replace bracketed placeholders with your specific values:
- `[workflow-type]` - e.g., "nutrition planning", "project requirements"
- `[module-path]` - e.g., "bmb/reference" or "custom"
- `[workflow-name]` - your workflow directory name
- `[output-file-name]` - base name for output document
- `[step-name]` - name for step 2 (e.g., "gather", "profile")
- `[main-template]` - name of your main template file
- `[workflow-output]` - what the workflow produces
- `[Document Type]` - type of input documents (if any)
- `[pattern1]`, `[pattern2]` - search patterns for input documents
- `[additional workflow-specific fields]` - any extra frontmatter fields needed
### 2. Customize Welcome Message
Adapt the welcome message in section 4C to match your workflow's tone and purpose.
### 3. Update Success Metrics
Ensure success metrics reflect your specific workflow requirements.
### 4. Adjust Next Step References
Update `{nextStepFile}` to point to your actual step 2 file.
## Implementation Notes
1. **This step MUST include continuation detection logic** - this is the key pattern
2. **Always include `continueFile` reference** in frontmatter
3. **Proper frontmatter initialization** is critical for continuation tracking
4. **Auto-proceed pattern** - this step should not have user choice menus (except for completed workflow handling)
5. **Template-based document creation** - ensures consistent output structure
## Integration with step-01b-continue.md
This template is designed to work seamlessly with the step-01b-template.md continuation step. The two steps together provide a complete pause/resume workflow capability.

View File

@@ -0,0 +1,223 @@
# BMAD Workflow Step 1B Continuation Template
This template provides the standard structure for workflow continuation steps. It handles resuming workflows that were started but not completed, ensuring seamless continuation across multiple sessions.
Use this template alongside **step-01-init-continuable-template.md** to create workflows that can be paused and resumed. The init template handles the detection and routing logic, while this template handles the resumption logic.
<!-- TEMPLATE START -->
---
name: 'step-01b-continue'
description: 'Handle workflow continuation from previous session'
<!-- Path Definitions -->
workflow\*path: '{project-root}/_bmad/[module-path]/workflows/[workflow-name]'
# File References (all use {variable} format in file)
thisStepFile: './step-01b-continue.md'
outputFile: '{output_folder}/[output-file-name]-{project_name}.md'
workflowFile: '{workflow_path}/workflow.md'
# Template References (if needed for analysis)
## analysisTemplate: '{workflow_path}/templates/[some-template].md'
# Step 1B: Workflow Continuation
## STEP GOAL:
To resume the [workflow-type] workflow from where it was left off, ensuring smooth continuation without loss of context or progress.
## MANDATORY EXECUTION RULES (READ FIRST):
### Universal Rules:
- 🛑 NEVER generate content without user input
- 📖 CRITICAL: Read the complete step file before taking any action
- 🔄 CRITICAL: When loading next step with 'C', ensure entire file is read
- 📋 YOU ARE A FACILITATOR, not a content generator
### Role Reinforcement:
- ✅ You are a [specific role, e.g., "business analyst" or "technical architect"]
- ✅ If you already have been given a name, communication_style and identity, continue to use those while playing this new role
- ✅ We engage in collaborative dialogue, not command-response
- ✅ You bring [your expertise], user brings [their expertise], and together we produce something better than we could on our own
- ✅ Maintain collaborative [adjective] tone throughout
### Step-Specific Rules:
- 🎯 Focus ONLY on analyzing and resuming workflow state
- 🚫 FORBIDDEN to modify content completed in previous steps
- 💬 Maintain continuity with previous sessions
- 🚪 DETECT exact continuation point from frontmatter of incomplete file {outputFile}
## EXECUTION PROTOCOLS:
- 🎯 Show your analysis of current state before taking action
- 💾 Keep existing frontmatter `stepsCompleted` values intact
- 📖 Review the template content already generated in {outputFile}
- 🚫 FORBIDDEN to modify content that was completed in previous steps
- 📝 Update frontmatter with continuation timestamp when resuming
## CONTEXT BOUNDARIES:
- Current [output-file-name] document is already loaded
- Previous context = complete template + existing frontmatter
- [Key data collected] already gathered in previous sessions
- Last completed step = last value in `stepsCompleted` array from frontmatter
## CONTINUATION SEQUENCE:
### 1. Analyze Current State
Review the frontmatter of {outputFile} to understand:
- `stepsCompleted`: Which steps are already done (the rightmost value is the last step completed)
- `lastStep`: Name/description of last completed step (if exists)
- `date`: Original workflow start date
- `inputDocuments`: Any documents loaded during initialization
- [Other relevant frontmatter fields]
Example: If `stepsCompleted: [1, 2, 3, 4]`, then step 4 was the last completed step.
### 2. Read All Completed Step Files
For each step number in `stepsCompleted` array (excluding step 1, which is init):
1. **Construct step filename**: `step-[N]-[name].md`
2. **Read the complete step file** to understand:
- What that step accomplished
- What the next step should be (from nextStep references)
- Any specific context or decisions made
Example: If `stepsCompleted: [1, 2, 3]`:
- Read `step-02-[name].md`
- Read `step-03-[name].md`
- The last file will tell you what step-04 should be
### 3. Review Previous Output
Read the complete {outputFile} to understand:
- Content generated so far
- Sections completed vs pending
- User decisions and preferences
- Current state of the deliverable
### 4. Determine Next Step
Based on the last completed step file:
1. **Find the nextStep reference** in the last completed step file
2. **Validate the file exists** at the referenced path
3. **Confirm the workflow is incomplete** (not all steps finished)
### 5. Welcome Back Dialog
Present a warm, context-aware welcome:
"Welcome back! I see we've completed [X] steps of your [workflow-type].
We last worked on [brief description of last step].
Based on our progress, we're ready to continue with [next step description].
Are you ready to continue where we left off?"
### 6. Validate Continuation Intent
Ask confirmation questions if needed:
"Has anything changed since our last session that might affect our approach?"
"Are you still aligned with the goals and decisions we made earlier?"
"Would you like to review what we've accomplished so far?"
### 7. Present MENU OPTIONS
Display: "**Resuming workflow - Select an Option:** [C] Continue to [Next Step Name]"
#### EXECUTION RULES:
- ALWAYS halt and wait for user input after presenting menu
- ONLY proceed to next step when user selects 'C'
- User can chat or ask questions - always respond and then end with display again of the menu options
- Update frontmatter with continuation timestamp when 'C' is selected
#### Menu Handling Logic:
- IF C:
1. Update frontmatter: add `lastContinued: [current date]`
2. Load, read entire file, then execute the appropriate next step file (determined in section 4)
- IF Any other comments or queries: help user respond then [Redisplay Menu Options](#7-present-menu-options)
## CRITICAL STEP COMPLETION NOTE
ONLY WHEN C is selected and continuation analysis is complete, will you then:
1. Update frontmatter in {outputFile} with continuation timestamp
2. Load, read entire file, then execute the next step file determined from the analysis
Do NOT modify any other content in the output document during this continuation step.
## 🚨 SYSTEM SUCCESS/FAILURE METRICS
### ✅ SUCCESS:
- Correctly identified last completed step from `stepsCompleted` array
- Read and understood all previous step contexts
- User confirmed readiness to continue
- Frontmatter updated with continuation timestamp
- Workflow resumed at appropriate next step
### ❌ SYSTEM FAILURE:
- Skipping analysis of existing state
- Modifying content from previous steps
- Loading wrong next step file
- Not updating frontmatter with continuation info
- Proceeding without user confirmation
**Master Rule:** Skipping steps, optimizing sequences, or not following exact instructions is FORBIDDEN and constitutes SYSTEM FAILURE.
<!-- TEMPLATE END -->
## Customization Guidelines
When adapting this template for your specific workflow:
### 1. Update Placeholders
Replace bracketed placeholders with your specific values:
- `[module-path]` - e.g., "bmb/reference" or "custom"
- `[workflow-name]` - your workflow directory name
- `[workflow-type]` - e.g., "nutrition planning", "project requirements"
- `[output-file-name]` - base name for output document
- `[specific role]` - the role this workflow plays
- `[your expertise]` - what expertise you bring
- `[their expertise]` - what expertise user brings
### 2. Add Workflow-Specific Context
Add any workflow-specific fields to section 1 (Analyze Current State) if your workflow uses additional frontmatter fields for tracking.
### 3. Customize Welcome Message
Adapt the welcome dialog in section 5 to match your workflow's tone and context.
### 4. Add Continuation-Specific Validations
If your workflow has specific checkpoints or validation requirements, add them to section 6.
## Implementation Notes
1. **This step should NEVER modify the output content** - only analyze and prepare for continuation
2. **Always preserve the `stepsCompleted` array** - don't modify it in this step
3. **Timestamp tracking** - helps users understand when workflows were resumed
4. **Context preservation** - the key is maintaining all previous work and decisions
5. **Seamless experience** - user should feel like they never left the workflow

View File

@@ -0,0 +1,290 @@
# BMAD Workflow Step Template
This template provides the standard structure for all BMAD workflow step files. Copy and modify this template for each new step you create.
<!-- TEMPLATE START -->
---
name: 'step-[N]-[short-name]'
description: '[Brief description of what this step accomplishes]'
<!-- Path Definitions -->
workflow\*path: '{project-root}/_bmad/[module]/reference/workflows/[workflow-name]' # the folder the workflow.md file is in
# File References (all use {variable} format in file)
thisStepFile: './step-[N]-[short-name].md'
nextStep{N+1}: './step-[N+1]-[next-short-name].md' # Remove for final step or no next step
altStep{Y}: './step-[Y]-[some-other-step].md' # if there is an alternate next story depending on logic
workflowFile: '{workflow_path}/workflow.md'
outputFile: '{output_folder}/[output-file-name]-{project_name}.md'
# Task References (IF THE workflow uses and it makes sense in this step to have these )
advancedElicitationTask: '{project-root}/_bmad/core/workflows/advanced-elicitation/workflow.xml'
partyModeWorkflow: '{project-root}/_bmad/core/workflows/party-mode/workflow.md'
# Template References (if this step uses a specific templates)
profileTemplate: '{workflow_path}/templates/profile-section.md'
assessmentTemplate: '{workflow_path}/templates/assessment-section.md'
strategyTemplate: '{workflow_path}/templates/strategy-section.md'
# Data (CSV for example) References (if used in this step)
someData: '{workflow_path}/data/foo.csv'
# Add more as needed - but ONLY what is used in this specific step file!
---
# Step [N]: [Step Name]
## STEP GOAL:
[State the goal in context of the overall workflow goal. Be specific about what this step accomplishes and how it contributes to the workflow's purpose.]
Example: "To analyze user requirements and document functional specifications that will guide the development process"
## MANDATORY EXECUTION RULES (READ FIRST):
### Universal Rules:
- 🛑 NEVER generate content without user input
- 📖 CRITICAL: Read the complete step file before taking any action
- 🔄 CRITICAL: When loading next step with 'C', ensure entire file is read
- 📋 YOU ARE A FACILITATOR, not a content generator
### Role Reinforcement:
- ✅ You are a [specific role, e.g., "business analyst" or "technical architect"]
- ✅ If you already have been given a name, communication_style and identity, continue to use those while playing this new role
- ✅ We engage in collaborative dialogue, not command-response
- ✅ You bring [your expertise], user brings [their expertise], and together we produce something better than we could on our own
- ✅ Maintain collaborative [adjective] tone throughout
### Step-Specific Rules:
- 🎯 Focus only on [specific task for this step]
- 🚫 FORBIDDEN to [what not to do in this step]
- 💬 Approach: [how to handle this specific task]
- 📋 Additional rule relevant to this step
## EXECUTION PROTOCOLS:
- 🎯 Follow the MANDATORY SEQUENCE exactly
- 💾 [Step-specific protocol 2 - e.g., document updates]
- 📖 [Step-specific protocol 3 - e.g., tracking requirements]
- 🚫 [Step-specific restriction]
## CONTEXT BOUNDARIES:
- Available context: [what context is available from previous steps]
- Focus: [what this step should concentrate on]
- Limits: [what not to assume or do]
- Dependencies: [what this step depends on]
## MANDATORY SEQUENCE
**CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise unless user explicitly requests a change.
### 1. Title
[Specific instructions for first part of the work]
### 2. Title
[Specific instructions for second part of the work]
### N. Title (as many as needed)
<!-- not ever step will include advanced elicitation or party mode, in which case generally will just have the C option -->
<!-- for example an init step 1 that loads data, or step 1b continues a workflow would not need advanced elicitation or party mode - but any step where the user and the llm work together on content, thats where it makes sense to include them -->
### N. Present MENU OPTIONS
Display: "**Select an Option:** [A] Advanced Elicitation [P] Party Mode [C] Continue"
#### Menu Handling Logic:
- IF A: Execute {advancedElicitationTask} # Or custom action
- IF P: Execute {partyModeWorkflow} # Or custom action
- IF C: Save content to {outputFile}, update frontmatter, then only then load, read entire file, then execute {nextStepFile}
- IF Any other comments or queries: help user respond then [Redisplay Menu Options](#n-present-menu-options)
#### EXECUTION RULES:
- ALWAYS halt and wait for user input after presenting menu
- ONLY proceed to next step when user selects 'C'
- After other menu items execution completes, redisplay the menu
- User can chat or ask questions - always respond when conversation ends, redisplay the menu
## CRITICAL STEP COMPLETION NOTE
[Specific conditions for completing this step and transitioning to the next, such as output to file being created with this tasks updates]
ONLY WHEN [C continue option] is selected and [completion requirements], will you then load and read fully `[installed_path]/step-[next-number]-[name].md` to execute and begin [next step description].
## 🚨 SYSTEM SUCCESS/FAILURE METRICS
### ✅ SUCCESS:
- [Step-specific success criteria 1]
- [Step-specific success criteria 2]
- Content properly saved/document updated
- Menu presented and user input handled correctly
- [General success criteria]
### ❌ SYSTEM FAILURE:
- [Step-specific failure mode 1]
- [Step-specific failure mode 2]
- Proceeding without user input/selection
- Not updating required documents/frontmatter
- [Step-specific failure mode N]
**Master Rule:** Skipping steps, optimizing sequences, or not following exact instructions is FORBIDDEN and constitutes SYSTEM FAILURE.
<!-- TEMPLATE END-->
## Common Menu Patterns to use in the final sequence item in a step file
FYI Again - party mode is useful for the user to reach out and get opinions from other agents.
Advanced elicitation is use to direct you to think of alternative outputs of a sequence you just performed.
### Standard Menu - when a sequence in a step results in content produced by the agent or human that could be improved before proceeding
```markdown
### N. Present MENU OPTIONS
Display: "**Select an Option:** [A] [Advanced Elicitation] [P] Party Mode [C] Continue"
#### Menu Handling Logic:
- IF A: Execute {advancedElicitationTask}
- IF P: Execute {partyModeWorkflow}
- IF C: Save content to {outputFile}, update frontmatter, then only then load, read entire file, then execute {nextStepFile}
- IF Any other comments or queries: help user respond then [Redisplay Menu Options](#n-present-menu-options)
#### EXECUTION RULES:
- ALWAYS halt and wait for user input after presenting menu
- ONLY proceed to next step when user selects 'C'
- After other menu items execution, return to this menu
- User can chat or ask questions - always respond and then end with display again of the menu options
```
### Optional Menu - Auto-Proceed Menu (No User Choice or confirm, just flow right to the next step once completed)
```markdown
### N. Present MENU OPTIONS
Display: "**Proceeding to [next action]...**"
#### Menu Handling Logic:
- After [completion condition], immediately load, read entire file, then execute {nextStepFile}
#### EXECUTION RULES:
- This is an [auto-proceed reason] step with no user choices
- Proceed directly to next step after setup
```
### Custom Menu Options
```markdown
### N. Present MENU OPTIONS
Display: "**Select an Option:** [A] [Custom Action 1] [B] [Custom Action 2] [C] Continue"
#### Menu Handling Logic:
- IF A: [Custom handler route for option A]
- IF B: [Custom handler route for option B]
- IF C: Save content to {outputFile}, update frontmatter, then only then load, read entire file, then execute {nextStepFile}
- IF Any other comments or queries: help user respond then [Redisplay Menu Options](#n-present-menu-options)
#### EXECUTION RULES:
- ALWAYS halt and wait for user input after presenting menu
- ONLY proceed to next step when user selects 'C'
- After other menu items execution, return to this menu
- User can chat or ask questions - always respond and then end with display again of the menu options
```
### Conditional Menu (Based on Workflow State)
```markdown
### N. Present MENU OPTIONS
Display: "**Select an Option:** [A] [Continue to Step Foo] [A] [Continue to Step Bar]"
#### Menu Handling Logic:
- IF A: Execute {customAction}
- IF C: Save content to {outputFile}, update frontmatter, check [condition]:
- IF [condition true]: load, read entire file, then execute {pathA}
- IF [condition false]: load, read entire file, then execute {pathB}
- IF Any other comments or queries: help user respond then [Redisplay Menu Options](#n-present-menu-options)
#### EXECUTION RULES:
- ALWAYS halt and wait for user input after presenting menu
- ONLY proceed to next step when user selects 'C'
- After other menu items execution, return to this menu
- User can chat or ask questions - always respond and then end with display again of the menu options
```
## Example Step Implementations
### Initialization Step Example
See [step-01-discovery.md](../steps-c/step-01-discovery.md) for an example of:
- Detecting existing workflow state and short circuit to 1b
- Creating output documents from templates
- Auto-proceeding to the next step (this is not the normal behavior of most steps)
- Handling continuation scenarios
### Continuation Step Example
See [step-01b-continue.md](../steps-c/step-01b-continuation.md) for an example of:
- Handling already-in-progress workflows that the user now wants to continue progress
- Detecting completion status (which step was already completed last)
- Presenting update vs new plan options
- Seamless workflow resumption by reviewing existing plan and output thus far that has been recorded and then jumping to the proper step
### Standard Step with Menu Example
See [step-02-classification.md](../steps-c/step-02-classification.md#8-present-menu-options) for an example of:
- Presenting a menu with A/P/C options
- Forcing halt until user selects 'C' (Continue)
- Writing all collected content to output file only when 'C' is selected
- Updating frontmatter with step completion before proceeding
- Using frontmatter variables for file references
### Final Step Example
See [step-11-completion.md](../steps-c/step-11-completion.md) for an example of:
- Completing workflow deliverables
- Marking workflow as complete in frontmatter
- Providing final success messages
- Ending the workflow session gracefully or moving on to a validation workflow if applicable
## Best Practices
1. **Keep step files focused** - Each step should do one thing well
2. **Be explicit in instructions** - No ambiguity about what to do
3. **Include all critical rules** - Don't assume anything from other steps
4. **Use clear, concise language** - Avoid jargon unless necessary
5. **Ensure all menu paths have handlers** - Ensure every option has clear instructions - use menu items that make sense for the situation.
6. **Document dependencies** - Clearly state what this step needs with full paths in front matter
7. **Define success and failure clearly** - Both for the step and the workflow
8. **Mark completion clearly** - Ensure final steps update frontmatter to indicate workflow completion

View File

@@ -0,0 +1,102 @@
# BMAD Workflow Template
This template provides the standard structure for all BMAD workflow files. Copy and modify this template for each new workflow you create.
<!-- TEMPLATE START -->
---
name: [WORKFLOW_DISPLAY_NAME]
description: [Brief description of what this workflow accomplishes]
web_bundle: [true/false] # Set to true for inclusion in web bundle builds
---
# [WORKFLOW_DISPLAY_NAME]
**Goal:** [State the primary goal of this workflow in one clear sentence]
**Your Role:** In addition to your name, communication_style, and persona, you are also a [role] collaborating with [user type]. This is a partnership, not a client-vendor relationship. You bring [your expertise], while the user brings [their expertise]. Work together as equals.
## WORKFLOW ARCHITECTURE
### Core Principles
- **Micro-file Design**: Each step of the overall goal is a self contained instruction file that you will adhere too 1 file as directed at a time
- **Just-In-Time Loading**: Only 1 current step file will be loaded, read, and executed to completion - never load future step files until told to do so
- **Sequential Enforcement**: Sequence within the step files must be completed in order, no skipping or optimization allowed
- **State Tracking**: Document progress in output file frontmatter using `stepsCompleted` array when a workflow produces a document
- **Append-Only Building**: Build documents by appending content as directed to the output file
### Step Processing Rules
1. **READ COMPLETELY**: Always read the entire step file before taking any action
2. **FOLLOW SEQUENCE**: Execute all numbered sections in order, never deviate
3. **WAIT FOR INPUT**: If a menu is presented, halt and wait for user selection
4. **CHECK CONTINUATION**: If the step has a menu with Continue as an option, only proceed to next step when user selects 'C' (Continue)
5. **SAVE STATE**: Update `stepsCompleted` in frontmatter before loading next step
6. **LOAD NEXT**: When directed, load, read entire file, then execute the next step file
### Critical Rules (NO EXCEPTIONS)
- 🛑 **NEVER** load multiple step files simultaneously
- 📖 **ALWAYS** read entire step file before execution
- 🚫 **NEVER** skip steps or optimize the sequence
- 💾 **ALWAYS** update frontmatter of output files when writing the final output for a specific step
- 🎯 **ALWAYS** follow the exact instructions in the step file
- ⏸️ **ALWAYS** halt at menus and wait for user input
- 📋 **NEVER** create mental todo lists from future steps
---
## INITIALIZATION SEQUENCE
### 1. Module Configuration Loading
Load and read full config from {project-root}/_bmad/[MODULE FOLDER]/config.yaml and resolve:
- `project_name`, `output_folder`, `user_name`, `communication_language`, `document_output_language`, [MODULE VARS]
### 2. First Step EXECUTION
Load, read the full file and then execute [FIRST STEP FILE PATH] to begin the workflow.
<!-- TEMPLATE END -->
## How to Use This Template
### Step 1: Copy and Replace Placeholders
Copy the template above and replace:
- `[WORKFLOW_DISPLAY_NAME]` → Your workflow's display name
- `[MODULE FOLDER]` → Default is `core` unless this is for another module (such as bmm, cis, or another as directed by user)
- `[Brief description]` → One-sentence description
- `[true/false]` → Whether to include in web bundle
- `[role]` → AI's role in this workflow
- `[user type]` → Who the user is
- `[CONFIG_PATH]` → Path to config file (usually `bmm/config.yaml` or `bmb/config.yaml`)
- `[WORKFLOW_PATH]` → Path to your workflow folder
- `[MODULE VARS]` → Extra config variables available in a module configuration that the workflow would need to use
### Step 2: Create the Folder Structure
```
[workflow-folder]/
├── workflow.md # This file
├── data/ # (Optional csv or other data files)
├── templates/ # template files for output
└── steps/
├── step-01-init.md
├── step-02-[name].md
└── ...
```
### Step 3: Configure the Initialization Path
Update the last line of the workflow.md being created to replace [FIRST STEP FILE PATH] with the path to the actual first step file.
Example: Load, read the full file and then execute `./step-01-init.md` to begin the workflow.
### NOTE: You can View a real example of a perfect workflow.md file from the one you were executed from `../workflow.md`