# Git Worktree Agent

> Safely manage isolated Git worktrees for parallel development, branch integration, and risk-free repository cleanup.

Git Worktree Agent is a free AI agent skill on Agensi by Lutian, in DevOps & Cloud. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Lutian](https://www.agensi.io/creators/lutian)
- Category: [DevOps & Cloud](https://www.agensi.io/skills/devops-cloud)
- Version: 1.0
- Last updated: 2026-11-03
- Security: scan passed (2026-10-17); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/git-worktree-agent
- Tags: git, automation-engine, devops, workflow-automation, code-review

## About this skill

Managing parallel features in a single repository often leads to messy stashes or risky branch switching that breaks build artifacts. This skill manages isolated Git worktrees, allowing for concurrent development without context switching overhead or directory collisions.

### What it does
- **Parallel workspace management** isolates features or bug fixes into dedicated directories to avoid `git stash` cycles.
- **Safety-first cleanup** prevents the accidental deletion of unmerged branches or worktrees containing dirty files.
- **Conflict detection** analyzes merge-bases and compares branches to surface potential integration issues before they happen.
- **Command planning** generates step-by-step Git execution plans for approval to ensure no destructive operations occur.
- **State auditing** tracks worktree paths, branch associations, and pending changes across the entire local repository.

### How it works
1. **Inspection** of the current repository state including `git status`, branch list, and existing worktree paths.
2. **Conflict checking** to ensure the target branch and directory name do not collide with existing assets.
3. **Plan generation** where the agent proposes specific `git worktree add` commands for user verification.
4. **Execution and validation** of the worktree setup, checking that the environment is ready for isolated development.
5. **Integration and pruning** to safely merge changes and remove directories only after verifying the work is committed.

### Frameworks & tools
This skill works with any standard Git installation. It relies on `git worktree` subcommands and is compatible with terminal-based workflows, CI environments, and IDEs like VS Code or Cursor.

### Why this beats prompting it yourself
Generic prompts often suggest risky flags like `--force` or forget to check for untracked files before pruning. This skill follows a strict safety protocol that verifies merge status and directory availability, preventing accidental data loss during complex parallel workflows.

### Use cases
- Manage a hotfix in a separate directory while keeping a long-running feature build intact.
- Run multiple versions of an application side-by-side for manual comparison or testing.
- Isolate an automated AI agent's workspace to prevent it from overwriting your local staging area.
- Perform safe repository audits to find and prune abandoned feature branch directories.

### Known limitations
Requires Git 2.5 or newer. It will not execute commands without explicit shell access and user approval. It does not manage submodules unless specifically instructed.

## Requires

- Git

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Git Worktree Agent skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### How does this agent prevent me from accidentally deleting uncommitted work?

Unlike generic prompts that might use risky force flags, this agent implements a safety-first protocol that verifies branch merge status and untracked files before pruning or switching, preventing accidental data loss.

### Which AI agents or IDEs are compatible with this Git worktree skill?

The skill is designed for any AI agent with terminal or shell access, such as Cursor, Windsurf, or custom LLM-based CLI tools, provided they have Git 2.5 or newer installed.

### Can I use this skill to manage multiple feature branches at the same time?

Yes, the agent can generate and execute plans to manage multiple worktrees simultaneously, allowing you to run different versions of your app side-by-side for comparison without directory collisions.

### What exactly is included in the purchase of this skill?

Your purchase includes the core skill logic, a set of safety-check protocols, and documentation for integrating the agent into your specific development environment.

### Does the agent help with conflict detection before I create a new worktree?

The agent identifies potential merge conflicts and integration issues by analyzing merge-bases and comparing branches before you even start the worktree, saving time on complex downstream merges.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
