This repository contains a set of rules and configurations for enhancing Roo modes with robust rules and additional custom modes. It provides tools to easily bootstrap other projects with these rules and modes.
The roo-mode-rules
project helps you:
- Define and organize mode-specific rules in a structured way
- Copy these rules to other projects
- Merge custom modes with existing configurations
- Maintain a consistent development experience across projects
- Node.js (v14 or higher)
- npm (v6 or higher)
- A target project where you want to apply the rules
# Clone the repository
git clone [email protected]:agentience/roo-mode-rules.git
# Install dependencies
cd roo-mode-rules
npm install
The copy-roo
script copies specific rule-{mode} folders in .roo
directory to a target project and handles merging of the .roomodes
file.
npm run copy-roo <target_directory>
For example:
npm run copy-roo ../my-project
To include modes/rules in addition to the set defined .roo/default_mode_set.yaml
:
npm run copy-roo -- ../my-project --modes=db-migration
This script:
- Copies the default mode set, plus any additional modes specified, to the
.roo
directory of the target project - Handles the
.roomodes
file:- If the target doesn't have a
.roomodes
file, it copies the default mode set (see more on modes below) to a .roomodes file in the target directory. - If the target has a
.roomodes
file, it merges the default modes, preserving existing modes and adding new ones
- If the target doesn't have a
You may find yourself editing rules or modes after having already targeted a number of projects. For this case, a playback functionality is provided.
When you target a specific project directory using npm run copy-roo {target_dir}
the command is recorded in the copy_history.json
file (which is not committed to the repo). To re-run the copy-roo
command against all previously targeted projects you can run the script without any additional parameters:
npm run copy-roo
- Define your rules in the appropriate context files
- Run
npm run copy-context
to update the.roo
directory - Run
npm run copy-roo <target_directory>
to apply these rules to another project
roo-mode-rules/
├── .roo/ # Rules and configurations for Roo modes
│ ├── rules-architect/ # Rules specific to Architect mode
│ ├── rules-code/ # Rules specific to Code mode
│ └── ... # Other mode-specific rules
├── scripts/
│ ├── copy-context-files.js # Script to copy context files
│ ├── copy_roo.js # Script to copy .roo directory to target
│ ├── mcp-server-relevance.js # MCP server relevance analysis
│ ├── enhance-task-delegation.js # Task delegation enhancement with MCP servers
│ └── test-mcp-relevance.js # Test script for MCP server relevance
├── mode-rule-context.yaml # Defines which context files to use for each mode
├── .roomodes # Custom modes configuration
└── package.json # Project dependencies and scripts
Mode rules can be configured in 2 ways:
When rules are certain to be specific to a single mode only, simply place the new rules yaml file under the mode-specific rules folder.
When rule files pertain to multiple modes, place these common rules under .roo/context folder. This folder provides a single place to edit files that are duplicated to specific modes using the script:
npm run copy-context
This script:
- Reads the
mode-rule-context.yaml
file - For each mode, creates a
.roo/rules-{mode}
directory, if it doesn't exist. - Copies the specified context files to the appropriate mode folders.
- Edit or add context files in the
.roo/context/
directory. For single-mode rules add or edit directly under.roo/rules-{mode}
- Update the
mode-rule-context.yaml
file to include any new rules files under.roo/context
- Run
npm run copy-context
to update the.roo
directory - Run
npm run copy-roo <target_directory>
to apply the changes to your target project
Managing your modes with copy_roo.js
provides several advantages:
- Consistency: Ensures a consistent set of available modes across different projects or team members, promoting standardized workflows.
- Simplified Setup: Simplifies the setup of new projects by quickly applying a predefined set of relevant modes.
- Shareability: Facilitates the sharing of standardized mode configurations within a team or across an organization.
- Edit the
.roomodes
file to define your custom modes - Create appropriate rule files in the
.roo/context/
directory, or mode-specific rules files directly in.roo/rules-{mode}
. - Update the
mode-rule-context.yaml
file to include your custom mode, as necessary. - Follow the steps above to apply the changes to your target project
The .roomodes
file in this repository acts as a central library containing the definitions (configuration) for all available custom modes. When you use copy_roo.js
, mode definitions are selected from this library.
The default_mode_set.yaml
file defines a set of mode slugs that are always included by default when you run the copy_roo.js
(npm run copy-roo
) script without specifying additional modes.
You can specify additional mode slugs to copy, beyond the default set, by using the --modes
command-line argument with the copy_roo.js
script. For example:
npm run copy-roo -- ../my-project --modes=mode-slug1,mode-slug2
This command would copy the default modes plus the modes with slugs mode-slug1
and mode-slug2
(if they exist in the source .roomodes
library).
The copy_roo.js
script performs the following steps:
- It reads the list of default mode slugs from
default_mode_set.yaml
. - It reads any additional mode slugs provided via the
--modes
command-line argument. - It combines the default slugs and the
--modes
slugs to create a final list of desired mode slugs. - It reads the source
.roomodes
file (the central library) in this repository. - It selects the mode definitions from the source
.roomodes
library that match the slugs in the final list. - It creates a new
.roomodes
file in the target directory containing only the selected mode definitions. - It modifies the two files responsible for helping Orchestrator mode understand how to transition between modes:
.roo/context/workflow-orchestration.roo.yaml
.roo/context/task-delegation-patterns.roo.yaml
If a .roomodes
file already exists in the target, it will be merged with the new mode selections.
This ensures that the target project's .roomodes
file contains the set of modes you intend to use, without impacting any modes already defined in the target project.
Note: Most of the work above is done in a temp directory that is then copied to the target directory this avoids manipulating the structure of the project or the .roomodes
file.
Here are some tips for effectively managing your modes:
- Curate Default Sets: Maintain a well-defined
default_mode_set.yaml
for common project types or team standards. - Use
--modes
for Customization: Leverage the--modes
argument for project-specific additions without modifying the default set. - Version Control: Keep your target project's
.roomodes
file under version control to track the specific mode configuration used for that project.
The project includes rules to enhance the orchestrator mode's task delegation with MCP server relevance. These rules instruct Orchestrator mode to analyze the instructions for a subtask and include MCP servers that are relevant to the task, providing this information to the delegated mode.
-
When the orchestrator mode delegates a task to another mode using the
new_task
tool, the system:- Analyzes the task's objective, requirements, and context
- Extracts keywords and concepts from the task content
- Matches these against MCP server descriptions, tools, and resources
- Identifies the most relevant MCP servers for the task
- Includes this information in the task delegation message
-
The delegated mode receives a task message with a "Relevant MCP Servers" section that lists MCP servers that are likely to be useful for the task, along with brief explanations of why they're relevant.
- Improved Efficiency: Modes immediately know which MCP servers to consider for a task
- Reduced Cognitive Load: Modes don't need to search through all available MCP servers
- Better Task Completion: Access to the right tools leads to better task outcomes
- Contextual Awareness: Modes have more context about the task requirements
The functionality captured in the .roo/context/mcp-server-relevance.roo.yaml
is also implemented as scripts, which may be incorporated into an mcp server at a later date.
You can test the MCP server relevance functionality using the provided test script:
npm run test-mcp-relevance
This script demonstrates how the system analyzes different types of tasks and identifies relevant MCP servers.
- mcp-server-relevance.js: Core functionality for analyzing tasks and identifying relevant MCP servers
- enhance-task-delegation.js: Integration with the task delegation process
- test-mcp-relevance.js: Test script with sample tasks and MCP servers
The task delegation template in .roo/rules-orchestrator/task-delegation-patterns.roo.yaml
has been updated to include a section for relevant MCP servers.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.