agent-workspace-clean

Remove the current Git worktree from the agent workspace.

Updated Jul 10, 2022
One-click install
npx skills add https://github.com/samuerio/.dotfiles --skill agent-workspace-clean
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: agent-workspace-clean
Source: https://github.com/samuerio/.dotfiles/tree/main/agents/skills/agent-workspace-clean
Command: npx skills add https://github.com/samuerio/.dotfiles --skill agent-workspace-clean

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Safely remove the current git worktree only when it is inside the agent workspace under <repo>/.worktree/*. This prevents accidental deletions of unrelated worktrees and helps maintain a clean development environment.

Core Features & Use Cases

  • Deterministic removal of the current agent worktree using the bundled clean_workspace.sh script.
  • Safety checks ensure the operation only runs inside the agent workspace path and respects the --force flag when explicitly requested.
  • Provides structured results, including a success message, the workspace path, and a summary of any leftovers for follow-up review.

Quick Start

Run the clean script for the agent workspace to remove the current worktree.

Frequently Asked Questions about agent-workspace-clean

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely remove a git worktree without deleting unrelated branches?

To safely remove a git worktree, use a script that enforces path preconditions, ensuring the operation only executes within a designated agent workspace directory like <repo>/.worktree/* to prevent accidental deletions of unrelated worktrees.

What is an agent workspace in the context of git worktrees?

An agent workspace is a designated directory path, typically structured under <repo>/.worktree/*, where automated agents operate within isolated git worktrees to maintain a clean development environment without interfering with the main repository.

How to force delete a git worktree inside an agent workspace?

You can force delete a git worktree by passing the --force flag to the cleanup script, which overrides standard safety checks to remove the workspace path when explicitly requested by the user or agent.

Can I use a bash script to automate worktree cleanup for multiple agents?

Yes, you can automate worktree cleanup using a bundled bash script that handles standard and forced deletions, enforces safety preconditions, and outputs structured results including the workspace path and any leftover files for review.

Why does my worktree deletion fail outside the agent workspace path?

Worktree deletion fails outside the agent workspace path due to built-in safety checks that restrict the operation to <repo>/.worktree/*, intentionally preventing the accidental removal of unrelated development worktrees.