Cancellable Loop
SkillCommunicationExample skill, demonstrates cooperative cancellation inside a skill script loop using check_cancelled(). Use as a reference when writing long-running domain skills that must respond to notifications/cancelled. Not intended for production use.
Use Cancellable Loop in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add Cancellable Loop and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the Cancellable Loop skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; ahel provides instructions and does not run this skill.
No other account needed.
Add ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.
What this skill tells your AI
The instructions your AI receives, as published by dcc-mcp/dcc-mcp-core in examples/skills/cancellable-loop/SKILL.md and read by ahel’s review.
A minimal example that shows how to write a skill script that honours
notifications/cancelled from the MCP client.
The pattern is simple: call check_cancelled() at the top of every
iteration of a long-running loop. When the dispatcher installs a
CancelToken and the client cancels the request, check_cancelled()
raises CancelledError and the script unwinds cleanly. Outside of a
request context (REPL, unit tests) check_cancelled() is a no-op, so
the same script remains easy to run in isolation.
Tools
cancellable_loop__count— Iterateiterationstimes, sleepingsleep_msmilliseconds per step, checking for cancellation each iteration.
Example
{"name": "cancellable_loop__count", "arguments": {"iterations": 100, "sleep_ms": 50}}
# → {"success": true, "message": "Completed 100 iterations", "context": {"iterations": 100}}
If the client sends notifications/cancelled while the loop is
running, the next check_cancelled() call raises CancelledError and
the @skill_entry wrapper converts it into a standard error dict.
Related
dcc_mcp_core.check_cancelled— the API this skill demonstrates.- Issue #329 — cooperative cancellation checkpoints.
- Issue #318 — async dispatcher integration (wires the CancelToken).
Signals
- GitHub stars
- 51
- Forks
- 4
- Last commit
- Oct 2026
Advanced
- Item type
- skill
- Key
cancellable-loop- Source
- github.com/dcc-mcp/dcc-mcp-core
github.com/dcc-mcp/dcc-mcp-core
Related picks
Skill · wshobson
The pick for Pythonpython-pro
Skill · jeffallan
The pick for Pythonslack-gif-creator
Skill · anthropics
More in Communicationerror-handling
Skill · affaan-m
More in Communicationemails
Skill · coreyhaines31
More in Communicationwait-what
Skill · mattpocock
More in Communication