Team Shutdown
Gracefully shut down an active agent team by sending shutdown requests to all teammates, collecting final results, and cleaning up team resources.
Phase 1: Pre-Shutdown
-
Parse
$ARGUMENTSfor team name and flags:- If no team name, check for active teams (same discovery as team-status)
--force: skip waiting for graceful shutdown responses--keep-tasks: preserve task list after cleanup
-
Read team config from
~/.claude/teams/{team-name}/config.jsonusing the Read tool -
Call
TaskListto check for in-progress tasks -
If there are in-progress tasks and
--forceis not set:- Display warning: "Warning: {N} tasks are still in progress"
- List the in-progress tasks
- Ask user: "Proceed with shutdown? In-progress work may be lost."
Phase 2: Graceful Shutdown
For each teammate in the team:
- Use
SendMessagewithtype: "shutdown_request"to request graceful shutdown- Include content: "Team shutdown requested. Please finish current work and save state."
- Wait for shutdown responses
- If teammate approves: mark as shut down
- If teammate rejects: report to user with reason
- If
--force: don't wait for responses
Phase 3: Cleanup
-
Display shutdown summary:
Team "{team-name}" shutdown complete. Members shut down: {N}/{total} Tasks completed: {completed}/{total} Tasks remaining: {remaining} -
Unless
--keep-tasksis set, callTeamDeleteto remove team and task directories -
If
--keep-tasksis set, inform user: "Task list preserved at ~/.claude/tasks/{team-name}/"