Customizing Modes
Saarthi allows you to create custom modes to tailor Saarthi'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).
Each modeβincluding custom onesβfeatures Sticky Models. This means Saarthi automatically remembers and selects the last model you used with a particular mode. This lets you assign different preferred models to different tasks without constant reconfiguration, as Saarthi switches between models when you change modes.
Why Use Custom Modes?β
- Specialization: Create modes optimized for specific tasks, like "Documentation Writer," "Test Engineer," or "Refactoring Expert."
- Safety: Restrict a mode's access to sensitive files or commands. For example, a "Review Mode" could be limited to read-only operations.
- Experimentation: Safely experiment with different prompts and configurations without affecting other modes.
- Team Collaboration: Share custom modes with your team to standardize workflows.
What's Included in a Custom Mode?β
Custom modes are defined by several key properties. Understanding these concepts will help you tailor Saarthi's behavior effectively.
| UI Field / YAML Property | Conceptual Description |
|---|---|
Slug (slug) | A unique internal identifier for the mode. It's used by Saarthi to reference the mode, especially for associating mode-specific instruction files. |
Name (name) | The display name for the mode as it appears in the Saarthi user interface. This should be human-readable and descriptive. |
Role Definition (roleDefinition) | Defines the core identity and expertise of the mode. This text is placed at the beginning of the system prompt. - Its primary function is to define Saarthi's personality and behavior when this mode is active. - The first sentence (up to the first period .) serves as a default concise summary for Saarthi to understand the mode's general purpose. - However, if the whenToUse property is defined, whenToUse takes precedence for summarizing the mode's function, especially in contexts like task orchestration or mode switching. In such cases, the first sentence of roleDefinition is less critical for this specific summarization task, though the entire roleDefinition is still used when the mode is active to guide its overall behavior. |
Available Tools (groups) | Defines the allowed toolsets and file access permissions for the mode. - In the UI, this corresponds to selecting which general categories of tools (like reading files, editing files, browsing, or executing commands) the mode can use. - File type restrictions for the "edit" group are typically managed via manual YAML/JSON configuration or by asking Saarthi to set them up, as detailed in the Property Details for groups. |
When to Use (optional) (whenToUse) | (Optional) Provides guidance for Saarthi to understand the mode's purpose, especially for automated decisions. - This text is used by Saarthi, particularly the πͺ Orchestrator mode, for orchestrating tasks (e.g., via the new_task tool).- It also helps Saarthi decide which mode is appropriate when switching modes (e.g., via the switch_mode tool).- If populated, this description is used by Saarthi to understand the mode's function; otherwise, the first sentence of the roleDefinition is used by default. |
Custom Instructions (optional) (customInstructions) | Specific behavioral guidelines or rules for the mode. - These instructions are added near the end of the system prompt to further refine Saarthi's behavior beyond the roleDefinition.- This can be provided directly in the configuration or via separate instruction files. |
Methods for Creating and Configuring Custom Modesβ
You can create and configure custom modes in several ways:
1. Ask Saarthi! (Recommended)β
You can quickly create a basic custom mode by asking Saarthi to do it for you. For example:
Create a new mode called "Documentation Writer". It should only be able to read files and write Markdown files.
Saarthi will guide you through the process, prompting for necessary information for the properties described in the What's Included in a Custom Mode? table. Saarthi will create the mode using the preferred YAML format. For fine-tuning or making specific adjustments later, you can use the Prompts tab or manual configuration.
2. Using the Prompts Tabβ
- Open Prompts Tab: Click the icon in the Saarthi top menu bar.
- Create New Mode: Click the button to the right of the Modes heading.
- Fill in Fields:

The custom mode creation interface showing fields for name, slug, save location, role definition, available tools, custom instructions.
The interface provides fields for Name, Slug, Save Location, Role Definition, When to Use (optional), Available Tools, and Custom Instructions. After filling these, click the "Create Mode" button. Saarthi will save the new mode in YAML format.
Refer to the What's Included in a Custom Mode? table for conceptual explanations of each property. File type restrictions for the "edit" tool group can be added by asking Saarthi or through manual YAML/JSON configuration.
3. Manual Configuration (YAML & JSON)β
You can directly edit the configuration files to create or modify custom modes. This method offers the most control over all properties. Saarthi now supports both YAML (preferred) and JSON formats.
- Global Modes: Edit the
custom_modes.yaml(preferred) orcustom_modes.jsonfile. Access it via Prompts Tab > (Settings Menu icon next to "Global Prompts") > "Edit Global Modes". - Project Modes: Edit the
.saarthimodesfile (which can be YAML or JSON) in your project root. Access it via Prompts Tab > (Settings Menu icon next to "Project Prompts") > "Edit Project Modes".
These files define an array/list of custom modes.
YAML Example (custom_modes.yaml or .saarthimodes):
customModes:
- slug: docs-writer
name: π Documentation Writer
roleDefinition: You are a technical writer specializing in clear documentation.
whenToUse: Use this mode for writing and editing documentation.
customInstructions: Focus on clarity and completeness in documentation.
groups:
- read
- - edit # This group allows editing specific files
- fileRegex: \.(md|mdx)$ # Regex for Markdown files
description: Markdown files only
- browser
- slug: another-mode
name: Another Mode
# ... other properties
JSON Alternative (custom_modes.json or .saarthimodes):
{
"customModes": [
{
"slug": "docs-writer",
"name": "π Documentation Writer",
"roleDefinition": "You are a technical writer specializing in clear documentation.",
"whenToUse": "Use this mode for writing and editing documentation.",
"customInstructions": "Focus on clarity and completeness in documentation.",
"groups": [
"read",
["edit", { "fileRegex": "\\.(md|mdx)$", "description": "Markdown files only" }],
"browser"
]
},
{
"slug": "another-mode",
"name": "Another Mode"
}
]
}
YAML/JSON Property Detailsβ
slugβ
- Purpose: A unique identifier for the mode.
- Format: Use lowercase letters, numbers, and hyphens.
- Usage: Used internally and in file/directory names for mode-specific rules (e.g.,
.saarthi/rules-{slug}/). - Recommendation: Keep it short and descriptive.
- YAML Example:
slug: docs-writer - JSON Example:
"slug": "docs-writer"
nameβ
- Purpose: The display name shown in the Saarthi UI.
- Format: Can include spaces and proper capitalization.
- YAML Example:
name: π Documentation Writer - JSON Example:
"name": "Documentation Writer"
roleDefinitionβ
- Purpose: Detailed description of the mode's role, expertise, and personality.
- Placement: This text is placed at the beginning of the system prompt when the mode is active.
- Important First Sentence: The first sentence (up to the first period
.) serves as a default concise summary for Saarthi to understand the mode's general purpose. However, if thewhenToUseproperty is defined,whenToUsetakes precedence for summarizing the mode's function, especially in contexts like task orchestration or mode selection. - YAML Example (multi-line):
roleDefinition: >-
You are a test engineer with expertise in:
- Writing comprehensive test suites
- Test-driven development - JSON Example:
"roleDefinition": "You are a technical writer specializing in clear documentation."
groupsβ
- Purpose: Array/list defining which tool groups the mode can access and any file restrictions.
- Available Tool Groups (Strings):
"read","edit","browser","command","mcp". - File Restrictions for "edit" group:
- To apply file restrictions, the "edit" entry becomes a list (YAML) or array (JSON) where the first element is
"edit"and the second is a map/object defining the restrictions. fileRegex: A regular expression string to control which files the mode can edit.- In YAML, typically use single backslashes for regex special characters (e.g.,
\.md$). - In JSON, backslashes must be double-escaped (e.g.,
\\.md$).
- In YAML, typically use single backslashes for regex special characters (e.g.,
description: An optional string describing the restriction.- For more complex patterns, see Understanding Regex in Custom Modes.
- To apply file restrictions, the "edit" entry becomes a list (YAML) or array (JSON) where the first element is
- YAML Example:
groups:
- read
- - edit # Start of "edit" tool with restrictions
- fileRegex: \.(js|ts)$ # Restriction map for JS/TS files
description: JS/TS files only
- command - JSON Example:
"groups": [
"read",
["edit", { "fileRegex": "\\.(js|ts)$", "description": "JS/TS files only" }],
"command"
]
whenToUseβ
- Purpose: (Optional) Provides guidance for Saarthi to understand what this mode does. Used by the Orchestrator mode and for mode switching.
- Format: A string describing ideal scenarios or task types for this mode.
- Usage: If populated, Saarthi uses this description. Otherwise, the first sentence of
roleDefinitionis used. - YAML Example:
whenToUse: This mode is best for refactoring Python code. - JSON Example:
"whenToUse": "This mode is best for refactoring Python code."
customInstructionsβ
- Purpose: A string containing additional behavioral guidelines for the mode.
- Placement: This text is added near the end of the system prompt.
- Supplementing: Can be supplemented by Mode-Specific Instructions via Files/Directories.
- YAML Example (multi-line):
customInstructions: |-
When writing tests:
- Use describe/it blocks
- Include meaningful descriptions - JSON Example:
"customInstructions": "Focus on explaining concepts and providing examples."
Benefits of YAML Formatβ
YAML is now the preferred format for defining custom modes due to several advantages over JSON:
- Readability: YAML's indentation-based structure is often easier for humans to read and understand complex configurations.
- Comments: YAML allows for comments (lines starting with
#), making it possible to annotate your mode definitions.customModes:
- slug: security-review
name: π Security Reviewer
# This mode is restricted to read-only access
roleDefinition: You are a security specialist reviewing code for vulnerabilities.
whenToUse: Use for security reviews and vulnerability assessments.
# Only allow reading files, no editing permissions
groups:
- read
- browser - Multi-line Strings: YAML provides cleaner syntax for multi-line strings (e.g., for
roleDefinitionorcustomInstructions) using|(literal block) or>(folded block).customModes:
- slug: test-engineer
name: π§ͺ Test Engineer
roleDefinition: >-
You are a test engineer with expertise in:
- Writing comprehensive test suites
- Test-driven development
- Integration testing
- Performance testing
customInstructions: |-
When writing tests:
- Use describe/it blocks
- Include meaningful descriptions
- Test edge cases
- Ensure proper coverage
# ... other properties - Less Punctuation: YAML generally requires less punctuation (like commas and braces) compared to JSON, reducing syntax errors.
- Editor Support: Most modern code editors provide excellent syntax highlighting and validation for YAML files, further enhancing readability and reducing errors.
While JSON is still fully supported, new modes created via the UI or by asking Saarthi will default to YAML.
Tips for Working with YAMLβ
When editing YAML manually, keep these points in mind:
- Indentation is Key: YAML uses indentation (spaces, not tabs) to define structure. Incorrect indentation is the most common source of errors. Ensure consistent spacing for nested elements.
- Colons for Key-Value Pairs: Keys must be followed by a colon and a space (e.g.,
slug: my-mode). - Hyphens for List Items: List items start with a hyphen and a space (e.g.,
- read). - Validate Your YAML: If you encounter issues, use an online YAML validator or your editor's built-in validation to check for syntax errors.
Migration to YAML Formatβ
-
Global Modes: The migration from
custom_modes.jsontocustom_modes.yamlhappens automatically when Saarthi starts up, under these conditions:- Saarthi starts up.
- A
custom_modes.jsonfile exists. - No
custom_modes.yamlfile exists yet. The migration process reads the existing JSON file, converts it to YAML format, creates a newcustom_modes.yamlfile, and preserves the original JSON file (e.g., by renaming it) for rollback purposes. Ifcustom_modes.yamlalready exists, it will be used, and no automatic migration ofcustom_modes.jsonwill occur.
-
Project Modes (
.saarthimodes):- No automatic startup migration: Unlike global modes, project-specific
.saarthimodesfiles are not automatically converted from JSON to YAML simply when Saarthi starts. - Format Detection: Saarthi can read
.saarthimodesfiles in either YAML or JSON format. - Conversion on UI Edit: If you edit a project-specific mode through the Saarthi UI (e.g., via the Prompts Tab), and the existing
.saarthimodesfile is in JSON format, Saarthi will save the changes in YAML format. This effectively converts the file to YAML. The original JSON content will be overwritten with YAML. - Manual Conversion: If you want to convert an existing
.saarthimodesJSON file to YAML without making UI edits, you'll need to do this manually. You can:- Open your existing JSON
.saarthimodesfile. - Convert its content to YAML (you can ask Saarthi to help with this, or use an online converter).
- Replace the content of your
.saarthimodesfile with the new YAML content, or rename the old file (e.g.,.saarthimodes.json.bak) and save the new content into a file named.saarthimodes. Ensure the resulting YAML is valid.
- Open your existing JSON
- No automatic startup migration: Unlike global modes, project-specific
For manual conversions of .saarthimodes files, you can use online JSON to YAML converters or ask Saarthi to help reformat a specific mode configuration from JSON to YAML. Always validate your YAML before saving.
Mode-Specific Instructions via Files/Directoriesβ
You can provide instructions for custom modes using dedicated files or directories within your workspace. This allows for better organization and version control compared to only using the customInstructions property.
Preferred Method: Directory (.saarthi/rules-{mode-slug}/)
.
βββ .saarthi/