worktree-switching

Featured

Git worktree support in sidecar: worktree detection, switching between worktrees, worktree state management, and plugin reinitialization. Covers the full lifecycle of worktree context switching including registry reinit, per-worktree state persistence, deleted worktree detection and fallback. Use when working on git worktree features or worktree-related functionality.

AI & Automation 1,079 stars 83 forks Updated 3 days ago MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Worktree Switching Sidecar supports seamless switching between git worktrees. When switching: 1. All plugins are stopped, reinitialized with the new WorkDir, and restarted 2. Per-worktree state (active plugin, sidebar selections) is saved/restored 3. Project-specific themes are applied 4. If a worktree is deleted externally, sidecar gracefully falls back to main ## Core Mechanism ### Project Switching Worktree switching uses `Model.switchProject()` in `internal/app/model.go`: ```go m.switchProject(worktreePath) ``` This triggers in order: 1. Save active plugin for old WorkDir 2. Update `m.ui.WorkDir` to new path 3. Apply resolved theme for new path 4. Call `registry.Reinit(newWorkDir)` -- stops all plugins, updates context, reinits all 5. Send `WindowSizeMsg` to all plugins for layout recalculation 6. Restore saved active plugin for new WorkDir 7. Show toast notification ### Registry Reinitialization `Registry.Reinit()` in `internal/plugin/registry.go`: ```go func (r *Registry) Reinit(newWorkDir string) []tea.Cmd { // Stop all plugins (reverse order) for i := len(r.plugins) - 1; i >= 0; i-- { r.safeStop(r.plugins[i]) } // Update context r.ctx.WorkDir = newWorkDir // Reinit all plugins for _, p := range r.plugins { r.safeInit(p) } // Collect and return start commands return startCmds } ``` ## Plugin Responsibilities on Worktree Switch ### Handle Reinitialization Cleanly Your plugin will be stopped and reinit...

Details

Author
marcus
Repository
marcus/sidecar
Created
9 months ago
Last Updated
3 days ago
Language
Go
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Listed

worktrees

Manage .oh/worktrees/ lifecycle: create worktree, list worktrees, remove worktree, clean worktrees, stale worktrees audit, isolate work, project clone. TRIGGER when: any git worktree operation, branch isolation needed, stale worktrees review, project clone under .oh/worktrees/project/ (e.g. "clone <owner>/<repo> to worktrees", "add <repo> to .oh/worktrees", "clone this repo into worktrees"), worktree cleanup. A leading-slash harness dir like "/worktrees" still means the repo-relative .oh/worktrees/ — never a literal filesystem-root path.

40 Updated today
mifunedev
AI & Automation Listed

project-worktrees

Use when creating, entering, debugging or removing a git worktree under `.worktrees/`, when a worktree URL returns 404 or 502, or when writing tooling that resolves a worktree's hostname, database or container name.

2 Updated today
ubermuda
AI & Automation Solid

worktrunk

Use this skill when the user asks about Worktrunk (wt), git worktree management, running parallel AI agents with worktrees, setting up wt hooks, configuring wt.toml, using `wt switch`, `wt list`, `wt merge`, `wt remove`, `wt step`, LLM commit messages, or integrating Worktrunk with your AI agent. Also trigger when the user wants to run multiple AI agent sessions in parallel across isolated git branches, or automate dev server / database / dependency setup per worktree. Always use this skill for any question involving the `wt` CLI, worktree lifecycle automation, or the worktrunk plugin.

48 Updated today
jjmartres