worktree-kit

Gitmaxd's avatarfrom Gitmaxd

Manage git worktrees (create/list/switch/cleanup) and copy .env files. Use for parallel feature work, isolated review, clean workspace, or when user mentions worktrees.

⭐0stars🔀0forks📁View on GitHub🕐Updated Dec 31, 2025

When & Why to Use This Skill

The Worktree Kit is a specialized Git workflow automation tool designed to enhance developer productivity by managing multiple concurrent environments. It streamlines the process of creating, switching, and cleaning up git worktrees while ensuring environment consistency through automated .env file synchronization, making it an essential utility for complex, multi-tasking software development.

Use Cases

  • Parallel Feature Development: Seamlessly work on urgent bug fixes in a separate directory while maintaining the state of a long-running feature branch, eliminating the need for frequent stashing or messy commits.
  • Isolated Code Reviews: Check out and test a colleague's pull request in a dedicated worktree to verify functionality in an isolated environment without disrupting your current workspace or build artifacts.
  • Environment Synchronization: Automatically copy sensitive configuration files like .env to new worktrees using the copy-env command, ensuring that every branch is immediately ready for local execution and testing.
  • Workspace Maintenance: Efficiently manage local disk space and project organization by listing all active worktrees and performing safe cleanups of completed tasks without risking branch or data loss.
nameworktree-kit
descriptionManage git worktrees (create/list/switch/cleanup) and copy .env files. Use for parallel feature work, isolated review, clean workspace, or when user mentions worktrees.

Worktree kit

Use the manager script for all worktree actions.

bash .factory/skills/worktree-kit/scripts/worktree.sh <command> [args]

Commands:

  • create <name> [base]
  • list
  • switch <name> (prints path)
  • cleanup
  • copy-env <name>

Safety notes:

  • create does not change the current branch
  • cleanup does not force-remove worktrees and does not delete branches
  • cleanup deletes the worktree directory (including ignored files); removal fails if the worktree is not clean
  • .env* is copied with no overwrite (symlinks skipped)
  • refuses to operate if .worktrees/ or any worktree path component is a symlink
  • copy-env only targets registered worktrees
  • origin fetch is optional; local base refs are allowed
  • fetch from origin only when base looks like a branch
  • Worktrees live under .worktrees/