cancel

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Cancel Skill

Cancel 技能

Intelligent cancellation that detects and cancels the active OMC mode.
The cancel skill is the standard way to complete and exit any OMC mode. When the stop hook detects work is complete, it instructs the LLM to invoke this skill for proper state cleanup. If cancel fails or is interrupted, retry with
--force
flag, or wait for the 2-hour staleness timeout as a last resort.
智能取消功能,可检测并取消处于活跃状态的OMC模式。
Cancel技能是完成并退出任何OMC模式的标准方式。 当停止钩子检测到工作完成时,会指示LLM调用此技能以进行适当的状态清理。如果取消操作失败或被中断,可使用
--force
标志重试,或者作为最后手段等待2小时的过期超时。

What It Does

功能说明

Automatically detects which mode is active and cancels it:
  • Autopilot: Stops workflow, preserves progress for resume
  • Ralph: Stops persistence loop, clears linked ultrawork if applicable
  • Ultrawork: Stops parallel execution (standalone or linked)
  • Ecomode: Stops token-efficient parallel execution (standalone or linked to ralph)
  • UltraQA: Stops QA cycling workflow
  • Swarm: Stops coordinated agent swarm, releases claimed tasks
  • Ultrapilot: Stops parallel autopilot workers
  • Pipeline: Stops sequential agent pipeline
  • Team: Sends shutdown_request to all teammates, waits for responses, calls TeamDelete, clears linked ralph if present
  • Team+Ralph (linked): Cancels team first (graceful shutdown), then clears ralph state. Cancelling ralph when linked also cancels team first.
自动检测当前活跃的模式并取消:
  • Autopilot:停止工作流,保留进度以便恢复
  • Ralph:停止持久化循环,如有关联的ultrawork则清除
  • Ultrawork:停止并行执行(独立模式或关联模式)
  • Ecomode:停止令牌高效的并行执行(独立模式或与ralph关联)
  • UltraQA:停止QA循环工作流
  • Swarm:停止协同Agent集群,释放已认领的任务
  • Ultrapilot:停止并行autopilot工作进程
  • Pipeline:停止顺序Agent流水线
  • Team:向所有团队成员发送shutdown_request,等待响应,调用TeamDelete,如有关联的ralph则清除
  • Team+Ralph(关联模式):先取消team(优雅关闭),再清除ralph状态。取消关联的ralph时也会先取消team。

Usage

使用方法

/oh-my-claudecode:cancel
Or say: "cancelomc", "stopomc"
/oh-my-claudecode:cancel
或者输入:"cancelomc"、"stopomc"

Auto-Detection

自动检测机制

/oh-my-claudecode:cancel
follows the session-aware state contract:
  • By default the command inspects the current session via
    state_list_active
    and
    state_get_status
    , navigating
    .omc/state/sessions/{sessionId}/…
    to discover which mode is active.
  • When a session id is provided or already known, that session-scoped path is authoritative. Legacy files in
    .omc/state/*.json
    are consulted only as a compatibility fallback if the session id is missing or empty.
  • Swarm is a shared SQLite/marker mode (
    .omc/state/swarm.db
    /
    .omc/state/swarm-active.marker
    ) and is not session-scoped.
  • The default cleanup flow calls
    state_clear
    with the session id to remove only the matching session files; modes stay bound to their originating session.
Active modes are still cancelled in dependency order:
  1. Autopilot (includes linked ralph/ultraqa/ecomode cleanup)
  2. Ralph (cleans its linked ultrawork or ecomode)
  3. Ultrawork (standalone)
  4. Ecomode (standalone)
  5. UltraQA (standalone)
  6. Swarm (standalone)
  7. Ultrapilot (standalone)
  8. Pipeline (standalone)
  9. Team (Claude Code native)
  10. Plan Consensus (standalone)
/oh-my-claudecode:cancel
遵循会话感知状态约定:
  • 默认情况下,该命令通过
    state_list_active
    state_get_status
    检查当前会话,遍历
    .omc/state/sessions/{sessionId}/…
    路径以发现活跃模式。
  • 当提供或已知会话ID时,该会话范围内的路径为权威来源。仅当会话ID缺失或为空时,才会将
    .omc/state/*.json
    中的遗留文件作为兼容性回退进行查询。
  • Swarm是共享SQLite/标记模式(
    .omc/state/swarm.db
    /
    .omc/state/swarm-active.marker
    ),不属于会话范围。
  • 默认清理流程会使用会话ID调用
    state_clear
    ,仅删除匹配的会话文件;模式始终绑定到其发起会话。
活跃模式仍会按依赖顺序取消:
  1. Autopilot(包括关联的ralph/ultraqa/ecomode清理)
  2. Ralph(清理其关联的ultrawork或ecomode)
  3. Ultrawork(独立模式)
  4. Ecomode(独立模式)
  5. UltraQA(独立模式)
  6. Swarm(独立模式)
  7. Ultrapilot(独立模式)
  8. Pipeline(独立模式)
  9. Team(Claude Code原生模式)
  10. Plan Consensus(独立模式)

Force Clear All

强制清除所有内容

Use
--force
or
--all
when you need to erase every session plus legacy artifacts, e.g., to reset the workspace entirely.
/oh-my-claudecode:cancel --force
/oh-my-claudecode:cancel --all
Steps under the hood:
  1. state_list_active
    enumerates
    .omc/state/sessions/{sessionId}/…
    to find every known session.
  2. state_clear
    runs once per session to drop that session’s files.
  3. A global
    state_clear
    without
    session_id
    removes legacy files under
    .omc/state/*.json
    ,
    .omc/state/swarm*.db
    , and compatibility artifacts (see list).
  4. Team artifacts (
    ~/.claude/teams/*/
    ,
    ~/.claude/tasks/*/
    ,
    .omc/state/team-state.json
    ) are best-effort cleared as part of the legacy fallback.
Every
state_clear
command honors the
session_id
argument, so even force mode still uses the session-aware paths first before deleting legacy files.
Legacy compatibility list (removed only under
--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/
    (directory)
  • .omc/state/sessions/
    (empty directory cleanup after clearing sessions)
当你需要擦除所有会话及遗留工件时,可使用
--force
--all
参数,例如完全重置工作区。
/oh-my-claudecode:cancel --force
/oh-my-claudecode:cancel --all
后台执行步骤:
  1. state_list_active
    枚举
    .omc/state/sessions/{sessionId}/…
    以查找所有已知会话。
  2. 对每个会话ID,执行
    state_clear
    以删除该会话的文件。
  3. 不带
    session_id
    的全局
    state_clear
    会删除
    .omc/state/*.json
    .omc/state/swarm*.db
    等遗留文件及兼容性工件(见列表)。
  4. Team工件(
    ~/.claude/teams/*/
    ~/.claude/tasks/*/
    .omc/state/team-state.json
    )会在遗留回退流程中尽可能清理。
每个
state_clear
命令都会遵循
session_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/
    (清除会话后清理空目录)

Implementation Steps

实现步骤

When you invoke this skill:
当你调用此技能时:

1. Parse Arguments

1. 解析参数

bash
undefined
bash
undefined

Check for --force or --all flags

检查--force或--all标志

FORCE_MODE=false if [[ "$" == "--force" ]] || [[ "$" == "--all" ]]; then FORCE_MODE=true fi
undefined
FORCE_MODE=false if [[ "$" == "--force" ]] || [[ "$" == "--all" ]]; then FORCE_MODE=true fi
undefined

2. Detect Active Modes

2. 检测活跃模式

The skill now relies on the session-aware state contract rather than hard-coded file paths:
  1. Call
    state_list_active
    to enumerate
    .omc/state/sessions/{sessionId}/…
    and discover every active session.
  2. For each session id, call
    state_get_status
    to learn which mode is running (
    autopilot
    ,
    ralph
    ,
    ultrawork
    , etc.) and whether dependent modes exist.
  3. If a
    session_id
    was supplied to
    /oh-my-claudecode:cancel
    , skip legacy fallback entirely and operate solely within that session path; otherwise, consult legacy files in
    .omc/state/*.json
    only if the state tools report no active session. Swarm remains a shared SQLite/marker mode outside session scoping.
  4. Any cancellation logic in this doc mirrors the dependency order discovered via state tools (autopilot → ralph → …).
该技能现在依赖会话感知状态约定,而非硬编码文件路径:
  1. 调用
    state_list_active
    枚举
    .omc/state/sessions/{sessionId}/…
    并发现所有活跃会话。
  2. 对每个会话ID,调用
    state_get_status
    以了解运行中的模式(
    autopilot
    ralph
    ultrawork
    等)以及是否存在依赖模式。
  3. 如果
    /oh-my-claudecode:cancel
    提供了
    session_id
    ,则完全跳过遗留回退,仅在该会话路径内操作;否则,仅当状态工具报告无活跃会话时,才会查询
    .omc/state/*.json
    中的遗留文件。Swarm仍属于会话范围外的共享SQLite/标记模式。
  4. 本文档中的任何取消逻辑均与状态工具发现的依赖顺序(autopilot → ralph → …)一致。

3A. Force Mode (if --force or --all)

3A. 强制模式(如果使用--force或--all)

Use force mode to clear every session plus legacy artifacts via
state_clear
. Direct file removal is reserved for legacy cleanup when the state tools report no active sessions.
使用强制模式通过
state_clear
清除所有会话及遗留工件。仅当状态工具报告无活跃会话时,才会直接删除文件进行遗留清理。

3B. Smart Cancellation (default)

3B. 智能取消(默认模式)

If Team Active (Claude Code native)

若Team处于活跃状态(Claude Code原生模式)

Teams are detected by checking for config files in
~/.claude/teams/
:
bash
undefined
通过检查
~/.claude/teams/
中的配置文件检测Team:
bash
undefined

Check for active teams

检查活跃的Team

TEAM_CONFIGS=$(find ~/.claude/teams -name config.json -maxdepth 2 2>/dev/null)

**Two-pass cancellation protocol:**

**Pass 1: Graceful Shutdown**
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"

**Pass 2: Reconciliation**
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

**TeamDelete + Cleanup:**
  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 report

**Structured Cancel Report:**
Team "{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}/

**Implementation note:** The cancel skill is executed by the LLM, not as a bash script. When you detect an active team:
1. Read `~/.claude/teams/*/config.json` to find active teams
2. If multiple teams exist, cancel oldest first (by `createdAt`)
3. For each non-lead member, call `SendMessage(type: "shutdown_request", recipient: member-name, content: "Cancelling")`
4. Wait briefly for shutdown responses (15s per member timeout)
5. Re-read config.json to check for remaining members (reconciliation pass)
6. Call `TeamDelete()` to clean up
7. Remove any local state: `rm -f .omc/state/team-state.json`
8. Report structured summary to user
TEAM_CONFIGS=$(find ~/.claude/teams -name config.json -maxdepth 2 2>/dev/null)

**两步取消协议:**

**第一步:优雅关闭**
对于在~/.claude/teams/中找到的每个Team:
  1. 读取config.json以获取team_name和成员列表
  2. 对每个非领导者成员: a. 通过SendMessage发送shutdown_request b. 等待最多15秒以获取shutdown_response c. 若收到响应:成员终止并自动移除 d. 若超时:标记成员为无响应,继续下一个
  3. 日志:"优雅关闭阶段:X/Y个成员已响应"

**第二步:协调处理**
优雅关闭阶段后:
  1. 重新读取config.json以检查剩余成员
  2. 若仅剩余领导者(或配置为空):执行TeamDelete
  3. 若仍有无响应成员: a. 再等待5秒(他们可能仍在处理) b. 再次重新读取config.json c. 若仍卡住:尝试执行TeamDelete d. 若TeamDelete失败:报告手动清理路径

**TeamDelete + 清理:**
  1. 调用TeamDelete() — 删除~/.claude/teams/{name}/和~/.claude/tasks/{name}/
  2. 清除Team状态:state_clear(mode="team")
  3. 检查是否有关联的ralph:state_read(mode="ralph") — 若linked_team为true: a. 清除ralph状态:state_clear(mode="ralph") b. 若有则清除关联的ultrawork:state_clear(mode="ultrawork")
  4. 生成结构化取消报告

**结构化取消报告:**
Team "{team_name}"已取消:
  • 已发送信号的成员数:N
  • 已收到响应的成员数:M
  • 无响应成员数:K(如有则列出名称)
  • TeamDelete:成功/失败
  • 是否需要手动清理:是/否 路径:~/.claude/teams/{name}/ 和 ~/.claude/tasks/{name}/

**实现说明:** Cancel技能由LLM执行,而非bash脚本。当检测到活跃Team时:
1. 读取`~/.claude/teams/*/config.json`以查找活跃Team
2. 若存在多个Team,按`createdAt`顺序取消最早的Team
3. 对每个非领导者成员,调用`SendMessage(type: "shutdown_request", recipient: member-name, content: "Cancelling")`
4. 短暂等待关闭响应(每个成员超时15秒)
5. 重新读取config.json以检查剩余成员(协调处理阶段)
6. 调用`TeamDelete()`进行清理
7. 删除本地状态:`rm -f .omc/state/team-state.json`
8. 向用户报告结构化摘要

If Autopilot Active

若Autopilot处于活跃状态

Call
cancelAutopilot()
from
src/hooks/autopilot/cancel.ts:27-78
:
bash
undefined
调用
src/hooks/autopilot/cancel.ts:27-78
中的
cancelAutopilot()
bash
undefined

Autopilot handles its own cleanup + ralph + ultraqa

Autopilot会处理自身清理 + ralph + ultraqa

Just mark autopilot as inactive (preserves state for resume)

仅标记autopilot为非活跃状态(保留状态以便恢复)

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." fi
undefined
if [[ -f .omc/state/autopilot-state.json ]]; then

若ralph活跃则清理

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')
# 先清理关联的ultrawork
if [[ "$LINKED_UW" == "true" ]] && [[ -f .omc/state/ultrawork-state.json ]]; then
  rm -f .omc/state/ultrawork-state.json
  echo "已清理:ultrawork(与ralph关联)"
fi

# 清理ralph
rm -f .omc/state/ralph-state.json
rm -f .omc/state/ralph-verification.json
echo "已清理:ralph"
fi

若ultraqa活跃则清理

if [[ -f .omc/state/ultraqa-state.json ]]; then rm -f .omc/state/ultraqa-state.json echo "已清理:ultraqa" fi

标记autopilot为非活跃但保留状态

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已在阶段:$CURRENT_PHASE 取消。进度已保留以便恢复。" echo "运行/oh-my-claudecode:autopilot以恢复。" fi
undefined

If Ralph Active (but not Autopilot)

若Ralph处于活跃状态(但Autopilot未活跃)

Call
clearRalphState()
+
clearLinkedUltraworkState()
from
src/hooks/ralph-loop/index.ts:147-182
:
bash
if [[ -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."
fi
调用
src/hooks/ralph-loop/index.ts:147-182
中的
clearRalphState()
+
clearLinkedUltraworkState()
bash
if [[ -f .omc/state/ralph-state.json ]]; then
  # 检查是否关联了ultrawork
  RALPH_STATE=$(cat .omc/state/ralph-state.json)
  LINKED_UW=$(echo "$RALPH_STATE" | jq -r '.linked_ultrawork // false')

  # 先清理关联的ultrawork
  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')

    # 仅当与ralph关联时才清除
    if [[ "$UW_LINKED" == "true" ]]; then
      rm -f .omc/state/ultrawork-state.json
      echo "已清理:ultrawork(与ralph关联)"
    fi
  fi

  # 清理ralph状态
  rm -f .omc/state/ralph-state.json
  rm -f .omc/state/ralph-plan-state.json
  rm -f .omc/state/ralph-verification.json

  echo "Ralph已取消。持久化模式已停用。"
fi

If Ultrawork Active (standalone, not linked)

若Ultrawork处于活跃状态(独立模式,未关联)

Call
deactivateUltrawork()
from
src/hooks/ultrawork/index.ts:150-173
:
bash
if [[ -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."
fi
调用
src/hooks/ultrawork/index.ts:150-173
中的
deactivateUltrawork()
bash
if [[ -f .omc/state/ultrawork-state.json ]]; then
  # 检查是否与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与Ralph关联。使用/oh-my-claudecode:cancel以同时取消两者。"
    exit 1
  fi

  # 删除本地状态
  rm -f .omc/state/ultrawork-state.json

  echo "Ultrawork已取消。并行执行模式已停用。"
fi

If UltraQA Active (standalone)

若UltraQA处于活跃状态(独立模式)

Call
clearUltraQAState()
from
src/hooks/ultraqa/index.ts:107-120
:
bash
if [[ -f .omc/state/ultraqa-state.json ]]; then
  rm -f .omc/state/ultraqa-state.json
  echo "UltraQA cancelled. QA cycling workflow stopped."
fi
调用
src/hooks/ultraqa/index.ts:107-120
中的
clearUltraQAState()
bash
if [[ -f .omc/state/ultraqa-state.json ]]; then
  rm -f .omc/state/ultraqa-state.json
  echo "UltraQA已取消。QA循环工作流已停止。"
fi

No Active Modes

无活跃模式

bash
echo "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."
bash
echo "未检测到活跃的OMC模式。"
echo ""
echo "已检查:"
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 "使用--force标志以清除所有状态文件。"

Implementation Notes

实现说明

The cancel skill runs as follows:
  1. Parse the
    --force
    /
    --all
    flags, tracking whether cleanup should span every session or stay scoped to the current session id.
  2. Use
    state_list_active
    to enumerate known session ids and
    state_get_status
    to learn the active mode (
    autopilot
    ,
    ralph
    ,
    ultrawork
    , etc.) for each session.
  3. When operating in default mode, call
    state_clear
    with that session_id to remove only the session’s files, then run mode-specific cleanup (autopilot → ralph → …) based on the state tool signals.
  4. In force mode, iterate every active session, call
    state_clear
    per session, then run a global
    state_clear
    without
    session_id
    to drop legacy files (
    .omc/state/*.json
    , compatibility artifacts) and report success. Swarm remains a shared SQLite/marker mode outside session scoping.
  5. Team artifacts (
    ~/.claude/teams/*/
    ,
    ~/.claude/tasks/*/
    ,
    .omc/state/team-state.json
    ) remain best-effort cleanup items invoked during the legacy/global pass.
State tools always honor the
session_id
argument, so even force mode still clears the session-scoped paths before deleting compatibility-only legacy state.
Mode-specific subsections below describe what extra cleanup each handler performs after the state-wide operations finish.
Cancel技能的执行流程如下:
  1. 解析
    --force
    /
    --all
    标志,跟踪清理操作是否应覆盖所有会话或仅局限于当前会话ID。
  2. 使用
    state_list_active
    枚举已知会话ID,并使用
    state_get_status
    了解每个会话的活跃模式(
    autopilot
    ralph
    ultrawork
    等)。
  3. 在默认模式下,使用该会话ID调用
    state_clear
    以仅删除该会话的文件,然后根据状态工具的信号执行模式特定的清理(autopilot → ralph → …)。
  4. 在强制模式下,遍历所有活跃会话,对每个会话调用
    state_clear
    ,然后执行不带
    session_id
    的全局
    state_clear
    以删除遗留文件(
    .omc/state/*.json
    、兼容性工件)并报告成功。Swarm仍属于会话范围外的共享SQLite/标记模式。
  5. Team工件(
    ~/.claude/teams/*/
    ~/.claude/tasks/*/
    .omc/state/team-state.json
    )仍会在遗留/全局清理阶段尽可能被清理。
状态工具始终遵循
session_id
参数,因此即使在强制模式下,也会先清除会话范围的路径,再删除仅兼容的遗留状态。
以下模式特定小节描述了在状态范围操作完成后,每个处理程序执行的额外清理操作。

Messages Reference

消息参考

ModeSuccess 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."
模式成功消息
Autopilot"Autopilot已在阶段:{phase}取消。进度已保留以便恢复。"
Ralph"Ralph已取消。持久化模式已停用。"
Ultrawork"Ultrawork已取消。并行执行模式已停用。"
Ecomode"Ecomode已取消。令牌高效执行模式已停用。"
UltraQA"UltraQA已取消。QA循环工作流已停止。"
Swarm"Swarm已取消。协同Agent已停止。"
Ultrapilot"Ultrapilot已取消。并行autopilot工作进程已停止。"
Pipeline"Pipeline已取消。顺序Agent链已停止。"
Team"Team已取消。团队成员已关闭并清理。"
Plan Consensus"Plan Consensus已取消。规划会话已结束。"
Force"所有OMC模式已清除。你可以重新开始。"
None"未检测到活跃的OMC模式。"

What Gets Preserved

保留的内容

ModeState PreservedResume Command
AutopilotYes (phase, files, spec, plan, verdicts)
/oh-my-claudecode:autopilot
RalphNoN/A
UltraworkNoN/A
UltraQANoN/A
SwarmNoN/A
UltrapilotNoN/A
PipelineNoN/A
Plan ConsensusYes (plan file path preserved)N/A
模式保留的状态恢复命令
Autopilot是(阶段、文件、规格、计划、 verdicts)
/oh-my-claudecode:autopilot
RalphN/A
UltraworkN/A
UltraQAN/A
SwarmN/A
UltrapilotN/A
PipelineN/A
Plan Consensus是(保留计划文件路径)N/A

Notes

注意事项

  • Dependency-aware: Autopilot cancellation cleans up Ralph and UltraQA
  • Link-aware: Ralph cancellation cleans up linked Ultrawork or Ecomode
  • Safe: Only clears linked Ultrawork, preserves standalone Ultrawork
  • Local-only: Clears state files in
    .omc/state/
    directory
  • Resume-friendly: Autopilot state is preserved for seamless resume
  • Team-aware: Detects native Claude Code teams and performs graceful shutdown
  • 依赖感知:取消Autopilot会清理Ralph和UltraQA
  • 关联感知:取消Ralph会清理其关联的Ultrawork或Ecomode
  • 安全可靠:仅清除关联的Ultrawork,保留独立的Ultrawork
  • 本地操作:清除
    .omc/state/
    目录中的状态文件
  • 易于恢复:Autopilot状态被保留以实现无缝恢复
  • Team感知:检测原生Claude Code Team并执行优雅关闭

MCP Worker Cleanup

MCP Worker清理

When cancelling modes that may have spawned MCP workers (team bridge daemons), the cancel skill should also:
  1. Check for active MCP workers: Look for heartbeat files at
    .omc/state/team-bridge/{team}/*.heartbeat.json
  2. Send shutdown signals: Write shutdown signal files for each active worker
  3. Kill tmux sessions: Run
    tmux kill-session -t omc-team-{team}-{worker}
    for each worker
  4. Clean up heartbeat files: Remove all heartbeat files for the team
  5. Clean up shadow registry: Remove
    .omc/state/team-mcp-workers.json
当取消可能已生成MCP Worker(team bridge守护进程)的模式时,Cancel技能还应:
  1. 检查活跃的MCP Worker:查找
    .omc/state/team-bridge/{team}/*.heartbeat.json
    路径下的心跳文件
  2. 发送关闭信号:为每个活跃Worker写入关闭信号文件
  3. 终止tmux会话:对每个Worker执行
    tmux kill-session -t omc-team-{team}-{worker}
  4. 清理心跳文件:删除该Team的所有心跳文件
  5. 清理影子注册表:删除
    .omc/state/team-mcp-workers.json

Force Clear Addition

强制清除补充内容

When
--force
is used, also clean up:
bash
rm -rf .omc/state/team-bridge/       # Heartbeat files
rm -f .omc/state/team-mcp-workers.json  # Shadow registry
当使用
--force
时,还需清理:
bash
rm -rf .omc/state/team-bridge/       # 心跳文件
rm -f .omc/state/team-mcp-workers.json  # 影子注册表

Kill all omc-team-* tmux sessions

终止所有omc-team-* tmux会话

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
undefined
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
undefined