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:

  1. Click the three dots in the top-right corner of the Bob sidebar.
  2. Click Modes.
  3. Select the mode you want to edit rules for.
  4. Click Edit.
  5. Scroll to Mode-specific custom instructions (optional).
  6. Type your rules.
  7. Click Save.

Through mode-specific rules files

Modes can also have additional rules files stored in directories:

  • Preferred method (directory structure):

    01-style-guide.md
    02-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" > .bobrules

Directory-based configuration

For better organization, use directories:

Workspace structure:

coding-style.md
typescript.md
  • rules/ - General rules for all modes
  • rules-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.md

Create 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.md

Rule priority

Bob combines rules from multiple sources in this order:

  1. Global rules (~/.bob/rules/)
  2. 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 APIs

Examples 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:

DirectoryPurpose
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 changes

Key details:

  • Automatically loaded by default
  • Version-control with your project
  • Disable with "bob-code.useAgentRules": false in 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:

  1. Create a shared rules repository
  2. Team members clone to ~/.bob/rules/
  3. 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
How is this topic?