設定

カスタムモード

特定のタスクやワークフローに合わせて Bob の動作を調整するカスタムモードを作成できます。Bob Shell のカスタムモードは Bob IDE のモードと同様に機能します。

Bob Shell でカスタムモードを使う理由

  • シェル最適化されたワークフロー:ターミナルベースの開発タスク専用に設計されたモードを作成する
  • コマンドラインの安全性:本番環境での作業時に安全な操作のみにモードを制限する
  • 環境固有の動作:異なるシェル環境に適応するモードを設定する
  • 自動化対応:インタラクティブと非インタラクティブの両セッションでシームレスに動作するモードを設計する
  • チームの標準化:一貫したワークフローのためにシェル固有のモードをチーム全体で共有する

カスタムモードに含まれるもの

Bob Shell のカスタムモードは Bob IDE のモードと同じコア構造を使用します:

プロパティ説明シェル固有の考慮事項
slug一意の内部識別子コマンドライン引数で使用:
bob --chat-mode=my-mode
nameUI での表示名インタラクティブモードのモードセレクターに表示される
descriptionモードセレクターに表示される短い説明モードの目的を簡潔に説明する
roleDefinitionコアのアイデンティティと専門知識シェルのコンテキストとコマンドラインワークフローを考慮する必要がある
groups許可されたツールセットとファイルアクセスシェル環境ではコマンド実行権限が重要
whenToUseモード選択のガイダンスBob Shell がタスクに適切なモードを選択するのに役立つ
customInstructions固有の動作ガイドラインまたはモードのルールBob Shell の開発パターンを参照できる

利用可能なツール

利用可能なツールグループ

  • read:ファイルとディレクトリを読み取る
  • edit:ファイルを変更する(fileRegex で制限可能)
  • browser:ブラウザー自動化を使用する
  • command:ターミナルコマンドを実行する
  • mcp:MCP サーバーにアクセスする

カスタムモードの作成

設定ファイル

Bob Shell は Bob IDE と同じ設定形式をサポートしており、YAML(推奨)と JSON 形式の両方に対応しています。

グローバルモード

すべてのプロジェクトで使用可能なモードのために ~/.bob/custom_modes.yaml を作成または編集します:

customModes:
  - slug: shell-debug
    name: 🐛 Shell Debugger
    roleDefinition: >-
      You are a debugging specialist focused on command-line troubleshooting.
      You excel at analyzing shell output, environment variables, and system logs.
    whenToUse: Use for debugging shell scripts, command failures, and environment issues.
    customInstructions: |-
      When debugging:
      - Always check environment variables first
      - Examine command exit codes
      - Review relevant log files
      - Test commands in isolation before suggesting fixes
    groups:
      - read
      - command
      - browser

プロジェクト固有のモード

プロジェクトルートの .bob/custom_modes.yaml を作成または編集します:

customModes:
  - slug: deploy-helper
    name: 🚀 Deployment Assistant
    roleDefinition: You are a deployment specialist for this project's infrastructure.
    whenToUse: Use for deployment tasks, infrastructure changes, and release management.
    customInstructions: |-
      Deployment guidelines:
      - Always verify the target environment before running commands
      - Check for running processes that might be affected
      - Validate configuration files before applying changes
      - Create backups before destructive operations
    groups:
      - read
      - - edit
        - fileRegex: \.(yaml|yml|sh|env)$
          description: Configuration and script files only
      - command

コマンドラインでのモード選択

Bob Shell を起動する際にモードを指定します:

# 特定のモードで Bob Shell を起動する
bob --chat-mode=shell-debug

# 他のオプションと組み合わせる
bob --chat-mode=deploy-helper --sandbox

インタラクティブなモードの切り替え

インタラクティブモードでは、スラッシュコマンドを使ってモードを切り替えます:

# カスタムモードに切り替える
/mode shell-debug

# またはモードのスラッグを直接使用する
/shell-debug

シェル固有の設定

本番安全モード

本番環境向けの安全重視モードを作成します:

customModes:
  - slug: prod-ops
    name: 🔒 Production Operations
    roleDefinition: >-
      You are a production operations specialist with a strong focus on safety.
      You never run destructive commands without explicit confirmation.
    whenToUse: Use when working with production systems or sensitive environments.
    customInstructions: |-
      Production safety rules:
      - NEVER run destructive commands without explicit user confirmation
      - Always verify the target environment before any operation
      - Suggest dry-run options when available
      - Check for active connections or processes before changes
      - Recommend backup procedures before modifications
    groups:
      - read
      - browser
      # Note: No edit or command groups for maximum safety

スクリプト開発モード

シェルスクリプト開発用のモードを作成します:

customModes:
  - slug: script-dev
    name: 📜 Script Developer
    roleDefinition: >-
      You are a shell scripting expert specializing in bash, zsh, and POSIX-compliant scripts.
    whenToUse: Use for creating, debugging, or improving shell scripts.
    customInstructions: |-
      Shell scripting best practices:
      - Use shellcheck-compliant syntax
      - Include proper error handling with set -e and set -u
      - Add usage documentation at the top of scripts
      - Quote variables to prevent word splitting
      - Provide exit codes for different error conditions
    groups:
      - read
      - - edit
        - fileRegex: \.(sh|bash|zsh)$
          description: Shell script files only
      - command

コマンド実行権限

コマンドアクセスの制限

command グループを省略することで、モードが実行できるコマンドを制御します:

customModes:
  - slug: safe-reviewer
    name: 👀 Safe Code Reviewer
    roleDefinition: You are a code reviewer focused on analysis, not modification.
    whenToUse: Use for code reviews and analysis without making changes.
    groups:
      - read
      - browser
      # No command or edit groups - read-only mode

特定のコマンドを許可する

設定ファイルでカスタムモードに Bob Shell の allowed ツール設定を使用します:

{
  "tools": {
    "allowed": [
      "run_shell_command(git status)",
      "run_shell_command(git log)",
      "run_shell_command(git diff)"
    ]
  }
}

インタラクティブと非インタラクティブの動作

両方のモードに対応した設計

インタラクティブと非インタラクティブの両セッションでうまく動作するモードを作成します:

customModes:
  - slug: test-runner
    name: 🧪 Test Runner
    roleDefinition: >-
      You are a testing specialist who runs and analyzes test suites.
      You adapt your output based on the running context.
    whenToUse: Use for running tests, analyzing test results, and debugging test failures.
    customInstructions: |-
      Testing guidelines:
      - In interactive mode: Provide detailed explanations and suggestions
      - In non-interactive mode: Focus on concise, actionable output
      - Always report test results clearly
      - Suggest fixes for failing tests
    groups:
      - read
      - command

非インタラクティブでの使用

非インタラクティブモードでモードを使用します:

# 自動化用に設計されたモードを使用する
bob --chat-mode=test-runner -p "Run the test suite and report failures"

# 出力処理と組み合わせる
bob --chat-mode=test-runner -p "Run tests" --hide-intermediary-output > results.txt

ファイルによるモード固有の指示

ディレクトリベースの指示

.bob/rules-{mode-slug}/ にモード固有の指示ファイルを作成します:

01-environment-checks.md
02-common-issues.md
03-debugging-steps.md
custom_modes.yaml

指示ファイルの例(.bob/rules-shell-debug/01-environment-checks.md):

# Environment Debugging Checklist

When debugging shell issues, always check:

1. **Environment Variables**: PATH, SHELL, TERM, and application-specific variables
2. **Shell Configuration**: .bashrc, .zshrc, .profile files
3. **System State**: Current working directory, file permissions, disk space
4. **Command Availability**: Use `command -v <cmd>` to verify commands exist

単一ファイルの指示(フォールバック)

代わりに、ワークスペースルートの単一ファイル .bobrules-{mode-slug} を使用することもできます。

設定の優先順位

モードの設定は次の順序で適用されます:

  1. コマンドライン引数(--chat-mode=mode-slug
  2. プロジェクトレベルのモード(.bob/custom_modes.yaml
  3. ユーザーレベルのモード(~/.bob/custom_modes.yaml
  4. システムレベルのモード(プラットフォーム固有の場所)
  5. デフォルトモード

カスタムモードでのサンドボックス化

安全な実験のためにカスタムモードと Bob Shell のサンドボックス機能を組み合わせます:

# カスタムモードでサンドボックスを起動する
bob --chat-mode=script-dev --sandbox

# Docker サンドボックスで使用する
bob --chat-mode=deploy-helper --sandbox

Bob IDE からのモードの移行

主な違い

Bob IDE から Bob Shell にカスタムモードを移行する際の違い:

側面Bob IDEBob Shell
UI インタラクションパネル付きビジュアルインターフェースターミナルベースインターフェース
ファイル編集エディター内の diff とプレビューCLI diff ビューまたは外部エディター
コマンド実行統合ターミナル直接シェル実行
モードの切り替えUI ドロップダウンまたはスラッシュコマンドスラッシュコマンドまたは CLI 引数
設定設定 UI + ファイル設定ファイルのみ

適応チェックリスト

Bob IDE のモードを Bob Shell に適応させる際:

  • シェル固有のコンテキストに合わせて roleDefinition を見直す
  • コマンドラインワークフローを参照するよう customInstructions を更新する
  • groups 設定でコマンド実行の安全性を考慮する
  • インタラクティブと非インタラクティブの両セッションでモードをテストする
  • シェルコンテキストでのファイルパスの処理を確認する
  • 該当する場合はサンドボックスモードでテストする

移行例

元の Bob IDE モード:

customModes:
  - slug: code-reviewer
    name: 👀 Code Reviewer
    roleDefinition: You are a code reviewer who provides detailed feedback.
    groups:
      - read
      - browser

Bob Shell 向けに適応したもの:

customModes:
  - slug: code-reviewer
    name: 👀 Code Reviewer
    roleDefinition: >-
      You are a code reviewer who provides detailed feedback.
      You work efficiently in terminal environments and provide clear, actionable suggestions.
    whenToUse: Use for code reviews, pull request analysis, and code quality checks.
    customInstructions: |-
      Code review guidelines:
      - Provide feedback in a structured format suitable for terminal output
      - Reference specific line numbers and file paths
      - Suggest concrete improvements with examples
      - Format output for easy parsing if used in non-interactive mode
    groups:
      - read
      - command  # Added for git operations
      - browser
このトピックはいかがですか?