Version: v1.2.3 | Status: Active | Last Updated: March 2026
When multiple Claude Code instances, CI runners, or AI agents operate concurrently on this repository, git .git/index.lock conflicts are the primary failure mode. This guide documents the coordination protocol established in CLAUDE.md.
Git uses .git/index.lock as a mutex for all staging operations. If two processes attempt git add simultaneously, the second fails:
fatal: Unable to create '.git/index.lock': File exists.
Pre-commit hooks on this repo run across 900+ files. A single commit can hold the lock for 20+ minutes, blocking all parallel agents.
Pre-commit hooks take 20+ minutes on this repo. Always bypass for automated/agent commits:
git add -A && git commit --no-verify -m "message"Always chain git add and git commit in one shell command to minimize lock hold time:
# CORRECT β acquires lock once, releases atomically
git add -A && git commit --no-verify -m "msg"
# WRONG β holds index state open between commands (race window)
git add -A
git commit -m "msg"ls .git/index.lock 2>/dev/null && echo "LOCK EXISTS β wait or investigate" || echo "clear"Only remove the lock if no git process is actually running:
# Step 1: Check for running git processes
ps aux | grep git | grep -v grep
# Step 2: If none found and lock is >60s old β safe to remove
rm -f .git/index.lockEach git worktree gets its own .git/worktrees/<name>/ with no shared lock:
# Create an isolated worktree for parallel agent work
git worktree add .worktrees/agent-feature -b agent-feature
cd .worktrees/agent-feature
# This agent can git add/commit freely β no lock contentionSee .agent/workflows/codomyrmexWorktree.md for the managed creation workflow.
GitHub rejects files over 100MB. Check before committing:
find . -not -path './.git/*' -size +50M| Operation | Lock needed? | Safe in parallel? |
|---|---|---|
git status |
No | Yes |
git log |
No | Yes |
git diff |
No | Yes |
git show |
No | Yes |
git add |
Yes | No |
git commit |
Yes | No |
git push |
No (index) | Usually yes |
git fetch |
No (index) | Yes |
# Prune stale worktree metadata
git worktree prune
# Remove agent worktree branches after merging
git branch --list 'worktree-agent-*' | xargs git branch -D 2>/dev/null- Parent: Development
- Root: docs/
- CLAUDE.md (canonical rules): ../../CLAUDE.md
- Worktree Workflow: ../../.agent/workflows/codomyrmexWorktree.md