designing-cli
Skill0 starsChanged 28 days agoMITView on GitHub
Designs CLIs that humans, scripts, and agents drive predictably. Use when creating a CLI, or adding or changing its commands, flags, output, errors, config, background process, or release.
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- writing-skillsSkill
- building-wikiSkill
- compressing-knowledgeSkill
- creating-issuesSkill
- fuckSkill
- functional-domain-modelingSkill
- git-shippingSkill
- no-commentsSkill
- orchestratingSkill
- receiving-code-reviewSkill
- tracking-tasksSkill
- writing-japaneseSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 20
Done: when every item passes or is n/a and the probe has no FAIL.
- Very specific: line 51
Write and destructive commands take --dry-run.
- Distinctive: line 57
When a binary ships, follow references/distribution.md.
- Distinctive: line 62
Start in 100–500ms, loading only the invoked command.
- Distinctive: line 63
No network at startup unless the command needs it.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Designing CLIs
Workflow
- Start. For a new CLI, confirm the language and whether it ships as a binary.
- Define commands, flags, help, examples, and effects in one framework definition: cobra and
github.com/jdx/usage/integrations/cobrafor Go, adding viper only with config files; gunshi v1 with@gunshi/plugin-suggestion,@h3y6e/gunshi-plugin-env, and@h3y6e/gunshi-plugin-usagefor TypeScript; usage-rs for Rust; usage#USAGEcomments for shell. For Go, also invoke thegolang-cliandgolang-spf13-cobraskills, plusgolang-spf13-viperonce viper is added; if they are not installed, ask the user to add them fromsamber/cc-skills-golang. - Classify each item below as pass, n/a, or deviation in a table, citing a probe line, command run, or code read. Items without a subject are n/a. Fix every deviation; references/rationale.md gives the reasons.
- Probe: build, then run
scripts/probe.mjs <bin> [app.usage.kdl], passing the spec when the framework exports one. Fix each FAIL; NOTEs are evidence. - Done when every item passes or is n/a and the probe has no FAIL.
Checklist
Input
- Subcommands nest with spaces in one consistent order (
app server start). Positionals name the target, one kind at most; flags are optional and also readAPP_*env vars; child-process arguments follow--. - Bare
app,-h, and--helpat any level print help to stdout and exit 0. --versionand bare-vprint the version;-Vandversionfollow the framework. Only the root parses version flags.- Prompt only on a TTY, with a flag to skip each prompt.
Output
- Results go to stdout; messages, progress, and child-process stderr go to stderr.
- List and status commands take
--json; streamed output is JSONL ending in a result record, even on early failure or cancellation. - Exit quietly on a closed pipe.
- Color and spinners:
--no-color, thenCLICOLOR_FORCE, thenNO_COLOR/TERM=dumb/CLICOLOR=0, then TTY detection. - Tables: one entry per line, no borders.
Errors
- Errors give a stable code, cause, runnable fix, and docs URL if any, as result-record fields under
--json;--quietnever hides them. - Unknown commands suggest "did you mean"; usage errors point to
--help. - Unexpected errors print a summary and the flag that adds a traceback and debug log. Log files are timestamped, truncated, and ANSI-free.
- Exit 0 on success, help, and version; 1 on failure; 2 on usage errors. Help documents other codes.
- On SIGINT or SIGTERM, cancel remote work, clean up, and re-raise the signal.
Safety
- Each command's effect is
read,write, ordestructive; help marks destructive ones. - Destructive commands show what will be deleted, overwritten, or sent, then confirm on a TTY; without
--yes, exit 2 and suggest--dry-run. - Write and destructive commands take
--dry-run. - Secrets never arrive as arguments or env vars.
Files and release
- Separate XDG directories for config, state, data, and cache. With config files, follow references/config.md.
- When a binary ships, follow references/distribution.md.
- With a TUI or an agent hook, follow references/situational.md.
Speed and compatibility
- Start in 100–500ms, loading only the invoked command.
- No network at startup unless the command needs it; update checks never block and can be disabled.
- Gate unstable features behind an
experimentalsetting. - Version data and wire formats,
--jsonincluded, apart from the CLI; removing, renaming, or retyping a field is breaking. - For a background process, follow references/daemon.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

