parallel-subagent-git-worktree-race

Detect and mitigate git branch corruption from parallel subagents sharing worktrees.

Updated Nov 18, 2025
One-click install
npx skills add https://github.com/cajias/claude-skills --skill parallel-subagent-git-worktree-race
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: parallel-subagent-git-worktree-race
Source: https://github.com/cajias/claude-skills/tree/main/plugins/git-workflow/skills/parallel-subagent-git-worktree-race
Command: npx skills add https://github.com/cajias/claude-skills --skill parallel-subagent-git-worktree-race

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps prevent and recover from git corruption caused by multiple Claude Code subagents mutating branches in what was supposed to be isolated worktrees, but actually share the same HEAD and index.

Core Features & Use Cases

  • Isolation Verification: Checks whether an agent truly has a separate worktree instead of a silent fallback to the main checkout.
  • Race Detection and Recovery: Identifies symptoms such as branch swaps, unexpected rebases, reflog drift, and shared-tree corruption, then guides a safe freeze-and-serialize recovery.
  • Safe Parallel Workflow Guardrails: Recommends a single-owner model for destructive git operations and a ref recheck pattern before each mutation.
  • Use Case: Useful when two or more agents are rebasing, merging, committing, or resetting different branches at the same time and one of them unexpectedly affects the other.

Quick Start

Use this skill when parallel Claude Code agents are mutating git in suspected shared worktrees, and ask it to verify isolation, freeze all git activity if needed, and guide a safe single-owner recovery.

Frequently Asked Questions about parallel-subagent-git-worktree-race

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

FAQPage Schema
Why do my git branches get corrupted when running parallel Claude Code agents?

Git branch corruption occurs when parallel Claude Code subagents share one working tree, causing concurrent rebase, merge, or commit operations to mutate the same HEAD and index unexpectedly.

How do I check if a Claude Code agent has true git worktree isolation?

You can verify git worktree isolation by checking whether an agent truly has a separate worktree instead of a silent fallback to the main checkout, ensuring no shared HEAD or index state.

How do I recover from a git race condition caused by parallel agents rebasing?

To recover from a git race condition, freeze all git activity immediately, then follow a safe single-owner recovery process that includes serialized operations and ref revalidation before destructive mutations.

What is the best way to prevent git branch corruption with parallel subagents?

The best way to prevent git branch corruption is enforcing a single-owner model for destructive git operations and applying a ref recheck pattern before each mutation in parallel Claude Code workflows.

When should I not run concurrent git operations across multiple agents?

You should not run concurrent git operations across multiple agents if worktree isolation fails, as shared HEAD and index state leads to reflog drift, branch swaps, and unexpected rebases that corrupt branch integrity.