Finishing a Development Branch
obra/superpowers
Walks the last step of a branch: confirm tests pass, detect the git environment, ask how to integrate, carry out your choice and clean up the worktree.
Git worktree support in sidecar: worktree detection, switching between worktrees, worktree state management, and plugin reinitialization.
$ npx skills add marcus/sidecar --skill worktree-switching -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install marcus/sidecar worktree-switching --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/marcus/sidecar.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/worktree-switching .claude/skills/worktree-switching && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "worktree-switching" agent skill from https://github.com/marcus/sidecar/tree/main/.claude/skills/worktree-switching into .claude/skills/worktree-switching/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "worktree-switching", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/marcus/sidecar/tree/main/.claude/skills/worktree-switchingType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add marcus/sidecar --skill worktree-switching -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install marcus/sidecar worktree-switching --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/marcus/sidecar.git skills-src && mkdir -p .agents/skills && cp -r skills-src/.claude/skills/worktree-switching .agents/skills/worktree-switching && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "worktree-switching" agent skill from https://github.com/marcus/sidecar/tree/main/.claude/skills/worktree-switching into .agents/skills/worktree-switching/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "worktree-switching", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add marcus/sidecar --skill worktree-switching -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install marcus/sidecar worktree-switching --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/marcus/sidecar.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/.claude/skills/worktree-switching .cursor/skills/worktree-switching && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "worktree-switching" agent skill from https://github.com/marcus/sidecar/tree/main/.claude/skills/worktree-switching into .cursor/skills/worktree-switching/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "worktree-switching", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/marcus/sidecar.git --path .claude/skills/worktree-switching--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add marcus/sidecar --skill worktree-switching -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install marcus/sidecar worktree-switching --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/marcus/sidecar.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/.claude/skills/worktree-switching .gemini/skills/worktree-switching && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "worktree-switching" agent skill from https://github.com/marcus/sidecar/tree/main/.claude/skills/worktree-switching into .gemini/skills/worktree-switching/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "worktree-switching", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install marcus/sidecar worktree-switchingInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add marcus/sidecar --skill worktree-switching -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/marcus/sidecar.git skills-src && mkdir -p .github/skills && cp -r skills-src/.claude/skills/worktree-switching .github/skills/worktree-switching && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "worktree-switching" agent skill from https://github.com/marcus/sidecar/tree/main/.claude/skills/worktree-switching into .github/skills/worktree-switching/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "worktree-switching", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add marcus/sidecar --skill worktree-switching -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install marcus/sidecar worktree-switching --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/marcus/sidecar.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/.claude/skills/worktree-switching .opencode/skills/worktree-switching && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "worktree-switching" agent skill from https://github.com/marcus/sidecar/tree/main/.claude/skills/worktree-switching into .opencode/skills/worktree-switching/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "worktree-switching", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
worktree-switchingGit worktree support in sidecar: worktree detection, switching between worktrees, worktree state management, and plugin reinitialization.
Worktree Switching is an agent skill from marcus/sidecar. 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.
Its SKILL.md is about 1.6k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
It sits in Development, covering Git worktrees. It works with Git. The repository describes itself as: Use sidecar next to CLI agents for diffs, file trees, conversation history, and task management with td. The licence is MIT.
4 steps, taken from the first numbered list in SKILL.md.
Read from SKILL.md and the folder at commit 3792a4e. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Shell commands in SKILL.md call:
gitFrom the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Worktree Switching loads about 1.6k tokens when it runs. Until then it costs about 97 tokens; SKILL.md has 448 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from marcus/sidecar at commit 3792a4e, republished under its MIT licence (© marcus). 448 words, ~1,594 tokens.
.claude/skills/worktree-switching/SKILL.md (or your agent's skills folder).Sidecar supports seamless switching between git worktrees. When switching:
Worktree switching uses Model.switchProject() in internal/app/model.go:
m.switchProject(worktreePath)This triggers in order:
m.ui.WorkDir to new pathregistry.Reinit(newWorkDir) -- stops all plugins, updates context, reinits allWindowSizeMsg to all plugins for layout recalculationRegistry.Reinit() in internal/plugin/registry.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
}Your plugin will be stopped and reinitialized on worktree switch. Ensure:
Stop() releases all resources (watchers, goroutines, channels)Init(ctx) resets state and reads from new ctx.WorkDirStart() kicks off fresh async work for the new contextfunc (p *Plugin) Stop() {
p.stopOnce.Do(func() {
if p.watcher != nil {
p.watcher.Close()
}
close(p.done)
})
}
func (p *Plugin) Init(ctx *plugin.Context) error {
p.ctx = ctx
p.items = nil // Reset state
p.stopOnce = sync.Once{} // Reset stop guard
p.done = make(chan struct{})
return nil
}After reinitialization, the app sends tea.WindowSizeMsg. Handle it in Update:
case tea.WindowSizeMsg:
p.width = msg.Width
p.height = msg.Height
return p, nilUse internal/state to save/restore preferences keyed by WorkDir:
// Restore state in Init or Start
saved := state.GetMyPluginState(p.ctx.WorkDir)
if saved.Selection != "" {
p.selection = saved.Selection
}
// Save state on user action
state.SetMyPluginState(p.ctx.WorkDir, MyPluginState{
Selection: p.selection,
})Add state struct and accessors following internal/state/state.go:
type MyPluginState struct {
Selection string `json:"selection,omitempty"`
}
func GetMyPluginState(workdir string) MyPluginState {
mu.RLock()
defer mu.RUnlock()
if current == nil || current.MyPlugin == nil {
return MyPluginState{}
}
return current.MyPlugin[workdir]
}State is saved to ~/.config/sidecar/state.json keyed by absolute WorkDir path. State is automatically per-worktree when you pass p.ctx.WorkDir.
When a worktree is deleted externally, plugins should detect this and request fallback to main.
Defined in internal/app/commands.go:
SwitchWorktreeMsg{WorktreePath} -- requests switching to a specific worktreeSwitchWorktree(path) tea.Cmd -- helper to create the aboveSwitchToMainWorktreeMsg{MainWorktreePath} -- requests fallback to main worktreeSwitchToMainWorktree(mainPath) tea.Cmd -- helper to create the above1. Define plugin-local message (internal/plugins/workspace/worktree.go):
type WorkDirDeletedMsg struct {
MainWorktreePath string
}2. Detect deletion in refresh command:
func (p *Plugin) refreshWorktrees() tea.Cmd {
workDir := p.ctx.WorkDir
return func() tea.Msg {
if _, err := os.Stat(workDir); os.IsNotExist(err) {
mainPath := findMainWorktreeFromDeleted(workDir)
if mainPath != "" {
return WorkDirDeletedMsg{MainWorktreePath: mainPath}
}
}
return RefreshDoneMsg{Worktrees: worktrees, Err: err}
}
}3. Handle message, return app command:
case WorkDirDeletedMsg:
p.refreshing = false
if msg.MainWorktreePath != "" {
return p, app.SwitchToMainWorktree(msg.MainWorktreePath)
}
return p, nilinternal/app/git.go provides:
| Function | Purpose |
|---|---|
GetWorktrees(workDir) | List all worktrees for the repo |
GetMainWorktreePath(workDir) | Get path to main worktree |
WorktreeNameForPath(workDir, path) | Derive display name for a worktree |
GetAllRelatedPaths(workDir) | Get all paths sharing the same repo |
| Key | Purpose |
|---|---|
ActivePlugin | Which plugin tab was focused |
FileBrowser | File browser selections and view state |
Workspace | Workspace/shell selections |
Init() -- do not carry over stale data from previous worktreesync.Once for Stop() -- prevents double-close panics during rapid switchingStart() non-blocking -- return commands that do async workgit worktree add ../my-feature feature-branch© marcus, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in .claude/skills/worktree-switching of marcus/sidecar.
Open the folder on GitHubat commit 3792a4e
Worktree Switching next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Worktree Switching this skillmarcus/sidecar | 1.1k | — | ~1.6k | Automated safety check: Pass | MIT | |
| Finishing a Development Branchobra/superpowers | 296k | 5 repos | ~1.9k | Automated safety check: Pass | MIT | |
| Finishing A Development Branchfarm-fe/farm | 5.6k | 34 repos | ~1.8k | Automated safety check: Pass | MIT | |
| Git Worktree Cleanuplobehub/lobehub | 83k | — | ~2.8k | Automated safety check: Pass | Custom licence | |
| Pre-Release PR Triagejamiepine/voicebox | 57k | — | ~3.1k | Automated safety check: Pass | MIT | |
| Ccmanager Configkbwo/ccmanager | 1.3k | — | ~1.5k | Automated safety check: Pass | MIT |
obra/superpowers
Walks the last step of a branch: confirm tests pass, detect the git environment, ask how to integrate, carry out your choice and clean up the worktree.
farm-fe/farm
A skill your agent uses when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for…
lobehub/lobehub
Audits stale Git worktrees and branches with a bundled script, classifies each one, and deletes only after you approve the exact candidates.
jamiepine/voicebox
Sorts a backlog of open pull requests into must-merge, candidate, superseded and deferred, writes a triage doc and works the merge loop before a release.
kbwo/ccmanager
Set up, review, or repair a CCManager config — .ccmanager.json at a git repository root, or the global ~/.config/ccmanager/config.json.
CapSoftware/Cap
Builds a Cap feature in an isolated Git worktree with disposable dev resources, verification, a recorded demo and a neutral pull request, started with /building.
marcus/sidecar
Create conversation adapters for importing AI chat history from different tools (Claude Code, Cursor, Warp, Codex, etc.).
marcus/sidecar
Create declarative modals using the modal library API. An agent skill from marcus/sidecar.
marcus/sidecar
Create new sidecar plugins implementing the plugin.Plugin interface, rendering views with Bubble Tea, handling keyboard input via keymap contexts, and integrating with the app shell (footer hints…
marcus/sidecar
Project switching implementation in sidecar: project discovery, state management, UI flow, modal rendering, filtering, theme preview, and plugin reinitialization.
marcus/sidecar
Interactive shell/TTY integration with tmux session management, shell command execution, control-mode output capture with polling fallback, native cursor rendering, lazy scrollback, selection, paste…
marcus/sidecar
Writing and maintaining the Sidecar Docusaurus documentation site, including page structure, doc authoring, blog posts, styling, images, and deployment workflow.
Works with
Categories
Git worktree support in sidecar: worktree detection, switching between worktrees, worktree state management, and plugin reinitialization. Worktree Switching is an agent skill from marcus/sidecar. Git worktree support in sidecar: worktree detection, switching between worktrees, worktree state management, and plugin reinitialization.
Worktree Switching fits situations like: working on git worktree features; worktree-related functionality.
Run `npx skills add marcus/sidecar --skill worktree-switching -a claude-code`. Or copy the skill folder (.claude/skills/worktree-switching in marcus/sidecar) into .claude/skills/worktree-switching in your project. Claude Code loads it when a task matches its description.
Run `npx skills add marcus/sidecar --skill worktree-switching -a codex`. Or copy the skill folder (.claude/skills/worktree-switching in marcus/sidecar) into .agents/skills/worktree-switching in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add marcus/sidecar --skill worktree-switching -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/worktree-switching, .gemini/skills/worktree-switching, .github/skills/worktree-switching and .opencode/skills/worktree-switching in your project.
Going by SKILL.md and its folder, Worktree Switching needs the command-line tools its instructions call (git).
SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Worktree Switching is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 1.6k tokens (SKILL.md is roughly 6.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Worktree Switching: Finishing a Development Branch (obra/superpowers, 296k stars), Finishing A Development Branch (farm-fe/farm, 5.6k stars), Git Worktree Cleanup (lobehub/lobehub, 83k stars) and Pre-Release PR Triage (jamiepine/voicebox, 57k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
marcus (a GitHub user) maintains it in marcus/sidecar, which has 1,085 GitHub stars. The repository holds 19 skills in this directory. The repository was last updated on October 5, 2026.
Source: marcus/sidecar on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.