name: ocaml-opam-tinyflags-add-flag description: Add a TinyFlags flag to an OCaml project with implementation, tests, and rollout notes.
Add TinyFlags Flag
Use this skill when adding a feature flag to an OCaml project that depends on
agentxm-example-tinyflags.
Workflow
- Find the OCaml module that constructs the
Tinyflags.tflag set from a(name, flag) list(typicallylib/<pkg>/flags.mlor similar). - Add the flag as either a
Boolean (Tinyflags.Bool.make_exn ...)or aVariantFlag (Tinyflags.Variant.make_exn ...)entry. - Prefer
kebab-caseflag names that mirror the call-site behavior. - Add or update alcotest coverage in
test/for default behavior and rollout behavior. Run viadune runtestordune exec ./test/<name>.exe. - Update the package's README or
.opamdescription when the flag is user-facing.
Boolean Flags
Use Tinyflags.Bool.make_exn ~default:false () for a disabled-by-default
feature.
Use Tinyflags.Bool.make_exn ~default:false ~rollout:10 () for a percentage
rollout. Rollout bucketing is deterministic on the Tinyflags.Context.t
[id] field — thread a stable identifier (user, session, account) through
the request boundary.
Variant Flags
Use
Tinyflags.Variant.make_exn ~default:"classic" ["classic"; "semantic"]
when the call site needs a named treatment instead of true / false.
Use ~rollout to allocate traffic:
Tinyflags.Variant.make_exn
~default:"classic"
~rollout:[ ("semantic", 10) ]
[ "classic"; "semantic" ]
Done Criteria
- New flag has an explicit
~defaultargument (boolean) or~defaultargument (variant) tied to a member of the variant list. - Rollout percentage is an
intin0..100. - Variant rollout pairs reference only declared variants.
- alcotest cases cover default behavior and at least one rollout boundary.
- Dead
matchbranches are not introduced.