Class: Gem::Commands::SkillCommand

Inherits:
Gem::Command
  • Object
show all
Defined in:
lib/gem/skill/cli/gem_command.rb

Overview

Registered as ‘gem skill` via lib/rubygems_plugin.rb. Manages the global ~/.gem/skills cache.

Instance Method Summary collapse

Constructor Details

#initializeSkillCommand

Returns a new instance of SkillCommand.



13
14
15
16
17
18
19
20
21
22
# File 'lib/gem/skill/cli/gem_command.rb', line 13

def initialize
  super "skill", "Manage Claude Code AI skills for Ruby gems"

  add_option("-f", "--force",         "Regenerate even if already cached") { |_, o| o[:force] = true }
  add_option("-a", "--all",           "Purge all cached versions of a gem") { |_, o| o[:all] = true }
  add_option("-m", "--model MODEL",   "LLM model to use (default: #{Gem::Skill::Generator::DEFAULT_MODEL})") do |model, o|
    o[:model] = model
  end
  add_option("-v", "--version",       "Print gem-skill version and exit") { |_, o| o[:version] = true }
end

Instance Method Details

#argumentsObject



24
25
26
# File 'lib/gem/skill/cli/gem_command.rb', line 24

def arguments
  "SUBCOMMAND  one of: install, list, purge, setup"
end

#descriptionObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/gem/skill/cli/gem_command.rb', line 36

def description
  <<~DESC
    install   Generate and cache a SKILL.md for a gem.
    list      Show all skills in the global cache (~/.gem/skills).
    purge     Remove a specific cached version.
    setup     Register gem-skill as a Bundler plugin (run once after install).

    Use 'bundle skill install' in any project after running 'gem skill setup'.
  DESC
end

#executeObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/gem/skill/cli/gem_command.rb', line 47

def execute
  if options[:version]
    say Gem::Skill::VERSION
    return
  end
  Gem::Skill.configure_llm!
  subcmd = options[:args].shift
  case subcmd
  when "install" then cmd_install
  when "list"    then cmd_list
  when "purge"   then cmd_purge
  when "setup"   then cmd_setup
  when nil
    say usage
  else
    alert_error "Unknown subcommand: #{subcmd.inspect}"
    say usage
  end
end

#usageObject



28
29
30
31
32
33
34
# File 'lib/gem/skill/cli/gem_command.rb', line 28

def usage
  "#{program_name} install GEM_NAME [GEM_NAME ...]\n" \
  "       #{program_name} list\n" \
  "       #{program_name} purge GEM_NAME VERSION\n" \
  "       #{program_name} purge GEM_NAME --all\n" \
  "       #{program_name} setup"
end