Skip to content

Commit 03ce1e5

Browse files
feat(mode-writer): add validation and cohesion checking for mode creation (#6313)
Co-authored-by: Matt Rubens <[email protected]>
1 parent b27673e commit 03ce1e5

File tree

4 files changed

+699
-218
lines changed

4 files changed

+699
-218
lines changed
Lines changed: 258 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,278 @@
1-
<mode_creation_workflow>
1+
<mode_management_workflow>
22
<overview>
3-
This workflow guides you through creating a new custom mode to be used in the Roo Code Software,
4-
from initial requirements gathering to final implementation.
3+
This workflow guides you through creating new custom modes or editing existing modes
4+
for the Roo Code Software, ensuring comprehensive understanding and cohesive implementation.
55
</overview>
66

7-
<detailed_steps>
7+
<initial_determination>
88
<step number="1">
9-
<title>Gather Requirements</title>
9+
<title>Determine User Intent</title>
1010
<description>
11-
Understand what the user wants the mode to accomplish
11+
Identify whether the user wants to create a new mode or edit an existing one
1212
</description>
13-
<actions>
14-
<action>Ask about the mode's primary purpose and use cases</action>
15-
<action>Identify what types of tasks the mode should handle</action>
16-
<action>Determine what tools and file access the mode needs</action>
17-
<action>Clarify any special behaviors or restrictions</action>
18-
</actions>
19-
<example>
13+
<detection_patterns>
14+
<pattern type="edit_existing">
15+
<indicators>
16+
<indicator>User mentions a specific mode by name or slug</indicator>
17+
<indicator>User references a mode directory path (e.g., .roo/rules-[mode-slug])</indicator>
18+
<indicator>User asks to modify, update, enhance, or fix an existing mode</indicator>
19+
<indicator>User says "edit this mode" or "change this mode"</indicator>
20+
</indicators>
21+
</pattern>
22+
<pattern type="create_new">
23+
<indicators>
24+
<indicator>User asks to create a new mode</indicator>
25+
<indicator>User describes a new capability not covered by existing modes</indicator>
26+
<indicator>User says "make a mode for" or "create a mode that"</indicator>
27+
</indicators>
28+
</pattern>
29+
</detection_patterns>
30+
<clarification_question>
2031
<ask_followup_question>
21-
<question>What is the primary purpose of this new mode? What types of tasks should it handle?</question>
32+
<question>I want to make sure I understand correctly. Are you looking to create a brand new mode or modify an existing one?</question>
2233
<follow_up>
23-
<suggest>A mode for writing and maintaining documentation</suggest>
24-
<suggest>A mode for database schema design and migrations</suggest>
25-
<suggest>A mode for API endpoint development and testing</suggest>
26-
<suggest>A mode for performance optimization and profiling</suggest>
34+
<suggest>Create a new mode for a specific purpose</suggest>
35+
<suggest>Edit an existing mode to add new capabilities</suggest>
36+
<suggest>Fix issues in an existing mode</suggest>
37+
<suggest>Enhance an existing mode with better workflows</suggest>
2738
</follow_up>
2839
</ask_followup_question>
29-
</example>
40+
</clarification_question>
3041
</step>
42+
</initial_determination>
3143

32-
<step number="2">
33-
<title>Design Mode Configuration</title>
34-
<description>
35-
Create the mode definition with all required fields
36-
</description>
37-
<required_fields>
38-
<field name="slug">
39-
<description>Unique identifier (lowercase, hyphens allowed)</description>
40-
<best_practice>Keep it short and descriptive (e.g., "api-dev", "docs-writer")</best_practice>
41-
</field>
42-
<field name="name">
43-
<description>Display name with optional emoji</description>
44-
<best_practice>Use an emoji that represents the mode's purpose</best_practice>
45-
</field>
46-
<field name="roleDefinition">
47-
<description>Detailed description of the mode's role and expertise</description>
48-
<best_practice>
49-
Start with "You are Roo Code, a [specialist type]..."
50-
List specific areas of expertise
51-
Mention key technologies or methodologies
52-
</best_practice>
53-
</field>
54-
<field name="groups">
55-
<description>Tool groups the mode can access</description>
56-
<options>
57-
<option name="read">File reading and searching tools</option>
58-
<option name="edit">File editing tools (can be restricted by regex)</option>
59-
<option name="command">Command execution tools</option>
60-
<option name="browser">Browser interaction tools</option>
61-
<option name="mcp">MCP server tools</option>
62-
</options>
63-
</field>
64-
</required_fields>
65-
<recommended_fields>
66-
<field name="whenToUse">
67-
<description>Clear description for the Orchestrator</description>
68-
<best_practice>Explain specific scenarios and task types</best_practice>
69-
</field>
70-
</recommended_fields>
71-
<important_note>
72-
Do not include customInstructions in the .roomodes configuration.
73-
All detailed instructions should be placed in XML files within
74-
the .roo/rules-[mode-slug]/ directory instead.
75-
</important_note>
76-
</step>
44+
<workflow_branches>
45+
<branch name="create_new_mode">
46+
<step number="2a">
47+
<title>Gather Requirements for New Mode</title>
48+
<description>
49+
Understand what the user wants the new mode to accomplish
50+
</description>
51+
<actions>
52+
<action>Ask about the mode's primary purpose and use cases</action>
53+
<action>Identify what types of tasks the mode should handle</action>
54+
<action>Determine what tools and file access the mode needs</action>
55+
<action>Clarify any special behaviors or restrictions</action>
56+
</actions>
57+
<example>
58+
<ask_followup_question>
59+
<question>What is the primary purpose of this new mode? What types of tasks should it handle?</question>
60+
<follow_up>
61+
<suggest>A mode for writing and maintaining documentation</suggest>
62+
<suggest>A mode for database schema design and migrations</suggest>
63+
<suggest>A mode for API endpoint development and testing</suggest>
64+
<suggest>A mode for performance optimization and profiling</suggest>
65+
</follow_up>
66+
</ask_followup_question>
67+
</example>
68+
</step>
7769

78-
<step number="3">
79-
<title>Implement File Restrictions</title>
80-
<description>
81-
Configure appropriate file access permissions
82-
</description>
83-
<example>
84-
<comment>Restrict edit access to specific file types</comment>
85-
<code>
70+
<step number="3a">
71+
<title>Design Mode Configuration</title>
72+
<description>
73+
Create the mode definition with all required fields
74+
</description>
75+
<required_fields>
76+
<field name="slug">
77+
<description>Unique identifier (lowercase, hyphens allowed)</description>
78+
<best_practice>Keep it short and descriptive (e.g., "api-dev", "docs-writer")</best_practice>
79+
</field>
80+
<field name="name">
81+
<description>Display name with optional emoji</description>
82+
<best_practice>Use an emoji that represents the mode's purpose</best_practice>
83+
</field>
84+
<field name="roleDefinition">
85+
<description>Detailed description of the mode's role and expertise</description>
86+
<best_practice>
87+
Start with "You are Roo Code, a [specialist type]..."
88+
List specific areas of expertise
89+
Mention key technologies or methodologies
90+
</best_practice>
91+
</field>
92+
<field name="groups">
93+
<description>Tool groups the mode can access</description>
94+
<options>
95+
<option name="read">File reading and searching tools</option>
96+
<option name="edit">File editing tools (can be restricted by regex)</option>
97+
<option name="command">Command execution tools</option>
98+
<option name="browser">Browser interaction tools</option>
99+
<option name="mcp">MCP server tools</option>
100+
</options>
101+
</field>
102+
</required_fields>
103+
<recommended_fields>
104+
<field name="whenToUse">
105+
<description>Clear description for the Orchestrator</description>
106+
<best_practice>Explain specific scenarios and task types</best_practice>
107+
</field>
108+
</recommended_fields>
109+
<important_note>
110+
Do not include customInstructions in the .roomodes configuration.
111+
All detailed instructions should be placed in XML files within
112+
the .roo/rules-[mode-slug]/ directory instead.
113+
</important_note>
114+
</step>
115+
116+
<step number="4a">
117+
<title>Implement File Restrictions</title>
118+
<description>
119+
Configure appropriate file access permissions
120+
</description>
121+
<example>
122+
<comment>Restrict edit access to specific file types</comment>
123+
<code>
86124
groups:
87125
- read
88126
- - edit
89127
- fileRegex: \.(md|txt|rst)$
90128
description: Documentation files only
91129
- command
92-
</code>
93-
</example>
94-
<guidelines>
95-
<guideline>Use regex patterns to limit file editing scope</guideline>
96-
<guideline>Provide clear descriptions for restrictions</guideline>
97-
<guideline>Consider the principle of least privilege</guideline>
98-
</guidelines>
99-
</step>
130+
</code>
131+
</example>
132+
<guidelines>
133+
<guideline>Use regex patterns to limit file editing scope</guideline>
134+
<guideline>Provide clear descriptions for restrictions</guideline>
135+
<guideline>Consider the principle of least privilege</guideline>
136+
</guidelines>
137+
</step>
138+
139+
<step number="5a">
140+
<title>Create XML Instruction Files</title>
141+
<description>
142+
Design structured instruction files in .roo/rules-[mode-slug]/
143+
</description>
144+
<file_structure>
145+
<file name="1_workflow.xml">Main workflow and step-by-step processes</file>
146+
<file name="2_best_practices.xml">Guidelines and conventions</file>
147+
<file name="3_common_patterns.xml">Reusable code patterns and examples</file>
148+
<file name="4_tool_usage.xml">Specific tool usage instructions</file>
149+
<file name="5_examples.xml">Complete workflow examples</file>
150+
</file_structure>
151+
<xml_best_practices>
152+
<practice>Use semantic tag names that describe content</practice>
153+
<practice>Nest tags hierarchically for better organization</practice>
154+
<practice>Include code examples in CDATA sections when needed</practice>
155+
<practice>Add comments to explain complex sections</practice>
156+
</xml_best_practices>
157+
</step>
158+
</branch>
100159

101-
<step number="4">
102-
<title>Create XML Instruction Files</title>
160+
<branch name="edit_existing_mode">
161+
<step number="2b">
162+
<title>Immerse in Existing Mode</title>
163+
<description>
164+
Fully understand the existing mode before making any changes
165+
</description>
166+
<actions>
167+
<action>Locate and read the mode configuration in .roomodes</action>
168+
<action>Read all XML instruction files in .roo/rules-[mode-slug]/</action>
169+
<action>Analyze the mode's current capabilities and limitations</action>
170+
<action>Understand the mode's role in the broader ecosystem</action>
171+
</actions>
172+
<questions_to_ask>
173+
<ask_followup_question>
174+
<question>What specific aspects of the mode would you like to change or enhance?</question>
175+
<follow_up>
176+
<suggest>Add new capabilities or tool permissions</suggest>
177+
<suggest>Fix issues with current workflows or instructions</suggest>
178+
<suggest>Improve the mode's roleDefinition or whenToUse description</suggest>
179+
<suggest>Enhance XML instructions for better clarity</suggest>
180+
</follow_up>
181+
</ask_followup_question>
182+
</questions_to_ask>
183+
</step>
184+
185+
<step number="3b">
186+
<title>Analyze Change Impact</title>
187+
<description>
188+
Understand how proposed changes will affect the mode
189+
</description>
190+
<analysis_areas>
191+
<area>Compatibility with existing workflows</area>
192+
<area>Impact on file permissions and tool access</area>
193+
<area>Consistency with mode's core purpose</area>
194+
<area>Integration with other modes</area>
195+
</analysis_areas>
196+
<validation_questions>
197+
<ask_followup_question>
198+
<question>I've analyzed the existing mode. Here's what I understand about your requested changes. Is this correct?</question>
199+
<follow_up>
200+
<suggest>Yes, that's exactly what I want to change</suggest>
201+
<suggest>Mostly correct, but let me clarify some details</suggest>
202+
<suggest>No, I meant something different</suggest>
203+
<suggest>I'd like to add additional changes</suggest>
204+
</follow_up>
205+
</ask_followup_question>
206+
</validation_questions>
207+
</step>
208+
209+
<step number="4b">
210+
<title>Plan Modifications</title>
211+
<description>
212+
Create a detailed plan for modifying the mode
213+
</description>
214+
<planning_steps>
215+
<step>Identify which files need to be modified</step>
216+
<step>Determine if new XML instruction files are needed</step>
217+
<step>Check for potential conflicts or contradictions</step>
218+
<step>Plan the order of changes for minimal disruption</step>
219+
</planning_steps>
220+
</step>
221+
222+
<step number="5b">
223+
<title>Implement Changes</title>
224+
<description>
225+
Apply the planned modifications to the mode
226+
</description>
227+
<implementation_order>
228+
<change>Update .roomodes configuration if needed</change>
229+
<change>Modify existing XML instruction files</change>
230+
<change>Create new XML instruction files if required</change>
231+
<change>Update examples and documentation</change>
232+
</implementation_order>
233+
</step>
234+
</branch>
235+
</workflow_branches>
236+
237+
<validation_and_cohesion>
238+
<step number="6">
239+
<title>Validate Cohesion and Consistency</title>
103240
<description>
104-
Design structured instruction files in .roo/rules-[mode-slug]/
241+
Ensure all changes are cohesive and don't contradict each other
105242
</description>
106-
<file_structure>
107-
<file name="1_workflow.xml">Main workflow and step-by-step processes</file>
108-
<file name="2_best_practices.xml">Guidelines and conventions</file>
109-
<file name="3_common_patterns.xml">Reusable code patterns and examples</file>
110-
<file name="4_tool_usage.xml">Specific tool usage instructions</file>
111-
<file name="5_examples.xml">Complete workflow examples</file>
112-
</file_structure>
113-
<xml_best_practices>
114-
<practice>Use semantic tag names that describe content</practice>
115-
<practice>Nest tags hierarchically for better organization</practice>
116-
<practice>Include code examples in CDATA sections when needed</practice>
117-
<practice>Add comments to explain complex sections</practice>
118-
</xml_best_practices>
243+
<validation_checks>
244+
<check type="configuration">
245+
<item>Mode slug follows naming conventions</item>
246+
<item>File restrictions align with mode purpose</item>
247+
<item>Tool permissions are appropriate</item>
248+
<item>whenToUse clearly differentiates from other modes</item>
249+
</check>
250+
<check type="instructions">
251+
<item>All XML files follow consistent structure</item>
252+
<item>No contradicting instructions between files</item>
253+
<item>Examples align with stated workflows</item>
254+
<item>Tool usage matches granted permissions</item>
255+
</check>
256+
<check type="integration">
257+
<item>Mode integrates well with Orchestrator</item>
258+
<item>Clear boundaries with other modes</item>
259+
<item>Handoff points are well-defined</item>
260+
</check>
261+
</validation_checks>
262+
<cohesion_questions>
263+
<ask_followup_question>
264+
<question>I've completed the validation checks. Would you like me to review any specific aspect in more detail?</question>
265+
<follow_up>
266+
<suggest>Review the file permission patterns</suggest>
267+
<suggest>Check for workflow contradictions</suggest>
268+
<suggest>Verify integration with other modes</suggest>
269+
<suggest>Everything looks good, proceed to testing</suggest>
270+
</follow_up>
271+
</ask_followup_question>
272+
</cohesion_questions>
119273
</step>
120274

121-
<step number="5">
275+
<step number="7">
122276
<title>Test and Refine</title>
123277
<description>
124278
Verify the mode works as intended
@@ -129,14 +283,19 @@ groups:
129283
<item>Instructions are clear and actionable</item>
130284
<item>Mode integrates well with Orchestrator</item>
131285
<item>All examples are accurate and helpful</item>
286+
<item>Changes don't break existing functionality (for edits)</item>
287+
<item>New capabilities work as expected</item>
132288
</checklist>
133289
</step>
134-
</detailed_steps>
290+
</validation_and_cohesion>
135291

136292
<quick_reference>
137293
<command>Create mode in .roomodes for project-specific modes</command>
138294
<command>Create mode in global custom_modes.yaml for system-wide modes</command>
139295
<command>Use list_files to verify .roo folder structure</command>
140296
<command>Test file regex patterns with search_files</command>
297+
<command>Use codebase_search to find existing mode implementations</command>
298+
<command>Read all XML files in a mode directory to understand its structure</command>
299+
<command>Always validate changes for cohesion and consistency</command>
141300
</quick_reference>
142-
</mode_creation_workflow>
301+
</mode_management_workflow>

0 commit comments

Comments
 (0)