close-session

Merge worktree changes into main, stop the dev server, and remove the worktree and branch.

25|4|Updated Sep 5, 2010
One-click install
npx skills add https://github.com/divad12/dotfiles --skill close-session-divad12
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: close-session
Source: https://github.com/divad12/dotfiles/tree/main/.claude/skills/close-session
Command: npx skills add https://github.com/divad12/dotfiles --skill close-session-divad12

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Tear down the current worktree session by ensuring changes are merged into main, stopping the dev server, and removing the worktree and branch to reclaim resources and avoid drift.

Core Features & Use Cases

  • Gather session details and verify prerequisites before teardown
  • Ensure work is merged into main and avoid data loss
  • Write a mandatory session log/file documenting the teardown
  • Perform a controlled teardown that cleans up ports, worktrees, and branches
  • Safe-guards to prevent running in the main repo or deleting unmerged work
  • Reuse across multiple short-lived worktrees to streamline workflows

Quick Start

Invoke the close-session skill to safely tear down your current worktree session after merging changes into main.

Frequently Asked Questions about close-session

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

FAQPage Schema
How do I safely tear down a git worktree session after merging?

To safely tear down a git worktree session, you must merge changes into main, stop the dev server, and remove the worktree and branch. This process prevents data loss and avoids repository drift.

What happens if I try to delete an unmerged git worktree?

Deleting an unmerged git worktree risks losing uncommitted work. Safe teardown processes include safeguards that detect unmerged changes and prevent accidental deletion of your active branch.

How do I stop a dev server and clean up ports when closing a worktree?

Closing a worktree session cleanly stops the dev server and cleans up occupied ports during a controlled teardown. This reclaims system resources and ensures no lingering background processes remain.

Do I need to create a session file before removing a git worktree?

Yes, a mandatory session file documenting the teardown details must be created before removing a git worktree. This log verifies prerequisites and records the merge state before final cleanup.

Can I run a worktree teardown process from inside the main repository?

No, worktree teardown safeguards prevent running the process from inside the main repository. The workflow targets short-lived worktree branches specifically and blocks execution in the main workspace to protect core files.

What is the best way to manage multiple short-lived git worktrees?

The best way to manage multiple short-lived git worktrees is using a single-step teardown workflow that merges into main, stops the dev server, and removes the worktree and branch. This streamlines workflows and reclaims resources.