# Concurrent session checkout clobbers shared worktree

> Concurrent session checkout clobbers shared worktree is an open-source agent skill for developer tools. Recovers uncommitted work when another session switches branches in your shared repo. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/wan-huiyan/agent-traffic-control/tree/main/plugins/agent-traffic-control/skills/concurrent-session-checkout-clobbers-shared-worktree
- **Repository:** https://github.com/wan-huiyan/agent-traffic-control
- **GitHub stars:** 5
- **License:** MIT
- **Skill name:** concurrent-session-checkout-clobbers-shared-worktree
- **Collection:** https://github.com/wan-huiyan/agent-traffic-control
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-04

## About

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`.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/wan-huiyan/agent-traffic-control/tree/HEAD/plugins/agent-traffic-control/skills/concurrent-session-checkout-clobbers-shared-worktree)
- [License: MIT](https://github.com/wan-huiyan/agent-traffic-control/tree/HEAD/plugins/agent-traffic-control/skills/concurrent-session-checkout-clobbers-shared-worktree)

## Features

- **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

## Install

### Claude Code

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):

```sh
/plugin marketplace add wan-huiyan/agent-traffic-control
/plugin install agent-traffic-control@wan-huiyan-agent-traffic-control
```

Or copy only this skill to `~/.claude/skills/concurrent-session-checkout-clobbers-shared-worktree`:

```sh
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.

### Codex

Copy the skill folder to `~/.agents/skills/concurrent-session-checkout-clobbers-shared-worktree` to use it in every repository:

```sh
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.

### Cursor

Copy the skill folder to `~/.cursor/skills/concurrent-session-checkout-clobbers-shared-worktree` to use it in every project:

```sh
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.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/wan-huiyan/agent-traffic-control.git --path plugins/agent-traffic-control/skills/concurrent-session-checkout-clobbers-shared-worktree
```

Or copy the folder to `~/.gemini/skills/concurrent-session-checkout-clobbers-shared-worktree` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/concurrent-session-checkout-clobbers-shared-worktree`:

```sh
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.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git
```

Then 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.

## 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.

## Alternatives

- [Cross worktree spec handoff via checkout paths](https://ai-powered.com/skills/cross-worktree-spec-handoff-via-checkout-paths): Cross worktree spec handoff via checkout paths is an open-source agent skill for developer tools.
- [Harness read write base repo path in worktree stale tree](https://ai-powered.com/skills/harness-read-write-base-repo-path-in-worktree-stale-tree): Harness read write base repo path in worktree stale tree is an open-source agent skill for developer tools.
- [Git worktree](https://ai-powered.com/skills/git-worktree): Git worktree is an open-source agent skill for developer tools.
- [Dispatched bash agent git checkout clobbers uncommitted edit](https://ai-powered.com/skills/dispatched-bash-agent-git-checkout-clobbers-uncommitted-edit): Dispatched bash agent git checkout clobbers uncommitted edit is an open-source agent skill for developer tools.
- [Injected claude md is the worktrees copy not mains](https://ai-powered.com/skills/injected-claude-md-is-the-worktrees-copy-not-mains): Injected claude md is the worktrees copy not mains is an open-source agent skill for developer tools.
- [Git auto maintenance recurring worktree index lock](https://ai-powered.com/skills/git-auto-maintenance-recurring-worktree-index-lock): Git auto maintenance recurring worktree index lock is an open-source agent skill for developer tools.
- [Credit stall mid orchestration revive collision](https://ai-powered.com/skills/credit-stall-mid-orchestration-revive-collision): Credit stall mid orchestration revive collision is an open-source agent skill for developer tools.
- [Main bash cwd persists nested worktree](https://ai-powered.com/skills/main-bash-cwd-persists-nested-worktree): Main bash cwd persists nested worktree is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/concurrent-session-checkout-clobbers-shared-worktree
