cli-design

Defines argparse structure and output conventions for the resoio CLI.

3|Updated Jun 7, 2026
One-click install
npx skills add https://github.com/MLShukai/ResoniteIO --skill cli-design-mlshukai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cli-design
Source: https://github.com/MLShukai/ResoniteIO/tree/main/.claude/skills/cli-design
Command: npx skills add https://github.com/MLShukai/ResoniteIO --skill cli-design-mlshukai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When adding new commands or changing output formats in the resoio CLI, developers need consistent rules for argparse structure, --format handling, stdout/stderr separation, and exit codes. This Skill consolidates those design conventions so new commands follow the established contract instead of diverging. ## Core Features & Use Cases - Command Structure Rules: Enforces the thin-module pattern (one file per command), flat command naming, lazy heavy imports, and common parent parser inheritance for nested subcommands. - Output Conventions: Standardizes --format human|json, single-document JSON on stdout, exit code semantics (0/1/2/130), and carve-outs for pid/path-only and interactive commands. - Serializer Guidance: Documents cli/output.py APIs (emit, to_jsonable, is_structured) including enum/bool dispatch ordering and bytes rejection pitfalls. - Use Case: When adding a new resoio command like resoio world list, follow this Skill to register the module, wire --format correctly, emit structured JSON, and write matching tests against a real grpclib server. ## Quick Start Read this Skill before adding a new resoio CLI command or changing any --format or output behavior, then follow its argparse, serialization, and testing conventions.

Frequently Asked Questions about cli-design

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new command to the resoio CLI?

Create a thin module in python/src/resoio/cli/<action>.py exposing register(subparsers, common) and async _run(args), then add it to _COMMAND_MODULES in cli/__init__.py. Keep heavy imports like gRPC and numpy inside _run so --help stays fast.

How do I add JSON output to an argparse CLI command?

Call output.add_format_argument(parser) for top-level commands or attach output.build_format_parent() to nested leaf parsers. In _run, check is_structured(args.format) and pass the dataclass or proto message directly to emit, which writes one JSON document to stdout.

Which CLI commands should not support --format json?

Commands returning only a pid or file path (shutdown, screenshot, record) print a single stdout line instead, and interactive commands (drive, grabber interactive, inventory REPL) stay human-only. If --format json is passed to an unsupported action, reject it with exit code 2 and a stderr message.

Why does my enum serialize as an integer in JSON output?

betterproto2 enums are IntEnum, so .value yields a meaningless int. The to_jsonable serializer checks enum before int and emits .name instead; keep that dispatch order and never use Message.to_dict(), which produces camelCase and drops default values.

How should CLI commands be tested in this project?

Spin up a real grpclib.server.Server on a real Unix domain socket with an inline fake modality base, then drive _amain with parsed args. For JSON cases capture stdout with capsys, assert a single document via json.loads, and pin argparse usage errors through SystemExit.code.