# Ruby CLI

> Build Ruby CLI tools with Thor and Zeitwerk. Use for new Ruby CLI gems, adding commands, refactoring, or 'Thor CLI', 'command-line tool in Ruby'.

- Skill: `steveclarke/ruby-cli` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx skillmds@latest add steveclarke/ruby-cli`
- Raw SKILL.md: https://api.skillmd.com/api/skills/steveclarke/ruby-cli/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: steveclarke (https://skillmd.com/u/steveclarke)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/steveclarke/ruby-cli

---


# Ruby CLI Development

Build Ruby CLI tools using Thor for commands and Zeitwerk for autoloading.

## Quick Navigation

- **Starting a new CLI gem from scratch?** See [references/bootstrap.md](references/bootstrap.md)
- **Adding commands or subcommands?** See [references/patterns.md](references/patterns.md)
- **Thor syntax reference?** See [references/patterns.md](references/patterns.md)
- **Rich terminal UI with Gum?** See [references/gum.md](references/gum.md)

## Core Principles

- Use compact class declarations: `class GemName::Cli::Main < GemName::Cli::Base`
- Use `extend self` instead of `module_function` for utility modules
- Keep the Base class lean - add helpers as patterns emerge

## Output Styling

For basic output, use Thor's built-in `say "message", :color`.

For rich terminal UI (headers, tables, spinners, confirmations), use the Gum gem:

```ruby
ui.header("Section Title")    # branded header with border
ui.success("Done!")           # green checkmark
ui.error("Failed")            # red X
ui.table(rows, columns: [...]) # formatted table
ui.spin("Working...") { ... } # spinner during work
```

See [references/gum.md](references/gum.md) for setup and full API.

## Tips & Gotchas

- Add `# rubocop:disable Rails/Output` to UI modules (stdout is intentional in CLIs)
- Gum requires `brew install gum` on the host machine

