Skip to content

Commit 54b3a19

Browse files
committed
refactor(workflows): restructure bmad-review as loop module and clean up prompts
- Convert bmad-review from step to loop module in workflow configuration - Remove interactive improvement process from story creation prompts - Update instructions to prevent redundant document loading - Clean up output messages and remove unnecessary sections
1 parent a31de3e commit 54b3a19

File tree

7 files changed

+52
-117
lines changed

7 files changed

+52
-117
lines changed

config/main.agents.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -241,18 +241,6 @@ module.exports = [
241241
path.join(promptsDir, 'bmad', '07-dev', '01-dev-story', 'checklist.md'),
242242
],
243243
},
244-
{
245-
id: 'bmad-review',
246-
name: 'Amelia [Dev: Review]',
247-
description: 'BMAD Developer for code review',
248-
promptPath: [
249-
path.join(promptsDir, 'bmad', 'shared', 'system-files-protection.md'),
250-
path.join(promptsDir, 'bmad', '07-dev', 'amelia.md'),
251-
path.join(promptsDir, 'bmad', '07-dev', '02-code-review', 'instructions.xml'),
252-
path.join(promptsDir, 'bmad', '07-dev', '02-code-review', 'checklist.md'),
253-
],
254-
},
255-
256244
// Test agents
257245
{
258246
id: 'test-agent-1',

config/modules.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@ const path = require('node:path');
33
const promptsDir = path.join(__dirname, '..', 'prompts');
44

55
module.exports = [
6+
// BMAD code review module with loop behavior
7+
{
8+
id: 'bmad-review',
9+
name: 'Amelia [Dev: Review]',
10+
description: 'BMAD Developer for code review',
11+
promptPath: [
12+
path.join(promptsDir, 'templates', 'bmad', 'shared', 'system-files-protection.md'),
13+
path.join(promptsDir, 'templates', 'bmad', '07-dev', 'amelia.md'),
14+
path.join(promptsDir, 'templates', 'bmad', '07-dev', '02-code-review', 'instructions.xml'),
15+
path.join(promptsDir, 'templates', 'bmad', '07-dev', '02-code-review', 'checklist.md'),
16+
],
17+
behavior: {
18+
type: 'loop',
19+
action: 'stepBack',
20+
},
21+
},
622
{
723
id: 'check-task',
824
name: 'Task Loop Checker',

prompts/templates/bmad/06-sm/02-create-story/checklist.md

Lines changed: 4 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ You are an independent quality validator in a **FRESH CONTEXT**. Your mission is
66

77
**Your purpose is NOT just to validate - it's to FIX and PREVENT LLM developer mistakes, omissions, or disasters!**
88

9+
> 🚫 **REMINDER:** DO NOT load/search/fetch Epics, PRD, Architecture, UX Design Spec - these are already in-memory from source_documents.
10+
911
### **🚨 CRITICAL MISTAKES TO PREVENT:**
1012

1113
- **Reinventing wheels** - Creating duplicate functionality instead of reusing existing
@@ -48,7 +50,7 @@ You will systematically re-do the entire story creation process, but with a crit
4850

4951
#### **2.1 Epics and Stories Analysis**
5052

51-
- Extract **COMPLETE Epic {{epic_num}} context** from the Epics document:
53+
- The Epics document is already loaded in-memory. Analyze for **COMPLETE Epic {{epic_num}} context**:
5254
- Epic objectives and business value
5355
- ALL stories in this epic (for cross-story context)
5456
- Our specific story's requirements, acceptance criteria
@@ -57,7 +59,7 @@ You will systematically re-do the entire story creation process, but with a crit
5759

5860
#### **2.2 Architecture Deep-Dive**
5961

60-
- **Systematically scan the Architecture document for ANYTHING relevant to this story:**
62+
- The Architecture document is already loaded in-memory. Analyze for **ANYTHING relevant to this story:**
6163
- Technical stack with versions (languages, frameworks, libraries)
6264
- Code structure and organization patterns
6365
- API design patterns and contracts
@@ -214,86 +216,6 @@ You will systematically re-do the entire story creation process, but with a crit
214216

215217
---
216218

217-
## **📋 INTERACTIVE IMPROVEMENT PROCESS**
218-
219-
After completing your systematic analysis, present your findings to the user interactively:
220-
221-
### **Step 5: Present Improvement Suggestions**
222-
223-
```
224-
🎯 **STORY CONTEXT QUALITY REVIEW COMPLETE**
225-
226-
**Story:** {{story_key}} - {{story_title}}
227-
228-
I found {{critical_count}} critical issues, {{enhancement_count}} enhancements, and {{optimization_count}} optimizations.
229-
230-
## **🚨 CRITICAL ISSUES (Must Fix)**
231-
232-
{{list each critical issue with clear, actionable description}}
233-
234-
## **⚡ ENHANCEMENT OPPORTUNITIES (Should Add)**
235-
236-
{{list each enhancement with clear benefit description}}
237-
238-
## **✨ OPTIMIZATIONS (Nice to Have)**
239-
240-
{{list each optimization with benefit description}}
241-
242-
## **🤖 LLM OPTIMIZATION (Token Efficiency & Clarity)**
243-
244-
{{list each LLM optimization that will improve dev agent performance:
245-
- Reduce verbosity while maintaining completeness
246-
- Improve structure for better LLM processing
247-
- Make instructions more actionable and direct
248-
- Enhance clarity and reduce ambiguity}}
249-
```
250-
251-
### **Step 6: Interactive User Selection**
252-
253-
After presenting the suggestions, ask the user:
254-
255-
```
256-
**IMPROVEMENT OPTIONS:**
257-
258-
Which improvements would you like me to apply to the story?
259-
260-
**Select from the numbered list above, or choose:**
261-
- **all** - Apply all suggested improvements
262-
- **critical** - Apply only critical issues
263-
- **select** - I'll choose specific numbers
264-
- **none** - Keep story as-is
265-
- **details** - Show me more details about any suggestion
266-
267-
Your choice:
268-
```
269-
270-
### **Step 7: Apply Selected Improvements**
271-
272-
When user accepts improvements:
273-
274-
- **Update the story file** at `.codemachine/artifacts/stories/{{story_key}}.md`
275-
- **Apply accepted changes** (make them look natural, as if they were always there)
276-
- **DO NOT reference** the review process, original LLM, or that changes were "added" or "enhanced"
277-
- **Ensure clean, coherent final story** that reads as if it was created perfectly the first time
278-
279-
### **Step 8: Confirmation**
280-
281-
After applying changes:
282-
283-
```
284-
✅ **STORY IMPROVEMENTS APPLIED**
285-
286-
Updated {{count}} sections in `.codemachine/artifacts/stories/{{story_key}}.md`
287-
288-
The story now includes comprehensive developer guidance to prevent common implementation issues and ensure flawless execution.
289-
290-
**Next Steps:**
291-
1. Review the updated story
292-
2. Run `dev-story` for implementation
293-
```
294-
295-
---
296-
297219
## **💪 COMPETITIVE EXCELLENCE MINDSET**
298220

299221
**Your goal:** Improve the story file with dev agent needed context that makes flawless implementation inevitable while being optimized for LLM developer agent consumption. Remember the dev agent will ONLY have this file to use.

prompts/templates/bmad/06-sm/02-create-story/instructions.xml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@
4949
This is the most important function in the entire development process!</critical>
5050
<critical>🔬 UTILIZE SUBPROCESSES AND SUBAGENTS: Use research subagents, subprocesses or parallel processing if available to thoroughly
5151
analyze different artifacts simultaneously and thoroughly</critical>
52-
<critical>❓ SAVE QUESTIONS: If you think of questions or clarifications during analysis, save them for the end after the complete story is
53-
written</critical>
5452
<critical>🎯 ZERO USER INTERVENTION: Process is fully automated - all data is pre-injected</critical>
53+
<critical>🚫 DO NOT load/search/fetch: Epics, PRD, Architecture, UX Design Spec, Story Template, Story Checklist - these are already in-memory in source_documents above</critical>
5554

5655
<step n="1" goal="Determine target story from sprint status">
5756
<action>From {sprint_status}, find the FIRST story (in order) where:
@@ -227,30 +226,13 @@
227226
<action>Save .codemachine/artifacts/sprint-status.yaml preserving all comments and structure</action>
228227

229228
<action>Report completion</action>
230-
<output>**🎯 ULTIMATE BMad Method STORY CONTEXT CREATED, {user_name}!**
229+
<output>**🎯 Story Context Created**
231230

232231
**Story Details:**
233232
- Story ID: {{story_id}}
234233
- Story Key: {{story_key}}
235234
- File: .codemachine/artifacts/stories/{{story_key}}.md
236235
- Status: ready-for-dev
237-
238-
**Next Steps:**
239-
1. Review the comprehensive story in .codemachine/artifacts/stories/{{story_key}}.md
240-
2. **Optional Quality Competition:** Run the scrum masters `*validate-create-story` to have a fresh LLM systematically review and
241-
improve the story context
242-
3. Run dev agents `dev-story` for optimized implementation
243-
4. Run `code-review` when complete (auto-marks done)
244-
245-
**Quality Competition Option:** The `*validate-create-story` command runs the story context through an independent LLM in fresh
246-
context that will:
247-
- Systematically re-analyze all source documents
248-
- Identify any misses, omissions, or improvements
249-
- Compete to create a more comprehensive story context
250-
- Present findings interactively for your approval
251-
- Apply improvements to create the ultimate developer implementation guide
252-
253-
**The developer now has everything needed for flawless implementation!**
254236
</output>
255237
</step>
256238

prompts/templates/bmad/07-dev/02-code-review/instructions.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,32 @@
195195
</output>
196196
</step>
197197

198+
<step n="6" goal="Write directive to control workflow continuation">
199+
<critical>MANDATORY: Write to .codemachine/memory/directive.json to signal workflow</critical>
200+
201+
<check if="{{new_status}} == 'done'">
202+
<action>Write to `.codemachine/memory/directive.json`:
203+
```json
204+
{
205+
"action": "loop",
206+
"reason": "Story {{story_key}} complete - continuing to next story"
207+
}
208+
```
209+
</action>
210+
<output>📋 Directive: loop - continuing to next story</output>
211+
</check>
212+
213+
<check if="HIGH issues remain unfixed OR critical errors occurred">
214+
<action>Write to `.codemachine/memory/directive.json`:
215+
```json
216+
{
217+
"action": "error",
218+
"reason": "Code review failed: {{unfixed_issues_summary}}"
219+
}
220+
```
221+
</action>
222+
<output>🛑 Directive: error - escalating to user for unresolved issues</output>
223+
</check>
224+
</step>
225+
198226
</workflow>

templates/workflows/bmad.workflow.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export default {
6363
separator("⟲ Story Loop ⟲"),
6464
resolveStep('bmad-stories', {}),
6565
resolveStep('bmad-dev', {}),
66-
resolveStep('bmad-review', {}),
67-
66+
resolveModule('bmad-review', { loopSteps: 2 }),
6867
],
6968
};

templates/workflows/test2.workflow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
separator("❚❚ Human Review"),
99

1010
// Module with conditions
11-
resolveModule('auto-loop', { loopSteps: 2, loopMaxIterations: 5 }),
11+
resolveModule('auto-loop', { loopSteps: 2 }),
1212
],
1313
subAgentIds: ['frontend-dev'],
1414
};

0 commit comments

Comments
 (0)