カスタムモード
特定のタスクやワークフローに合わせて Bob の動作を調整するカスタムモードを作成できます。Bob Shell のカスタムモードは Bob IDE のモードと同様に機能します。
Bob Shell でカスタムモードを使う理由
- シェル最適化されたワークフロー:ターミナルベースの開発タスク専用に設計されたモードを作成する
- コマンドラインの安全性:本番環境での作業時に安全な操作のみにモードを制限する
- 環境固有の動作:異なるシェル環境に適応するモードを設定する
- 自動化対応:インタラクティブと非インタラクティブの両セッションでシームレスに動作するモードを設計する
- チームの標準化:一貫したワークフローのためにシェル固有のモードをチーム全体で共有する
カスタムモードに含まれるもの
Bob Shell のカスタムモードは Bob IDE のモードと同じコア構造を使用します:
| プロパティ | 説明 | シェル固有の考慮事項 |
|---|---|---|
slug | 一意の内部識別子 | コマンドライン引数で使用:bob --mode my-mode |
name | UI での表示名 | インタラクティブモードのモードセレクターに表示される |
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}/ にモード固有の指示ファイルを作成します:
指示ファイルの例(.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 は次の順序で最初に見つかったモードを使用します:
- 組み込みモード(
agent、plan、ask) - ユーザーレベルのモード(
~/.bob/settings/custom_modes.yaml) - プロジェクトレベルのモード(
.bob/custom_modes.yaml)
カスタムモードごとに一意のスラッグを使用してください。--mode フラグは、どのモードで起動するかを選択するだけです。
Bob IDE からのモードの移行
主な違い
Bob IDE から Bob Shell にカスタムモードを移行する際の違い:
| 側面 | Bob IDE | Bob 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
- browserBob 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