stale-worktree-cleanup

Identify and remove stale git worktrees and orphaned compdev_* PostgreSQL databases via confirmation-driven workflow.

1.8k|375|Updated Jan 15, 2025
One-click install
npx skills add https://github.com/trycompai/comp --skill stale-worktree-cleanup
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: stale-worktree-cleanup
Source: https://github.com/trycompai/comp/tree/main/.agents/skills/stale-worktree-cleanup
Command: npx skills add https://github.com/trycompai/comp --skill stale-worktree-cleanup

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill defines a safe, reversible process to reap both the worktree directories and their dangling PostgreSQL databases created by per-worktree setups, preventing disk usage from accumulating while protecting active work.

Core Features & Use Cases

  • Safe inventory and classification of worktrees (main, safe-to-remove, needs-confirm, keep, and skip) with explicit guidance.
  • Steps to enumerate worktrees, list orphan compdev_* databases, and map relations to their worktrees.
  • End-to-end cleanup with safeguards that remove the worktree and drop its corresponding compdev_* database only after explicit confirmation and safety checks.

Quick Start

From the main worktree, run the cleanup workflow to identify and remove stale worktrees and their compdev_* databases.

Frequently Asked Questions about stale-worktree-cleanup

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

FAQPage Schema
How do I safely clean up stale git worktrees and their orphaned databases?

This workflow inventories and classifies git worktrees by status, then removes both the stale worktree directory and its associated compdev_* PostgreSQL database only after strict naming safeguards and explicit confirmation pass.

What is the best way to remove orphaned compdev PostgreSQL databases left behind by merged branches?

The best way to remove orphaned compdev_* PostgreSQL databases is to map them to their stale worktrees, verify the branch status, and drop the database only after the worktree directory is safely removed.

How does the worktree cleanup process classify which directories are safe to remove?

The worktree cleanup process classifies directories into main, safe-to-remove, needs-confirm, keep, and skip categories, ensuring active work is protected while identifying stale worktrees for deletion.

Do I need to manually delete PostgreSQL databases when removing git worktrees?

No, you do not need to manually delete PostgreSQL databases when removing git worktrees. The workflow enumerates orphan compdev_* databases, maps them to worktrees, and drops the database after the worktree is safely removed.

Can I prevent disk space bloat from accumulated git worktrees and databases?

Yes, you can prevent disk space bloat by running a confirmation-driven workflow that reaps both stale worktree directories and their dangling compdev_* PostgreSQL databases before they accumulate across repositories.