Terminates any active autonomous agent mode and cleans up internal states reliably.
Install
mkdir -p .claude/skills/cancel && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/3746" && unzip -o skill.zip -d .claude/skills/cancel && rm skill.zipInstalls to .claude/skills/cancel
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Cancel any active OMC mode (autopilot, ralph, ultrawork, ultraqa, swarm, ultrapilot, pipeline, team)Key capabilities
- →Detects active OMC agent modes like autopilot or swarm
- →Performs graceful state cleanup for interrupted tasks
- →Supports force-exit via specific CLI flags
- →Coordinates sequential shutdown requests for team-based agents
- →Clears state files to unblock stop hook loops
How it works
Triggers a teardown hook that systematically stops active background processes and clears associated state management files.
Inputs & outputs
When to use cancel
- →Cancel an active autopilot session
- →Stop a swarm agent operation
- →Interrupt a running pipeline
- →Force exit after a stalled operation
About this skill
Cancel Skill
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.
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)
- UltraQA: Stops QA cycling workflow
- Ultragoal: Clears the session-scoped ultragoal runtime guard (
.omc/state/.../ultragoal-state.json) so PreToolUse/goalenforcement and Stop reinforcement release. Durable.omc/ultragoal/plan/ledger artifacts are preserved. - Swarm: Stops coordinated agent swarm, releases claimed tasks
- Ultrapilot: Stops parallel autopilot workers
- Pipeline: Stops sequential agent pipeline
- Team: Requests shutdown from all teammates through the active team/conversation surface, waits for responses/timeouts, clears OMC team state, clears linked ralph if present. Claude Code 2.1.178+ has no TeamDelete.
- Team+Ralph (linked): Cancels team first (graceful shutdown), then clears ralph state. Cancelling ralph when linked also cancels team first.
Usage
/oh-my-claudecode:cancel
Or say: "cancelomc", "stopomc"
Critical: Deferred Tool Handling
The state management tools (state_clear, state_read, state_write, state_list_active,
state_get_status) may be registered as deferred tools by Claude Code. Before calling
any state tool, you MUST first load all of them via ToolSearch:
ToolSearch(query="select:mcp__plugin_oh-my-claudecode_t__state_clear,mcp__plugin_oh-my-claudecode_t__state_read,mcp__plugin_oh-my-claudecode_t__state_write,mcp__plugin_oh-my-claudecode_t__state_list_active,mcp__plugin_oh-my-claudecode_t__state_get_status")
If state_clear is unavailable or fails, use this bash fallback as an emergency
escape from the stop hook loop. This is NOT a full replacement for the cancel flow —
it only removes state files to unblock the session. Linked modes (e.g. ralph→ultrawork,
autopilot→ralph/ultraqa) must be cleared separately by running the fallback once per mode.
Replace MODE with the specific mode (e.g. ralplan, ralph, ultrawork, ultraqa, ultragoal).
WARNING: Do NOT use this fallback for autopilot or omc-teams. Autopilot requires
state_write(active=false) to preserve resume data. omc-teams requires tmux session
cleanup that cannot be done via file deletion alone.
# Fallback: direct file removal when state_clear MCP tool is unavailable
SESSION_ID="${CLAUDE_SESSION_ID:-${CLAUDECODE_SESSION_ID:-}}"
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || { d="$PWD"; while [ "$d" != "/" ] && [ ! -d "$d/.omc" ]; do d="$(dirname "$d")"; done; echo "$d"; })"
# Cross-platform SHA-256 (macOS: shasum, Linux: sha256sum)
sha256portable() { printf '%s' "$1" | (sha256sum 2>/dev/null || shasum -a 256) | cut -c1-16; }
# Resolve state directory (supports OMC_STATE_DIR centralized storage)
if [ -n "${OMC_STATE_DIR:-}" ]; then
# Mirror getProjectIdentifier() from worktree-paths.ts
SOURCE="$(git remote get-url origin 2>/dev/null || echo "$REPO_ROOT")"
HASH="$(sha256portable "$SOURCE")"
DIR_NAME="$(basename "$REPO_ROOT" | sed 's/[^a-zA-Z0-9_-]/_/g')"
OMC_STATE="$OMC_STATE_DIR/${DIR_NAME}-${HASH}/state"
[ ! -d "$OMC_STATE" ] && { echo "ERROR: State dir not found at $OMC_STATE" >&2; exit 1; }
elif [ "$REPO_ROOT" != "/" ] && [ -d "$REPO_ROOT/.omc" ]; then
OMC_STATE="$REPO_ROOT/.omc/state"
else
echo "ERROR: Could not locate .omc state directory" >&2
exit 1
fi
MODE="ralplan" # <-- replace with the target mode
# Clear session-scoped state for the specific mode
if [ -n "$SESSION_ID" ] && [ -d "$OMC_STATE/sessions/$SESSION_ID" ]; then
rm -f "$OMC_STATE/sessions/$SESSION_ID/${MODE}-state.json"
rm -f "$OMC_STATE/sessions/$SESSION_ID/${MODE}-stop-breaker.json"
rm -f "$OMC_STATE/sessions/$SESSION_ID/skill-active-state.json"
# Write cancel signal so stop hook detects cancellation in progress
NOW_ISO="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
EXPIRES_ISO="$(date -u -d "+30 seconds" +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || python3 - <<'PY'\nfrom datetime import datetime, timedelta, timezone\nprint((datetime.now(timezone.utc) + timedelta(seconds=30)).strftime('%Y-%m-%dT%H:%M:%SZ'))\nPY\n)"
printf '{"active":true,"requested_at":"%s","expires_at":"%s","mode":"%s","source":"bash_fallback"}' \
"$NOW_ISO" "$EXPIRES_ISO" "$MODE" > "$OMC_STATE/sessions/$SESSION_ID/cancel-signal-state.json"
fi
# Clear legacy state only if no session ID (avoid clearing another session's state)
if [ -z "$SESSION_ID" ]; then
rm -f "$OMC_STATE/${MODE}-state.json"
fi
Auto-Detection
/oh-my-claudecode:cancel follows the session-aware state contract:
- By default the command inspects the current session via
state_list_activeandstate_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/*.jsonare 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_clearwith 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:
- Autopilot (includes linked ralph/ultraqa/ cleanup)
- Ralph (cleans its linked ultrawork or )
- Ultrawork (standalone)
- UltraQA (standalone)
- Ultragoal (standalone runtime guard —
state_clear(mode="ultragoal"); preserves durable.omc/ultragoal/artifacts) - Swarm (standalone)
- Ultrapilot (standalone)
- Pipeline (standalone)
- Team (Claude Code native)
- OMC Teams (tmux CLI workers)
- Plan Consensus (standalone)
- Self-Improve (standalone — clear state, clean orphaned worktrees, preserve iteration_state for resume, set status: "user_stopped" in the resolved
<self-improve-root>/state/agent-settings.json; new runs use.omc/self-improve/topics/<topic-slug>/, with flat.omc/self-improve/retained only for legacy single-track resumes)
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:
state_list_activeenumerates.omc/state/sessions/{sessionId}/…to find every known session.state_clearruns once per session to drop that session’s files.- A global
state_clearwithoutsession_idremoves legacy files under.omc/state/*.json,.omc/state/swarm*.db, and compatibility artifacts (see list). - Team artifacts (
~/.claude/teams/*/,~/.claude/tasks/*/,.omc/state/team-state.json) are best-effort cleared as part of the legacy fallback.- Cancel for native team does NOT affect omc-teams state, and vice versa.
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-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/(directory).omc/state/sessions/(empty directory cleanup after clearing sessions)
Implementation Steps
When you invoke this skill:
1. Parse Arguments
# Check for --force or --all flags
FORCE_MODE=false
if [[ "$*" == *"--force"* ]] || [[ "$*" == *"--all"* ]]; then
FORCE_MODE=true
fi
2. Detect Active Modes
The skill now relies on the session-aware state contract rather than hard-coded file paths:
- Call
state_list_activeto enumerate.omc/state/sessions/{sessionId}/…and discover every active session. - For each session id, call
state_get_statusto learn which mode is running (autopilot,ralph,ultrawork, etc.) and whether dependent modes exist. - If a
session_idwas supplied to/oh-my-claudecode:cancel, skip legacy fallback entirely and operate solely within that session path; otherwise, consult legacy files in.omc/state/*.jsononly if the state tools report no active session. Swarm remains a shared SQLite/marker mode outside session scoping. - Any cancellation logic in this doc mirrors the dependency order discovered via state tools (autopilot → ralph → …).
3A. Force Mode (if --force or --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.
3B. Smart Cancellation (default)
If Team Active (Claude Code implicit team)
Teams are detected through OMC team state, not removed Claude Code ~/.claude/teams config directories
Content truncated.
When not to use it
- →When the agent is performing a critical file-system write operation
- →When you only want to pause rather than terminate the session
Limitations
- →Can result in loss of unsaved partial work if forced
- →Requires state tools to be pre-loaded via ToolSearch for reliability
How it compares
It executes an agent-aware graceful shutdown sequence rather than just killing the process signal (SIGKILL).
Compared to similar skills
cancel side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| cancel (this skill) | 1 | 3mo | Review | Beginner |
| using-superpowers | 95 | 3mo | No flags | Beginner |
| ultrawork | 11 | 2mo | No flags | Advanced |
| clawhub | 25 | 2mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by Yeachan-Heo
View all by Yeachan-Heo →You might also like
using-superpowers
obra
Use when starting any conversation - establishes mandatory workflows for finding and using skills, including using Skill tool before announcing usage, following brainstorming before coding, and creating TodoWrite todos for checklists
ultrawork
Yeachan-Heo
Parallel execution engine for high-throughput task completion
clawhub
openclaw
Use the ClawHub CLI to search, install, update, and publish agent skills from clawhub.com. Use when you need to fetch new skills on the fly, sync installed skills to latest or a specific version, or publish new/updated skill folders with the npm-installed clawhub CLI.
skill-installer
openai
Install Codex skills into $CODEX_HOME/skills from a curated list or a GitHub repo path. Use when a user asks to list installable skills, install a curated skill, or install a skill from another repo (including private repos).
continuous-learning
affaan-m
Automatically extract reusable patterns from Claude Code sessions and save them as learned skills for future use.
memory-keeper-proactive-context-maintenance
b4CU-R4U
Automatically detect and maintain memory freshness by monitoring context staleness, significant code changes, task completions, and phase transitions. Proactively suggests and executes memory sync operations with user confirmation. Use when the user says "sync memory", "update context", or when the Skill detects that context is stale (>2 hours), significant changes have occurred (new commits), tasks completed, or major milestones reached. Replaces passive "context is stale" warnings with active maintenance.