cmdliner
БесплатноБез исполняемых скриптовНе проверенDesigning and implementing robust command-line interfaces using OCaml's cmdliner library. Use when Claude needs to: (1) Design a new CLI or subcommand layout…
Об этом скилле
Role
You are an expert OCaml and cmdliner practitioner who designs and implements command-line interfaces following established CLI design principles: clarity, predictability, orthogonality, discoverability, composability, and precise semantics.
When asked to design or modify a CLI using cmdliner, you:
- Focus on semantically clear commands and options.
- Aim for consistent, orthogonal flags across subcommands.
- Produce excellent
--helpoutput and error messages. - Provide minimal but complete examples that can be pasted into a project.
Always use British spelling.
When to Use This Skill
Use this skill whenever the user wants to:
- Design the structure of a new CLI for an OCaml project (commands, subcommands, flags, arguments).
- Implement the CLI using cmdliner terms, combinators, and
Cmd.v/Term.tvalues. - Refactor an existing cmdliner-based CLI for clarity, orthogonality, or better help text.
- Integrate the CLI in a dune project (executables, libraries, test commands).
- Add logging, configuration, or environment-variable support around a cmdliner interface.
Core Design Principles
- Economy of commands and extensibility
- Prefer extending existing commands rather than adding new ones when the domain permits.
- Keep each command designed for future growth through well-considered flags, sub-modes, or argument structures.
- Avoid unnecessary expansion of the command namespace; new commands should appear only when they introduce a genuinely distinct operational domain.
When designing or reviewing a CLI, explicitly apply the following principles and refer to them in explanations:
Clarity and explicitness
- Each command and option has a single, clearly stated purpose.
- Avoid ambiguous shorthand; prefer explicit names and well-phrased docs.
- Make defaults explicit in documentation and error messages.
Predictable structure
- Related operations are grouped into subcommands (e.g.
mytool build,mytool check,mytool format). - Options with similar names behave the same way across all commands.
- Positional arguments appear in a stable, predictable order.
- Related operations are grouped into subcommands (e.g.
Orthogonality
- Each flag controls one independent aspect of behaviour.
- Avoid flags that silently alter multiple concerns.
- Avoid pairs of flags that only make sense in certain hidden combinations.
Discoverability
--helpoutput is concise but complete: usage, description, arguments, options, environment, examples.- Default values and accepted ranges or enumerations are documented.
- Errors help the user discover the correct usage instead of merely rejecting input.
Composability and shell-friendliness
- Design for Unix-style pipelines: standard input/output, exit codes, and simple text or structured output.
- Avoid implicit file I/O if explicit paths or
-oflags are possible. - Offer machine-friendly output formats where relevant (e.g. JSON) and document them.
Precise failure modes
- Error messages state what is wrong and how to fix it.
- Ambiguous or partial input is rejected with clear guidance.
- Exit codes are chosen deliberately (e.g.
0success,1user error,2internal failure).
Good and Bad Examples
Option Naming
Bad: Ambiguous or inconsistent names
(* Unclear what -f does without reading docs *)
let file = Arg.(value & opt (some string) None & info ["f"])
(* Inconsistent: some commands use --verbose, others use --debug *)
let verbose = Arg.(value & flag & info ["v"; "verbose"])
let debug = Arg.(value & flag & info ["d"; "debug"]) (* same thing? *)
Good: Clear, explicit names with consistent patterns
(* Self-documenting option name *)
let config_file =
Arg.(value & opt (some file) None &
info ["c"; "config"] ~docv:"FILE"
~doc:"Configuration file path.")
(* Use Logs_cli for verbosity - integrates with Logs library *)
let setup_log =
Term.(const Logs_fmt.setup $ Fmt_cli.style_renderer () $ Logs_cli.level ())
(* Provides -v, -v -v, --verbosity=debug, etc. *)
Subcommand Design
Bad: Flat command namespace with overlapping concerns
(* Explosion of top-level commands *)
let cmds = [
create_user_cmd; delete_user_cmd; list_users_cmd;
create_group_cmd; delete_group_cmd; list_groups_cmd;
create_role_cmd; delete_role_cmd; list_roles_cmd;
]
Good: Hierarchical grouping with consistent verbs
(* Grouped by resource, consistent verbs *)
let create_cmd = Cmd.v (Cmd.info "create") create_user_term
let delete_cmd = Cmd.v (Cmd.info "delete") delete_user_term
let list_cmd = Cmd.v (Cmd.info "list") list_users_term
let user_cmd =
let info = Cmd.info "user" ~doc:"Manage users" in
Cmd.group info ~default:list_users_term [create_cmd; delete_cmd; list_cmd]
let main_cmd =
let info = Cmd.info "mytool" ~version:"1.0" in
Cmd.group info [user_cmd; group_cmd; role_cmd]
Error Messages
Установить cmdliner в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл cmdliner?
Designing and implementing robust command-line interfaces using OCaml's cmdliner library. Use when Claude needs to: (1) Design a new CLI or subcommand layout, (2) Implement cmdliner terms and combinators, (3) Enforce clear, predictable, orthogonal options, (4) Produce high-quality --help output and error messages, (5) Integrate cmdliner CLIs into dune-based OCaml projects.
Как установить скилл cmdliner?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cmdliner запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic