ruby-cli_skill

This skill helps you build and maintain Ruby CLI tools with Thor and Zeitwerk, guiding patterns, UI, and auto-loading best practices.
  • Shell

31

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill steveclarke/dotfiles --skill ruby-cli

  • SKILL.md1.6 KB

Overview

This skill helps you build and maintain Ruby command-line tools using Thor for command structure and Zeitwerk for autoloading. It focuses on creating new CLI gems, adding or refactoring commands, and integrating rich terminal UI patterns. The guidance emphasizes minimal, testable base classes and consistent output handling.

How this skill works

The skill inspects Thor-based command classes, Zeitwerk autoload layouts, and UI helper modules to suggest changes, add commands, or refactor code into patterns. It recommends compact class declarations, utility module conventions, and when to introduce helpers in a lean Base class. It also offers output styling options and integration notes for Gum when richer terminal UI is needed.

When to use it

  • Starting a new Ruby CLI gem or scaffolding a CLI structure.
  • Adding commands, subcommands, or flags to an existing Thor CLI.
  • Refactoring CLI command classes or reorganizing autoloaded code with Zeitwerk.
  • Improving or standardizing terminal output and UX across machines.
  • Integrating advanced UI elements (spinners, tables, confirmations) using Gum.

Best practices

  • Declare command classes compactly, e.g., class GemName::Cli::Main < GemName::Cli::Base.
  • Keep the Base class small; add helper methods only as common patterns emerge.
  • Use extend self for utility modules to provide module-level methods cleanly.
  • Route simple output through Thor's say for basic messages and use a UI wrapper for richer elements.
  • Add rubocop:disable comments for intentional stdout use in UI modules to avoid lint noise.

Example use cases

  • Scaffold a new CLI gem with a Main command and Zeitwerk-friendly folder layout.
  • Add a 'sync' subcommand that performs background work and shows a Gum spinner.
  • Refactor duplicated flag parsing into helper methods on the Base class.
  • Replace ad-hoc puts calls with ui.success/ui.error for consistent branding and color.
  • Document and install Gum on developer machines to enable rich terminal features.

FAQ

No. Gum is optional for richer UI elements. Thor's say covers basic colored output and is sufficient for many CLIs.

How should I structure files for Zeitwerk?

Follow Zeitwerk naming and directory conventions: nested modules map to nested directories and file names match class/module names for predictable autoloading.

When should helpers move from Base to a module?

Move helpers to modules when they are reusable across multiple command classes or when they grow beyond a few lines to keep Base lean.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
ruby-cli skill by steveclarke/dotfiles | VeilStrat