# Deterministic Git Worktree Squash & Teardown Pro

> Safely squash linked worktree changes to main, exclude build artifacts, update SemVer, and teardown worktree cleanly.

Deterministic Git Worktree Squash & Teardown Pro is a paid AI agent skill on Agensi by Julia, in Workflow Automation. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $1.99 (one-time purchase)
- Creator: [Julia](https://www.agensi.io/creators/spxzhu)
- Category: [Workflow Automation](https://www.agensi.io/skills/workflow-automation)
- Version: 1.0
- Last updated: 2026-11-23
- Security: scan passed (2026-11-23); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/deterministic-git-worktree-squash-teardown-pro
- Tags: automation, devops, code-review, git, python

## About this skill

### Overview
A deterministic, artifact-excluding Git worktree squash, SemVer synchronization, and teardown skill designed for modern AI coding agents (Claude Code, Cursor, Codex, Windsurf, Antigravity, OpenClaw, Roo Code).

### Why sgit-merge-worktree?
Multi-agent and branch workflows frequently spin up separate Git worktrees. However, integrating a worktree back into the main branch often results in serious problems:
- **Artifact Pollution**: Worktrees accumulate local build outputs, compilation artifacts (`.local/`, `build/`, `dist/`, `tmp/`), caches, and debug logs. Standard `git merge --squash` pulls these dirty files directly into the main repository.
- **Worktree Leaks & Drift**: Agents abandon unremoved worktree folders across disk, leaving locked repositories or stale tracking branches.
- **Accidental Data Loss**: Force-deleting worktrees without creating a safety snapshot of uncommitted experimentation.
- **Version Drift**: The version on the main branch is not incremented, or requires multiple corrective commits after the merge.

### Key Capabilities
1. **Pre-Merge Artifact Cleanup (`merge_artifacts.py`)**: Purges unneeded temporary build directories while protecting game saves, signing keys, and source assets.
2. **Strict Artifact Exclusion**: Guarantees temporary files and caches NEVER enter the Git index, safety stash, squash diff, or final commit.
3. **Safety Snapshot Stash**: Captures an identifiable safety stash of uncommitted work before performing any mutations.
4. **Conventional Commits & Automated SemVer Bump**: Calculates a 3-segment Semantic Versioning patch bump against the target main branch and bundles the update into the single squash commit.
5. **Clean Worktree Removal & Teardown**: Performs pre-removal sanity checks (`check-cleanup`), removes the linked worktree (`git worktree remove`) without dangerous force flags, and cleans up task state directories.
6. **Zero External Dependencies**: Pure Python 3.10+ standard library.

### Supported Platforms
- Claude Code (`~/.claude/skills/sgit-merge-worktree/`)
- Cursor / Windsurf / Codex (`~/.agents/skills/sgit-merge-worktree/`)
- Antigravity (`~/.gemini/config/skills/sgit-merge-worktree/`)

## Requires

- Python
- Git

## Known limitations

Requires target branch to be clean. Does not support automatic conflict resolution. Source must be a removable linked worktree. Limited to Python 3.10+ environments.

## 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 Deterministic Git Worktree Squash & Teardown Pro skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### How does this skill simplify the Git worktree lifecycle compared to manual commands?

The skill automates the transition from a secondary worktree back to your main branch, handling the exclusion of local artifacts, squash-committing the history, and performing a clean filesystem teardown in one atomic operation.

### What are the technical requirements for running this skill?

It is designed for any Python 3.10+ environment with Git installed and is compatible with AI agents capable of executing local CLI tools and managing file systems.

### How does the automated SemVer update work?

The skill analyzes your commit history against Conventional Commit standards to determine if a major, minor, or patch version bump is required, automatically updating your project's version files.

### What safeguards are in place to prevent accidental data loss during the worktree teardown?

Before any destructive action like a worktree removal, the skill creates a safety stash and state-tracking JSON file to ensure you can recover your work if the merge is interrupted.

### Can I use this skill for standard branch merges without a worktree?

No, this skill is specifically optimized for repository structures that utilize Git worktrees to isolate feature development; it expects a linked worktree to be present as the source.

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

You receive the core logic for the worktree integration protocol, the artifact scrubbing configurations, and the state-management framework to ensure clean merges every time.

---

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.
