cancel by yeachan-heo/oh-my-claudecode
npx skills add https://github.com/yeachan-heo/oh-my-claudecode --skill cancel智能取消功能,检测并取消活动的 OMC 模式。
取消技能是完成并退出任何 OMC 模式的标准方式。 当停止钩子检测到工作完成时,它会指示 LLM 调用此技能以进行适当的状态清理。如果取消失败或被中断,请使用 --force 标志重试,或作为最后手段等待 2 小时的不活动超时。
自动检测哪个模式处于活动状态并取消它:
/oh-my-claudecode:cancel
或说:"cancelomc", "stopomc"
/oh-my-claudecode:cancel 遵循会话感知状态约定:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
state_list_active 和 state_get_status 检查当前会话,导航 .omc/state/sessions/{sessionId}/… 以发现哪个模式处于活动状态。.omc/state/*.json 中的遗留文件作为兼容性回退方案进行查询。.omc/state/swarm.db / .omc/state/swarm-active.marker),不在会话作用域内。state_clear 并传入会话 ID,以仅删除匹配的会话文件;模式仍绑定到其原始会话。活动模式仍按依赖顺序取消:
当您需要擦除每个会话以及遗留工件时,例如要完全重置工作区,请使用 --force 或 --all。
/oh-my-claudecode:cancel --force
/oh-my-claudecode:cancel --all
内部执行的步骤:
state_list_active 枚举 .omc/state/sessions/{sessionId}/… 以查找每个已知会话。state_clear 对每个会话运行一次以删除该会话的文件。session_id 的全局 state_clear 会删除 .omc/state/*.json、.omc/state/swarm*.db 下的遗留文件以及兼容性工件(见列表)。~/.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/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/omc-teams-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/(清除会话后的空目录清理)当您调用此技能时:
# 检查 --force 或 --all 标志
FORCE_MODE=false
if [[ "$*" == *"--force"* ]] || [[ "$*" == *"--all"* ]]; then
FORCE_MODE=true
fi
该技能现在依赖于会话感知状态约定,而不是硬编码的文件路径:
state_list_active 以枚举 .omc/state/sessions/{sessionId}/… 并发现每个活动会话。state_get_status 以了解哪个模式正在运行(autopilot、ralph、ultrawork 等)以及是否存在依赖模式。/oh-my-claudecode:cancel 提供了 session_id,则完全跳过遗留回退,仅在该会话路径内操作;否则,仅当状态工具报告没有活动会话时,才查询 .omc/state/*.json 中的遗留文件。Swarm 仍然是会话作用域之外的共享 SQLite/标记模式。使用强制模式通过 state_clear 清除每个会话以及遗留工件。直接文件删除保留用于状态工具报告没有活动会话时的遗留清理。
通过检查 ~/.claude/teams/ 中的配置文件来检测团队:
# 检查活动团队
TEAM_CONFIGS=$(find ~/.claude/teams -name config.json -maxdepth 2 2>/dev/null)
两阶段取消协议:
阶段 1:优雅关闭
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"
阶段 2:协调
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 + 清理:
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. Run orphan scan (see below)
5. Emit structured cancel report
孤儿检测(清理后):
TeamDelete 后,验证没有智能体进程残留:
node "${CLAUDE_PLUGIN_ROOT}/scripts/cleanup-orphans.mjs" --team-name "{team_name}"
孤儿扫描器:
ps aux(Unix)或 tasklist(Windows)中是否有 --team-name 匹配已删除团队的进程使用 --dry-run 进行检查而不杀死进程。扫描器可以安全地多次运行。
结构化取消报告:
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}/
实现说明: 取消技能由 LLM 执行,而不是作为 bash 脚本执行。当您检测到活动团队时:
~/.claude/teams/*/config.json 以查找活动团队createdAt)SendMessage(type: "shutdown_request", recipient: member-name, content: "Cancelling")TeamDelete() 进行清理state_clear(mode="team", session_id)Autopilot 处理其自身的清理,包括关联的 ralph 和 ultraqa。
state_read(mode="autopilot", session_id) 读取 autopilot 状态以获取当前阶段state_read(mode="ralph", session_id) 检查关联的 ralph:
linked_ultrawork: true,则首先清除 ultrawork:state_clear(mode="ultrawork", session_id)state_clear(mode="ralph", session_id)state_read(mode="ultraqa", session_id) 检查关联的 ultraqa:
state_clear(mode="ultraqa", session_id)state_write(mode="autopilot", session_id, state={active: false, ...existing}) 将 autopilot 标记为非活动状态(保留状态以供恢复)state_read(mode="ralph", session_id) 读取 ralph 状态以检查关联的 ultraworklinked_ultrawork: true:
linked_to_ralph: truestate_clear(mode="ultrawork", session_id)state_clear(mode="ralph", session_id)state_read(mode="ultrawork", session_id) 读取 ultrawork 状态linked_to_ralph: true,警告用户改为取消 ralph(这将级联)state_clear(mode="ultrawork", session_id)直接清除:state_clear(mode="ultraqa", session_id)
报告:"未检测到活动的 OMC 模式。使用 --force 清除所有状态文件。"
取消技能按以下方式运行:
--force / --all 标志,跟踪清理是否应跨越每个会话或保持在当前会话 ID 的作用域内。state_list_active 枚举已知的会话 ID,并使用 state_get_status 了解每个会话的活动模式(autopilot、ralph、ultrawork 等)。state_clear 并传入该 session_id 以仅删除会话的文件,然后根据状态工具信号运行特定于模式的清理(autopilot → ralph → …)。state_clear,然后运行不带 session_id 的全局 state_clear 以删除遗留文件(.omc/state/*.json、兼容性工件)并报告成功。Swarm 仍然是会话作用域之外的共享 SQLite/标记模式。~/.claude/teams/*/、~/.claude/tasks/*/、.omc/state/team-state.json)仍然是尽力清理项,在遗留/全局阶段调用。状态工具始终遵循 session_id 参数,因此即使在强制模式下,也会在删除仅用于兼容性的遗留状态之前清除会话作用域路径。
下面的特定于模式的小节描述了每个处理程序在状态范围操作完成后执行的额外清理。
| 模式 | 成功消息 |
|---|---|
| Autopilot | "Autopilot 已在阶段取消:{phase}。进度已保留以供恢复。" |
| Ralph | "Ralph 已取消。持久化模式已停用。" |
| Ultrawork | "Ultrawork 已取消。并行执行模式已停用。" |
| UltraQA | "UltraQA 已取消。QA 循环工作流已停止。" |
| Swarm | "Swarm 已取消。协调的智能体已停止。" |
| Ultrapilot | "Ultrapilot 已取消。并行 autopilot 工作器已停止。" |
| Pipeline | "Pipeline 已取消。顺序智能体链已停止。" |
| Team | "团队已取消。队友已关闭并清理。" |
| Plan Consensus | "Plan Consensus 已取消。规划会话已结束。" |
| Force | "所有 OMC 模式已清除。您可以重新开始。" |
| None | "未检测到活动的 OMC 模式。" |
| 模式 | 状态保留 | 恢复命令 |
|---|---|---|
| Autopilot | 是(阶段、文件、规范、计划、裁决) | /oh-my-claudecode:autopilot |
| Ralph | 否 | 不适用 |
| Ultrawork | 否 | 不适用 |
| UltraQA | 否 | 不适用 |
| Swarm | 否 | 不适用 |
| Ultrapilot | 否 | 不适用 |
| Pipeline | 否 | 不适用 |
| Plan Consensus | 是(计划文件路径保留) | 不适用 |
.omc/state/ 目录中的状态文件当取消可能已生成 MCP 工作器(团队桥接守护进程)的模式时,取消技能还应:
.omc/state/team-bridge/{team}/*.heartbeat.json 处查找心跳文件tmux kill-session -t omc-team-{team}-{worker}.omc/state/team-mcp-workers.json当使用 --force 时,同时清理:
rm -rf .omc/state/team-bridge/ # 心跳文件
rm -f .omc/state/team-mcp-workers.json # 影子注册表
# 终止所有 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
每周安装次数
128
代码仓库
GitHub 星标数
11.2K
首次出现
2026年1月24日
安全审计
安装于
claude-code122
opencode117
cursor112
codex111
gemini-cli111
github-copilot101
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.
Automatically detects which mode is active and cancels it:
/oh-my-claudecode:cancel
Or say: "cancelomc", "stopomc"
/oh-my-claudecode:cancel follows the session-aware state contract:
state_list_active and state_get_status, navigating .omc/state/sessions/{sessionId}/… to discover which mode is active..omc/state/*.json are consulted only as a compatibility fallback if the session id is missing or empty..omc/state/swarm.db / .omc/state/swarm-active.marker) and is not session-scoped.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:
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:
state_list_active enumerates .omc/state/sessions/{sessionId}/… to find every known session.state_clear runs once per session to drop that session’s files.state_clear without session_id removes legacy files under .omc/state/*.json, .omc/state/swarm*.db, and compatibility artifacts (see list).~/.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/ultraqa-state.json.omc/state/swarm.db.omc/state/swarm.db-wal.omc/state/swarm.db-shmWhen you invoke this skill:
# Check for --force or --all flags
FORCE_MODE=false
if [[ "$*" == *"--force"* ]] || [[ "$*" == *"--all"* ]]; then
FORCE_MODE=true
fi
The skill now relies on the session-aware state contract rather than hard-coded file paths:
state_list_active to enumerate .omc/state/sessions/{sessionId}/… and discover every active session.state_get_status to learn which mode is running (autopilot, ralph, ultrawork, etc.) and whether dependent modes exist.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.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.
Teams are detected by checking for config files in ~/.claude/teams/:
# Check for active teams
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. Run orphan scan (see below)
5. Emit structured cancel report
Orphan Detection (Post-Cleanup):
After TeamDelete, verify no agent processes remain:
node "${CLAUDE_PLUGIN_ROOT}/scripts/cleanup-orphans.mjs" --team-name "{team_name}"
The orphan scanner:
ps aux (Unix) or tasklist (Windows) for processes with --team-name matching the deleted teamUse --dry-run to inspect without killing. The scanner is safe to run multiple times.
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:
~/.claude/teams/*/config.json to find active teamscreatedAt)SendMessage(type: "shutdown_request", recipient: member-name, content: "Cancelling")TeamDelete() to clean upstate_clear(mode="team", session_id)Autopilot handles its own cleanup including linked ralph and ultraqa.
state_read(mode="autopilot", session_id) to get current phasestate_read(mode="ralph", session_id):
linked_ultrawork: true, clear ultrawork first: state_clear(mode="ultrawork", session_id)state_clear(mode="ralph", session_id)state_read(mode="ultraqa", session_id):
state_clear(mode="ultraqa", session_id)state_write(mode="autopilot", session_id, state={active: false, ...existing})state_read(mode="ralph", session_id) to check for linked ultraworklinked_ultrawork: true:
linked_to_ralph: truestate_clear(mode="ultrawork", session_id)state_clear(mode="ralph", session_id)state_read(mode="ultrawork", session_id)linked_to_ralph: true, warn user to cancel ralph instead (which cascades)state_clear(mode="ultrawork", session_id)Clear directly: state_clear(mode="ultraqa", session_id)
Report: "No active OMC modes detected. Use --force to clear all state files anyway."
The cancel skill runs as follows:
--force / --all flags, tracking whether cleanup should span every session or stay scoped to the current session id.state_list_active to enumerate known session ids and state_get_status to learn the active mode (autopilot, ralph, ultrawork, etc.) for each session.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.state_clear per session, then run a global state_clear without to drop legacy files (, compatibility artifacts) and report success. Swarm remains a shared SQLite/marker mode outside session scoping.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.
| 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." |
| 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) | /oh-my-claudecode:autopilot |
| 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/ directoryWhen cancelling modes that may have spawned MCP workers (team bridge daemons), the cancel skill should also:
.omc/state/team-bridge/{team}/*.heartbeat.jsontmux kill-session -t omc-team-{team}-{worker} for each worker.omc/state/team-mcp-workers.jsonWhen --force is used, also clean up:
rm -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
Weekly Installs
128
Repository
GitHub Stars
11.2K
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code122
opencode117
cursor112
codex111
gemini-cli111
github-copilot101
AI Elements:基于shadcn/ui的AI原生应用组件库,快速构建对话界面
66,200 周安装
.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/omc-teams-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)session_id.omc/state/*.json~/.claude/teams/*/, ~/.claude/tasks/*/, .omc/state/team-state.json) remain best-effort cleanup items invoked during the legacy/global pass.