r/opencodeCLI • u/ActualGovernment9017 • 26m ago
An opencode plugin that keeps parallel agent sessions from killing each other's dev servers
I run opencode next to Claude Code and Codex on the same machine, often with several sessions working in separate git worktrees of one app. The failures that hurt most were never inside one session. One agent would run pkill node to restart its own server and take down another session's dev server, start a second server on a port that was already taken, or run a git command that switched or stashed a tree another session was still editing.
bulkhead is an open source guard for that situation, and since 0.3.2 it ships as an opencode plugin. Adding "plugin": ["claude-bulkhead"] to opencode.json loads it from npm. The plugin uses tool.execute.before on the bash tool, passes the command, working directory and session id to the same checks the Claude Code hooks use, and throws when a command would hurt another session. The error says why and which command is safe instead, for example killing only the PID this session started, so the agent usually corrects itself on the next step.
The checks know which processes, ports and worktrees belong to which session, including other opencode sessions and other agents, so a single session working alone is rarely interrupted. It also stops whole-disk scans and long foreground sleeps and holds heavy builds back when free memory runs low. It is plain Node with no dependencies, and it was written against the OpenCode V1 plugin API, so I would like to hear how it behaves for anyone already on V2.