doc-style
OCaml comment and ocamldoc writing style, in the voice of a POSIX manual page. Use whenever writing, rewording, reviewing or deleting any OCaml comment or documentation. Triggers on ocamldoc, odoc, doc comments, (** ... *), .mli documentation, .mld pages, documenting a function, type or module, and on any request to add, tidy, rewrite or strip OCaml comments.
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-doc-styleManual setup by platform
Claude Code
~/.claude/skills/ocaml-dev-doc-style/SKILL.md
Instructions
OCaml Comment and Documentation Style
Write ocamldoc the way a POSIX manual page is written. State what a thing is
and what it does, in full sentences, and stop.
Implementations carry no comments at all unless the code cannot speak for
itself.
This skill covers what to write. For odoc reference syntax, cross-package
links and build warnings, see the ocaml-docs skill.
The Six Rules
- Full sentences. Every doc comment is one or more complete sentences,
each ending in a full stop. No fragments, no bullet-point shorthand, no
trailing "...". - Manpage voice. Terse, declarative, present tense, third person. No "we",
no "you", no "this function", no enthusiasm. - No extraneous detail. Document what a caller must know to call it.
History, rationale, benchmarks, future plans and implementation trivia do
not appear. - No connectives. No colons and no em dashes joining clauses. Split into
separate sentences instead. Semicolons only inside a genuine list. - User-facing, not internal. Describe observable behaviour. Mention an
internal only when the caller can observe it, such as time complexity,
allocation behaviour, evaluation order or thread safety. [f x y] is .... A function's documentation opens with the function
applied to its arguments in brackets, followed byis.
Function Documentation
The doc comment follows the val declaration. Name the arguments in the
bracketed application and refer to them with [x] thereafter.
val length : t -> int
(** [length t] is the number of elements in [t]. *)
val find : string -> t -> element option
(** [find name t] is the element of [t] called [name], or [None] if [t] has
no such element. *)
val is_bot : t -> bool
(** [is_bot u] is [true] if [u] is a bot user. *)
Use is whenever the function has a meaningful result. Reserve an active verb
for functions that exist for their effect.
val flush : out_channel -> unit
(** [flush oc] writes the buffered bytes of [oc] to its underlying file. *)
val set : t -> key:string -> value:string -> unit
(** [set t ~key ~value] binds [key] to [value] in [t]. Any previous binding of
[key] is dropped. *)
Effectful constructors are still is.
val create : unit -> t
(** [create ()] is a new empty table. *)
val of_file : Fpath.t -> (t, Error.t) result
(** [of_file file] is the configuration parsed from [file]. The error holds a
human readable message suitable for a command line tool. *)
Document optional arguments in their own sentence, and give the default.
val sub : ?start:int -> ?len:int -> string -> string
(** [sub ~start ~len s] is the substring of [s] of length [len] starting at
[start]. [start] defaults to [0]. [len] defaults to the remainder of [s]
after [start]. *)
Failure conditions go last, as tags.
val get : t -> string -> element
(** [get t name] is the element of [t] called [name].
@raise Not_found if [t] has no element called [name]. *)
Prefer naming arguments in the bracketed application over @param tags.
@param restates the signature and reads nothing like a manual page.
Type and Value Documentation
A type is documented by what its values represent, not by its representation.
type t
(** The type for users. *)
type id = string
(** The type for user identifiers. An identifier is unique within a workspace
and stable across renames. *)
type level = Debug | Info | Warning | Error
(** The type for message severities, in increasing order of severity. *)
Constructors and record fields take a doc comment only when the name is not
enough.
type t = {
name : string; (** The display name. It is not unique. *)
id : id;
created : Ptime.t; (** The creation time, in UTC. *)
}
Module Documentation
The first line of an .mli is a synopsis in the shape of a manpage NAME
line. A blank line follows, then the description.
(** User accounts and profiles.
Users are workspace members. A user is identified by an {!type:id} that is
stable for the lifetime of the account. Profile fields are populated
lazily and may be absent on users who have never signed in. *)
Keep the description to what a caller needs before reading the values below
it. Use {1 Section} headings once the interface is long enough to need them,
and name the sections after what they hold, such as {1 Users} or
{1 Predicates and comparisons}.
Rewrites
| Instead of | Write |
|---|---|
(** Returns the length of the buffer *) | (** [length b] is the number of bytes in [b]. *) |
(** [parse s] parses [s]: it splits on commas and builds a record. *) | (** [parse s] is the record encoded in [s]. *) |
(** [send t msg] sends a message — note this blocks. *) | (** [send t msg] sends [msg] on [t]. It blocks until [msg] has been written. *) |
(** This function is used internally by the scheduler to requeue fibers. *) | Delete it, or make the value private. |
(** Fast lookup (uses a hashtable). *) | (** [find t k] is the value bound to [k] in [t]. Lookup is constant time. *) |
(** TODO: document *) | Write the sentence. |
Banned Words and Shapes
Delete these on sight.
This function,This value,This moduleas an opener. Name the thing.Basically,simply,just,obviously,of course.Note that,Please note,Be aware. State the fact as a sentence.Internally,under the hood,behind the scenes.Helper for,Wrapper around,Convenience function.- A colon or em dash introducing an explanatory clause.
- A parenthetical that repeats the type signature.
- Author names, dates, ticket numbers and changelog entries.
Comments in Implementations
Default is no comment. If a reader who knows OCaml can see what the code
does, the code says it already. Naming a value is better than commenting it.
Delete on sight:
- Comments that restate the code, such as
(* increment i *). - Section banners and boxes, such as
(* ---- Helpers ---- *). - Commented-out code. Version control keeps it.
- Narration of obvious control flow, such as
(* loop over the list *). - Attribution, dates and changelog entries.
- Doc comments in an
.mlthat has an.mli. The documentation belongs in
the interface, and a second copy will drift.
Write a comment only for something the code cannot state:
- A citation for behaviour mandated elsewhere, such as
(* RFC 8259 §7. *). - An invariant a reader cannot check locally, such as
(* [buf] is never empty here, see [refill]. *). - A deliberate deviation or workaround, with the reason it exists.
- A justification for an unsafe or unusual operation.
- Why the obvious approach was rejected, when someone would otherwise
reinstate it.
Kept comments are full sentences in (* ... *), placed on the line above the
code they explain.
(* Bad. *)
let decode s =
(* get the length *)
let n = String.length s in
(* loop over the characters *)
let b = Buffer.create n in
...
(* Good. *)
let decode s =
let b = Buffer.create (String.length s) in
...
(* Good. The comment states what the code cannot. *)
let decode s =
(* RFC 4648 §3.2 requires padding to be rejected in strict mode. *)
if strict && String.length s mod 4 <> 0 then invalid_arg "decode";
...
Checklist
Before committing documentation:
- Every exported value has a doc comment.
- Every function doc opens with
[f x y] isor an active verb for an
effect. - Every argument named in the brackets is referred to in the prose.
- Every optional argument has its default stated.
- Every sentence is complete and ends in a full stop.
- No colons or em dashes join clauses.
- No sentence describes the implementation.
- No banned word from the list above survives.
- The
.mlhas no comment that the code already says. -
dune build @docis clean.
Security
Reviews (0)
Related skills
Browse all →More from OCaml Dev (avsm)
View source →More Build skills
Browse category →Frequently asked questions about doc-style
What does the doc-style skill do?
OCaml comment and ocamldoc writing style, in the voice of a POSIX manual page. Use whenever writing, rewording, reviewing or deleting any OCaml comment or documentation. Triggers on ocamldoc, odoc, doc comments, (** ... *), .mli documentation, .mld pages, documenting a function, type or module, and on any request to add, tidy, rewrite or strip OCaml comments. 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 doc-style skill?
Run `npx @skills-hub-ai/cli install ocaml-dev-doc-style` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/ocaml-dev-doc-style/ 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 doc-style work with?
doc-style 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 doc-style 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 doc-style after installing it?
In Claude Code, type `/ocaml-dev-doc-style` (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 doc-style 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.