/moonbit-skills:make-moonbit-c-bindingsfrom moonbit-skills
Guides creation of complete, maintainable MoonBit FFI bindings for C/C++ libraries: upstream survey, vendoring, safe API design, documentation tests, and ASan validation.
Ships in moonbit-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Use this skill for end-to-end binding projects. Also read moonbit-c-binding
before implementation for low-level FFI syntax, ownership annotations, and
moonbit.h details.
templates/prepare.py or link to a system library only
when that is explicitly desired.moon check, native tests, ASan, moon info, and vendoring
script idempotency.Prefer this layout, adapting names to the library. Start from bundled templates instead of rewriting scaffolding from scratch:
scripts/prepare.py # optional: pinned upstream download + generated stubs
moon.mod.json # preferred/supported native targets
src/moon.pkg # native-stub list and file target gates
src/wrapper.c # ABI normalization and ownership boundaries
src/ffi.mbt # private extern "c" declarations
src/<domain>.mbt # safe public MoonBit API
src/<domain>_test.mbt # regression tests
src/README.mbt.md # tested documentation examples
README.md -> src/README.mbt.md
Template mapping:
templates/prepare.py -> scripts/prepare.pytemplates/moon.mod.json -> moon.mod.jsontemplates/moon.pkg -> src/moon.pkgtemplates/wrapper.c -> src/wrapper.ctemplates/ffi.mbt -> src/ffi.mbttemplates/api.mbt -> src/<domain>.mbttemplates/README.mbt.md -> src/README.mbt.mdFor ASan validation, copy or invoke the companion runner from
moonbit-c-binding/scripts/run-asan.py as scripts/run-asan.py; do not invent
a new ASan patching script unless that runner cannot fit the project.
destroy/free calls.native-stub with a pinned
revision and a repeatable script.ffi.mbt should keep externs private and use #borrow / #owned explicitly.Moonbit_array_length in C.Run, at minimum:
moon fmt
moon check --target all --warn-list +73
moon test --target native
python3 scripts/run-asan.py
moon info --target native
python3 scripts/prepare.py
git status --short
For native-only packages, set "preferred-target": "native" and
the smallest true "supported-targets" value in moon.mod.json.
Lifecycle And Ownership; Vendoring And Package Setup; Testing And Documentation.
references/lifecycle-and-ownership.md (opens in a new tab)references/testing-and-documentation.md (opens in a new tab)references/vendoring-and-package-setup.md (opens in a new tab)templates/README.mbt.md (opens in a new tab)templates/api.mbt (opens in a new tab)templates/ffi.mbt (opens in a new tab)templates/moon.mod.json (opens in a new tab)templates/moon.pkg (opens in a new tab)templates/prepare.py (opens in a new tab)templates/wrapper.c (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub moonbitlang/skills --plugin moonbit-skills9 skills in this plugin
/moonbit-agent-guideGuide for writing, refactoring, and testing MoonBit projects, including exclusive use of `.mbtx` for agent-authored automation. Use when working in MoonBit modules or packages, organizing MoonBit files, using moon tooling (build/check/run/test/doc/ide etc.), or following MoonBit-specific layout, scripting, documentation, and testing conventions./moonbit-c-bindingGuide for writing MoonBit bindings to C libraries using native FFI. Use when adding extern "c" declarations, writing C stubs with moonbit.h, configuring native-stub and link.native in moon.pkg, choosing/moonbit-extract-spec-testExtract formal spec and comprehensive test suites from existing MoonBit implementations. Use when asked to "extract spec from implementation", "generate tests from code", or "create spec-driven tests for existing package". Analyzes existing code to produce spec.mbt with `declare` keyword stubs and organized test files (valid/invalid)./moonbit-orientationUse this skill when the user needs help solving MoonBit language, code, compiler diagnostic, package, toolchain, backend, FFI, test, or "does MoonBit have X?" questions. Use it even when MoonBit is only implied by .mbt files, moon.mod/moon.pkg manifests (or legacy moon.mod.json/moon.pkg.json), moon commands, wasm/js/native targets, or mooncakes packages. This skill helps choose the right MoonBit source of truth, discover APIs with moon ide, avoid stale assumptions, and validate fixes./moonbit-proofUse when writing or refactoring proof-carrying code in MoonBit, especially for Why3-backed specifications, abstraction functions, representation invariants, proof assertions, recursive verified data structures, or reducing trusted proof bridges./moonbit-refactoringRefactor MoonBit code to be idiomatic: shrink public APIs, convert functions to methods, use pattern matching with views, add loop invariants, and ensure test coverage without regressions. Use when updating MoonBit packages or refactoring MoonBit APIs, modules, or tests.Other plugins' skills for the same job