task-cleanup

Remove task branches and worktrees after merge to main.

4|Updated Sep 25, 2025
One-click install
npx skills add https://github.com/cowwoc/styler --skill task-cleanup
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: task-cleanup
Source: https://github.com/cowwoc/styler/tree/main/.claude/skills/task-cleanup
Command: npx skills add https://github.com/cowwoc/styler --skill task-cleanup

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

After a task is completed and merged, leftover task branches and Git worktrees clutter the repository and consume disk space. Manually cleaning these up is tedious and often forgotten. This Skill automates the safe removal of these artifacts, keeping your repository tidy and efficient.

Core Features & Use Cases

  • Worktree Removal: Safely removes all task-related Git worktrees, including agent-specific ones.
  • Branch Deletion: Deletes all task-related Git branches, preventing branch accumulation.
  • Audit Trail Preservation: Crucially, preserves the task directory containing task.json, task.md, and approval flags for future auditing.
  • State Transition: Updates the task's state to CLEANUP in task.json for accurate tracking.
  • Use Case: Once a task is fully complete and merged to main, invoke this Skill to automatically remove all associated branches and worktrees. This keeps your repository tidy, reclaims disk space, and ensures a clean development environment without manual effort.

Quick Start

After your task is in the 'COMPLETE' state, clean it up: cd /workspace/main /workspace/main/.claude/scripts/task-cleanup.sh "implement-formatter-api"

Frequently Asked Questions about task-cleanup

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

FAQPage Schema
How do I clean up Git branches and worktrees after merging a task?

Task cleanup removes all Git branches and worktrees associated with a completed task after it merges to main. Run the cleanup script with your task name to safely delete these artifacts while preserving the task directory for audit purposes.

Does task cleanup delete everything, or does it preserve audit records?

Cleanup deletes branches and worktrees but preserves the task directory containing task.json, task.md, and approval flags. This keeps your repository tidy while maintaining a complete audit trail of completed work.

When should I run task cleanup on completed tasks?

Run cleanup after your task reaches COMPLETE state, passes validation, obtains approval, and merges to main. This reclaims disk space and removes branch clutter without manual effort.

Can task cleanup handle multiple tasks at once?

Yes, task cleanup supports both single and batch cleanup operations. Process multiple completed tasks in one operation to efficiently reclaim resources across your repository.

What happens if cleanup encounters errors during branch or worktree removal?

Cleanup implements best-effort error handling and returns a structured JSON summary of results. If removal fails for specific branches or worktrees, the operation continues and reports what succeeded and what failed.