| name | pan-kill |
| description | pan kill <id> — stop a running agent (workspace and branch preserved) |
| triggers | ["pan kill","stop agent","kill agent","terminate agent","abort agent"] |
| allowed-tools | ["Bash","Read"] |
Stop Agent
Overview
This skill guides you through gracefully stopping a running autonomous agent and cleaning up its resources.
When to Use
- Agent is stuck or not making progress
- Need to reassign the work
- Agent completed work and should be stopped
- Emergency stop needed
- Freeing up system resources
Quick Command
pan kill ISSUE-123
tmux kill-session -t agent-ISSUE-123
Workflow
1. Check Agent Status First
Before killing, understand what the agent is doing:
pan status
tmux list-sessions | grep agent
tmux capture-pane -t agent-ISSUE-123 -p | tail -30
2. Graceful Shutdown (Recommended)
Give the agent a chance to save state:
pan tell ISSUE-123 "Please save your progress to STATE.md and stop working."
sleep 10
tmux capture-pane -t agent-ISSUE-123 -p | tail -10
tmux kill-session -t agent-ISSUE-123
WARNING: DO NOT use raw tmux send-keys - agents often forget the Enter key. Always use pan tell which handles this correctly.
3. Immediate Stop (If Needed)
tmux kill-session -t agent-ISSUE-123
4. Verify Stopped
tmux list-sessions | grep agent-ISSUE-123
5. Clean Up (Optional)
ls -la /path/to/workspaces/ISSUE-123/
cd /path/to/workspaces/ISSUE-123
git status
git diff
Kill All Agents
tmux list-sessions -F "#{session_name}" | grep "^agent-" | xargs -I {} tmux kill-session -t {}
tmux list-sessions | grep agent
Preserving Work
Before killing, you may want to preserve the agent's progress:
tmux attach -t agent-ISSUE-123
tmux capture-pane -t agent-ISSUE-123 -p -S - > agent-output.txt
cd /path/to/workspaces/ISSUE-123
git add -A && git commit -m "WIP: state before kill"
After Killing
Options for the work:
- Resume later - Use
pan start ISSUE-123 to spawn a new agent
- Do it yourself - Work in the existing workspace manually
- Abandon - Remove the workspace if work is no longer needed
Troubleshooting
Session won't die:
tmux kill-session -t agent-ISSUE-123
ps aux | grep "agent-ISSUE-123"
kill -9 <PID>
Multiple agents for same issue:
tmux list-sessions | grep ISSUE-123
tmux kill-session -t agent-ISSUE-123
tmux kill-session -t agent-ISSUE-123-2
Can't find the session:
tmux list-sessions
ps aux | grep claude
Related Skills
/pan:status - Check agent status
/pan:tell - Send message before killing
/pan:rescue - Recover work from killed agents