How to Create Custom LLM Rules in VS Code with Roo Code
As developers, we’re always looking for ways to tailor our tools to our specific workflows. When working with large language models (LLMs) in Visual Studio Code, the Roo Code extension is a powerful tool. While it comes with five default roles—Architect, Code, Ask, Debug, and Orchestra—you’ve likely encountered a need for more specialized rules to perfectly fit your development, testing, or other software development tasks.

This is where custom rules come in. If you’ve used the Cursor editor, you may be familiar with the various .mdc
rule files available on GitHub. These files allow you to define custom rules for specific scenarios. The great news is that Roo Code can use these same .mdc
files, allowing you to leverage a vast collection of community-made rules.
https://github.com/PatrickJS/awesome-cursorrules/tree/main
https://github.com/sanjeed5/awesome-cursor-rules-mdc
https://cursor.directory/rules
Implementing a Custom Rule
Let’s walk through a simple example of how to implement a custom rule from the community within the Roo Code extension. We’ll use the python.mdc
rule file from PatrickJS’s awesome-cursorrules
repository.
1. Find your rule file.
Navigate to the python.mdc
file in the following GitHub repository:
2. Copy the content.
Open the file and copy the entire content.
3. Create a new custom rule in VS Code.
In VS Code, open the Command Palette (Ctrl/Cmd + Shift + P) and search for “Roo Code: Create Custom Role.”
4. Name and paste the rule.
Give your new rule a descriptive name, like “Python,” and press Enter. A new file will open. Paste the content you copied from the python.mdc
file into this new file.
5. Save the file.
Save the file. Your new custom rule is now ready to use within the Roo Code extension. You should now be able to select and use your custom “Python” rule for your projects.
This process gives you the flexibility to import any .mdc
rule file you find, allowing you to customize your LLM experience in VS Code to an unprecedented degree.
Roo code extension is capable of using this rule *.mdc files as their own roocode rule files.
Lets see how we can implement one of the rule file python.mdc of cursor inside roocode extension in vscode.
Follow the simple steps.





Finally start using the rule you have created just now. FYI we have used the python.mdc rule given in
https://github.com/PatrickJS/awesome-cursorrules/tree/main/rules-new/python.mdc
So in short follow the below given step to configure rule of cursor in roo code extension in vscode
Step 1: Install the Roo Code Extension
If you haven’t already, the first step is to install the Roo Code extension from the VS Code Marketplace.
- Open VS Code.
- Go to the Extensions view by pressing
Ctrl+Shift+X
. - Search for “Roo Code” by RooVeterinaryInc.
- Click Install.
- Reload VS Code if prompted.
Step 2: Set Up Your Rule Directory Structure
To integrate your custom rules, you need to create a specific directory structure within your project.
- In the root directory of your project, create a new folder named
.roo/
. - Inside the
.roo/
folder, create mode-specific subfolders for your rules. For this guide, we’ll create a folder for a custom mode called python-dev to house our Python rule.
Your directory structure should look something like this:
1 2 | .roo/ └── rules-python-dev/ |
- Now, download the
python.mdc
file from the repository and place it inside the newly created.roo/rules-python-dev/
folder.
Note: If you use both Cursor and Roo Code, you can use symbolic links to point to the
.mdc
files in your.cursor/rules/
directory, which helps maintain consistency and avoid duplication.
Step 3: Create a Custom Mode in Roo Code
With your rule file in place, you can now create a custom mode in Roo Code that links to it.
- Open the Roo Code panel in VS Code.
- Navigate to the Prompts (book icon).
- Click the + button to add a new custom mode.
- Fill in the following details for your new mode:
- Name:
Python Dev
- Slug:
python-dev
- Role Definition:
An expert Python developer.
(or a description that fits your needs) - Available Tools:
None
(or select tools as needed for your workflow) - Custom Instructions: Link to the rule file you just added by entering its path:
.roo/rules-python-dev/python.mdc
.
- Name:
Step 4: Start Using Your Custom Rule
Once your new custom mode is set up, you can start using it to interact with your codebase. Roo Code will automatically apply the rules defined in the python.mdc
file whenever you activate the Python Dev mode. This allows you to leverage the power of custom rules to streamline tasks, maintain consistency, and enhance your overall coding experience with LLMs.
No comments:
Post a Comment