A plugin for OpenCode that automatically manages Git worktrees for every AI session created from the opencode-plugin-template.
This plugin ensures your main working directory remains clean while the AI works in an isolated branch. On session end, it automatically generates a commit message, pushes the branch, and removes the worktree.
.opencode/worktrees/.main branch to prevent accidental corruption.cwd) to the worktree automatically.Add to your opencode.json:
{
"plugin": ["@tmegit/opencode-worktree-session"]
}
opencode.feature-xyz).opencode/feature-xyz and moves the session into that path.origin.Creating a Worktree
https://github.com/user-attachments/assets/58e59a3e-80eb-4877-b5c9-ae8b9f93e816
Deleting a Worktree
https://github.com/user-attachments/assets/f30a8329-f8d0-4c8d-9785-5101cff67b9d
Example (save as .opencode/opencode-worktree-session-config.json):
{
"terminal": {
"mode": "custom",
"bin": "alacritty",
"args": "",
"workingDirectoryArgument": "--working-directory",
"commandFlag": "-e"
},
"postWorktree": {
"cmd": "webstorm",
"args": ""
},
"configToolsAvailable": false
}
Configure the plugin in .opencode/opencode-worktree-session-config.json.
terminal — Controls how the plugin launches a terminal.
mode — launch mode: default | custom | specificbin — terminal binaryargs — extra argsworkingDirectoryArgument — workdir flagcommandFlag — command flagterminal (specific mode) — Alacritty, iTerm, iTerm2, TerminalpostWorktree — Command run after worktree creation.
cmd — command to runargs — command argsconfigToolsAvailable — Enable or disable config helper tools (affects setpostworktree, setworktreesync, setterminal).
boolean — true/falseNote: change configToolsAvailable and restart your OpenCode session for it to take effect.
bun run typecheck - TypeScript type checkingbun run lint - Fix linting issuesbun run format - Format code with Prettierbun run test - Run testsbun run build - Build the pluginApache License 2.0
17 commits
2 commits
TypeScript
83.0%
Python
13.1%
Shell
2.9%
JavaScript
1.0%
A plugin for OpenCode that automatically manages Git worktrees for every AI session created from the opencode-plugin-template.
This plugin ensures your main working directory remains clean while the AI works in an isolated branch. On session end, it automatically generates a commit message, pushes the branch, and removes the worktree.
.opencode/worktrees/.main branch to prevent accidental corruption.cwd) to the worktree automatically.Add to your opencode.json:
{
"plugin": ["@tmegit/opencode-worktree-session"]
}
opencode.feature-xyz).opencode/feature-xyz and moves the session into that path.origin.Creating a Worktree
https://github.com/user-attachments/assets/58e59a3e-80eb-4877-b5c9-ae8b9f93e816
Deleting a Worktree
https://github.com/user-attachments/assets/f30a8329-f8d0-4c8d-9785-5101cff67b9d
Example (save as .opencode/opencode-worktree-session-config.json):
{
"terminal": {
"mode": "custom",
"bin": "alacritty",
"args": "",
"workingDirectoryArgument": "--working-directory",
"commandFlag": "-e"
},
"postWorktree": {
"cmd": "webstorm",
"args": ""
},
"configToolsAvailable": false
}
Configure the plugin in .opencode/opencode-worktree-session-config.json.
terminal — Controls how the plugin launches a terminal.
mode — launch mode: default | custom | specificbin — terminal binaryargs — extra argsworkingDirectoryArgument — workdir flagcommandFlag — command flagterminal (specific mode) — Alacritty, iTerm, iTerm2, TerminalpostWorktree — Command run after worktree creation.
cmd — command to runargs — command argsconfigToolsAvailable — Enable or disable config helper tools (affects setpostworktree, setworktreesync, setterminal).
boolean — true/falseNote: change configToolsAvailable and restart your OpenCode session for it to take effect.
bun run typecheck - TypeScript type checkingbun run lint - Fix linting issuesbun run format - Format code with Prettierbun run test - Run testsbun run build - Build the pluginApache License 2.0
17 commits
2 commits
TypeScript
83.0%
Python
13.1%
Shell
2.9%
JavaScript
1.0%