cancellable-loop

cancellable-loop is a skill for Claude Code, Codex from dcc-mcp/dcc-mcp-core. It costs 45 tokens per session (482 once invoked), scanned A, original, MIT.

A small example showing how a long-running loop can notice when the user or calling program asks it to stop. Cooperative cancellation means the loop checks for that request during its work and exits cleanly.

In plain words
What is it for?
Use it when writing or studying skills that repeat work over many steps and need to respond to cancellation requests.
Why use it?
It demonstrates how to prevent lengthy tasks from continuing after cancellation. The example can be used as a reference when building similar skills.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when writing or studying skills that repeat work over many steps and need to respond to cancellation requests.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/dcc-mcp/dcc-mcp-core/cancellable-loop
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add dcc-mcp/dcc-mcp-core --skill cancellable-loop
Clone the repo
git clone --depth 1 https://github.com/dcc-mcp/dcc-mcp-core

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cancellable-loop

README.md
[![agentmods](https://agentmods.dev/badge/skills/dcc-mcp/dcc-mcp-core/cancellable-loop/github.svg)](https://agentmods.dev/skills/dcc-mcp/dcc-mcp-core/cancellable-loop)
Your own site
<a href="https://agentmods.dev/skills/dcc-mcp/dcc-mcp-core/cancellable-loop"><img src="https://agentmods.dev/badge/skills/dcc-mcp/dcc-mcp-core/cancellable-loop/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for cancellable-loop

Your own site · 80×15
<a href="https://agentmods.dev/skills/dcc-mcp/dcc-mcp-core/cancellable-loop"><img src="https://agentmods.dev/badge/skills/dcc-mcp/dcc-mcp-core/cancellable-loop.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 45 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 482 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00045 $0.00482
Opus 5.5 $0.00018 $0.00193
Sonnet 5.5 $0.00009 $0.00096
Haiku 4.5 $0.00005 $0.00048

Measured 27d ago against content hash ffc75f428267, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

cancellable-loop scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 27d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/count.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

examples/skills/cancellable-loop/SKILL.md · 58 lines

What it actually says

Cancellable Loop

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 — Iterate iterations times, sleeping sleep_ms milliseconds 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.

  • dcc_mcp_core.check_cancelled — the API this skill demonstrates.
  • Issue #329 — cooperative cancellation checkpoints.
  • Issue #318 — async dispatcher integration (wires the CancelToken).
Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 27d ago Changed · +5 lines ffc75f428267
  2. 1mo ago First seen · 53 lines · 45 tokens per session scan A d7d8a5217ab0

Subscribe to this mod's changes

cancellable-loop is a skill published in the GitHub repository dcc-mcp/dcc-mcp-core (70 stars, last pushed today), licensed MIT. It adds 45 tokens to every session and 482 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.