Clean Stale Git Worktrees, Branches and Docker

    by Chris Cheng

    1

    Dry-run-first cleanup of merged git worktrees, stale branches and orphaned Docker containers, with optional macOS launchd scheduling.

    Free

    Security scanned

    Works with the AI Agents you already use

    About this skill

    scripts/clean.sh does the safe tier and is the only thing that runs unattended. Everything beyond it is a judgment call made with the user in the session.

    Safe tier, applied by the script:

    • Prunes worktrees whose folder is gone.
    • Removes worktrees that are clean, have no process inside, and whose tip is merged (ancestor of origin/HEAD, a merged PR head, or behind one). Orca-managed worktrees go through orca worktree rm.
    • Deletes branches that are merged or whose last commit is older than --age-days (21). Each deletion is logged to ~/.local/state/clean-git-workspaces/<key>.deleted-branches.
    • Removes containers whose bind-mount source no longer exists. Prunes images and build cache unused for 7+ days.

    schedule.sh takes daily, weekly or biweekly. Weekly and biweekly take a day (sun..sat, default mon); biweekly skips a run when the last one was under 13 days ago. Missed runs fire on wake. The log is ~/Library/Logs/clean-git-workspaces/<key>.log.

    1. Run the dry run and show its WOULD and KEEP lines.
    2. Run --apply on what the user approves.
    3. Each KEEP item needs the user's decision:

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 3 days ago

    • Free with an Agensi account

    Mac only

    Accounts
    GitHub
    Software
    Git
    Optional
    GitHub CLI
    Docker
    orOrbStack
    Orca CLI

    Permissions

    Terminal / Shell
    Read Files
    Write Files
    Network Access

    Allowed Hosts

    github.com

    File Scopes

    the
    target
    git
    repository
    and
    its
    worktrees
    ~/.local/state/clean-git-workspaces
    ~/Library/LaunchAgents
    ~/Library/Logs/clean-git-workspaces

    Dry run by default. With --apply it removes merged clean worktrees, deletes merged branches and local branches older than 21 days (logged), removes containers whose bind mounts are gone, and prunes Docker images and build cache unused for 7+ days. Never prunes Docker volumes.

    Listed3 days ago

    What's inside

    Frequently Asked Questions

    Dry-run-first cleanup of merged git worktrees, stale branches and orphaned Docker containers, with optional macOS launchd scheduling.

    This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

    Connect your AI agent to Agensi through MCP, then ask it to use Clean Stale Git Worktrees, Branches and Docker on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

    New in Productivity

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Productivity.

    Free