Custom rules

Custom rules influence how Bob Shell responds to your requests in the terminal environment, 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 Shell's default behavior by defining preferences, constraints, and guidelines that direct how Bob Shell approaches tasks to match your needs when working in the terminal environment.

Common uses include:

  • Coding style preferences (indentation, naming conventions)
  • Documentation formats and standards
  • Testing methodologies and requirements
  • Project workflows and processes
  • Team-specific conventions

Rule scopes

Bob Shell 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

Bob Shell uses the same custom rules system as IBM Bob IDE.

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:

.bob/
├── rules/              # General rules
│   └── coding-style.md
└── rules-code/         # Code mode rules
    └── typescript.md

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 Shell 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: "Always use relative paths when suggesting file operations in the terminal"

Avoid: "Use good paths"

Use clear structure

Organize rules by topic:

# Shell Commands
- Prefer using standard Unix commands over specialized tools when possible
- Include explanations of what each flag does

# Script Style
- Format shell script examples with proper error handling
- Use portable shell syntax that works across bash, zsh, and other common shells

# File Operations
- Always check for file existence before operations in shell scripts
- Always use relative paths when suggesting file operations

Examples of effective rules

  • "Always use relative paths when suggesting file operations in the terminal"
  • "Prefer using standard Unix commands over specialized tools when possible"
  • "Format shell script examples with proper error handling"
  • "When suggesting commands, include explanations of what each flag does"
  • "Always check for file existence before operations in shell scripts"
  • "Use portable shell syntax that works across bash, zsh, and other common shells"

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-cline.useAgentRules": false in settings
  • Loaded after mode-specific rules but before general workspace rules

File behavior

  • Recursive reading: Bob Shell 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 using Bob Shell 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?