Per-directory switching
Drop a .ocprofile file in a project and any opencode launched within it uses that profile:
sh
cd ~/work/some-repo
ocp pin work # writes ./.ocprofile containing "work"
opencode # uses the 'work' profileocp walks up from the current directory to find the nearest .ocprofile, so a single file at the repo root applies to every subdirectory inside it. A .ocprofile only selects one of your existing profiles — it never runs code.
Resolution order
When you run ocp launch (or the opencode wrapper), the profile is chosen by this priority chain:
-p <name>/--profile <name>flag$OCP_PROFILEenvironment variable- nearest
.ocprofilewalking up from the current directory - the global default (
ocp use) - none → plain opencode with no isolation
Inspecting resolution
sh
ocp current # the profile active here
ocp resolve # the profile, where it came from, and its pathsprofile : work
source : .ocprofile
config : ~/.config/ocp/profiles/work/config
data : ~/.config/ocp/profiles/work/dataThe source field tells you why a profile was chosen — flag, env:OCP_PROFILE, .ocprofile, active-default, or none.
TIP
This only kicks in when you launch through the wrapper (opencode after eval "$(ocp init-shell)", or ocp launch). Calling the bare opencode binary bypasses ocp and ignores .ocprofile.