shutdown-session

Terminates peer Claude Code sessions by resolving claude binary PIDs from working directories.

Updated May 12, 2026
One-click install
npx skills add https://github.com/fryanpan/ai-team-lead --skill shutdown-session-fryanpan
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: shutdown-session
Source: https://github.com/fryanpan/ai-team-lead/tree/main/.claude/skills/shutdown-session
Command: npx skills add https://github.com/fryanpan/ai-team-lead --skill shutdown-session-fryanpan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Shutting down peer Claude Code sessions is error-prone because the hive-mcp list_peers tool returns the wrong PID (the bun hive-mcp child process, not the actual claude binary). Killing that PID leaves the session alive and spawning a new hive-mcp child. This Skill provides a reliable procedure to find the real claude binary PID by working directory, kill it safely, and clean up orphaned processes. ## Core Features & Use Cases - Correct PID Resolution: Maps claude binary PIDs to their working directories using ps and lsof, avoiding the misleading PIDs returned by list_peers. - Safe Termination Workflow: Excludes the team-lead's own session, uses explicit PID kills (which pass the permission classifier, unlike pkill patterns), verifies termination, and escalates to kill -9 if needed. - Orphan Cleanup & Graceful Shutdown: Sweeps orphaned hive-mcp server processes reparented to launchd, and supports messaging peers to checkpoint in-flight work before killing them. - Use Case: After a /weekly-plan pass decides which agents are needed, spin down the peers not on this week's committed goals to free memory, then confirm via list_peers that they are gone. ## Quick Start Ask the agent to shut down the peer session for a specific project, for example: "Spin down the peer running on the marketing-site project and verify it's gone."

Frequently Asked Questions about shutdown-session

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

FAQPage Schema
How do I shut down a peer Claude Code session?▼

Find the claude binary's PID by mapping running claude processes to their working directories with ps and lsof, then kill that explicit PID. Do not use the PID from list_peers, which points to the hive-mcp child process instead of the actual session.

Why does a peer session keep reappearing after I kill it?▼

You likely killed the hive-mcp child PID returned by list_peers rather than the claude binary itself. The claude process survives and spawns a new hive-mcp child, so the peer reappears. Use cwd-based PID mapping to target the real binary.

Why does pkill fail when terminating Claude sessions?▼

Pattern-based kills like pkill -f are refused by the permission classifier because a pattern can match anything and reads as unbounded. Resolving explicit PIDs first and running kill with those PIDs passes the permission check and achieves the same result.

How do I shut down an agent without losing its in-flight work?▼

Send the peer a hive message asking it to checkpoint its work (commit WIP branches, save drafts) and acknowledge before you kill the session. For idle peers with no active task, you can skip the ping and kill directly.

What are orphaned hive-mcp processes and how do I clean them up?▼

When a claude binary dies, its bun hive-mcp child can be reparented to launchd (PPID 1) instead of exiting, leaving orphans that confuse the hive registry. Find them with ps by filtering for PPID 1 and kill them with kill -9.