Skip to content

Commit efd53a5

Browse files
committed
4. **Custom Instructions** (advanced-usage/custom-instructions.md)
- Expanded and merged content from the previously separate Custom Rules document - Added comprehensive comparison between custom instructions and rules approaches - Added detailed examples of rule file formats with proper markdown formatting - Included project-specific rule examples for various types of projects - Added best practices for effective customization with clear examples - Added section on advanced usage with custom modes - Added guidance on when to use each customization approach - Added link to managing preferences documentation
1 parent 5834d22 commit efd53a5

File tree

4 files changed

+278
-40
lines changed

4 files changed

+278
-40
lines changed
Lines changed: 275 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,124 @@
1-
# Custom Instructions
1+
# Customizing Roo Code Behavior
22

3-
Roo Code allows you to customize its behavior using custom instructions at both global and workspace levels. These instructions are added to the system prompt and influence how Roo Code responds to your requests. You can define:
3+
Roo Code allows you to customize its behavior using custom instructions and rules at both global and workspace levels. These customizations are added to the system prompt and influence how Roo Code responds to your requests.
4+
5+
## Types of Customization
6+
7+
Roo Code offers two complementary approaches to customization:
8+
9+
1. **Custom Instructions**: General guidelines that shape how Roo interacts with you
10+
2. **Custom Rules**: Structured technical guidelines for code standards and practices
11+
12+
| Feature | Custom Instructions | Custom Rules |
13+
|---------|---------------------|--------------|
14+
| **Primary Purpose** | General behavioral guidance | Specific technical guidelines |
15+
| **Format** | Free-form text | Structured markdown format |
16+
| **Configuration Method** | UI (Prompts Tab) or rules files | Rules files in project root |
17+
| **Scope** | Global or workspace-specific | Global or mode-specific |
18+
| **Best For** | General preferences, tone, approach | Coding standards, technical requirements |
19+
20+
Both approaches complement each other - you can use custom instructions for general guidance and custom rules for specific technical requirements.
21+
22+
## Custom Instructions Configuration
23+
24+
You can define custom instructions at various levels:
425

526
* **Global Custom Instructions:** Apply across all workspaces
627
* **Workspace-Level Instructions:**
728
* **Workspace-Wide:** Apply to all modes in the workspace through `.clinerules` files
829
* **Mode-Specific:** Apply to specific modes in the workspace through files like `.clinerules-code`
930

10-
## Preferred Language
31+
### Preferred Language
1132

1233
You can specify a preferred language for Roo Code to use. When set, this appears at the start of your custom instructions and directs Roo Code to communicate in your chosen language. You can set this in the **Prompts** tab. For more details on managing this and other settings, see [Managing Preferences and Settings](managing-preferences).
1334

14-
## Global Custom Instructions
35+
### Setting Global Custom Instructions
1536

1637
These instructions apply across all workspaces. They're useful for setting preferences that you want to maintain regardless of which project you're working on.
1738

1839
**How to set them:**
1940

20-
1. **Open Prompts Tab:** Click the <Codicon name="notebook" /> icon in the Roo Code top menu bar
21-
2. **Find Section:** Find the "Custom Instructions for All Modes" section
22-
3. **Enter Instructions:** Enter your instructions in the text area
23-
4. **Save Changes:** Click "Done" to save your changes
41+
1. **Open Prompts Tab:** Click the <Codicon name="notebook" /> icon in the Roo Code top menu bar
42+
2. **Find Section:** Find the "Custom Instructions for All Modes" section
43+
3. **Enter Instructions:** Enter your instructions in the text area
44+
4. **Save Changes:** Click "Done" to save your changes
2445

25-
## Workspace-Level Instructions
46+
### Setting Workspace-Level Instructions
2647

2748
These instructions only apply within your current workspace, allowing you to customize Roo Code's behavior for specific projects.
2849

29-
### Workspace-Wide Instructions
50+
#### Workspace-Wide Instructions
3051

3152
Workspace-wide instructions are defined through rule files in your workspace root, primarily using `.clinerules`. Additional support for `.cursorrules` and `.windsurfrules` is available for editor compatibility.
3253

33-
### Mode-Specific Instructions
54+
#### Mode-Specific Instructions
3455

3556
Mode-specific instructions can be set in two independent ways that can be used simultaneously:
3657

37-
1. **Using the Prompts Tab:**
38-
* **Open Tab:** Click the <Codicon name="notebook" /> icon in the Roo Code top menu bar
39-
* **Select Mode:** Under the Modes heading, click the button for the mode you want to customize
40-
* **Enter Instructions:** Enter your instructions in the text area under "Mode-specific Custom Instructions (optional)"
41-
* **Save Changes:** Click "Done" to save your changes
58+
1. **Using the Prompts Tab:**
59+
* **Open Tab:** Click the <Codicon name="notebook" /> icon in the Roo Code top menu bar
60+
* **Select Mode:** Under the Modes heading, click the button for the mode you want to customize
61+
* **Enter Instructions:** Enter your instructions in the text area under "Mode-specific Custom Instructions (optional)"
62+
* **Save Changes:** Click "Done" to save your changes
4263

43-
2. **Using Rule Files:** Create a `.clinerules-[mode]` file in your workspace root (e.g., `.clinerules-code`)
64+
2. **Using Rule Files:** Create a `.clinerules-[mode]` file in your workspace root (e.g., `.clinerules-code`)
4465

4566
When both tab instructions and rule files are set for a mode, both sets of instructions will be included in the system prompt.
4667

47-
### How Instructions are Combined
68+
## Custom Rules
69+
70+
Custom rules provide more structured guidelines stored in special files in your project's root directory. They tell Roo how to approach various aspects of your codebase, such as:
71+
72+
- Coding style and formatting preferences
73+
- Documentation requirements
74+
- Testing practices
75+
- Error handling approaches
76+
- Project-specific conventions
77+
78+
### Rule File Types
79+
80+
Roo Code supports several rule file formats:
81+
82+
| File Name | Purpose |
83+
|-----------|---------|
84+
| `.clinerules` | Primary rule file for all modes |
85+
| `.clinerules-code` | Rules specific to Code mode |
86+
| `.clinerules-architect` | Rules specific to Architect mode |
87+
| `.clinerules-[mode]` | Rules for any custom mode |
88+
| `.cursorrules` | Alternative format (compatible with Cursor AI) |
89+
| `.windsurfrules` | Alternative format (compatible with Windsurf) |
90+
91+
All rule files should be placed in your project's root directory.
92+
93+
### Rule File Format
94+
95+
Rule files use a simple, markdown-based format that's easy to read and write:
96+
97+
```markdown
98+
# Category Title
99+
100+
1. Rule Group Title:
101+
- Specific guideline
102+
- Another guideline
103+
- Technical requirement
104+
105+
2. Another Rule Group:
106+
- Guideline one
107+
- Guideline two
108+
```
109+
110+
This format makes rules easy to read for both humans and AI.
111+
112+
### Global vs. Mode-Specific Rules
113+
114+
Roo Code allows you to create both global rules and mode-specific rules:
115+
116+
- **Global Rules** (`.clinerules`) apply to all modes
117+
- **Mode-Specific Rules** (`.clinerules-[mode]`) only apply when using that specific mode
118+
119+
When both exist, mode-specific rules take priority, but global rules still apply if they don't conflict.
120+
121+
## How Instructions and Rules are Combined
48122

49123
Instructions are placed in the system prompt in this exact format:
50124

@@ -70,23 +144,9 @@ Rules:
70144
* **Source Headers:** Each rule file's contents are included with a header indicating its source
71145
* **Rule Interaction:** Mode-specific rules complement global rules rather than replacing them
72146

73-
## Difference Between Custom Instructions and Custom Rules
74-
75-
While related, custom instructions and custom rules serve slightly different purposes:
147+
## Examples and Best Practices
76148

77-
* **Custom Instructions** (set via Prompts Tab):
78-
- General behavioral guidance for Roo
79-
- Often more conversational or high-level
80-
- Set through the UI or via rule files
81-
82-
* **Custom Rules** (primarily in rule files):
83-
- More structured, specific technical guidelines
84-
- Often focused on code standards and practices
85-
- Typically organized by categories
86-
87-
For detailed information on creating effective structured rules in rule files, see the [Custom Rules](custom-rules.md) documentation.
88-
89-
## Examples of Custom Instructions
149+
### Example Custom Instructions
90150

91151
* "Always use spaces for indentation, with a width of 4 spaces"
92152
* "Use camelCase for variable names"
@@ -96,9 +156,103 @@ For detailed information on creating effective structured rules in rule files, s
96156
* "Prioritize using the most common library in the community"
97157
* "When adding new features to websites, ensure they are responsive and accessible"
98158

99-
## Strategies for Effective Custom Instructions
159+
### Example Rule Categories
160+
161+
#### Code Style Rules
162+
163+
```markdown
164+
# Code Style
165+
166+
1. Formatting:
167+
- Use 2-space indentation for all files
168+
- Keep line length under 100 characters
169+
- Place opening braces on the same line
170+
- Use trailing commas in multi-line arrays and objects
171+
172+
2. Naming Conventions:
173+
- Use camelCase for variables and functions
174+
- Use PascalCase for classes and components
175+
- Use UPPER_SNAKE_CASE for constants
176+
- Prefix private methods with underscore
177+
```
178+
179+
#### Testing Rules
180+
181+
```markdown
182+
# Testing Requirements
183+
184+
1. Test Coverage:
185+
- Write tests for all new functions
186+
- Maintain at least 80% code coverage
187+
- Test both success and error paths
188+
- Use descriptive test names
189+
190+
2. Test Structure:
191+
- Organize tests by feature or component
192+
- Use setup and teardown for common operations
193+
- Mock external dependencies
194+
- Test edge cases explicitly
195+
```
196+
197+
#### Documentation Rules
198+
199+
```markdown
200+
# Documentation Standards
201+
202+
1. Code Documentation:
203+
- Document all public functions with JSDoc
204+
- Explain complex algorithms with comments
205+
- Include examples for APIs
206+
- Document parameters and return values
207+
208+
2. Project Documentation:
209+
- Keep README up-to-date
210+
- Document setup steps
211+
- Include troubleshooting guidance
212+
- Add comments for non-obvious code
213+
```
214+
215+
### Project-Specific Rule Examples
216+
217+
#### Web Development Project
100218

101-
### Be Clear and Specific
219+
```markdown
220+
# Web Project Rules
221+
222+
1. Accessibility:
223+
- Use semantic HTML elements
224+
- Include alt text for images
225+
- Ensure keyboard navigation works
226+
- Maintain WCAG AA compliance
227+
228+
2. Performance:
229+
- Keep bundle size under 500KB
230+
- Optimize images before adding
231+
- Implement code splitting
232+
- Lazy load non-critical resources
233+
```
234+
235+
#### Data Science Project
236+
237+
```markdown
238+
# Data Science Rules
239+
240+
1. Data Management:
241+
- Document data sources
242+
- Version control datasets
243+
- Include data cleaning steps
244+
- Note missing value handling
245+
246+
2. Models:
247+
- Document training parameters
248+
- Include accuracy metrics
249+
- Validate against test data
250+
- Explain feature importance
251+
```
252+
253+
## Best Practices for Effective Customization
254+
255+
### Be Specific and Clear
102256

103257
Vague instructions can lead to inconsistent results. Be as specific as possible:
104258

@@ -108,6 +262,40 @@ Vague instructions can lead to inconsistent results. Be as specific as possible:
108262
**Less Effective:**
109263
"Make sure to use types properly."
110264

265+
For rules files, write clear, actionable guidelines rather than vague principles:
266+
267+
**Good:**
268+
```markdown
269+
- Validate all user inputs before processing
270+
- Log errors with stack traces and context
271+
- Use parameterized queries for database operations
272+
```
273+
274+
**Not as helpful:**
275+
```markdown
276+
- Make sure code is secure
277+
- Handle errors properly
278+
- Be careful with databases
279+
```
280+
281+
### Organize Logically
282+
283+
Group related rules together under clear categories:
284+
285+
```markdown
286+
# Security
287+
288+
1. Input Validation:
289+
- Validate all user inputs
290+
- Sanitize data before use
291+
- Reject unexpected values
292+
293+
2. Authentication:
294+
- Require strong passwords
295+
- Implement account lockouts
296+
- Log authentication attempts
297+
```
298+
111299
### Prioritize Important Guidelines
112300

113301
Put the most important instructions first, as they'll receive more attention:
@@ -125,4 +313,54 @@ Too many rigid instructions can limit Roo's ability to help, while too few may l
125313
**Balanced Approach:**
126314
"Follow the existing code style in the project, but feel free to suggest improvements where patterns are unclear or could be more efficient."
127315

128-
By using custom instructions effectively, you can tailor Roo Code's behavior to match your coding style, project requirements, and personal preferences.
316+
### Keep Rules Updated
317+
318+
Review and update your rules as your project evolves:
319+
320+
- Remove outdated guidelines
321+
- Add rules for new technologies
322+
- Refine based on project learnings
323+
324+
## Advanced Usage
325+
326+
### Combining Rules with Custom Modes
327+
328+
For an even more tailored experience, you can:
329+
330+
1. Create a [custom mode](custom-modes) with specific capabilities
331+
2. Create matching `.clinerules-[mode]` file
332+
3. Get specialized assistance that follows your guidelines
333+
334+
For example, you might create a "security-auditor" mode with a `.clinerules-security-auditor` file containing security-focused rules.
335+
336+
### Testing Your Customizations
337+
338+
To verify your customizations are working:
339+
340+
1. Create your rule file in the project root
341+
2. Switch to the appropriate mode if using mode-specific rules
342+
3. Ask Roo to perform a task related to your rules
343+
4. Check if the response follows your guidelines
344+
345+
For example, after adding code style rules, ask Roo to write a new function and see if it follows your specified style.
346+
347+
## When to Use Each Approach
348+
349+
Here's guidance on when to use each customization approach:
350+
351+
**Use Custom Instructions when:**
352+
- Setting general preferences that apply across projects
353+
- Specifying how Roo should communicate with you
354+
- Providing high-level guidance on approach and methodology
355+
- Setting simple preferences without complex formatting
356+
357+
**Use Custom Rules when:**
358+
- Defining specific coding standards
359+
- Setting project-specific technical requirements
360+
- Creating structured, categorical guidelines
361+
- Sharing standards across a team
362+
- Creating mode-specific behavior
363+
364+
For best results, combine both approaches - use custom instructions for general guidance and custom rules for specific technical requirements.
365+
366+
By effectively customizing Roo Code's behavior, you can transform it into a team member who understands and follows your project's unique needs and standards.

docs/basic-usage/using-tools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Here's a brief overview of the core tools available in Roo Code:
2626
| `ask_followup_question` | Asks you a clarifying question. |
2727
| `attempt_completion` | Indicates that Roo Code believes the task is complete. |
2828

29-
**Note:** The availability of some tools may depend on the current [mode](./modes.md) and your settings.
29+
**Note:** The availability of some tools may depend on the current [mode](./modes) and your settings.
3030

3131
## How Tools are Used
3232

docs/providers/openai-compatible.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Roo Code supports a wide range of AI model providers that offer APIs compatible
1010
* **Cloud providers** like Perplexity, Together AI, Anyscale, and others.
1111
* **Any other provider** offering an OpenAI-compatible API endpoint.
1212

13-
This document focuses on setting up providers *other than* the official OpenAI API (which has its own [dedicated configuration page](./openai.md)).
13+
This document focuses on setting up providers *other than* the official OpenAI API (which has its own [dedicated configuration page](./openai)).
1414

1515
## General Configuration
1616

docs/providers/openai.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ Refer to the [OpenAI Models documentation](https://platform.openai.com/docs/mode
4040
## Tips and Notes
4141

4242
* **Pricing:** Refer to the [OpenAI Pricing](https://openai.com/pricing) page for details on model costs.
43-
* **Azure OpenAI Service:** If you'd like to use the Azure OpenAI service, please see our section on [OpenAI-compatible](./openai-compatible.md) providers.
43+
* **Azure OpenAI Service:** If you'd like to use the Azure OpenAI service, please see our section on [OpenAI-compatible](./openai-compatible) providers.

0 commit comments

Comments
 (0)