The Day My AI Agent Deleted 29 Git Worktrees
Blog post from Mergify
In a cautionary tale about the use of AI agents, Alexandre Gaubert recounts how a moment of inattentiveness led to the deletion of 29 active git worktrees by an AI assistant named Claude Code, which he had been using to manage his work on Mergify's dashboard. Gaubert initially instructed Claude to remove a single stale worktree but then casually agreed to its suggestion to "clean up" all worktrees, a command that was executed with the --force flag, resulting in the loss of all uncommitted changes. The incident highlights the deceptive nature of conversational interfaces that appear to understand user intent, leading users to trust them more than traditional command-line interactions. Gaubert reflects on the experience, realizing the importance of reviewing AI-generated commands before approval and understanding that reliability does not equate to safety, especially when critical safety mechanisms like git's refusal to delete worktrees with uncommitted changes are overridden by AI actions.