tyro-cli

Create self-documenting Python command-line interfaces using tyro type annotations.

3|Updated Jan 10, 2026
One-click install
npx skills add https://github.com/MaxWolf-01/agents --skill tyro-cli-maxwolf-01
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tyro-cli
Source: https://github.com/MaxWolf-01/agents/tree/main/mx/skills/tyro-cli
Command: npx skills add https://github.com/MaxWolf-01/agents --skill tyro-cli-maxwolf-01

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires tyro.

What problem does it solve? Writing Python CLIs with argparse, click, or fire involves boilerplate, manual help text, and fragile argument wiring. This Skill provides conventions and patterns for building CLIs with tyro, where type annotations and docstrings generate the entire interface and --help output automatically. ## Core Features & Use Cases - Type-Driven CLI Generation: Build argument parsers from dataclasses, function signatures, and Literal types with zero argparse boilerplate. - Self-Documenting Help: Module docstrings become program descriptions and field docstrings become argument help, so --help is always complete and current. - Subcommand & Nested Config Patterns: Use SubcommandApp decorators, Union-based dispatch, or nested dataclasses for hierarchical flags like --optimizer.lr. - Machine-Consumable Output: Standardize --json and --plain flags with documented JSON schemas so scripts and LLM agents can consume CLI output reliably. - Use Case: You need a standalone script that processes experiment data. Write a dataclass with typed fields and docstrings, add PEP 723 inline metadata, and run it with uv run script.py --help to get a fully documented CLI. ## Quick Start Ask the AI to create a Python CLI script using tyro with a dataclass for arguments, field docstrings for help text, and PEP 723 inline dependencies so it runs with uv.

Frequently Asked Questions about tyro-cli

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

FAQPage Schema
How do I create a Python CLI with tyro?

Define a dataclass with typed fields and docstrings, then call tyro.cli(Args, description=__doc__). tyro generates the argument parser from type annotations, and field docstrings become the --help text automatically.

tyro vs argparse vs click for Python CLIs?

tyro generates CLIs directly from type annotations and docstrings with zero boilerplate, while argparse requires manual add_argument calls and click uses decorators. tyro also derives --help output from type hints, giving Literal choices and defaults for free.

How do I add subcommands in tyro?

Use tyro.extras.SubcommandApp with @app.command decorators for extensible CLIs, or a Union of dataclasses annotated with tyro.conf.subcommand for static dispatch. Union requires at least two variants since Python collapses a single-element Union.

Why does my tyro boolean flag require an explicit value?

A bool field without a default requires --flag True or --flag False. Give the field a default value like verbose: bool = False to get the standard --flag and --no-flag toggle behavior.

Why does uv run recurse infinitely on my tyro script?

The shebang is missing the --script flag, so uv ignores the PEP 723 inline metadata and re-invokes itself. Use #!/usr/bin/env -S uv run --script --quiet so uv detects the inline dependency block.

How do I make CLI output machine-readable for scripts and LLMs?

Add a --json flag that emits valid JSON to stdout with the schema documented in the docstring, and a --plain flag that strips colors, progress bars, and unicode formatting. Consumers can then pipe output to jq for filtering.