opencode-multi
A Rust CLI tool for managing multiple OpenCode profiles through isolated config and data directories.
Overview
opencode-multi enables multi-profile support for OpenCode by managing separate config and data environments. Each profile gets:
- Isolated configuration directory (
~/.config/opencode-multi/profiles/{name}/) - Isolated data directory (
~/.local/share/opencode-multi/profiles/{name}/) - Separate authentication state (separate
auth.jsonper profile)
This allows you to:
- Use different OpenCode accounts/providers per profile
- Maintain separate plugin configurations
- Keep work and personal environments completely isolated
Installation
From crates.io (recommended)
From source
Quick Start
# Create two profiles
# List profiles
# Run OpenCode with a profile
# In another terminal, switch to personal profile
Commands
create <name>
Create a new profile with scaffolded directory structure.
Creates:
~/.config/opencode-multi/profiles/{name}/~/.config/opencode-multi/profiles/{name}/plugins/~/.config/opencode-multi/profiles/{name}/commands/~/.config/opencode-multi/profiles/{name}/agents/~/.config/opencode-multi/profiles/{name}/modes/~/.local/share/opencode-multi/profiles/{name}/
list
Display all profiles with status information.
Output:
NAME CONFIG AUTH STATUS
work yes yes healthy
personal yes no needs-auth
show <name>
Display detailed information about a profile.
run <name> [-- <opencode-args>]
Launch OpenCode with the specified profile.
# Basic usage
# With additional OpenCode arguments
clone <source> <destination>
Copy an existing profile to a new profile.
remove <name> [--yes]
Delete a profile and all its data.
# With confirmation prompt
# Skip confirmation
doctor
Check system health and profile status.
Output:
[ok] opencode found at /usr/local/bin/opencode
[ok] Config root exists
[ok] Data root exists
[ok] Profile 'work' healthy
[warn] Profile 'personal' needs authentication
How It Works
OpenCode reads configuration from a config directory and stores runtime data (including auth.json) in a data directory. opencode-multi works by:
- Managing separate config/data directories per profile
- Setting environment variables when launching OpenCode:
OPENCODE_CONFIG_DIR→ profile's config directoryXDG_DATA_HOME→ profile's data parent directoryOPENCODE_PROFILE→ profile name (for reference)
This approach requires no modifications to OpenCode itself.
Directory Structure
~/.config/opencode-multi/
└── profiles/
├── work/
│ ├── opencode.json
│ ├── plugins/
│ ├── commands/
│ ├── agents/
│ └── modes/
└── personal/
├── opencode.json
├── plugins/
├── commands/
├── agents/
└── modes/
~/.local/share/opencode-multi/
└── profiles/
├── work/
│ └── opencode/
│ └── auth.json
└── personal/
└── opencode/
└── auth.json
Profile Lifecycle Example
# 1. Create work profile
# 2. Run OpenCode and authenticate with work account
# Inside OpenCode: /connect (authenticate with work provider)
# 3. Create personal profile
# 4. Run OpenCode and authenticate with personal account
# Inside OpenCode: /connect (authenticate with personal provider)
# 5. Switch between profiles anytime
Requirements
- Rust 1.70+ (for building from source)
- OpenCode installed and available in PATH
License
MIT © Dominic Codespoti