Custom rules
Custom rules influence how Bob responds to your requests, aligning output with your specific preferences and project requirements. You can control coding style, documentation approach, and decision-making processes.
What are custom rules?
Custom rules extend Bob's default behavior by defining preferences, constraints, and guidelines that direct how Bob approaches tasks to match your needs.
Common uses include:
- Coding style preferences (indentation, naming conventions)
- Documentation formats and standards
- Testing methodologies and requirements
- Project workflows and processes
- Team-specific conventions
Adding custom rules for a mode
You can add custom rules to modes in two ways:
Through the UI
Configure rules that apply across all your projects:
- Click the three dots in the top-right corner of the Bob sidebar.
- Click Modes.
- Select the mode you want to edit rules for.
- Click Edit.
- Scroll to Mode-specific custom instructions (optional).
- Type your rules.
- Click Save.
Through mode-specific rules files
Modes can also have additional rules files stored in directories:
-
Preferred method (directory structure):
01-style-guide.md02-formatting.txt -
Alternative method (single file):
.bobrules-{mode-slug}
The directory method takes precedence if both exist. Files in the directory are loaded alphabetically and combined with the customInstructions property from your mode configuration. For more details, see Custom modes.
Rule scopes
Bob supports two rule scopes that determine where your rules apply:
- Global rules: Apply automatically across all your projects
- Workspace rules: Apply only within your current project
Use global rules for personal or organization-wide standards. Use workspace rules for project-specific requirements.
Configuration methods
File-based configuration
The simplest approach uses single files in your workspace root:
.bobrules- General workspace rules.bobrules-code- Rules for Code mode.bobrules-{modeSlug}- Rules for any mode
Create a .bobrules file:
# In your project root
echo "Use 4 spaces for indentation" > .bobrulesDirectory-based configuration
For better organization, use directories:
Workspace structure:
rules/- General rules for all modesrules-code/- Code mode specific rules
Global structure:
Linux/macOS: ~/.bob/rules/
Windows: %USERPROFILE%\.bob\rules\
Create workspace rules:
mkdir -p .bob/rules
echo "# Project standards" > .bob/rules/coding-style.mdCreate global rules:
# Linux/macOS
mkdir -p ~/.bob/rules
echo "# Global standards" > ~/.bob/rules/coding-standards.md
# Windows
mkdir %USERPROFILE%\.bob\rules
echo # Global standards > %USERPROFILE%\.bob\rules\coding-standards.mdRule priority
Bob combines rules from multiple sources in this order:
- Global rules (
~/.bob/rules/) - Workspace rules (
.bob/rules/)
Within each level, mode-specific rules load before general rules. Workspace rules can override global rules.
Writing effective rules
Be specific and actionable
Good: "Use 4 spaces for indentation in JavaScript files"
Avoid: "Format code nicely"
Use clear structure
Organize rules by topic:
# Code Style
- Use camelCase for variables
- Use PascalCase for classes
# Testing
- Write unit tests for all public functions
- Use Jest for testing framework
# Documentation
- Add JSDoc comments for public APIsExamples of effective rules
- "Always use spaces for indentation, with a width of 4 spaces"
- "Use camelCase for variable names"
- "Write unit tests for all new functions"
- "Explain your reasoning before providing code"
- "When adding features to websites, ensure they are responsive and accessible"
Advanced configuration
Mode-specific rules
Target specific modes with dedicated directories:
| Directory | Purpose |
|---|---|
rules/ | General rules for all modes |
rules-code/ | Code mode only |
rules-plan/ | Plan mode only |
rules-{mode}/ | Any custom mode |
Using AGENTS.md files
For team standardization, you can use an AGENTS.md file in your workspace root:
# Team Standards
- Follow company coding guidelines
- Use approved libraries only
- Document all API changesKey details:
- Automatically loaded by default
- Version-control with your project
- Disable with
"bob-code.useAgentRules": falsein settings - Loaded after mode-specific rules but before general workspace rules
File behavior
- Recursive reading: Bob reads all files in rules directories, including subdirectories
- Alphabetical order: Files process in alphabetical order by filename
- Automatic filtering: Excludes cache files (
.DS_Store,*.bak,*.cache,*.log,*.tmp,Thumbs.db) - Symbolic links: Supported with maximum depth of 5
- Empty files: Silently skipped
Team standardization
Project-level standards
Use workspace .bob/rules/ directories under version control:
# Add to version control
git add .bob/rules/
git commit -m "Add Bob custom rules"This ensures consistent behavior across team members for specific projects.
Organization-wide standards
Distribute global rules to team members:
- Create a shared rules repository
- Team members clone to
~/.bob/rules/ - Update periodically for consistency
Hybrid approach
You can combine both approaches:
- Global rules for organization standards
- Workspace rules for project-specific requirements
- Workspace rules override global rules when needed
Custom modes
Tailor Bob's behavior for specific tasks or workflows by creating custom modes. You can make modes global (available across all projects) or project-specific.
Telemetry data
Learn about the telemetry data IBM Bob can collect, how it's used to improve the product, and how to enable or disable data collection.