Cli ergonomics craft

From Intense-Visions/harness-engineering · View interactive version

Cli ergonomics craft is an AI agent skill from the GitHub repository Intense-Visions/harness-engineering. > LLM-judgment critique of command-line ergonomics quality — the ceiling counterpart to mechanical CLI checks. The direct structural twin of harness-docs-craft, but with no rule-based floor twin: a me

How to use this skill

Skill file

CLI Ergonomics Craft

LLM-judgment critique of command-line ergonomics quality — the ceiling counterpart to mechanical CLI checks. The direct structural twin of harness-docs-craft, but with no rule-based floor twin: a mechanical linter can confirm a flag is documented, but only judgment can tell whether the name is predictable, whether the help teaches, and whether the error says what to do next. Emits 3-axis findings (tier × impact × confidence per ADR 0019).

When to Use

Capability Roles

<!-- Capability seam: this skill participates in a real extension point whose three roles are named and concrete. A seam with only one role filled is accidental single-implementation lock-in. See harness-skill-authoring Phase 1C. -->

Process

B' precondition check (every invocation)

cli-ergonomics-craft is the ceiling; it runs regardless of setup, but its critique sharpens when a project declares its CLI conventions. Before critiquing, note the state:

| Precondition | Source | If missing |

| ------------------ | ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| cliStyleDeclared | a project CLI style guide (e.g. docs/**/CLI.md) | Run with the generic seed rubrics; note in the summary that a style guide would sharpen critique and offer to seed one (progressive upgrade — the same posture as docs-craft's B'). |

When no style guide exists, cli-ergonomics-craft still runs with the seed rubrics (degraded, not blocked). It never refuses to critique just because a project has not written its CLI conventions down.

Phase 1: DISCOVER — Find command definitions

  1. Read project configuration. Shared craft config under craft.llm.* selects the judgment backend. maxFiles (default 60) caps the command count.
  1. Walk the command source tree(s). Discover command-definition source files under the conventional roots (packages/cli/src/commands, src/commands, src/cli, cli, cmd, …). Classify each as leaf (a command with its own action handler — it does work, produces output, can error, may mutate state) or group (a namespace whose job is to host subcommands). --commands-dir points discovery at an explicit directory; --files overrides discovery entirely.
  1. Exclude non-command surfaces. Tests / specs, type declarations, barrels and registries (index.ts, _registry.ts), and build / dependency trees (node_modules, dist, tests) are skipped — they are not authored command surfaces.

Phase 2: CRITIQUE — Per (command, rubric) loop, kind-filtered

7 seed rubrics, each declaring which command kinds it applies to:

| Rubric | Title | Applies to |

| ---------- | ------------------------------------------------------------------------- | ---------- |

| CLI-R001 | Command and flag names are predictable and consistent | all |

| CLI-R002 | Help text is task-oriented (teaches the job, not just lists flags) | all |

| CLI-R003 | Errors are actionable (name the cause AND the next step) | leaf |

| CLI-R004 | Defaults are sane and the safe path is the default | leaf |

| CLI-R005 | Output is scannable for a human and respects the terminal | leaf |

| CLI-R006 | Composes with other tools (pipeable, machine-readable, honest exit codes) | leaf |

| CLI-R007 | Destructive actions are guarded | leaf |

For each (command, rubric) where the rubric applies to the command's kind:

  1. Build a prompt with the rubric description + command kind + definition source (truncated to 6000 chars for cost).
  2. The LLM returns fenced JSON: null (rubric doesn't apply / the command already clears the bar) OR { tier, impact, confidence, message }.
  3. On non-null: emit a CliErgonomicsFinding with cite.rubricId populated for ADR 0020 traceability, and a derived priority for sorting.

A group command (a pure namespace) is critiqued only for naming and help; the other five rubrics critique a leaf command's own output, error, default, and safety surfaces, which a namespace does not have.

A small curated exemplar set anchors the catalog — gh, cargo, ripgrep, docker, the Stripe CLI — each a public reference point for one ergonomic dimension (gh for a uniform noun-verb grammar and --json composability, cargo for task-oriented help and actionable errors, ripgrep for terminal-aware output, docker for guarded destructive operations, the Stripe CLI for job-first help). The exemplars ground the rubric sources today and seed a future BENCHMARK phase, the direct analogue of docs-craft's exemplar corpus.

Phase 3: REPORT — Aggregate + cost telemetry

Emit CliErgonomicsCraftOutput:

{
  findings: CliErgonomicsFinding[];
  summary: {
    phaseRun: ['critique'];
    mode: 'fast';
    durationMs: number;
    llmCalls: { provider, model, count, costUsd };
    catalog: { rubricsApplied: string[]; exemplarsAvailable: number };
    counts: { filesScanned, filesSkipped };
    runId: string;
  }
}

Harness Integration

Invoked as a review hook

cli-ergonomics-craft auto-activates as an advisory review hook whenever a diff touches the surface it

owns — harness-autopilot at after:REVIEW / after:FINAL_REVIEW, and harness-code-review at

after:mechanical. The domain table is CRAFT_REVIEW_DOMAINS and the per-host events are

CRAFT_REVIEW_EVENTS_BY_HOST, both in packages/core/src/hooks/craft-review-hooks.ts. The host

forwards the subset of the diff this domain owns:

reads it from plan.files["cli-ergonomics-craft"], which holds repo-relative POSIX paths, and resolves each

entry against the project root before calling mcp__harness__cli_ergonomics_craft. Absolute is the

recommended form, not a correctness requirement for this domain: its collector resolves a

relative entry against the tool's path (never the process CWD), so a repo-relative entry

forwarded unresolved still reads the in-diff file (pinned by

packages/cli/tests/shared/craft/relative-files-scope.test.ts). Only

mcp__harness__design_craft still requires absolute paths.

Findings from a hook-triggered run are advisory: reported, never blocking, never counted toward

review severity, and never entered into a host's mechanical exclusion set. A hook-triggered run

that fails is a missing opinion, not a broken gate.

In-session flow (default)

When HARNESS_CRAFT_LLM is unset (or set to in-session), the MCP tool does not call any LLM. It discovers the command definitions, builds one prompt per (command, rubric) pair, and returns them for the calling agent to answer with its own model. This is a two-step protocol — skipping step 3 leaves you with prompts, never findings.

Step 1 — mcp__harness__cli_ergonomics_craft({ path, ... }) returns { "status": "collected", "runId": "<uuid>", "pendingPrompts": [{ "promptId", "systemPrompt", "userPrompt" }, ...], "projection": { "promptCount": N, "budget": 100 } }. If projection.promptCount > budget, status is "budget-exceeded" and pendingPrompts is empty — re-invoke with a smaller maxFiles, or pass promptBudget to raise the ceiling.

Step 2 — for each pending prompt, generate the fenced-JSON response as if you were a senior CLI/developer-experience engineer applying the rubric to the command: a fenced null block if the rubric does not apply or the command already clears the bar, otherwise a fenced block of { "tier": "foundational|polish|aspirational", "impact": "small|medium|large", "confidence": "high|medium|low", "message": "a critique naming the specific command/flag/handler and a concrete suggested change" }.

Step 3 — mcp__harness__cli_ergonomics_craft_finalize({ path, runId, responses: [{ promptId, raw }, ...] }) parses the responses through the same validation the inline path uses and returns the standard CliErgonomicsCraftOutput.

If you want inline behavior (the skill calls an LLM directly), pass mode: 'inline' to step 1 and set HARNESS_CRAFT_LLM to a non-in-session provider. Running the CLI (harness cli-ergonomics-craft) under the default in-session provider fails loudly with this guidance rather than returning an empty result.

Success Criteria

See docs/changes/cli-ergonomics-craft/proposal.md for the full success criteria. Highlights:

Rationalizations to Reject

These are common rationalizations that sound reasonable but lead to incorrect results. When you catch yourself thinking any of these, stop and follow the documented process instead.

| Rationalization | Why It Is Wrong |

| ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| "The flag is registered and the command compiles, so the surface is sound." | Registration and compilation are the mechanical floor. CLI-R001 asks whether the name is PREDICTABLE against the rest of the surface — a working --out still breaks the convention when every sibling command uses --output. |

| "The help text lists every flag, so the command is documented." | CLI-R002 wants task-oriented help that teaches the job. An exhaustive flag enumeration is a reference dump, not teaching — a user still cannot tell what the command is FOR or which flags they actually need. |

| "It prints a friendly message when it fails, so error handling is fine." | CLI-R003 wants the error to name the cause AND the next step; CLI-R006 wants an honest exit code. A friendly message that still exits 0 on failure silently breaks every script and pipeline that consumes the command. |

| "I collected the pending prompts, so the critique is done." | The in-session flow is a two-step protocol. Stopping after step 1 leaves you with prompts and zero findings — you must answer each prompt as the rubric-applying reviewer and call ..._finalize to get a real CliErgonomicsCraftOutput. |

| "This is a pure namespace group, but I will still apply the destructive-guard rubric to be thorough." | The kind filter fires CLI-R007 (and the output/default/safety rubrics) on leaf commands only. A group has no action handler to guard; forcing the rubric onto it manufactures a false finding the kind filter exists to prevent. |

Examples

Example: A flag that breaks the naming convention

Input: src/commands/build.ts defining new Command('build').option('--out <f>') while the rest of the surface uses --output.

Output (mock LLM):

src/commands/build.ts (leaf)
  CLI-R001 [foundational/large/high] src/commands/build.ts (leaf)
    `--out` breaks the `--output` convention every other subcommand uses. A
    user who learned `--output` on one command cannot predict `--out` here.
    Rename to `--output` (keep `--out` as a hidden alias for one release).

Example: A destructive command with no guard

Input: src/commands/reset.ts — a reset command that deletes state immediately in its action handler with no confirmation and no dry-run.

Output:

src/commands/reset.ts (leaf)
  CLI-R007 [foundational/large/high] src/commands/reset.ts (leaf)
    `reset` destroys state the moment it runs — no confirmation, no `--dry-run`,
    no `--force` gate. Confirm before proceeding (skip the prompt when stdin is
    not a TTY only if `--force` is passed), and add `--dry-run` to preview.

Example: A clean command — no findings

Input: A leaf command with a conventional flag set, task-oriented help, a sane zero-flag default, --json output, and a guarded destructive path.

Output:

No CLI-ergonomics-craft findings.

Summary: 0 findings across 1 commands (0 skipped, 7 rubrics, 5 exemplars, 7 LLM calls, $0.0000, 4ms)

Gates

Escalation

Status

v1 — CRITIQUE phase. See:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.