A CLI tool for managing and switching AI models and modes for Opencode agents.
- Agent Discovery: Automatically detects available agents from multiple sources:
- Global markdown:
~/.config/opencode/agents/*.md - Global JSON:
~/.config/opencode/opencode.json - Project markdown:
.opencode/agents/*.md - Project JSON:
./opencode.json
- Global markdown:
- Model Switching: Change the AI model assigned to any agent
- Mode Switching: Change agent mode (primary/subagent/all)
- Templates: Save and restore agent configurations (model + mode) as named templates
- Templates stored globally in
~/.config/opencode-agent-switcher/templates/ - Strict matching by agent name + source (global/project, markdown/JSON)
- Load, delete, and overwrite templates with confirmation
- Templates stored globally in
- Sorting Options: Sort agents and models alphabetically (A-Z/Z-A) with case-sensitivity toggle
- Custom Model Input: Enter custom model IDs directly (format:
provider/model) - Interactive TUI: Beautiful terminal user interface using Huh?
- Batch Updates: Detects if multiple agents use the same model and offers to update them all
- Undo Support: Restore previous settings after updates
- Source Indicators: See where each agent is defined (global/project, markdown/JSON)
- Go: Version 1.26 or higher
- Opencode: The
opencodeCLI tool must be installed and configured
Download the latest release for your platform from the Releases page:
# Linux (amd64)
curl -sL https://github.com/mario-gc/opencode-agent-switcher/releases/latest/download/opencode-agent-switcher_0.7.2_linux_amd64.tar.gz | tar xz
# Linux (arm64)
curl -sL https://github.com/mario-gc/opencode-agent-switcher/releases/latest/download/opencode-agent-switcher_0.7.2_linux_arm64.tar.gz | tar xz
# Make executable
chmod +x opencode-agent-switcher# Clone the repository
git clone https://github.com/mario-gc/opencode-agent-switcher.git
cd opencode-agent-switcher
# Install to GOPATH/bin
go install github.com/mario-gc/opencode-agent-switcher@latest
# Or build locally
go build -o opencode-agent-switcher main.gomake build # Build the binary
make install # Install to GOPATH/binRun the tool directly from the terminal:
opencode-agent-switcher| Option | Description |
|---|---|
-v, --version |
Show version information |
opencode-agent-switcher --version
# Output: opencode-agent-switcher 0.7.2 (commit: abc1234, built: 2026-04-02)- The tool loads your Opencode configuration and available agents from all sources
- An interactive menu appears with:
- Sort by... - Change how agents are sorted (Agent A-Z/Z-A, Model A-Z/Z-A)
- Templates - Save, load, or delete agent configuration templates
- All available agents with their current model, mode, and source
- An "Exit" option to quit the application
- Select an agent to modify
- Choose an action:
- Change Model - Select a new AI model or enter a custom one
- Change Mode - Switch between primary/subagent/all modes
- Back - Return to agent selection
- If changing mode and the agent has no mode set, choose whether to add the field
- If other agents use the same model, you'll be asked to update them all
- After updating, you can undo changes or continue
- Select Templates from the main menu
- Choose:
- Save current configuration as template - Enter a name and save all agent configs
- Show existing templates - View, inspect, load, or delete saved templates
- When viewing templates:
- Inspect - View all agents, models, and modes in the template
- Load - Apply the template to current agents
- Delete - Remove the template
- When loading a template:
- Shows summary of agents that will be updated
- Warns about unmatched agents (different source type)
- Confirms before applying changes
- Offers undo after applying
Agents are tagged with their source location:
[g/md]- Global markdown file[g/json]- Global JSON config[p/md]- Project markdown file[p/json]- Project JSON config
When agents have the same name in different sources, project-level configurations take precedence over global ones.
.
├── main.go # Entry point with main loop
├── cli/ # User interaction and TUI prompts
│ └── prompt.go # Huh? based interactive prompts
├── config/ # Configuration loading and parsing
│ └── config.go # Opencode config handling
├── agents/ # Agent discovery and modification
│ └── agents.go # Agent file operations
├── models/ # Shared data structures
│ └── models.go # Agent, Template, ModelOption structs
├── templates/ # Template management
│ └── templates.go # Template save/load/delete operations
├── Makefile # Build automation
├── .golangci.yml # Linting configuration
└── go.mod # Go module definition
make build # Build the binary
make test # Run tests with race detection
make test-coverage # Generate coverage report
make lint # Run golangci-lint
make fmt # Format code
make vet # Run go vet
make check # Run all checks (fmt, vet, lint, test)
make clean # Remove build artifactsgo test -v -race ./...See CONTRIBUTING.md for guidelines.
See CHANGELOG.md for version history.
This project is licensed under the MIT License - see the LICENSE file for details.