
Concurrent session checkout clobbers shared worktree
Recovers uncommitted work when another session switches branches in your shared repo
Concurrent session checkout clobbers shared worktree is an open-source agent skill for developer tools. It is available on Claude Code.
- Scripts
- None
- Platforms
- Claude Code
- GitHub stars
- 5
- Last commit
- License
- MIT
- Listing updated
Similar skills
About Concurrent session checkout clobbers shared worktree
This skill covers the case where two Claude Code sessions, or an agent and a person, work in the same clone and one of them runs git checkout or git switch, changing HEAD for the whole working tree. It explains how to confirm the collision from the reflog and branch state, and how to rescue edits that were reverted or left in a half-state.
The recovery path moves the work into an isolated git worktree on the original branch. The steps cover re-creating the worktree, copying untracked files across, reapplying lost tracked-file edits, cleaning the stray changes out of the shared directory, and committing early so later checkouts cannot clobber the work. It also includes a diagnostic for a stale git index.lock that blocks every session sharing a directory, with checks for lock age and running git processes before removal.
The skill relies on standard git commands such as reflog, worktree, status and log, and it references a native EnterWorktree tool for switching the session into the new worktree. It is written for Claude Code sessions and assumes a single shared clone.
When your agent uses it
A second Claude Code session (or agent/person) sharing the same working directory runs `git checkout`/`git switch`, flipping the branch for the whole working tree underneath your session and clobbering your uncommitted work. Use when: (1) a file you just edited has silently reverted — often with a "file was modified, either by the user or by a linter" system reminder, (2) `git branch --show-current` shows a branch you didn't switch to, (3) `git reflog` shows a `checkout: moving from X to Y` you never ran, (4) unfamiliar files/changes appear in `git status`. Covers detecting the collision and recovering via an isolated git worktree. Every trigger above is a symptom, so this skill fires only once damage exists; the pre-dispatch check that prevents the fan-out case is a separate skill, `pre-dispatch-agent-isolation-parameter-not-prompt`.
From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.
What it can access
From a static check of its 1 file (7 KB) on GitHub on 4 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.
Check another skill before you install it.
Install
This skill ships in the agent-traffic-control plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):
/plugin marketplace add wan-huiyan/agent-traffic-control
/plugin install agent-traffic-control@wan-huiyan-agent-traffic-controlOr copy only this skill to ~/.claude/skills/concurrent-session-checkout-clobbers-shared-worktree:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/concurrent-session-checkout-clobbers-shared-worktree &&
cp -R "$tmp/plugins/agent-traffic-control/skills/concurrent-session-checkout-clobbers-shared-worktree" ~/.claude/skills/concurrent-session-checkout-clobbers-shared-worktree &&
rm -rf "$tmp"For one project only, put the folder in .claude/skills/concurrent-session-checkout-clobbers-shared-worktree inside it instead.
Copy the skill folder to ~/.agents/skills/concurrent-session-checkout-clobbers-shared-worktree to use it in every repository:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/concurrent-session-checkout-clobbers-shared-worktree &&
cp -R "$tmp/plugins/agent-traffic-control/skills/concurrent-session-checkout-clobbers-shared-worktree" ~/.agents/skills/concurrent-session-checkout-clobbers-shared-worktree &&
rm -rf "$tmp"For one repository only, put the folder in .agents/skills/concurrent-session-checkout-clobbers-shared-worktree inside it instead.
Copy the skill folder to ~/.cursor/skills/concurrent-session-checkout-clobbers-shared-worktree to use it in every project:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/concurrent-session-checkout-clobbers-shared-worktree &&
cp -R "$tmp/plugins/agent-traffic-control/skills/concurrent-session-checkout-clobbers-shared-worktree" ~/.cursor/skills/concurrent-session-checkout-clobbers-shared-worktree &&
rm -rf "$tmp"For one project only, put the folder in .cursor/skills/concurrent-session-checkout-clobbers-shared-worktree inside it instead.
Run in a terminal (add --scope workspace to install it for the current workspace only):
gemini skills install https://github.com/wan-huiyan/agent-traffic-control.git --path plugins/agent-traffic-control/skills/concurrent-session-checkout-clobbers-shared-worktreeOr copy the folder to ~/.gemini/skills/concurrent-session-checkout-clobbers-shared-worktree yourself.
For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/concurrent-session-checkout-clobbers-shared-worktree:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/concurrent-session-checkout-clobbers-shared-worktree &&
cp -R "$tmp/plugins/agent-traffic-control/skills/concurrent-session-checkout-clobbers-shared-worktree" ~/.copilot/skills/concurrent-session-checkout-clobbers-shared-worktree &&
rm -rf "$tmp"For one project only, put the folder in .github/skills/concurrent-session-checkout-clobbers-shared-worktree inside it instead.
Get the folder:
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.gitThen copy agent-traffic-control/plugins/agent-traffic-control/skills/concurrent-session-checkout-clobbers-shared-worktree into your agent's skills folder as concurrent-session-checkout-clobbers-shared-worktree. Agents that support SKILL.md read one folder per skill.
What it does
- Collision detection
- Identifies a foreign checkout from git reflog, the current branch and unexpected status changes.
- Worktree recovery
- Moves your branch into a separate git worktree placed outside the repository.
- Uncommitted work migration
- Copies untracked files and reapplies tracked edits that a branch switch reverted.
- Shared directory cleanup
- Restores modified tracked files and removes stray files so the other session gets its tree back.
- Stale lock diagnosis
- Checks lock file age and active git processes before removing an orphaned index.lock.
- Commit-early guidance
- Recommends committing to the feature branch often so committed work survives foreign checkouts.
Good for
- Recover an edit that disappeared after another session switched branches
- Find out which session changed the branch using git reflog
- Move my in-progress work into a separate worktree
- Clear a stale index.lock that blocks commits in a shared directory
- Check whether my uncommitted changes are still safe on my branch
Concurrent session checkout clobbers shared worktree FAQ
What does Concurrent session checkout clobbers shared worktree need to run?
It relies on git in a shared clone and, for the switch step, a native EnterWorktree tool to enter the new worktree. It is a single markdown file with no scripts.
Does Concurrent session checkout clobbers shared worktree prevent branch collisions from happening?
No. It covers recovery after damage. The prevention step for parallel agents is described in a separate skill, pre-dispatch-agent-isolation-parameter-not-prompt.
Will my committed work be lost if another session switches branches?
The skill states that commits survive a checkout and only uncommitted work is at risk.
When does the skill trigger?
Its description lists symptoms such as a silently reverted file, an unexpected branch, a foreign checkout in the reflog, or unfamiliar changes in git status.
How do I install Concurrent session checkout clobbers shared worktree in Claude Code?
Copy the skill folder from GitHub to ~/.claude/skills/concurrent-session-checkout-clobbers-shared-worktree to use it in all your projects, or to .claude/skills/concurrent-session-checkout-clobbers-shared-worktree in one project. Or install the agent-traffic-control plugin, which includes it: /plugin marketplace add wan-huiyan/agent-traffic-control, then /plugin install agent-traffic-control@wan-huiyan-agent-traffic-control.
Does Concurrent session checkout clobbers shared worktree run scripts?
No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.
Which AI agents can use Concurrent session checkout clobbers shared worktree?
Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.
What are the best alternatives to Concurrent session checkout clobbers shared worktree?
The closest alternatives to Concurrent session checkout clobbers shared worktree are Cross worktree spec handoff via checkout paths, Harness read write base repo path in worktree stale tree, Git worktree, Dispatched bash agent git checkout clobbers uncommitted edit and Injected claude md is the worktrees copy not mains.
Where this comes from
- Description: from the skill's own SKILL.md.
More from wan-huiyan/agent-traffic-control

Teaches agents to refuse a flawed instruction only with measured evidence attached
- Open source
- 5 GitHub stars
- Developer tools

Catches silent deletions when a subagent edits large files with repeated blocks
- Open source
- 5 GitHub stars
- Developer tools

Holds a pull request from merging by stopping its agent, disarming auto-merge, then
- Open source
- 5 GitHub stars
- Developer tools

Checks that a batch of pull requests does not cite file paths that will never exist
- Open source
- 5 GitHub stars
- Developer tools

Checks whether a pull request truly landed by comparing file content, not commit subjects
- Open source
- 5 GitHub stars
- Developer tools

Checks a branch for stale-base changes that would silently undo newer main work
- Open source
- 5 GitHub stars
- Developer tools

