Best use case
swarm-shutdown is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Gracefully shutdown a swarm team
Teams using swarm-shutdown should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/swarm-shutdown/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How swarm-shutdown Compares
| Feature / Agent | swarm-shutdown | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Gracefully shutdown a swarm team
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# /swarm-shutdown
Gracefully shutdown a swarm team with optional force flag.
## Usage
```bash
/swarm-shutdown <team-id> [--force]
```
## Arguments
| Argument | Required | Description |
|----------|----------|-------------|
| `<team-id>` | Yes | The swarm team ID to shutdown |
| `--force` | No | Skip graceful shutdown, kill immediately |
## Process
When you receive this command:
### Graceful Shutdown (Default)
1. **Broadcast Shutdown Message**
```bash
source {{HOME_TOOL_DIR}}/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"
```
2. **Wait for Checkpoint**
```bash
echo "Waiting 10 seconds for agents to checkpoint..."
sleep 10
```
3. **Verify Agent Status**
```bash
# Check if agents have acknowledged
TEAM_DIR="{{HOME_TOOL_DIR}}/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
```
4. **Kill tmux Sessions**
```bash
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
```
5. **Update Team State**
```bash
swarm_update_team "$TEAM_ID" '{"status": "shutdown", "shutdown_at": "'"$(date -Iseconds)"'"}'
```
6. **Report**
```bash
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 ""
```
### Force Shutdown (--force)
Skip the graceful steps and kill immediately:
```bash
echo "Force shutdown of $TEAM_ID..."
# Kill all sessions without waiting
swarm_shutdown "$TEAM_ID" --force
echo "Force shutdown complete"
```
## Output
### Graceful Shutdown
```
================================================================
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: {{HOME_TOOL_DIR}}/swarm/swarm-1738585396/
Options:
Archive team: swarm-lib.sh archive swarm-1738585396
View final state: cat {{HOME_TOOL_DIR}}/swarm/swarm-1738585396/team.json
Restart: /swarm-create --epic bd-epic-123
================================================================
```
### Force Shutdown
```
================================================================
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
================================================================
```
## Agent Checkpoint Protocol
When agents receive a shutdown message, they should:
1. **Complete or Pause Current Work**
- If close to completion: finish the task
- Otherwise: save progress state
2. **Update Beads**
```bash
# Mark task as paused/blocked
bd update $CURRENT_TASK --status blocked --reason "Swarm shutdown"
```
3. **Send Checkpoint Confirmation**
```bash
swarm_send_message "$TEAM_ID" "$AGENT_NAME" "system" "checkpoint" \
'{"task": "'"$CURRENT_TASK"'", "progress": 75, "state": "saved"}'
```
4. **Clean Up**
- Close any open files
- Save session notes to shared/
## Post-Shutdown Options
### Archive Team
```bash
# Move team to .archive/ directory
swarm-lib.sh archive swarm-1738585396
```
### Delete Team
```bash
# Permanently remove team data
rm -rf {{HOME_TOOL_DIR}}/swarm/swarm-1738585396
```
### Restart Team
```bash
# Create new swarm from same epic
/swarm-create --epic bd-epic-platform-rebuild --agents 3
```
## Error Handling
| 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 |Related Skills
swarm-status
Display comprehensive status dashboard for a swarm team
swarm-orchestration
A tmux-based persistent multi-agent swarm system with file-based inter-agent messaging
swarm-join
Join an existing swarm team as a worker agent
swarm-inbox
Read and send inter-agent messages within a swarm team
swarm-create
Create a new self-sufficient swarm team from a Beads epic with N worker agents + a watchdog daemon that auto-recovers stuck panes and notify-only finalizes when the epic is done. Cross-provider (Claude/Codex/Copilot).
swarm-attach-watchdog
Retrofit a watchdog daemon onto an existing v1 swarm (no recreation). Upgrades team.json to v2 schema and spawns the watchdog tmux session.
swarm-agent-troubleshooting
Diagnose and fix swarm agent spawn failures when agents don't start processing tasks
workflow
Guide through structured delivery workflow with plan, implement, validate phases
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
validate
Verify implementation against specifications
ui-ux-pro-max
UI/UX design intelligence. 67 styles, 96 palettes, 57 font pairings, 25 charts, 13 stacks (React, Next.js, Vue, Svelte, Astro, Nuxt, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui, Jetpack Compose). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient.
tui-style-guide
TUI style guide for consistent terminal interface design