plugins/ocaml-dev/skills/dune-migration/SKILL.md
Migrating OCaml projects from ocamlbuild/topkg to dune. Use when discussing _tags files, .mllib files, pkg/pkg.ml, topkg, or build system migration.
npx skillsauth add avsm/ocaml-claude-marketplace dune-migrationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Invoke this skill when:
Read these files to understand the project:
_tags - ocamlbuild compilation flags and package dependenciespkg/pkg.ml - topkg package descriptionpkg/META - findlib metadata*.mllib files - module lists for librariesopam - package dependencies(lang dune 3.20)
(name <package-name>)
(generate_opam_files true)
For each library (from .mllib files):
(library
(name <library_name>)
(public_name <package.subname>)
(libraries <dependencies>))
For optional libraries (from pkg/pkg.ml):
(library
(name <library_name>)
(public_name <package.subname>)
(optional)
(libraries <dependencies>))
Files like *_top_init.ml shouldn't be compiled as modules:
(library
(name lib_name)
(modules lib_module) ; Explicitly list modules
(libraries deps))
(install
(package pkg)
(section lib)
(files lib_top_init.ml))
If the original code triggers warnings:
(library
(name lib)
(flags (:standard -w -27)))
Common warnings to suppress in vendored code:
-w -27 - unused variable(test
(name test_name)
(libraries lib_name alcotest))
For optional tests:
(executable
(name test_optional)
(modules test_optional)
(optional)
(libraries lib some_optional_lib))
opam to <package>.opamdepends: [
"ocaml" {>= "4.14.0"}
"dune" {>= "3.0"}
]
build: [
["dune" "subst"] {dev}
["dune" "build" "-p" name "-j" jobs]
["dune" "runtest" "-p" name "-j" jobs] {with-test}
["dune" "build" "@doc" "-p" name "-j" jobs] {with-doc}
]
If there's a doc/ directory:
(documentation
(package <package-name>))
Files to delete:
_tags.merlinpkg/pkg.mlpkg/META*.mllib files*.itarget filespkg/ directory| ocamlbuild | dune |
|------------|------|
| _tags: package(foo) | (libraries foo) |
| _tags: thread | (libraries threads) |
| foo.mllib with Foo | (library (name foo) (modules foo)) |
| pkg/pkg.ml: Pkg.mllib ~cond:x | (library ... (optional)) |
| pkg/META | Auto-generated by dune |
| opam | <package>.opam |
Use (optional) on the library stanza.
Add (flags (:standard -w -27)).
Use (modules ...) to explicitly list modules.
Exclude from library with (modules ...) and use (install ...).
After migration:
dune build @check # Verify syntax
dune build # Build project
dune runtest # Run tests
dune build @doc # Build docs
tools
Working with the OxCaml extensions to OCaml. Use when the oxcaml compiler is available and you need high-performance, unboxing, stack allocation, data-race-free parallelism
development
Creating OCaml library tutorials using .mld documentation format with MDX executable examples. Use when discussing tutorials, documentation, .mld files, MDX, or interactive documentation.
development
Testing strategies for OCaml libraries. Use when discussing tests, alcotest, eio mocks, test structure, or test-driven development in OCaml projects.
development
Security hardening for OCaml libraries through systematic vulnerability research. Use when Claude needs to: (1) Research CVEs in similar implementations (C, Rust, Go, Python) and add regression tests, (2) Add fuzz tests for parsers and encoders, (3) Audit integer handling and buffer operations, (4) Test boundary conditions and malformed input, (5) Review cryptographic usage, (6) Add defensive checks against common vulnerability classes