dune-migration
Migrating OCaml projects from ocamlbuild/topkg to dune. Use when discussing _tags files, .mllib files, pkg/pkg.ml, topkg, or build system migration.
Unsigned, install at your own risk
UnverifiedThis skill has no cryptographic signature attached. We can't verify the contents match what the publisher intended.
Install this skill
No account required. Pick your tool, or use the command that detects it for you.
Run in your terminal. It detects your AI tool.
npx @skills-hub-ai/cli install ocaml-dev-dune-migrationManual setup by platform
Claude Code
~/.claude/skills/ocaml-dev-dune-migration/SKILL.md
Instructions
OCaml Build System Migration
When to Use This Skill
Invoke this skill when:
- Converting a project from ocamlbuild to dune
- Discussing _tags, .mllib, or pkg.ml files
- Migrating from topkg to dune
- Understanding ocamlbuild artifacts
Process Overview
1. Analyze the Existing Build
Read these files to understand the project:
_tags- ocamlbuild compilation flags and package dependenciespkg/pkg.ml- topkg package descriptionpkg/META- findlib metadata*.mllibfiles - module lists for librariesopam- package dependencies
2. Create dune-project
(lang dune 3.20)
(name <package-name>)
(generate_opam_files true)
3. Create Library dune Files
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>))
4. Handle Toplevel Init Files
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))
5. Handle Warnings
If the original code triggers warnings:
(library
(name lib)
(flags (:standard -w -27)))
Common warnings to suppress in vendored code:
-w -27- unused variable
6. Create Test dune File
(test
(name test_name)
(libraries lib_name alcotest))
For optional tests:
(executable
(name test_optional)
(modules test_optional)
(optional)
(libraries lib some_optional_lib))
7. Update opam File
- Rename
opamto<package>.opam - Remove ocamlbuild/topkg dependencies
- Add dune:
depends: [
"ocaml" {>= "4.14.0"}
"dune" {>= "3.0"}
]
- Update build commands:
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}
]
8. Documentation dune File
If there's a doc/ directory:
(documentation
(package <package-name>))
9. Remove ocamlbuild Files
Files to delete:
_tags.merlinpkg/pkg.mlpkg/META*.mllibfiles*.itargetfiles- The
pkg/directory
Mapping Reference
| 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 |
Common Issues
"Library not found" for optional deps
Use (optional) on the library stanza.
Unused variable warnings
Add (flags (:standard -w -27)).
Module in wrong library
Use (modules ...) to explicitly list modules.
Toplevel init files
Exclude from library with (modules ...) and use (install ...).
Verification
After migration:
dune build @check # Verify syntax
dune build # Build project
dune runtest # Run tests
dune build @doc # Build docs
Security
Reviews (0)
Related skills
Browse all →More from OCaml Dev (avsm)
View source →More Build skills
Browse category →Frequently asked questions about dune-migration
What does the dune-migration skill do?
Migrating OCaml projects from ocamlbuild/topkg to dune. Use when discussing _tags files, .mllib files, pkg/pkg.ml, topkg, or build system migration. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.
How do I install the dune-migration skill?
Run `npx @skills-hub-ai/cli install ocaml-dev-dune-migration` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/ocaml-dev-dune-migration/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.
Which AI tools does dune-migration work with?
dune-migration runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.
Is the dune-migration skill free?
Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.
How do I use dune-migration after installing it?
In Claude Code, type `/ocaml-dev-dune-migration` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.
Can I share the dune-migration skill with my team?
Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.