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
- Adding commands or subcommands? See references/patterns.md
- Thor syntax reference? See references/patterns.md
- Rich terminal UI with Gum? See references/gum.md
Core Principles
- Use compact class declarations:
class GemName::Cli::Main < GemName::Cli::Base - Use
extend selfinstead ofmodule_functionfor 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:
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 for setup and full API.
Tips & Gotchas
- Add
# rubocop:disable Rails/Outputto UI modules (stdout is intentional in CLIs) - Gum requires
brew install gumon the host machine
More from steveclarke/dotfiles
md-to-pdf
Convert markdown files to PDF using Chrome. Use when user wants to render markdown to PDF, print a document, or create a shareable PDF from markdown. Triggers on "markdown to pdf", "render to pdf", "pdf from markdown", "print this markdown".
75bruno-endpoint-creation
Create Bruno REST API endpoint configurations with proper authentication, environment setup, and documentation. Use when setting up API testing with Bruno, creating new endpoints, or configuring collection-level authentication. Triggers on "create Bruno endpoint", "Bruno API testing", "set up Bruno collection".
68readme-writer
Write and revise READMEs and technical documentation for software projects. Scores readability with Flesch-Kincaid and vocabulary profiling. Use when writing, revising, or reviewing a README, README.md, or project documentation. Triggers on "write readme", "improve readme", "readme review", "documentation writing".
56time-tracking
Manage time tracking with Toggl or Clockify. Use when user asks about time tracking, timers, timesheets, logging hours, starting/stopping work, checking what's running, viewing time entries, or creating manual entries. Triggers on "toggl", "clockify", "time tracking", "timer", "timesheet", "log time", "track time", "hours worked".
521password
Fetch secrets and create/manage 1Password items via CLI. Use when needing API keys, tokens, or credentials, or when storing new secrets. Ask user for the 1Password secret reference (op://Vault/Item/field format) rather than the actual secret.
49feature-spec
Creates concise technical specification documents through guided architectural decisions, system contracts, and technical design. Produces a spec.md covering API design, data models, frontend architecture, and integration points without implementation details.
49