tidy

tidy is a command for Claude Code from avsm/ocaml-claude-marketplace. It costs 15 tokens per session (1,143 once invoked), scanned A, original, ISC.

A command for reviewing and refactoring OCaml code into clearer, more idiomatic patterns. OCaml is a programming language, and idiomatic code follows the language's usual conventions.

In plain words
What is it for?
Tidying Option and Result handling, nested conditionals, pattern matching, and error propagation in a file or directory.
Why use it?
It helps reduce repetitive or deeply nested code that can be harder to maintain.

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 Tidying Option and Result handling, nested conditionals, pattern matching, and error propagation in a file or directory.

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

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

Your own site · 80×15
<a href="https://agentmods.dev/commands/avsm/ocaml-claude-marketplace/tidy"><img src="https://agentmods.dev/badge/commands/avsm/ocaml-claude-marketplace/tidy.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 15 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,143 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.00015 $0.01143
Opus 5 $0.00008 $0.00571
Sonnet 5 $0.00003 $0.00229
Haiku 4.5 $0.00002 $0.00114

Measured 7d ago against content hash e6ff243980fc, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

tidy 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 7d 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/tidy.md · 194 lines

How it starts

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

Tidy OCaml Code

This command analyzes and refactors OCaml code to make it more idiomatic, maintainable, and concise.

Arguments

Optional file or directory path: $ARGUMENTS (defaults to current directory)

Before You Start

Invoke the doc-style skill. Comments and documentation are part of tidying, and that skill is the standard for both.

Analysis Categories

1. Option and Result Patterns

Look for:

  • Verbose match expressions that could use combinators
  • Nested Option/Result handling without let*/let+
  • Direct pattern matching where Option.map, Option.bind, etc. would be clearer

Transform:

(* Before *)
match get_value () with
| Some x -> Some (x + 1)
| None -> None

(* After *)
Option.map (fun x -> x + 1) (get_value ())

2. Monadic Syntax

Look for:

  • Deeply nested match expressions on Result/Option
  • Manual error propagation chains

Transform:

(* Before *)
match fetch_user id with
| Ok user ->
    (match fetch_perms user with
     | Ok perms -> Ok (user, perms)
     | Error e -> Error e)
| Error e -> Error e

(* After *)
let open Result.Syntax in
let* user = fetch_user id in
let+ perms = fetch_perms user in
(user, perms)

3. Pattern Matching vs Conditionals

Look for:

  • Nested if/then/else chains
  • Boolean condition checking that could be pattern matching

Transform:

(* Before *)
if x > 0 then
  if x < 10 then "small"
  else "large"
else "negative"

(* After *)
match x with
| x when x < 0 -> "negative"
| x when x < 10 -> "small"
| _ -> "large"

4. Code Duplication

Look for:

  • Repeated error message patterns
  • Similar function implementations
  • Copy-pasted code blocks

Suggest:

  • Helper functions
  • Parameterized abstractions
  • Shared error constructors

5. Module Hygiene

Look for:

  • Generic module names (Util, Helpers, Common)
  • Exposed record types without abstract type t
  • Missing pretty-printers for main types
  • Unlabeled boolean parameters

6. Comments and Documentation

Read the full file on GitHub · 194 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. 7d ago Changed · +19 lines e6ff243980fc
  2. 11d ago First seen · 175 lines · 15 tokens per session scan A 9b8a4c21d47b

Subscribe to this mod's changes

tidy is a command published in the GitHub repository avsm/ocaml-claude-marketplace (35 stars, last pushed 9d ago), licensed ISC. It adds 15 tokens to every session and 1,143 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.