concurrent-session-checkout-clobbers-shared-worktree

Detects foreign git checkouts in shared working directories and recovers work via isolated worktrees.

3|Updated May 8, 2026
One-click install
npx skills add https://github.com/wan-huiyan/agent-traffic-control --skill concurrent-session-checkout-clobbers-shared-worktree-wan-huiyan
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: concurrent-session-checkout-clobbers-shared-worktree
Source: https://github.com/wan-huiyan/agent-traffic-control/tree/main/plugins/agent-traffic-control/skills/concurrent-session-checkout-clobbers-shared-worktree
Command: npx skills add https://github.com/wan-huiyan/agent-traffic-control --skill concurrent-session-checkout-clobbers-shared-worktree-wan-huiyan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When two Claude Code sessions (or any two agents/people) share the same working directory, one session's git checkout or git switch flips the branch for the entire working tree, silently reverting or clobbering the other session's uncommitted edits. This Skill helps you detect that collision and recover your work without losing anything. ## Core Features & Use Cases - Collision Detection: Confirms a foreign checkout using git reflog (looking for checkout: moving from X to Y entries you never ran), git branch --show-current, and unexpected git status output. - Worktree-Based Recovery: Guides you through creating a git worktree for your existing branch, migrating uncommitted and clobbered edits into it, and cleaning your pollution out of the shared directory. - Stale Lock Handling: Diagnoses orphaned index.lock files that block both concurrent sessions, with age and process checks before safe removal. - Use Case: Your app/config.py edit vanishes after a parallel session runs git checkout feature/settings-page in the shared repo. This Skill walks you through confirming the reflog entry, spinning up git worktree add ../config-worktree feature/config-validation, re-applying the lost edit, and continuing work in isolation. ## Quick Start Ask the AI to check whether a parallel session switched branches underneath you and to recover your uncommitted work into an isolated git worktree.

Frequently Asked Questions about concurrent-session-checkout-clobbers-shared-worktree

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I recover uncommitted changes lost after a git checkout by another session?▼

Confirm the foreign checkout with `git reflog`, then create a worktree for your branch with `git worktree add <path> <branch>`. Copy untracked files over, re-apply tracked edits from conversation context, and clean your changes out of the shared directory.

How can I tell if another session switched branches in my working directory?▼

Run `git reflog` and look for a `checkout: moving from X to Y` entry you never performed — this is the decisive signal. Supporting symptoms include `git branch --show-current` showing an unexpected branch and unfamiliar files in `git status`.

Why does git commit fail with 'Unable to create index.lock: File exists'?▼

In a shared worktree this is usually an orphaned lock from a killed git process, not an active operation. Check the lock's age and confirm no git process is running with `ps aux`, then remove it with `rm -f` and retry the commit.

Does git checkout affect all sessions sharing the same working directory?▼

Yes. `git checkout` and `git switch` change HEAD for the entire working tree, not per-session. Uncommitted edits may be carried across, reverted, or left in a half-state, while untracked files risk being swept into the other session's next commit.

When should I use a git worktree instead of a shared directory?▼

Use a worktree whenever multiple sessions or agents work in parallel — shared-directory work is only safe for a single session. Create the worktree before starting feature work, place it outside the repo, and commit early since committed work cannot be clobbered.