with one click
swarm-shutdown
Gracefully shutdown a swarm team
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Gracefully shutdown a swarm team
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Argus — all-in-one information gathering & reconnaissance toolkit. 135 modules covering network infrastructure, web app analysis, and security/threat intelligence. Use for domain recon, subdomain enum, SSL analysis, tech stack detection, vulnerability scanning, and OSINT.
Manage secrets via Bitwarden CLI (bw). Use when pulling secrets into a shell session, creating/updating Secure Notes from .env files, listing vault items, or setting up Bitwarden on a new machine. Secrets live in Bitwarden, get loaded into memory on demand, and die with the shell session — no files on disk.
Develop a thorough, step-by-step specification for a given idea
Set up a recurring build tracker cron job for any GitHub repo. Runs a zero-LLM shell script to detect stale PRs, stale assigned issues, and phase progress, then posts to a Discord channel only when there's something actionable. Use when asked to "track this build every N hours", "prod agents on a project", "set up a build monitor", "watch this repo for stale work", or similar. The tracker is cheap to run — script does all the work, the agent only speaks when findings exist.
Run long-running coding tasks in cloud environments (Claude Code or Codex), with session teleporting and automatic PR creation.
Delegate coding tasks to subagents or run Claude Code/Codex in tmux sessions. Use the Task tool for focused multi-step coding work. Use tmux for long-running interactive sessions, parallel worktree-based fixes, and PR reviews. NOT for simple single-file edits — do those directly.
| name | swarm-shutdown |
| description | Gracefully shutdown a swarm team |
| user-invocable | true |
Gracefully shutdown a swarm team with optional force flag.
/swarm-shutdown <team-id> [--force]
| Argument | Required | Description |
|---|---|---|
<team-id> | Yes | The swarm team ID to shutdown |
--force | No | Skip graceful shutdown, kill immediately |
When you receive this command:
Broadcast Shutdown Message
source ~/.claude/utils/swarm-lib.sh
echo "Initiating graceful shutdown of $TEAM_ID..."
# Notify all agents
swarm_broadcast "$TEAM_ID" "system" "shutdown" \
'{"reason": "graceful shutdown requested", "checkpoint": true}'
echo "Shutdown message broadcast to all agents"
Wait for Checkpoint
echo "Waiting 10 seconds for agents to checkpoint..."
sleep 10
Verify Agent Status
# Check if agents have acknowledged
TEAM_DIR="~/.claude/swarm/$TEAM_ID"
for inbox in "$TEAM_DIR"/inbox/*.jsonl; do
AGENT=$(basename "$inbox" .jsonl)
LAST_MSG=$(tail -1 "$inbox" 2>/dev/null | jq -r '.type' || echo "")
if [ "$LAST_MSG" = "checkpoint" ]; then
echo " + $AGENT checkpointed"
else
echo " o $AGENT (no checkpoint confirmation)"
fi
done
Kill tmux Sessions
TEAM_JSON=$(cat "$TEAM_DIR/team.json")
# Kill leader
LEADER_SESSION=$(echo "$TEAM_JSON" | jq -r '.leader.session')
if tmux has-session -t "$LEADER_SESSION" 2>/dev/null; then
tmux kill-session -t "$LEADER_SESSION"
echo " + Killed leader: $LEADER_SESSION"
fi
# Kill agents
for session in $(echo "$TEAM_JSON" | jq -r '.members[].session'); do
if tmux has-session -t "$session" 2>/dev/null; then
tmux kill-session -t "$session"
echo " + Killed agent: $session"
fi
done
Update Team State
swarm_update_team "$TEAM_ID" '{"status": "shutdown", "shutdown_at": "'"$(date -Iseconds)"'"}'
Report
echo ""
echo "========================================"
echo " Swarm Shutdown Complete: $TEAM_ID"
echo "========================================"
echo ""
echo " Team data preserved at:"
echo " $TEAM_DIR/"
echo ""
echo " To archive: /swarm-archive $TEAM_ID"
echo " To restart: /swarm-create with same epic"
echo ""
Skip the graceful steps and kill immediately:
echo "Force shutdown of $TEAM_ID..."
# Kill all sessions without waiting
swarm_shutdown "$TEAM_ID" --force
echo "Force shutdown complete"
================================================================
SWARM SHUTDOWN: swarm-1738585396
================================================================
Phase 1: Broadcasting shutdown...
-> Sent to leader
-> Sent to agent-1
-> Sent to agent-2
-> Sent to agent-3
Phase 2: Waiting for checkpoints (10s)...
==================== 100%
Phase 3: Verifying checkpoints...
+ leader: checkpointed
+ agent-1: checkpointed
+ agent-2: checkpointed
o agent-3: no response (will force kill)
Phase 4: Terminating sessions...
+ Killed: swarm-1738585396-leader
+ Killed: swarm-1738585396-agent-1
+ Killed: swarm-1738585396-agent-2
+ Killed: swarm-1738585396-agent-3
Phase 5: Updating team state...
+ Status set to: shutdown
================================================================
SHUTDOWN COMPLETE
================================================================
Team data preserved at: ~/.claude/swarm/swarm-1738585396/
Options:
Archive team: swarm-lib.sh archive swarm-1738585396
View final state: cat ~/.claude/swarm/swarm-1738585396/team.json
Restart: /swarm-create --epic bd-epic-123
================================================================
================================================================
FORCE SHUTDOWN: swarm-1738585396
================================================================
Killing sessions immediately...
+ Killed: swarm-1738585396-leader
+ Killed: swarm-1738585396-agent-1
+ Killed: swarm-1738585396-agent-2
Status updated to: shutdown
================================================================
When agents receive a shutdown message, they should:
Complete or Pause Current Work
Update Beads
# Mark task as paused/blocked
bd update $CURRENT_TASK --status blocked --reason "Swarm shutdown"
Send Checkpoint Confirmation
swarm_send_message "$TEAM_ID" "$AGENT_NAME" "system" "checkpoint" \
'{"task": "'"$CURRENT_TASK"'", "progress": 75, "state": "saved"}'
Clean Up
# Move team to .archive/ directory
swarm-lib.sh archive swarm-1738585396
# Permanently remove team data
rm -rf ~/.claude/swarm/swarm-1738585396
# Create new swarm from same epic
/swarm-create --epic bd-epic-platform-rebuild --agents 3
| Error | Resolution |
|---|---|
| Team not found | Verify team ID exists |
| Sessions already dead | Proceeds with state update only |
| Permission denied | Check tmux socket permissions |
| Checkpoint timeout | Force flag used automatically after timeout |