cancel
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCancel 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 flag, or wait for the 2-hour staleness timeout as
a last resort.
--force智能取消功能,可检测并取消处于活跃状态的OMC模式。
Cancel技能是完成并退出任何OMC模式的标准方式。
当停止钩子检测到工作完成时,会指示LLM调用此技能以进行适当的状态清理。如果取消操作失败或被中断,可使用标志重试,或者作为最后手段等待2小时的过期超时。
--forceWhat 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:cancelOr say: "cancelomc", "stopomc"
/oh-my-claudecode:cancel或者输入:"cancelomc"、"stopomc"
Auto-Detection
自动检测机制
/oh-my-claudecode:cancel- By default the command inspects the current session via and
state_list_active, navigatingstate_get_statusto discover which mode is active..omc/state/sessions/{sessionId}/… - When a session id is provided or already known, that session-scoped path is authoritative. Legacy files in are consulted only as a compatibility fallback if the session id is missing or empty.
.omc/state/*.json - Swarm is a shared SQLite/marker mode (/
.omc/state/swarm.db) and is not session-scoped..omc/state/swarm-active.marker - The default cleanup flow calls with the session id to remove only the matching session files; modes stay bound to their originating session.
state_clear
Active modes are still cancelled in dependency order:
- Autopilot (includes linked ralph/ultraqa/ecomode cleanup)
- Ralph (cleans its linked ultrawork or ecomode)
- Ultrawork (standalone)
- Ecomode (standalone)
- UltraQA (standalone)
- Swarm (standalone)
- Ultrapilot (standalone)
- Pipeline (standalone)
- Team (Claude Code native)
- 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
活跃模式仍会按依赖顺序取消:
- Autopilot(包括关联的ralph/ultraqa/ecomode清理)
- Ralph(清理其关联的ultrawork或ecomode)
- Ultrawork(独立模式)
- Ecomode(独立模式)
- UltraQA(独立模式)
- Swarm(独立模式)
- Ultrapilot(独立模式)
- Pipeline(独立模式)
- Team(Claude Code原生模式)
- Plan Consensus(独立模式)
Force Clear All
强制清除所有内容
Use or when you need to erase every session plus legacy artifacts, e.g., to reset the workspace entirely.
--force--all/oh-my-claudecode:cancel --force/oh-my-claudecode:cancel --allSteps under the hood:
- enumerates
state_list_activeto find every known session..omc/state/sessions/{sessionId}/… - runs once per session to drop that session’s files.
state_clear - A global without
state_clearremoves legacy files undersession_id,.omc/state/*.json, and compatibility artifacts (see list)..omc/state/swarm*.db - Team artifacts (,
~/.claude/teams/*/,~/.claude/tasks/*/) are best-effort cleared as part of the legacy fallback..omc/state/team-state.json
Every command honors the argument, so even force mode still uses the session-aware paths first before deleting legacy files.
state_clearsession_idLegacy 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- (directory)
.omc/state/checkpoints/ - (empty directory cleanup after clearing sessions)
.omc/state/sessions/
当你需要擦除所有会话及遗留工件时,可使用或参数,例如完全重置工作区。
--force--all/oh-my-claudecode:cancel --force/oh-my-claudecode:cancel --all后台执行步骤:
- 枚举
state_list_active以查找所有已知会话。.omc/state/sessions/{sessionId}/… - 对每个会话ID,执行以删除该会话的文件。
state_clear - 不带的全局
session_id会删除state_clear、.omc/state/*.json等遗留文件及兼容性工件(见列表)。.omc/state/swarm*.db - Team工件(、
~/.claude/teams/*/、~/.claude/tasks/*/)会在遗留回退流程中尽可能清理。.omc/state/team-state.json
每个命令都会遵循参数,因此即使在强制模式下,也会先清理会话范围的路径,再删除遗留文件。
state_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/
Implementation Steps
实现步骤
When you invoke this skill:
当你调用此技能时:
1. Parse Arguments
1. 解析参数
bash
undefinedbash
undefinedCheck for --force or --all flags
检查--force或--all标志
FORCE_MODE=false
if [[ "$" == "--force" ]] || [[ "$" == "--all" ]]; then
FORCE_MODE=true
fi
undefinedFORCE_MODE=false
if [[ "$" == "--force" ]] || [[ "$" == "--all" ]]; then
FORCE_MODE=true
fi
undefined2. Detect Active Modes
2. 检测活跃模式
The skill now relies on the session-aware state contract rather than hard-coded file paths:
- Call to enumerate
state_list_activeand discover every active session..omc/state/sessions/{sessionId}/… - For each session id, call to learn which mode is running (
state_get_status,autopilot,ralph, etc.) and whether dependent modes exist.ultrawork - If a was supplied to
session_id, skip legacy fallback entirely and operate solely within that session path; otherwise, consult legacy files in/oh-my-claudecode:cancelonly if the state tools report no active session. Swarm remains a shared SQLite/marker mode outside session scoping..omc/state/*.json - Any cancellation logic in this doc mirrors the dependency order discovered via state tools (autopilot → ralph → …).
该技能现在依赖会话感知状态约定,而非硬编码文件路径:
- 调用枚举
state_list_active并发现所有活跃会话。.omc/state/sessions/{sessionId}/… - 对每个会话ID,调用以了解运行中的模式(
state_get_status、autopilot、ralph等)以及是否存在依赖模式。ultrawork - 如果提供了
/oh-my-claudecode:cancel,则完全跳过遗留回退,仅在该会话路径内操作;否则,仅当状态工具报告无活跃会话时,才会查询session_id中的遗留文件。Swarm仍属于会话范围外的共享SQLite/标记模式。.omc/state/*.json - 本文档中的任何取消逻辑均与状态工具发现的依赖顺序(autopilot → ralph → …)一致。
3A. Force Mode (if --force or --all)
3A. 强制模式(如果使用--force或--all)
Use force mode to clear every session plus legacy artifacts via . Direct file removal is reserved for legacy cleanup when the state tools report no active sessions.
state_clear使用强制模式通过清除所有会话及遗留工件。仅当状态工具报告无活跃会话时,才会直接删除文件进行遗留清理。
state_clear3B. 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通过检查中的配置文件检测Team:
~/.claude/teams/bash
undefinedCheck 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/:
- Read config.json to get team_name and members list
- 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
- Log: "Graceful pass: X/Y members responded"
**Pass 2: Reconciliation**After graceful pass:
- Re-read config.json to check remaining members
- If only lead remains (or config is empty): proceed to TeamDelete
- 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:**- Call TeamDelete() — removes ~/.claude/teams/{name}/ and ~/.claude/tasks/{name}/
- Clear team state: state_clear(mode="team")
- 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")
- 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 userTEAM_CONFIGS=$(find ~/.claude/teams -name config.json -maxdepth 2 2>/dev/null)
**两步取消协议:**
**第一步:优雅关闭**对于在~/.claude/teams/中找到的每个Team:
- 读取config.json以获取team_name和成员列表
- 对每个非领导者成员: a. 通过SendMessage发送shutdown_request b. 等待最多15秒以获取shutdown_response c. 若收到响应:成员终止并自动移除 d. 若超时:标记成员为无响应,继续下一个
- 日志:"优雅关闭阶段:X/Y个成员已响应"
**第二步:协调处理**优雅关闭阶段后:
- 重新读取config.json以检查剩余成员
- 若仅剩余领导者(或配置为空):执行TeamDelete
- 若仍有无响应成员: a. 再等待5秒(他们可能仍在处理) b. 再次重新读取config.json c. 若仍卡住:尝试执行TeamDelete d. 若TeamDelete失败:报告手动清理路径
**TeamDelete + 清理:**- 调用TeamDelete() — 删除~/.claude/teams/{name}/和~/.claude/tasks/{name}/
- 清除Team状态:state_clear(mode="team")
- 检查是否有关联的ralph:state_read(mode="ralph") — 若linked_team为true: a. 清除ralph状态:state_clear(mode="ralph") b. 若有则清除关联的ultrawork:state_clear(mode="ultrawork")
- 生成结构化取消报告
**结构化取消报告:**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 from :
cancelAutopilot()src/hooks/autopilot/cancel.ts:27-78bash
undefined调用中的:
src/hooks/autopilot/cancel.ts:27-78cancelAutopilot()bash
undefinedAutopilot 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
undefinedif [[ -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
undefinedIf Ralph Active (but not Autopilot)
若Ralph处于活跃状态(但Autopilot未活跃)
Call + from :
clearRalphState()clearLinkedUltraworkState()src/hooks/ralph-loop/index.ts:147-182bash
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-182clearRalphState()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已取消。持久化模式已停用。"
fiIf Ultrawork Active (standalone, not linked)
若Ultrawork处于活跃状态(独立模式,未关联)
Call from :
deactivateUltrawork()src/hooks/ultrawork/index.ts:150-173bash
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-173deactivateUltrawork()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已取消。并行执行模式已停用。"
fiIf UltraQA Active (standalone)
若UltraQA处于活跃状态(独立模式)
Call from :
clearUltraQAState()src/hooks/ultraqa/index.ts:107-120bash
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-120clearUltraQAState()bash
if [[ -f .omc/state/ultraqa-state.json ]]; then
rm -f .omc/state/ultraqa-state.json
echo "UltraQA已取消。QA循环工作流已停止。"
fiNo 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:
- Parse the /
--forceflags, tracking whether cleanup should span every session or stay scoped to the current session id.--all - Use to enumerate known session ids and
state_list_activeto learn the active mode (state_get_status,autopilot,ralph, etc.) for each session.ultrawork - When operating in default mode, call with that session_id to remove only the session’s files, then run mode-specific cleanup (autopilot → ralph → …) based on the state tool signals.
state_clear - In force mode, iterate every active session, call per session, then run a global
state_clearwithoutstate_clearto drop legacy files (session_id, compatibility artifacts) and report success. Swarm remains a shared SQLite/marker mode outside session scoping..omc/state/*.json - Team artifacts (,
~/.claude/teams/*/,~/.claude/tasks/*/) remain best-effort cleanup items invoked during the legacy/global pass..omc/state/team-state.json
State tools always honor the argument, so even force mode still clears the session-scoped paths before deleting compatibility-only legacy state.
session_idMode-specific subsections below describe what extra cleanup each handler performs after the state-wide operations finish.
Cancel技能的执行流程如下:
- 解析/
--force标志,跟踪清理操作是否应覆盖所有会话或仅局限于当前会话ID。--all - 使用枚举已知会话ID,并使用
state_list_active了解每个会话的活跃模式(state_get_status、autopilot、ralph等)。ultrawork - 在默认模式下,使用该会话ID调用以仅删除该会话的文件,然后根据状态工具的信号执行模式特定的清理(autopilot → ralph → …)。
state_clear - 在强制模式下,遍历所有活跃会话,对每个会话调用,然后执行不带
state_clear的全局session_id以删除遗留文件(state_clear、兼容性工件)并报告成功。Swarm仍属于会话范围外的共享SQLite/标记模式。.omc/state/*.json - Team工件(、
~/.claude/teams/*/、~/.claude/tasks/*/)仍会在遗留/全局清理阶段尽可能被清理。.omc/state/team-state.json
状态工具始终遵循参数,因此即使在强制模式下,也会先清除会话范围的路径,再删除仅兼容的遗留状态。
session_id以下模式特定小节描述了在状态范围操作完成后,每个处理程序执行的额外清理操作。
Messages Reference
消息参考
| 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." |
| 模式 | 成功消息 |
|---|---|
| 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
保留的内容
| 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 |
| 模式 | 保留的状态 | 恢复命令 |
|---|---|---|
| Autopilot | 是(阶段、文件、规格、计划、 verdicts) | |
| Ralph | 否 | N/A |
| Ultrawork | 否 | N/A |
| UltraQA | 否 | N/A |
| Swarm | 否 | N/A |
| Ultrapilot | 否 | N/A |
| Pipeline | 否 | N/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 directory
.omc/state/ - 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:
- Check for active MCP workers: Look for heartbeat files at
.omc/state/team-bridge/{team}/*.heartbeat.json - Send shutdown signals: Write shutdown signal files for each active worker
- Kill tmux sessions: Run for each worker
tmux kill-session -t omc-team-{team}-{worker} - Clean up heartbeat files: Remove all heartbeat files for the team
- Clean up shadow registry: Remove
.omc/state/team-mcp-workers.json
当取消可能已生成MCP Worker(team bridge守护进程)的模式时,Cancel技能还应:
- 检查活跃的MCP Worker:查找路径下的心跳文件
.omc/state/team-bridge/{team}/*.heartbeat.json - 发送关闭信号:为每个活跃Worker写入关闭信号文件
- 终止tmux会话:对每个Worker执行
tmux kill-session -t omc-team-{team}-{worker} - 清理心跳文件:删除该Team的所有心跳文件
- 清理影子注册表:删除
.omc/state/team-mcp-workers.json
Force Clear Addition
强制清除补充内容
When is used, also clean up:
--forcebash
rm -rf .omc/state/team-bridge/ # Heartbeat files
rm -f .omc/state/team-mcp-workers.json # Shadow registry当使用时,还需清理:
--forcebash
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
undefinedtmux 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