Conversation
This comprehensive solution handles stale lock files from background Git operations (like Claude Code) that can interfere with auto-worktree operations. Features: - Process-based stale detection: Checks if lock file owner process exists - Automatic retry logic: Git operations retry up to 3 times on lock errors - New 'doctor' command: Detects and optionally removes stale locks - Startup integration: Warns about stale locks during initialization - Comprehensive tests: Full test coverage for all lock file functionality Components: 1. internal/git/lockfile.go - Lock file detection and management 2. internal/git/lockfile_test.go - Complete test suite 3. internal/git/executor.go - Retry logic for git operations 4. internal/cmd/commands.go - New RunDoctor command and startup integration 5. cmd/auto-worktree/main.go - CLI integration for doctor command 6. README.md - Documentation with troubleshooting section The implementation is conservative (warn-only by default), user-friendly, and designed to work seamlessly with AI agent workflows. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements comprehensive stale Git lock file detection and handling to address Issue #175, which describes how Claude Code's background Git operations can leave stale lock files that interfere with auto-worktree operations.
Changes
New Files
Modified Files
RunDoctorcommand and startup lock detectionFeatures
1. Lock File Detection
.gitfiles (worktree pointers) and directories2. Automatic Retry Logic
3. Doctor Command
4. Startup Integration
Implementation Details
Conservative Approach
Error Detection Pattern
Identifies lock file errors by checking for:
Test Coverage
Testing
All validation passed:
Documentation
Added comprehensive troubleshooting section to README.md covering:
Usage Examples
Check for stale locks:
Remove stale locks:
Related Issues
.git/index.lockfiles created by CC's background git operations block user git commands anthropics/claude-code#11005Test Plan
🤖 Generated with Claude Code