kdcokenny/opencode-worktree
Zero-friction git worktrees for OpenCode. Auto-spawns terminals, syncs files, cleans up on exit.
What it solves
This project provides a way for AI agents to create and manage isolated development environments using git worktrees. It removes the manual friction of creating a worktree, opening a terminal, and starting an AI coding tool (OpenCode) in that specific directory, allowing agents to experiment in isolation without disrupting the main codebase.
How it works
The plugin integrates with OpenCode and provides two primary tools: worktree_create and worktree_delete.
- Creation: When an AI calls
worktree_create, the plugin creates a git worktree in a dedicated local directory, synchronizes necessary files (like.envfiles) and symlinks directories (likenode_modules) based on a configuration file, runs post-creation hooks (e.g.,pnpm install), and automatically spawns a new terminal window with OpenCode running inside. - Deletion: When the AI calls
worktree_delete, the plugin runs pre-deletion hooks, automatically commits any changes made in the worktree to a branch, and then removes the worktree from the system.
It supports a wide variety of terminal emulators across macOS, Linux, and Windows, as well as multiplexers like tmux and cmux for more programmatic control.
Who it’s for
Developers who use OpenCode and want to enable AI agents to autonomously manage isolated development sessions, specifically those who prefer CLI-first workflows over GUI-based tools.
Highlights
- Automatic Terminal Spawning: Automatically opens a new terminal window or tmux/cmux workspace for each new worktree.
- Lifecycle Hooks: Supports
postCreateandpostDeletehooks to automate setup and cleanup (e.g., starting/stopping Docker containers). - File Synchronization: Configurable synchronization of files and directories to ensure the isolated environment is ready for use.
- Broad Terminal Support: Native support for a wide range of modern terminal emulators across all major operating systems.
Related
- Project
- Project
- Project
- Project
- Project