Loading...
Loading...
Cancel any active OMC mode (autopilot, ralph, ultrawork, ecomode, ultraqa, swarm, ultrapilot, pipeline, team)
npx skill4agent add yeachan-heo/oh-my-claudecode cancel--force/oh-my-claudecode:cancel/oh-my-claudecode:cancelstate_list_activestate_get_status.omc/state/sessions/{sessionId}/….omc/state/*.json.omc/state/swarm.db.omc/state/swarm-active.markerstate_clear--force--all/oh-my-claudecode:cancel --force/oh-my-claudecode:cancel --allstate_list_active.omc/state/sessions/{sessionId}/…state_clearstate_clearsession_id.omc/state/*.json.omc/state/swarm*.db~/.claude/teams/*/~/.claude/tasks/*/.omc/state/team-state.jsonstate_clearsession_id--force--all.omc/state/autopilot-state.json.omc/state/ralph-state.json.omc/state/ralph-plan-state.json.omc/state/ralph-verification.json.omc/state/ultrawork-state.json.omc/state/ecomode-state.json.omc/state/ultraqa-state.json.omc/state/swarm.db.omc/state/swarm.db-wal.omc/state/swarm.db-shm.omc/state/swarm-active.marker.omc/state/swarm-tasks.db.omc/state/ultrapilot-state.json.omc/state/ultrapilot-ownership.json.omc/state/pipeline-state.json.omc/state/plan-consensus.json.omc/state/ralplan-state.json.omc/state/boulder.json.omc/state/hud-state.json.omc/state/subagent-tracking.json.omc/state/subagent-tracker.lock.omc/state/rate-limit-daemon.pid.omc/state/rate-limit-daemon.log.omc/state/checkpoints/.omc/state/sessions/# Check for --force or --all flags
FORCE_MODE=false
if [[ "$*" == *"--force"* ]] || [[ "$*" == *"--all"* ]]; then
FORCE_MODE=true
fistate_list_active.omc/state/sessions/{sessionId}/…state_get_statusautopilotralphultraworksession_id/oh-my-claudecode:cancel.omc/state/*.jsonstate_clear~/.claude/teams/# Check for active teams
TEAM_CONFIGS=$(find ~/.claude/teams -name config.json -maxdepth 2 2>/dev/null)For each team found in ~/.claude/teams/:
1. Read config.json to get team_name and members list
2. For each non-lead member:
a. Send shutdown_request via SendMessage
b. Wait up to 15 seconds for shutdown_response
c. If response received: member terminates and is auto-removed
d. If timeout: mark member as unresponsive, continue to next
3. Log: "Graceful pass: X/Y members responded"After graceful pass:
1. Re-read config.json to check remaining members
2. If only lead remains (or config is empty): proceed to TeamDelete
3. If unresponsive members remain:
a. Wait 5 more seconds (they may still be processing)
b. Re-read config.json again
c. If still stuck: attempt TeamDelete anyway
d. If TeamDelete fails: report manual cleanup path 1. Call TeamDelete() — removes ~/.claude/teams/{name}/ and ~/.claude/tasks/{name}/
2. Clear team state: state_clear(mode="team")
3. Check for linked ralph: state_read(mode="ralph") — if linked_team is true:
a. Clear ralph state: state_clear(mode="ralph")
b. Clear linked ultrawork if present: state_clear(mode="ultrawork")
4. Emit structured cancel reportTeam "{team_name}" cancelled:
- Members signaled: N
- Responses received: M
- Unresponsive: K (list names if any)
- TeamDelete: success/failed
- Manual cleanup needed: yes/no
Path: ~/.claude/teams/{name}/ and ~/.claude/tasks/{name}/~/.claude/teams/*/config.jsoncreatedAtSendMessage(type: "shutdown_request", recipient: member-name, content: "Cancelling")TeamDelete()rm -f .omc/state/team-state.jsoncancelAutopilot()src/hooks/autopilot/cancel.ts:27-78# Autopilot handles its own cleanup + ralph + ultraqa
# Just mark autopilot as inactive (preserves state for resume)
if [[ -f .omc/state/autopilot-state.json ]]; then
# Clean up ralph if active
if [[ -f .omc/state/ralph-state.json ]]; then
RALPH_STATE=$(cat .omc/state/ralph-state.json)
LINKED_UW=$(echo "$RALPH_STATE" | jq -r '.linked_ultrawork // false')
# Clean linked ultrawork first
if [[ "$LINKED_UW" == "true" ]] && [[ -f .omc/state/ultrawork-state.json ]]; then
rm -f .omc/state/ultrawork-state.json
echo "Cleaned up: ultrawork (linked to ralph)"
fi
# Clean ralph
rm -f .omc/state/ralph-state.json
rm -f .omc/state/ralph-verification.json
echo "Cleaned up: ralph"
fi
# Clean up ultraqa if active
if [[ -f .omc/state/ultraqa-state.json ]]; then
rm -f .omc/state/ultraqa-state.json
echo "Cleaned up: ultraqa"
fi
# Mark autopilot inactive but preserve state
CURRENT_STATE=$(cat .omc/state/autopilot-state.json)
CURRENT_PHASE=$(echo "$CURRENT_STATE" | jq -r '.phase // "unknown"')
echo "$CURRENT_STATE" | jq '.active = false' > .omc/state/autopilot-state.json
echo "Autopilot cancelled at phase: $CURRENT_PHASE. Progress preserved for resume."
echo "Run /oh-my-claudecode:autopilot to resume."
ficlearRalphState()clearLinkedUltraworkState()src/hooks/ralph-loop/index.ts:147-182if [[ -f .omc/state/ralph-state.json ]]; then
# Check if ultrawork is linked
RALPH_STATE=$(cat .omc/state/ralph-state.json)
LINKED_UW=$(echo "$RALPH_STATE" | jq -r '.linked_ultrawork // false')
# Clean linked ultrawork first
if [[ "$LINKED_UW" == "true" ]] && [[ -f .omc/state/ultrawork-state.json ]]; then
UW_STATE=$(cat .omc/state/ultrawork-state.json)
UW_LINKED=$(echo "$UW_STATE" | jq -r '.linked_to_ralph // false')
# Only clear if it was linked to ralph
if [[ "$UW_LINKED" == "true" ]]; then
rm -f .omc/state/ultrawork-state.json
echo "Cleaned up: ultrawork (linked to ralph)"
fi
fi
# Clean ralph state
rm -f .omc/state/ralph-state.json
rm -f .omc/state/ralph-plan-state.json
rm -f .omc/state/ralph-verification.json
echo "Ralph cancelled. Persistent mode deactivated."
fideactivateUltrawork()src/hooks/ultrawork/index.ts:150-173if [[ -f .omc/state/ultrawork-state.json ]]; then
# Check if linked to ralph
UW_STATE=$(cat .omc/state/ultrawork-state.json)
LINKED=$(echo "$UW_STATE" | jq -r '.linked_to_ralph // false')
if [[ "$LINKED" == "true" ]]; then
echo "Ultrawork is linked to Ralph. Use /oh-my-claudecode:cancel to cancel both."
exit 1
fi
# Remove local state
rm -f .omc/state/ultrawork-state.json
echo "Ultrawork cancelled. Parallel execution mode deactivated."
ficlearUltraQAState()src/hooks/ultraqa/index.ts:107-120if [[ -f .omc/state/ultraqa-state.json ]]; then
rm -f .omc/state/ultraqa-state.json
echo "UltraQA cancelled. QA cycling workflow stopped."
fiecho "No active OMC modes detected."
echo ""
echo "Checked for:"
echo " - Autopilot (.omc/state/autopilot-state.json)"
echo " - Ralph (.omc/state/ralph-state.json)"
echo " - Ultrawork (.omc/state/ultrawork-state.json)"
echo " - UltraQA (.omc/state/ultraqa-state.json)"
echo ""
echo "Use --force to clear all state files anyway."--force--allstate_list_activestate_get_statusautopilotralphultraworkstate_clearstate_clearstate_clearsession_id.omc/state/*.json~/.claude/teams/*/~/.claude/tasks/*/.omc/state/team-state.jsonsession_id| Mode | Success Message |
|---|---|
| Autopilot | "Autopilot cancelled at phase: {phase}. Progress preserved for resume." |
| Ralph | "Ralph cancelled. Persistent mode deactivated." |
| Ultrawork | "Ultrawork cancelled. Parallel execution mode deactivated." |
| Ecomode | "Ecomode cancelled. Token-efficient execution mode deactivated." |
| UltraQA | "UltraQA cancelled. QA cycling workflow stopped." |
| Swarm | "Swarm cancelled. Coordinated agents stopped." |
| Ultrapilot | "Ultrapilot cancelled. Parallel autopilot workers stopped." |
| Pipeline | "Pipeline cancelled. Sequential agent chain stopped." |
| Team | "Team cancelled. Teammates shut down and cleaned up." |
| Plan Consensus | "Plan Consensus cancelled. Planning session ended." |
| Force | "All OMC modes cleared. You are free to start fresh." |
| None | "No active OMC modes detected." |
| Mode | State Preserved | Resume Command |
|---|---|---|
| Autopilot | Yes (phase, files, spec, plan, verdicts) | |
| Ralph | No | N/A |
| Ultrawork | No | N/A |
| UltraQA | No | N/A |
| Swarm | No | N/A |
| Ultrapilot | No | N/A |
| Pipeline | No | N/A |
| Plan Consensus | Yes (plan file path preserved) | N/A |
.omc/state/.omc/state/team-bridge/{team}/*.heartbeat.jsontmux kill-session -t omc-team-{team}-{worker}.omc/state/team-mcp-workers.json--forcerm -rf .omc/state/team-bridge/ # Heartbeat files
rm -f .omc/state/team-mcp-workers.json # Shadow registry
# Kill all omc-team-* tmux sessions
tmux list-sessions -F '#{session_name}' 2>/dev/null | grep '^omc-team-' | while read s; do tmux kill-session -t "$s" 2>/dev/null; done