設定

カスタムモード

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

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

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

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

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

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

利用可能なツール

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

  • read:ファイルとディレクトリを読み取る
  • edit:ファイルを変更する(fileRegex で制限可能)
  • execute:ターミナルコマンドを実行する(レガシーエイリアスとして command も使用可能)
  • browser:公開 Web ページを取得する(実験的機能。experiments.webFetch が必要)
  • mcp:MCP サーバーにアクセスする
  • skill:スキルを有効化する
  • todo:To-do リストを更新する
  • subagent:サブエージェントを生成する
  • mode:モードを切り替える

カスタムモードの作成

設定ファイル

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

グローバルモード

すべてのプロジェクトで使用可能なモードのために ~/.bob/settings/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
      - execute
      - 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
      - execute

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

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

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

# 他のオプションと組み合わせる
bob --mode deploy-helper --max-turns 20

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

インタラクティブモードでは、/mode と入力してモードピッカーを開き、カスタムモードを選択します。カスタムモードは、組み込みの Agent、Plan、Ask モードと並んでピッカーに表示されます。

シェル固有の設定

本番安全モード

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

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 execute 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
      - execute

コマンド実行権限

コマンドアクセスの制限

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

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 execute or edit groups - read-only mode

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

特定のコマンドを自動承認するには、~/.bob/settings/settings.json で approval.allowed_permissions に "execute" を追加し、execute_command ツールの approval.allowedExecutors にコマンドを列挙します:

{
  "approval": {
    "allowed_permissions": ["read", "execute"],
    "allowedExecutors": [
      {
        "toolId": "execute_command",
        "approvedCommands": ["git status", "git log", "git diff"],
        "deniedCommands": []
      }
    ]
  }
}

allowedExecutors を設定すると、承認済みコマンドのデフォルトリストが置き換えられるため、残したいデフォルトも含めてください。詳細については、承認設定を参照してください。

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

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

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

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
      - execute

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

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

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

# 出力処理と組み合わせる
bob run --mode test-runner --format json "Run tests" > results.json

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

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

.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

設定の優先順位

2 つのモードが同じスラッグを共有している場合、Bob Shell は次の順序で最初に見つかったモードを使用します:

  1. 組み込みモード(agent、plan、ask)
  2. ユーザーレベルのモード(~/.bob/settings/custom_modes.yaml)
  3. プロジェクトレベルのモード(.bob/custom_modes.yaml)

カスタムモードごとに一意のスラッグを使用してください。--mode フラグは、どのモードで起動するかを選択するだけです。

Bob IDE からのモードの移行

主な違い

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

側面Bob IDEBob Shell
UI インタラクションパネル付きビジュアルインターフェースターミナルベースインターフェース
ファイル編集エディター内の diff とプレビューCLI diff ビューまたは外部エディター
コマンド実行統合ターミナル直接シェル実行
モードの切り替えモードセレクターのドロップダウン/mode ピッカーまたは --mode 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
      - execute  # Added for git operations
      - browser
このトピックはいかがですか?