{"name":"opencode-worktree: Zero-Friction Git Worktrees for AI-Driven Development","description":"opencode-worktree is an OpenCode plugin designed to streamline git worktree management. It automates the creation and deletion of isolated development environments, complete with terminal spawning and file synchronization. This tool is ideal for AI-driven workflows, offering a zero-friction experience for developers who prioritize automation and efficiency.","github":"https://github.com/kdcokenny/opencode-worktree","url":"https://osrepos.com/repo/kdcokenny-opencode-worktree","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/kdcokenny-opencode-worktree","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/kdcokenny-opencode-worktree.md","json":"https://osrepos.com/repo/kdcokenny-opencode-worktree.json","topics":["ai","ai-assistant","git","git-worktree","opencode","developer-tools","typescript","terminal-automation"],"keywords":["ai","ai-assistant","git","git-worktree","opencode","developer-tools","typescript","terminal-automation"],"stars":null,"summary":"opencode-worktree is an OpenCode plugin designed to streamline git worktree management. It automates the creation and deletion of isolated development environments, complete with terminal spawning and file synchronization. This tool is ideal for AI-driven workflows, offering a zero-friction experience for developers who prioritize automation and efficiency.","content":"## Introduction\n\nopencode-worktree is an innovative [OpenCode](https://github.com/sst/opencode) plugin that revolutionizes how developers interact with git worktrees. It provides a zero-friction solution for creating isolated development environments, automatically spawning dedicated terminals with OpenCode running inside. This eliminates manual setup, context switching, and cleanup, making it perfect for modern, AI-driven development workflows.\n\n## Why Use It & Benefits\n\nTraditional git worktree management, whether manual or via OpenCode Desktop's UI, often introduces friction. Manual worktrees require multiple steps: creating the worktree, opening a terminal, navigating, and then starting OpenCode. While OpenCode Desktop offers a visual approach, it can limit automation.\n\nopencode-worktree addresses these challenges by providing a seamless, automated workflow:\n\n*   **Zero-Friction Isolation**: When an AI agent calls `worktree_create`, a new terminal automatically spawns with OpenCode pre-loaded, and files are synchronized. For `worktree_delete`, changes are committed, and the worktree is cleaned up automatically.\n*   **AI-Driven Development**: It's specifically designed to integrate with AI agents, allowing them to effortlessly create and manage isolated development sessions.\n*   **Automated Lifecycle Management**: Handles the entire worktree lifecycle, from creation to cleanup, reducing developer overhead.\n*   **Terminal Automation**: Automatically detects and integrates with various terminals across macOS, Linux, and Windows, including `cmux` and `tmux` for advanced multiplexing.\n*   **Configurable Synchronization**: Allows defining files to copy, directories to symlink, and patterns to exclude, ensuring each worktree has the necessary context.\n*   **Custom Hooks**: Supports `postCreate` and `preDelete` hooks for running custom commands, such as `pnpm install` or `docker compose up -d`.\n\nThis plugin transforms worktrees from a manual tool into an integral part of an automated development workflow, especially when paired with tools like [cmux](https://www.cmux.dev/).\n\n## Installation\n\nTo install `opencode-worktree`, you'll need [OCX](https://github.com/kdcokenny/ocx) installed. If you don't have OCX, follow the instructions on its repository first.\n\nOnce OCX is ready, add the plugin using the following command:\n\nbash\nocx add kdco/worktree --from https://registry.kdco.dev\n\n\nFor a more comprehensive experience, consider installing `kdco-workspace`, which bundles worktrees with background agents, planning tools, and notifications:\n\nbash\nocx add kdco/workspace --from https://registry.kdco.dev\n\n\n## Examples\n\nThe plugin introduces two primary tools for managing worktrees:\n\n### Creating a Worktree\n\nUse `worktree_create` to set up a new isolated environment. A new terminal will spawn with OpenCode ready.\n\nyaml\nworktree_create:\n  branch: \"feature/dark-mode\"\n  baseBranch: \"main\"  # optional, defaults to HEAD\n\n\nUpon execution, this command:\n1.  Creates a git worktree at `~/.local/share/opencode/worktree/<project-id>/feature/dark-mode`.\n2.  Synchronizes files based on your `.opencode/worktree.jsonc` configuration.\n3.  Runs any defined `postCreate` hooks (e.g., `pnpm install`).\n4.  Opens a new terminal window with OpenCode running within the worktree.\n\n### Deleting a Worktree\n\nUse `worktree_delete` to remove the current worktree. All changes are automatically committed before removal.\n\nyaml\nworktree_delete:\n  reason: \"Feature complete, merging to main\"\n\n\nWhen called, this command:\n1.  Executes any `preDelete` hooks (e.g., `docker compose down`).\n2.  Commits all pending changes with a snapshot message.\n3.  Removes the git worktree with `--force`.\n4.  Cleans up the session state.\n\n## Links\n\n*   **GitHub Repository**: [kdcokenny/opencode-worktree](https://github.com/kdcokenny/opencode-worktree){:target=\"_blank\"}\n*   **OpenCode**: [sst/opencode](https://github.com/sst/opencode){:target=\"_blank\"}\n*   **OCX (OpenCode eXtensions)**: [kdcokenny/ocx](https://github.com/kdcokenny/ocx){:target=\"_blank\"}\n*   **cmux**: [cmux.dev](https://www.cmux.dev/){:target=\"_blank\"}\n*   **Related Plugin - opencode-workspace**: [kdcokenny/opencode-workspace](https://github.com/kdcokenny/opencode-workspace){:target=\"_blank\"}\n*   **Related Plugin - opencode-background-agents**: [kdcokenny/opencode-background-agents](https://github.com/kdcokenny/opencode-background-agents){:target=\"_blank\"}\n*   **Related Plugin - opencode-notify**: [kdcokenny/opencode-notify](https://github.com/kdcokenny/opencode-notify){:target=\"_blank\"}","metrics":{"detailViews":1,"githubClicks":0},"dates":{"published":null,"modified":"2026-09-06T08:37:15.000Z"}}