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 completion, it instructs the LLM to invoke this
skill for state cleanup. Retry a failed operation in the same scope and report
what remains; --force changes shutdown urgency, never scope, lock handling,
or ownership checks. --all is the only cross-session authorization.
Cancellation Contract
The flags control independent scope and shutdown dimensions:
| Invocation | Scope | Shutdown behavior |
|---|---|---|
| no flags | Current session only | Graceful cancellation, including teammate shutdown waits |
--force | Current session only | Forced cancellation: skip graceful waits, but still use protected state tools and honor locks/ownership |
--all | Every known session, by explicit session id | Normal safe cancellation independently for each session, then explicit legacy/global cleanup |
--force --all | Every known session, by explicit session id | Forced-all: skip graceful waits for each session, then perform the authorized legacy/global cleanup |
Resolve the current identity from OMC_SESSION_ID in CLI contexts or the
hook-provided session_id. A missing or ambiguous identity for no flags or
--force fails closed: do not aggregate state, choose a discovered session,
or issue an unscoped cleanup. This is a fail-closed error for the default
command and for --force. --all may enumerate known sessions, but every
concrete id is still read, cancelled, and cleared independently.
What It Does
Automatically detects and cancels active modes:
- Autopilot: Stops the workflow while preserving progress for resume.
- Ralph: Stops the persistence loop.
- Legacy Ultrawork / UltraQA: Removes stale upgraded-installation state only; neither is a live workflow.
- Ultragoal: Clears its session runtime guard while preserving durable
.omc/ultragoal/plan and ledger artifacts. - Swarm: Stops coordinated agents and releases claimed tasks only in its authorized shared cleanup path.
- Ultrapilot / Pipeline: Stops their worker or sequential execution.
- Team: Uses the active team surface for graceful shutdown, then clears
session-scoped Team state; forced paths skip waits. Claude Code 2.1.178+ has
no
TeamDelete. - Team + Ralph: Team is cancelled first, then linked Ralph is cleared in the same session; a Team failure retains linked Ralph.
- OMC Teams, Plan Consensus, and Self-Improve: Use their mode-specific protected cleanup and preserve artifacts designated for resume.
Usage
/oh-my-claudecode:cancel
/oh-my-claudecode:cancel --force
/oh-my-claudecode:cancel --all
/oh-my-claudecode:cancel --force --all
Or say: cancelomc, stopomc.
Critical: Deferred Tool Handling
The state tools (state_clear, state_read, state_write,
state_list_active, state_get_status) may be deferred by Claude Code. Before
calling any of them, load all of them with 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, retry the same scoped operation and
report the failure. The fallback below is only an emergency escape from a
stop-hook loop for a non-force, non-Team cancellation. It removes files only
for an explicitly identified current session. Do NOT use this fallback for
autopilot, team, or omc-teams, or for --force/--all; never use it to
bypass a lock, ownership check, corruption, or another state-tool failure.
Linked modes need one protected operation per mode.
Replace MODE with the specific mode (for example ralplan, ralph,
ultrawork, or ultragoal).
# Emergency fallback: direct file removal for one identified session only.
SESSION_ID="${OMC_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"; })"
sha256portable() { printf '%s' "$1" | (sha256sum 2>/dev/null || shasum -a 256) | cut -c1-16; }
if [ -n "${OMC_STATE_DIR:-}" ]; then
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"
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
[ -d "$OMC_STATE" ] || { echo "ERROR: State dir not found at $OMC_STATE" >&2; exit 1; }
MODE="ralplan" # replace with the target mode
[ -n "$SESSION_ID" ] || { echo "ERROR: current session identity is required; refusing unscoped fallback" >&2; exit 1; }
if [ -d "$OMC_STATE/sessions/$SESSION_ID" ]; then
rm -f "$OMC_STATE/sessions/$SESSION_ID/${MODE}-state.json" \
"$OMC_STATE/sessions/$SESSION_ID/${MODE}-stop-breaker.json" \
"$OMC_STATE/sessions/$SESSION_ID/skill-active-state.json"
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'
from datetime import datetime, timedelta, timezone
print((datetime.now(timezone.utc) + timedelta(seconds=30)).strftime('%Y-%m-%dT%H:%M:%SZ'))
PY
)"
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
Cancellation Flow
This is the authoritative procedure for every invocation.
1. Parse Arguments
Parse exact flags independently; unknown or near-match arguments do nothing:
FORCE_MODE=false
ALL_MODE=false
for arg in "$@"; do
case "$arg" in
--force) FORCE_MODE=true ;;
--all) ALL_MODE=true ;;
esac
done
SCOPE="current"
if [[ "$ALL_MODE" == true ]]; then SCOPE="all"; fi
GRACEFUL_MODE=true
if [[ "$FORCE_MODE" == true ]]; then GRACEFUL_MODE=false; fi
The parsed values select exactly one row in the contract above.
2. Detect Active Modes
- For no flags or
--force, require one unambiguous current session id and callstate_list_active(session_id="<current_session_id>"). Its scoped result is authoritative; never use an aggregate result to infer ownership. - For
--all, callstate_list_active(all=true)once and retain every concrete session id. Discovery enumerates targets; it is not a Team read. - For each selected id, call
state_get_status(mode="<mode>", session_id="<session_id>")before mode cleanup. Treat Ultrawork as retired cleanup input. - Pass the selected id to every read, write, and clear. Protected state tools enforce the shared mutation lock and ownership boundary; no flag bypasses either one.
Use this dependency order when several modes appear in one scoped status:
- Autopilot (including its linked Ralph and retired-state cleanup)
- Standalone Ralph
- Retired Ultrawork and UltraQA
- Ultragoal runtime guard
- Shared Swarm state (global pass only)
- Ultrapilot and Pipeline
- Native Team
- Legacy OMC Teams
- Plan Consensus and Self-Improve
Ralph linked to Team is excluded from the standalone step and is handled only after Team succeeds; this prevents the persistence loop from outliving workers.
3. Cancel Each Selected Session
Process each selected session independently in this dependency order. A failed
or unresolved scoped operation marks that session unsuccessful: retain affected
state/runtime records, report the scope and reason, and do not claim linked
cleanup. An --all run may continue other ids, but any such failure blocks the
final global pass.
Autopilot (primary first)
- Read the exact session state, including
workflowRunIdwhen present. - Pause only that run with
state_write(mode="autopilot", session_id="<session_id>", active=false, state={workflowRunId: "<exact run id>"}); do not replay the readback. The state tool revalidates workflow integrity under its mutation lock. - If the primary write fails, stop this session's dependent cleanup. Otherwise,
clear only same-session named-workflow
state_clear(mode="ralplan", session_id="<session_id>"), then linked Ralph, then retired UltraQA. Preserve the paused primary for resume when a dependent clear fails. Force mode keeps this primary-first ordering.
The primary pause preserves workflow, pipeline tracking, and task identity. A
target_state_sha256 may be supplied only when it is the exact hash of the
current serialized state. Never clear nested ralplan, linked state, cancel
signals, or runtime artifacts after a failed primary write; report the exact
dependent failure and retry it in the same session.
Team (native Claude Code)
- Read
state_read(mode="team", session_id="<session_id>")and obtain the captured team name and active worker labels. Never select a Team from an aggregate read. - On graceful paths, signal each named teammate through the active surface, wait up to 15 seconds per member, then reconcile for 5 more seconds. Record acknowledgements and timeouts. Forced paths skip both waits.
- After graceful confirmation/timeouts (or immediately when forced), clear
state_clear(mode="team", session_id="<session_id>"). If the protected clear fails for lock, ownership, corruption, or another reason, retain Team runtime records and linked Ralph; do not use an unscoped clear or fallback. - Only after Team clear succeeds, inspect linked Ralph and clear it with the
same session id (
state_read(mode="ralph", session_id="<session_id>")then `state_clear(mode="ralph", session_id="<session_i
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 | 4mo | Review | Beginner |
| using-superpowers | 95 | 5mo | No flags | Beginner |
| ultrawork | 11 | 4mo | No flags | Advanced |
| clawhub | 25 | 4mo | 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.