port-to-dune

port-to-dune is a command for Claude Code from avsm/ocaml-claude-marketplace. It costs 12 tokens per session (908 once invoked), scanned A, original, ISC.

A command that moves an OCaml project from ocamlbuild or topkg to Dune. Dune is a build system that describes how OCaml code is compiled, tested, and packaged.

In plain words
What is it for?
Migrating projects that contain files such as _tags, .mllib, pkg.ml, META, or opam.
Why use it?
It replaces older build metadata with Dune project and library configuration while carrying over dependencies and compiler settings.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the ocaml-dev plugin — 21 skills, 5 commands shipped together

Good fit Migrating projects that contain files such as _tags, .mllib, pkg.ml, META, or opam.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/avsm/ocaml-claude-marketplace/port-to-dune
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.

Clone the repo
git clone --depth 1 https://github.com/avsm/ocaml-claude-marketplace

Made for: Claude Code.

Or install ocaml-dev, the plugin that ships this one along with the rest of its 21 skills, 5 commands.

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 port-to-dune

README.md
[![agentmods](https://agentmods.dev/badge/commands/avsm/ocaml-claude-marketplace/port-to-dune/github.svg)](https://agentmods.dev/commands/avsm/ocaml-claude-marketplace/port-to-dune)
Your own site
<a href="https://agentmods.dev/commands/avsm/ocaml-claude-marketplace/port-to-dune"><img src="https://agentmods.dev/badge/commands/avsm/ocaml-claude-marketplace/port-to-dune/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 port-to-dune

Your own site · 80×15
<a href="https://agentmods.dev/commands/avsm/ocaml-claude-marketplace/port-to-dune"><img src="https://agentmods.dev/badge/commands/avsm/ocaml-claude-marketplace/port-to-dune.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 12 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 908 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.
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.00012 $0.00908
Opus 5 $0.00006 $0.00454
Sonnet 5 $0.00002 $0.00182
Haiku 4.5 $0.00001 $0.00091

Measured 8d ago against content hash 582dea20fb6a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

port-to-dune 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 8d ago.

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.

plugins/ocaml-dev/commands/port-to-dune.md · 163 lines

How it starts

The opening of the file, as written. The whole thing — 163 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Port to Dune

This command migrates an OCaml project from ocamlbuild/topkg to dune.

Arguments

None - operates on the current directory.

Prerequisites

The command expects to find ocamlbuild artifacts:

  • _tags - ocamlbuild compilation flags
  • *.mllib files - module lists for libraries
  • pkg/pkg.ml - topkg package description (optional)
  • pkg/META - findlib metadata (optional)
  • opam - package dependencies

Migration Process

1. Analyze Existing Build

Read and parse:

  • _tags - Extract package dependencies, compiler flags, thread usage
  • *.mllib - Identify libraries and their modules
  • pkg/pkg.ml - Find optional libraries and conditions
  • pkg/META - Get public library names
  • opam - Current dependencies

2. Create dune-project

(lang dune 3.20)
(name <package-name>)
(generate_opam_files true)
; ... rest from existing opam metadata

3. Create Library dune Files

For each library identified 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 Special Cases

Warning suppression (if needed):

(flags (:standard -w -27))

Toplevel init files (excluded from library):

(library
 (name lib_name)
 (modules lib_module)
 (libraries deps))

(install
 (package pkg)
 (section lib)
 (files lib_top_init.ml))

5. Create Test dune Files

(test
 (name test_name)
 (libraries lib_name alcotest))

6. Update opam File

  • Rename opam to <package>.opam
  • Remove ocamlbuild/topkg dependencies
  • Add dune dependency
  • Update build commands

7. Cleanup

List files to delete (don't delete automatically):

  • _tags
  • .merlin
  • pkg/pkg.ml
  • pkg/META
  • *.mllib files
  • *.itarget files

Mapping Reference

ocamlbuild dune
_tags: package(foo) (libraries foo)
_tags: thread (libraries threads)
foo.mllib (library (name foo))
pkg/pkg.ml: Pkg.mllib ~cond:x (library ... (optional))
pkg/META Auto-generated by dune

Read the full file on GitHub · 163 lines

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. 8d ago Changed 582dea20fb6a
  2. 12d ago First seen · 163 lines · 12 tokens per session scan A f3c563fa3595

Subscribe to this mod's changes

port-to-dune is a command published in the GitHub repository avsm/ocaml-claude-marketplace (35 stars, last pushed 10d ago), licensed ISC. It adds 12 tokens to every session and 908 once invoked, about $0.0001 per session on Opus 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.