r/opencodeCLI • u/soul105 • 1d ago
Native multi-profile support in OpenCode 2 (separate subscriptions & MCPs)?
Does anyone know if native multi-profile support (like a `--profile` flag) is planned or already possible in OpenCode 2?
I want to maintain completely separate setups, work vs. personal where each profile has:
* Its own authenticated subscriptions / providers (`auth.json`)
* Its own set of enabled MCP servers (`opencode.jsonc`)
3
Upvotes
1
u/molovo 1d ago edited 1d ago
Yes, it's possible, but a bit tricky to set up. You can separate out the directories so that two instances have entirely separate databases and config directories. I have a shell function that loads the correct one for me, based on the Github organisation for the repository I'm in, so I don't need to worry about running the wrong command.
Just add this to
.zshrc, and then when you runopencodeit'll run this function instead.Just replace
myworkorganisationin the function above with your own work organisation. I use Claude Agent within Opencode, so this also sets up a separate Claude Code directory as well so I get the correct Claude account for each Opencode profile. If you don't use Claude just remove theCLAUDE_CONFIG_DIRbits.To set up the initial state:
The way I have it set up, I have a shared config, and then overrides. So my main config in the work directory is symlinked to my personal directory:
Repeat the above for any other files you want shared, e.g.
cli.json,agents,skills,plugins.And then, I have a second config file at
~/.config/opencode-work/work.jsoncwhich contains any overrides. In my case, it's just a couple of additional MCP servers. That's all set up in the function at the top of this post.If you're in a repository for a different organisation, but still want your work profile, just run
OPENCODE_ENV_WORK=1 opencodeand it'll load your work profile.