Overview
This tutorial walks you through creating a simple CLI that greets users. You’ll learn:- How to create a CLI with
Cli.create() - How to define arguments and options with Zod schemas
- How to add multiple commands
- How to enable agent discovery
- How to test your CLI with an agent
Create a simple CLI
Create a new file
greet.ts with a basic single-command CLI:greet.ts
Key points:
Cli.create() takes a name and configuration. The args field defines positional arguments with Zod schemas. The run() function receives typed context with c.args.name, and the return value is automatically wrapped and formatted.Run your CLI
Execute your CLI:You’ll see:This is TOON format (Token-Optimized Object Notation) - more readable than JSON and uses 60% fewer tokens.Check the built-in help:Output:
Add multiple commands
Convert your CLI to support multiple commands:Now you can:
greet.ts
The
export default cli is important for agent discovery and type generation.Enable agent discovery
Make your CLI discoverable by AI agents using Skills:This generates skill files and installs them globally so agents can discover your CLI automatically.Output:Alternatively, register as an MCP server:This adds your CLI to your agent’s MCP configuration.
Skills are lightweight Markdown files that describe your CLI’s commands, arguments, and options. They’re automatically kept in sync with your code.
Test with an agent
Now your agent can discover and use your CLI. Try asking:The agent will automatically:This outputs Markdown documentation that agents can read:
- Discover your CLI via Skills or MCP
- Read the available commands and their schemas
- Execute
greet hello alice - Parse the TOON output
What You’ve Learned
CLI Creation
How to create CLIs with
Cli.create() and add commands with .command()Type Safety
Using Zod schemas for arguments and options with automatic type inference
Output Formats
TOON as the default token-efficient format, with JSON, YAML, and more available
Agent Discovery
Enabling automatic discovery via
skills add and mcp addNext Steps
Commands & Arguments
Deep dive into command patterns, schemas, and validation
Output & Formats
Learn about output envelopes, CTAs, and format options
Agent Integration
Configure Skills, MCP, and customize agent behavior
Complete Example
Here’s the final CLI from this tutorial:greet.ts

