Agent skill · modular

closure_migration

Migrates Mojo code off legacy parametric closures (`capturing[_]`, `@__parameter` / `@parameter`, `api[fn](args)`) onto value-taking unified closures (`api(args, fn)` with `{imm}` / `{mut}` / `{var}` / named capture lists). Use when removing parametric overloads, fixing "capturing thin" conversion errors, rewriting nested launch/callback closures, or migrating any API that took a comptime function parameter. Also use when CI SIGSEGVs while compiling a Mojo object with `compile_offload_closure func must be fully bound` — that is host elaboration; verify with `kgen -elaborate`, not remote GPU execution.

What it needs

About 11k tokens when loaded.

What this skill does

Closure migration Migrate callers before deleting parametric overloads. Prefer value-taking APIs with unified closures. Pair with mojo-syntax (and mojo-gpu-fundamentals for GPU launch code). Forbidden Hard ban — do not under any circumstance add @parameter / @parameter to a nested closure to persist, introduce, or paper over a legacy closure. Not as a migration bridge, not to satisfy a still-capturing API, not to “borrow imm”, not behind a thin value wrapper. That is forbidden. Hard ban — do not under any circumstance add a new caller of a capturing parametric endpoint (func: def(...) capturing [] -> None or capturing without thin), or restore a deleted capturing overload, to paper over a typecheck or bind failure. Look at the callee parameter type: thin is a function pointer and is fine (addfunction[vecadd], compilefunctionkernel). capturing and not thin is the legacy closure. Do not route a unified-closure site back through capturing[]. Hard ban — do not write an empty capture list {}. If the nested def has no free runtime captures, omit the list: def foo() -> Int: not def foo() {} -> Int: and not raises {}. {} is not a spelling of “no captures”; it is noise that reviewers will flag. {imm} is capture-all of outer state, not a stand-in for an empty list. Do not Do instead -------- ------------ @parameter / @parameter on nested defs Unified def … {imm}: / {mut x, imm}: / named captures @parameter body + value forwarder Make the body unified; pass it as a value @parameter “imm borrow” helper File-scope / normal function with an imm parameter @copycapture(x, y) dropped for {imm} {var x, var y, imm} (copy each listed name). {var} capture-all only if every capture was copy-captured. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills modular/closure_migration

View the source on GitHub

Browse the @skills marketplace