home / skills / trentshaines / dotfiles / cleanup-panes
/dot_claude/skills/cleanup-panes
This skill closes all tmux panes in the current window except the one you are in, streamlining your workspace.
npx playbooks add skill trentshaines/dotfiles --skill cleanup-panesReview the files below or copy the command above to add this skill to your agents.
---
name: cleanup-panes
description: Clean up tmux panes. Use when user wants to close/kill all other panes, clean up tmux window, or reset pane layout.
---
# Cleanup Panes Skill
## Overview
Closes all tmux panes in the current window except the one you're in.
## Trigger
User invokes `/cleanup-panes` or asks to clean up/close other panes.
## Instructions
Execute this bash script:
```bash
#!/bin/bash
ORIGINAL_PANE=$(tmux display-message -p '#{pane_id}')
echo "Keeping pane: $ORIGINAL_PANE"
# Get all panes except original, then kill each
PANES_TO_KILL=$(tmux list-panes -F '#{pane_id}' | grep -v "^${ORIGINAL_PANE}$")
if [ -z "$PANES_TO_KILL" ]; then
echo "No other panes to close."
else
COUNT=0
while IFS= read -r PANE; do
if [ -n "$PANE" ]; then
tmux kill-pane -t "$PANE" 2>/dev/null && ((COUNT++))
fi
done <<< "$PANES_TO_KILL"
echo "Closed $COUNT panes. Only current pane remains."
fi
```
## Important Notes
- Only affects the current tmux window
- Preserves the pane you're currently in
- Safe to run even if there are no other panes
This skill closes all tmux panes in the current window except the active one, letting you quickly reduce clutter or reset a window layout. It is a simple, safe command for keeping only the pane you are working in while leaving the window and session intact. Use it when you want a clean workspace without manually closing each pane.
The skill reads the current pane ID, lists all panes in the active tmux window, filters out the current pane, and kills each remaining pane. It counts successful kills and reports how many panes were closed. If there are no other panes, it reports that nothing needed closing.
Will this close panes in other tmux windows or sessions?
No. It only targets panes listed in the current tmux window.
What happens to processes running in killed panes?
Killing a pane terminates its running processes. Save work or stop important tasks before running the cleanup.