Skip to content

Commit 0f9aae7

Browse files
committed
Add custom modes images for enhanced documentation visuals
1 parent 27810c4 commit 0f9aae7

File tree

4 files changed

+161
-64
lines changed

4 files changed

+161
-64
lines changed

docs/advanced-usage/custom-modes.md

Lines changed: 161 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
# Custom Modes
22

3-
Roo Code allows you to create **custom modes** to tailor Roo's behavior to specific tasks or workflows. Custom modes can be either **global** (available across all projects) or **project-specific** (defined within a single project). They allow you to define:
4-
5-
* **A unique name and slug:** For easy identification
6-
* **A role definition:** Placed at the beginning of the system prompt, this defines Roo's core expertise and personality for the mode. This placement is crucial as it shapes Roo's fundamental understanding and approach to tasks
7-
* **Custom instructions:** Added at the end of the system prompt, these provide specific guidelines that modify or refine Roo's behavior. Unlike `.clinerules` files (which only add rules at the end), this structured placement of role and instructions allows for more nuanced control over Roo's responses
8-
* **Allowed tools:** Which Roo Code tools the mode can use (e.g., read files, write files, execute commands)
9-
* **File restrictions:** (Optional) Limit file access to specific file types or patterns (e.g., only allow editing `.md` files)
3+
Roo Code allows you to create **custom modes** to tailor Roo's behavior to specific tasks or workflows. Custom modes can be either **global** (available across all projects) or **project-specific** (defined within a single project).
104

115
## Why Use Custom Modes?
126

@@ -15,56 +9,18 @@ Roo Code allows you to create **custom modes** to tailor Roo's behavior to speci
159
* **Experimentation:** Safely experiment with different prompts and configurations without affecting other modes
1610
* **Team Collaboration:** Share custom modes with your team to standardize workflows
1711

18-
## Creating Custom Modes
19-
20-
You have three options for creating custom modes:
21-
22-
### 1. Ask Roo! (Recommended)
23-
24-
You can quickly create a basic custom mode by asking Roo Code to do it for you. For example:
25-
26-
> Create a new mode called "Documentation Writer". It should only be able to read files and write Markdown files.
27-
28-
Roo Code will guide you through the process. However, for fine-tuning modes or making specific adjustments, you'll want to use the Prompts tab or manual configuration methods described below.
29-
30-
### 2. Using the Prompts Tab
31-
32-
1. **Open Prompts Tab:** Click the <Codicon name="notebook" /> icon in the Roo Code top menu bar
33-
2. **Create New Mode:** Click the <Codicon name="add" /> button to the right of the Modes heading
34-
3. **Fill in Fields:**
35-
* **Name:** Enter a display name for the mode
36-
* **Slug:** Enter a lowercase identifier (letters, numbers, and hyphens only)
37-
* **Save Location:** Choose Global (via `cline_custom_modes.json`, available across all workspaces) or Project-specific (via `.roomodes` file in project root)
38-
* **Role Definition:** Define Roo's expertise and personality for this mode (appears at the start of the system prompt)
39-
* **Available Tools:** Select which tools this mode can use
40-
* **Custom Instructions:** (Optional) Add behavioral guidelines specific to this mode (appears at the end of the system prompt)
41-
4. **Create Mode:** Click the "Create Mode" button to save your new mode
42-
43-
Note: File type restrictions can only be added through manual configuration.
44-
45-
### 3. Manual Configuration
46-
47-
You can configure custom modes by editing JSON files through the Prompts tab:
48-
49-
Both global and project-specific configurations can be edited through the Prompts tab:
50-
51-
1. **Open Prompts Tab:** Click the <Codicon name="notebook" /> icon in the Roo Code top menu bar
52-
2. **Access Settings Menu:** Click the <Codicon name="bracket" /> button to the right of the Modes heading
53-
3. **Choose Configuration:**
54-
* Select "Edit Global Modes" to edit `cline_custom_modes.json` (available across all workspaces)
55-
* Select "Edit Project Modes" to edit `.roomodes` file (in project root)
56-
4. **Edit Configuration:** Modify the JSON file that opens
57-
5. **Save Changes:** Roo Code will automatically detect the changes
12+
<img src="/img/custom-modes/custom-modes.png" alt="Overview of custom modes interface" width="400" />
13+
*Roo Code's interface for creating and managing custom modes.*
5814

59-
## Configuration Precedence
15+
## What's Included in a Custom Mode?
6016

61-
Mode configurations are applied in this order:
17+
Custom modes allow you to define:
6218

63-
1. Project-level mode configurations (from `.roomodes`)
64-
2. Global mode configurations (from `cline_custom_modes.json`)
65-
3. Default mode configurations
66-
67-
This means that project-specific configurations will override global configurations, which in turn override default configurations.
19+
* **A unique name and slug:** For easy identification
20+
* **A role definition:** Placed at the beginning of the system prompt, this defines Roo's core expertise and personality for the mode. This placement is crucial as it shapes Roo's fundamental understanding and approach to tasks
21+
* **Custom instructions:** Added at the end of the system prompt, these provide specific guidelines that modify or refine Roo's behavior. Unlike `.clinerules` files (which only add rules at the end), this structured placement of role and instructions allows for more nuanced control over Roo's responses
22+
* **Allowed tools:** Which Roo Code tools the mode can use (e.g., read files, write files, execute commands)
23+
* **File restrictions:** (Optional) Limit file access to specific file types or patterns (e.g., only allow editing `.md` files)
6824

6925
## Custom Mode Configuration (JSON Format)
7026

@@ -115,13 +71,11 @@ Both global and project-specific configurations use the same JSON format. Each c
11571
}]
11672
```
11773

118-
### Optional Properties
74+
### Understanding File Restrictions
11975

120-
#### `customInstructions`
121-
* Additional behavioral guidelines for the mode
122-
* Example: `"Focus on explaining concepts and providing examples"`
76+
<img src="/img/custom-modes/custom-modes-3.png" alt="File restriction pattern examples" width="600" />
12377

124-
### Understanding File Restrictions
78+
*Visual examples of file restriction patterns and which files they match/don't match.*
12579

12680
The `fileRegex` property uses regular expressions to control which files a mode can edit:
12781

@@ -136,11 +90,99 @@ Common regex patterns:
13690

13791
[Learn more about regular expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions)
13892

139-
### Example Configurations
93+
### Optional Properties
94+
95+
#### `customInstructions`
96+
* Additional behavioral guidelines for the mode
97+
* Example: `"Focus on explaining concepts and providing examples"`
98+
99+
#### `apiConfiguration`
100+
* Optional settings to customize the AI model and parameters for this mode
101+
* Allows optimizing the model selection for specific tasks
102+
* Example: `{"model": "gpt-4", "temperature": 0.2}`
103+
104+
### Mode-Specific Custom Instructions Files
105+
106+
In addition to the `customInstructions` property in JSON, you can use a dedicated file for mode-specific instructions:
107+
108+
1. Create a file named `.clinerules-{mode-slug}` in your workspace root
109+
* Replace `{mode-slug}` with your mode's slug (e.g., `.clinerules-docs-writer`)
110+
2. Add your custom instructions to this file
111+
3. Roo Code will automatically apply these instructions to the specified mode
112+
113+
This approach is particularly useful for:
114+
* Keeping lengthy instructions separate from your mode configuration
115+
* Managing instructions with version control
116+
* Allowing non-technical team members to modify instructions without editing JSON
117+
118+
Note: If both `.clinerules-{mode-slug}` and the `customInstructions` property exist, they will be combined, with the file contents appended after the JSON property.
119+
120+
## Configuration Precedence
121+
122+
Mode configurations are applied in this order:
123+
124+
1. Project-level mode configurations (from `.roomodes`)
125+
2. Global mode configurations (from `cline_custom_modes.json`)
126+
3. Default mode configurations
127+
128+
This means that project-specific configurations will override global configurations, which in turn override default configurations.
129+
130+
## Creating Custom Modes
131+
132+
You have three options for creating custom modes:
133+
134+
### 1. Ask Roo! (Recommended)
135+
136+
You can quickly create a basic custom mode by asking Roo Code to do it for you. For example:
137+
```
138+
Create a new mode called "Documentation Writer". It should only be able to read files and write Markdown files.
139+
```
140+
Roo Code will guide you through the process. However, for fine-tuning modes or making specific adjustments, you'll want to use the Prompts tab or manual configuration methods described below.
141+
:::info
142+
#### Custom Mode Creation Settings
143+
When enabled, Roo allows you to create custom modes using prompts like 'Make me a custom mode that...'. Disabling this reduces your system prompt by about 700 tokens when this feature isn't needed. When disabled you can still manually create custom modes using the + button above or by editing the related config JSON.
144+
<img src="/img/custom-modes/custom-modes-1.png" alt="Enable Custom Mode Creation Through Prompts setting" width="600" />
145+
You can find this setting within the prompt settings by clicking the <Codicon name="notebook" /> icon in the Roo Code top menu bar.
146+
:::
147+
148+
### 2. Using the Prompts Tab
149+
150+
1. **Open Prompts Tab:** Click the <Codicon name="notebook" /> icon in the Roo Code top menu bar
151+
2. **Create New Mode:** Click the <Codicon name="add" /> button to the right of the Modes heading
152+
3. **Fill in Fields:**
153+
154+
<img src="/img/custom-modes/custom-modes-3.png" alt="Custom mode creation interface in the Prompts tab" width="600" />
155+
*The custom mode creation interface showing fields for name, slug, save location, role definition, available tools, and custom instructions.*
156+
157+
* **Name:** Enter a display name for the mode
158+
* **Slug:** Enter a lowercase identifier (letters, numbers, and hyphens only)
159+
* **Save Location:** Choose Global (via `cline_custom_modes.json`, available across all workspaces) or Project-specific (via `.roomodes` file in project root)
160+
* **Role Definition:** Define Roo's expertise and personality for this mode (appears at the start of the system prompt)
161+
* **Available Tools:** Select which tools this mode can use
162+
* **Custom Instructions:** (Optional) Add behavioral guidelines specific to this mode (appears at the end of the system prompt)
163+
4. **Create Mode:** Click the "Create Mode" button to save your new mode
164+
165+
Note: File type restrictions can only be added through manual configuration.
166+
167+
### 3. Manual Configuration
168+
169+
You can configure custom modes by editing JSON files through the Prompts tab:
170+
171+
Both global and project-specific configurations can be edited through the Prompts tab:
172+
173+
1. **Open Prompts Tab:** Click the <Codicon name="notebook" /> icon in the Roo Code top menu bar
174+
2. **Access Settings Menu:** Click the <Codicon name="bracket" /> button to the right of the Modes heading
175+
3. **Choose Configuration:**
176+
* Select "Edit Global Modes" to edit `cline_custom_modes.json` (available across all workspaces)
177+
* Select "Edit Project Modes" to edit `.roomodes` file (in project root)
178+
4. **Edit Configuration:** Modify the JSON file that opens
179+
5. **Save Changes:** Roo Code will automatically detect the changes
180+
181+
## Example Configurations
140182

141183
Each example shows different aspects of mode configuration:
142184

143-
#### Basic Documentation Writer
185+
### Basic Documentation Writer
144186
```json
145187
{
146188
"customModes": [{
@@ -156,7 +198,7 @@ Each example shows different aspects of mode configuration:
156198
}
157199
```
158200

159-
#### Test Engineer with File Restrictions
201+
### Test Engineer with File Restrictions
160202
```json
161203
{
162204
"customModes": [{
@@ -171,7 +213,7 @@ Each example shows different aspects of mode configuration:
171213
}
172214
```
173215

174-
#### Project-Specific Mode Override
216+
### Project-Specific Mode Override
175217
```json
176218
{
177219
"customModes": [{
@@ -188,6 +230,61 @@ Each example shows different aspects of mode configuration:
188230
```
189231
By following these instructions, you can create and manage custom modes to enhance your workflow with Roo-Code.
190232

233+
## Understanding Regex in Custom Modes
234+
235+
Regex patterns in custom modes let you precisely control which files Roo can edit:
236+
237+
### Basic Syntax
238+
239+
When you specify `fileRegex` in a custom mode, you're creating a pattern that file paths must match:
240+
241+
```json
242+
["edit", { "fileRegex": "\\.md$", "description": "Markdown files only" }]
243+
```
244+
245+
### Important Rules
246+
247+
- **Double Backslashes:** In JSON, backslashes must be escaped with another backslash. So `\.md$` becomes `\\.md$`
248+
- **Path Matching:** Patterns match against the full file path, not just the filename
249+
- **Case Sensitivity:** Regex patterns are case-sensitive by default
250+
251+
### Common Pattern Examples
252+
253+
| Pattern | Matches | Doesn't Match |
254+
|---------|---------|---------------|
255+
| `\\.md$` | `readme.md`, `docs/guide.md` | `script.js`, `readme.md.bak` |
256+
| `^src/.*` | `src/app.js`, `src/components/button.tsx` | `lib/utils.js`, `test/src/mock.js` |
257+
| `\\.(css\|scss)$` | `styles.css`, `theme.scss` | `styles.less`, `styles.css.map` |
258+
| `docs/.*\\.md$` | `docs/guide.md`, `docs/api/reference.md` | `guide.md`, `src/docs/notes.md` |
259+
| `^(?!.*(test\|spec)).*\\.js$` | `app.js`, `utils.js` | `app.test.js`, `utils.spec.js` |
260+
261+
### Pattern Building Blocks
262+
263+
- `\\.` - Match a literal dot (period)
264+
- `$` - Match the end of the string
265+
- `^` - Match the beginning of the string
266+
- `.*` - Match any character (except newline) zero or more times
267+
- `(a|b)` - Match either "a" or "b"
268+
- `(?!...)` - Negative lookahead (exclude matches)
269+
270+
### Testing Your Patterns
271+
272+
Before applying a regex pattern to a custom mode:
273+
274+
1. Test it on sample file paths to ensure it matches what you expect
275+
2. Remember that in JSON, each backslash needs to be doubled (`\d` becomes `\\d`)
276+
3. Start with simpler patterns and build complexity gradually
277+
278+
279+
:::tip
280+
### Let Roo Build Your Regex Patterns
281+
Instead of writing complex regex patterns manually, you can ask Roo to create them for you! Simply describe which files you want to include or exclude:
282+
```
283+
Create a regex pattern that matches JavaScript files but excludes test files
284+
```
285+
Roo will generate the appropriate pattern with proper escaping for JSON configuration.
286+
:::
287+
191288
## Community Gallery
192289

193-
Ready to explore more? Check out the [Custom Modes Gallery](/community#custom-modes-gallery) to discover and share custom modes created by the community!
290+
Ready to explore more? Check out the [Custom Modes Gallery](/community#custom-modes-gallery) to discover and share custom modes created by the community!
61.8 KB
Loading
245 KB
Loading
203 KB
Loading

0 commit comments

Comments
 (0)