claude_code_slash_commands 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c210edb72d63d4cdb518fb644dae19bad1f8b78fce946896832949dcf2b15a12
4
- data.tar.gz: bd4a22abcae98bb843b902eee41eeeafc9575ec9dd8d127b03e4abe5b146afc6
3
+ metadata.gz: 89ca4fe43efd662a0ead8fbc2638980bf11b1c087e1c67d2c8b8294e75af34b5
4
+ data.tar.gz: 7f137f9800fda4559099125496339ad688add88e40ff5ab4562434c9265d5679
5
5
  SHA512:
6
- metadata.gz: f994df51e9893d1a0bc8b37481470bf04846ff7ed5fac3a9ed1b9fbd0e8f7c005177a0d27dfd7a5575e7a5cd0e11a2b7c33c26204eeb86f1f3c59905d00397d5
7
- data.tar.gz: a23b39eef771857dfff527f9ff070341e625051e70940b0380b57c7f3fac9cf0964cb5337e9a06a709c35b8dcf69035dce3c7b8b52625df14cc6974830c8d3de
6
+ metadata.gz: 39e56a72e6087ea9388136c7c8fda53af496a5a8cbafcd76f57e3abb8b3d40997a345562b81719ccd4260320fbbfc24dfafbcfa75eb651ad31b11d4f9e20d8b1
7
+ data.tar.gz: 48db40cc5f04f83e8cea64ce05149306c6584391bb3ba4275ed1b9e73a08324b55274469bd660b79117a5cd4a6e3bea93a036866b1cfc8b0f2d80c93aa8368da
data/CLAUDE.md ADDED
@@ -0,0 +1,57 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Commands
6
+
7
+ ### Testing and Development
8
+ - `rake test` - Run the test suite using Minitest
9
+ - `bundle exec rake test` - Run tests with bundler
10
+ - `rake standard` - Run StandardRB linter for code formatting
11
+ - `rake standard:fix` - Auto-fix StandardRB formatting issues
12
+ - `rake` - Run default task (both tests and linting)
13
+
14
+ ### Gem Development
15
+ - `bundle exec rake install` - Install gem locally for testing
16
+ - `bundle exec rake release` - Create git tag and push to RubyGems
17
+ - `bundle exec rake build` - Build the gem file
18
+ - `bin/setup` - Install dependencies after checkout
19
+ - `bin/console` - Start interactive console with gem loaded
20
+
21
+ ### CLI Usage
22
+ - `claude_code_slash_commands install` - Install commands to ~/.claude/commands from GitHub
23
+ - `claude_code_slash_commands install --local` - Install commands from local commands/ directory
24
+ - `claude_code_slash_commands help` - Show help message
25
+
26
+ ## Architecture
27
+
28
+ This is a Ruby gem that distributes slash commands for Claude Code. The main components are:
29
+
30
+ ### Core Structure
31
+ - `ClaudeCodeSlashCommands::CLI` - Command-line interface handler that processes user commands
32
+ - `ClaudeCodeSlashCommands::Installer` - Handles downloading and installing command files from GitHub to `~/.claude/commands`
33
+ - `commands/` directory - Contains the actual slash command markdown files that get distributed
34
+
35
+ ### Key Features
36
+ - **GitHub Integration**: Uses `gh` CLI to fetch command files directly from the repository
37
+ - **Smart Installation**: Compares file contents to avoid unnecessary overwrites, prompts for confirmation when files differ
38
+ - **Command Format**: Slash commands are markdown files with optional YAML frontmatter for metadata
39
+
40
+ ### Dependencies
41
+ - Requires GitHub CLI (`gh`) to be installed and configured
42
+ - Uses StandardRB for code formatting
43
+ - Minitest for testing framework
44
+ - Mocha for test mocking
45
+
46
+ ### Command File Structure
47
+ Slash commands are stored as `.md` files in the `commands/` directory with this format:
48
+ ```markdown
49
+ ---
50
+ description: Brief description of the command
51
+ allowed-tools: Bash(git status:*)
52
+ ---
53
+
54
+ Command prompt content goes here
55
+ ```
56
+
57
+ The installer fetches these files from GitHub and copies them to the user's `~/.claude/commands` directory.
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in claude_code_slash_commands.gemspec
6
+ gemspec
7
+
8
+ gem "irb"
9
+ gem "rake", "~> 13.0"
10
+
11
+ gem "minitest", "~> 5.16"
12
+ gem "mocha"
13
+
14
+ gem "standard", "~> 1.3"
data/Gemfile.lock ADDED
@@ -0,0 +1,93 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ claude_code_slash_commands (0.2.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.3)
10
+ date (3.4.1)
11
+ erb (5.0.1)
12
+ io-console (0.8.0)
13
+ irb (1.15.2)
14
+ pp (>= 0.6.0)
15
+ rdoc (>= 4.0.0)
16
+ reline (>= 0.4.2)
17
+ json (2.12.2)
18
+ language_server-protocol (3.17.0.5)
19
+ lint_roller (1.1.0)
20
+ minitest (5.25.5)
21
+ mocha (2.7.1)
22
+ ruby2_keywords (>= 0.0.5)
23
+ parallel (1.27.0)
24
+ parser (3.3.8.0)
25
+ ast (~> 2.4.1)
26
+ racc
27
+ pp (0.6.2)
28
+ prettyprint
29
+ prettyprint (0.2.0)
30
+ prism (1.4.0)
31
+ psych (5.2.6)
32
+ date
33
+ stringio
34
+ racc (1.8.1)
35
+ rainbow (3.1.1)
36
+ rake (13.3.0)
37
+ rdoc (6.14.2)
38
+ erb
39
+ psych (>= 4.0.0)
40
+ regexp_parser (2.10.0)
41
+ reline (0.6.1)
42
+ io-console (~> 0.5)
43
+ rubocop (1.75.8)
44
+ json (~> 2.3)
45
+ language_server-protocol (~> 3.17.0.2)
46
+ lint_roller (~> 1.1.0)
47
+ parallel (~> 1.10)
48
+ parser (>= 3.3.0.2)
49
+ rainbow (>= 2.2.2, < 4.0)
50
+ regexp_parser (>= 2.9.3, < 3.0)
51
+ rubocop-ast (>= 1.44.0, < 2.0)
52
+ ruby-progressbar (~> 1.7)
53
+ unicode-display_width (>= 2.4.0, < 4.0)
54
+ rubocop-ast (1.45.1)
55
+ parser (>= 3.3.7.2)
56
+ prism (~> 1.4)
57
+ rubocop-performance (1.25.0)
58
+ lint_roller (~> 1.1)
59
+ rubocop (>= 1.75.0, < 2.0)
60
+ rubocop-ast (>= 1.38.0, < 2.0)
61
+ ruby-progressbar (1.13.0)
62
+ ruby2_keywords (0.0.5)
63
+ standard (1.50.0)
64
+ language_server-protocol (~> 3.17.0.2)
65
+ lint_roller (~> 1.0)
66
+ rubocop (~> 1.75.5)
67
+ standard-custom (~> 1.0.0)
68
+ standard-performance (~> 1.8)
69
+ standard-custom (1.0.2)
70
+ lint_roller (~> 1.0)
71
+ rubocop (~> 1.50)
72
+ standard-performance (1.8.0)
73
+ lint_roller (~> 1.1)
74
+ rubocop-performance (~> 1.25.0)
75
+ stringio (3.1.7)
76
+ unicode-display_width (3.1.4)
77
+ unicode-emoji (~> 4.0, >= 4.0.4)
78
+ unicode-emoji (4.0.4)
79
+
80
+ PLATFORMS
81
+ arm64-darwin-24
82
+ ruby
83
+
84
+ DEPENDENCIES
85
+ claude_code_slash_commands!
86
+ irb
87
+ minitest (~> 5.16)
88
+ mocha
89
+ rake (~> 13.0)
90
+ standard (~> 1.3)
91
+
92
+ BUNDLED WITH
93
+ 2.6.9
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # claude_code_slash_commands
2
2
 
3
- This gem is intended to distribute [slash commands](https://docs.anthropic.com/en/docs/claude-code/slash-commands) for [Claude Code](https://www.anthropic.com/claude-code).
3
+ This gem is for distributing Ruby-specific [slash commands](https://docs.anthropic.com/en/docs/claude-code/slash-commands) for [Claude Code](https://www.anthropic.com/claude-code).
4
+
5
+ ## Prerequisites
6
+
7
+ The [GitHub CLI](https://cli.github.com) must be installed and configured.
4
8
 
5
9
  ## Installation
6
10
 
@@ -29,14 +33,28 @@ claude_code_slash_commands install
29
33
  ```
30
34
 
31
35
  This will:
32
- - Create `~/.claude/commands` directory if it doesn't exist
33
- - Copy all command files from the gem
36
+ - Create the `~/.claude/commands` directory if it doesn't exist
37
+ - Copy all command files from the `commands/` directory on GitHub to your local `~/.claude/commands` directory.
34
38
  - Ask for confirmation before overwriting existing commands
35
39
  - Skip files that are already identical
36
40
 
41
+ #### Local Installation
42
+
43
+ By default, commands will be fetched from the gem's GitHub repository. That means you'll always get the latest versions.
44
+
45
+ To install commands from the gem's `commands/` directory instead of GitHub:
46
+
47
+ ```bash
48
+ claude_code_slash_commands install --local
49
+ ```
50
+
51
+ This is useful for:
52
+ - Testing new commands during development
53
+ - Installing commands when you don't have internet access
54
+
37
55
  ### Available Commands
38
56
 
39
- - `hello_world.md` - A simple example command that demonstrates the slash command format
57
+ Check the `commands/` directory to see what is available.
40
58
 
41
59
  ## Development
42
60
 
@@ -0,0 +1,10 @@
1
+ ---
2
+ description: Configure a gem's CI pipeline using GitHub Actions
3
+ ---
4
+ The goal is to create a CI workflow file that runs the gem's tests as well as any linting or other verificiation tasks.
5
+
6
+ If no CI workflow file exists, create one, otherwise update the existing one.
7
+
8
+  Read https://www.ruby-lang.org/en/downloads/branches/ to check the latest Ruby release version.
9
+
10
+ Configure the CI matrix such that it covers the the minimum `required_ruby_version` in the `.gemspec`, as well as every minor release up to the latest Ruby version.
@@ -15,7 +15,8 @@ module ClaudeCodeSlashCommands
15
15
  def run
16
16
  case @args.first
17
17
  when "install"
18
- Installer.new.install
18
+ local = @args.include?("--local")
19
+ Installer.new(local: local).install
19
20
  when "help", "-h", "--help", nil
20
21
  show_help
21
22
  else
@@ -29,14 +30,18 @@ module ClaudeCodeSlashCommands
29
30
 
30
31
  def show_help
31
32
  puts <<~HELP
32
- Usage: claude_code_slash_commands <command>
33
+ Usage: claude_code_slash_commands <command> [options]
33
34
 
34
35
  Commands:
35
36
  install Install slash commands to ~/.claude/commands
36
37
  help Show this help message
37
38
 
39
+ Options:
40
+ --local Install from local commands/ directory instead of GitHub
41
+
38
42
  Examples:
39
43
  claude_code_slash_commands install
44
+ claude_code_slash_commands install --local
40
45
  claude_code_slash_commands help
41
46
  HELP
42
47
  end
@@ -2,25 +2,42 @@
2
2
 
3
3
  require "fileutils"
4
4
  require "pathname"
5
+ require "json"
6
+ require "open3"
5
7
 
6
8
  module ClaudeCodeSlashCommands
7
9
  class Installer
8
- def initialize(commands_source: nil, commands_target: nil)
10
+ def initialize(commands_source: nil, commands_target: nil, repo: nil, local: false)
9
11
  @gem_root = Pathname.new(__dir__).parent.parent
10
12
  @commands_source = commands_source || @gem_root.join("commands")
11
13
  @commands_target = commands_target || Pathname.new(Dir.home).join(".claude", "commands")
14
+ @repo = repo || "andyw8/claude_code_slash_commands"
15
+ @local = local
12
16
  end
13
17
 
14
18
  def install
15
19
  ensure_target_directory
16
20
 
17
- if command_files.empty?
18
- puts "❌ No command files found to install"
19
- return
20
- end
21
+ if @local
22
+ commands = fetch_commands_from_local
23
+ if commands.empty?
24
+ puts "❌ No command files found in local commands/ directory"
25
+ return
26
+ end
27
+
28
+ commands.each do |command_file|
29
+ install_command_from_local(command_file)
30
+ end
31
+ else
32
+ commands = fetch_commands_from_github
33
+ if commands.empty?
34
+ puts "❌ No command files found to install"
35
+ return
36
+ end
21
37
 
22
- command_files.each do |file|
23
- install_command(file)
38
+ commands.each do |command|
39
+ install_command_from_github(command)
40
+ end
24
41
  end
25
42
 
26
43
  puts "✅ Installation complete!"
@@ -35,31 +52,44 @@ module ClaudeCodeSlashCommands
35
52
  FileUtils.mkdir_p(@commands_target)
36
53
  end
37
54
 
38
- def command_files
39
- @commands_source.glob("*.md")
55
+ def fetch_commands_from_github
56
+ stdout, stderr, status = Open3.capture3("gh", "api", "repos/#{@repo}/contents/commands")
57
+
58
+ unless status.success?
59
+ raise "Failed to fetch commands from GitHub: #{stderr}"
60
+ end
61
+
62
+ contents = JSON.parse(stdout)
63
+ contents.select { |item| item["type"] == "file" && item["name"].end_with?(".md") }
40
64
  end
41
65
 
42
- def install_command(source_file)
43
- target_file = @commands_target.join(source_file.basename)
66
+ def install_command_from_github(command)
67
+ filename = command["name"]
68
+ target_file = @commands_target.join(filename)
69
+
70
+ # Fetch the content of the command file
71
+ stdout, stderr, status = Open3.capture3("gh", "api", command["download_path"])
72
+
73
+ unless status.success?
74
+ raise "Failed to fetch command content for #{filename}: #{stderr}"
75
+ end
76
+
77
+ content = stdout
44
78
 
45
79
  if target_file.exist?
46
- if files_identical?(source_file, target_file)
47
- puts "⏭️ #{source_file.basename} already exists and is identical"
80
+ if target_file.read == content
81
+ puts "⏭️ #{filename} already exists and is identical"
48
82
  return
49
83
  end
50
84
 
51
- unless confirm_overwrite(source_file.basename)
52
- puts "⏭️ Skipping #{source_file.basename}"
85
+ unless confirm_overwrite(filename)
86
+ puts "⏭️ Skipping #{filename}"
53
87
  return
54
88
  end
55
89
  end
56
90
 
57
- FileUtils.cp(source_file, target_file)
58
- puts "📄 Installed #{source_file.basename}"
59
- end
60
-
61
- def files_identical?(file1, file2)
62
- file1.read == file2.read
91
+ target_file.write(content)
92
+ puts "📄 Installed #{filename}"
63
93
  end
64
94
 
65
95
  def confirm_overwrite(filename)
@@ -67,5 +97,33 @@ module ClaudeCodeSlashCommands
67
97
  response = $stdin.gets.chomp.downcase
68
98
  response == "y" || response == "yes"
69
99
  end
100
+
101
+ def fetch_commands_from_local
102
+ return [] unless @commands_source.exist?
103
+
104
+ @commands_source.glob("*.md").select(&:file?)
105
+ end
106
+
107
+ def install_command_from_local(command_file)
108
+ filename = command_file.basename.to_s
109
+ target_file = @commands_target.join(filename)
110
+
111
+ content = command_file.read
112
+
113
+ if target_file.exist?
114
+ if target_file.read == content
115
+ puts "⏭️ #{filename} already exists and is identical"
116
+ return
117
+ end
118
+
119
+ unless confirm_overwrite(filename)
120
+ puts "⏭️ Skipping #{filename}"
121
+ return
122
+ end
123
+ end
124
+
125
+ target_file.write(content)
126
+ puts "📄 Installed #{filename}"
127
+ end
70
128
  end
71
129
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClaudeCodeSlashCommands
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: claude_code_slash_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Waite
@@ -18,10 +18,13 @@ extra_rdoc_files: []
18
18
  files:
19
19
  - ".ruby-version"
20
20
  - ".standard.yml"
21
+ - CLAUDE.md
22
+ - Gemfile
23
+ - Gemfile.lock
21
24
  - LICENSE.txt
22
25
  - README.md
23
26
  - Rakefile
24
- - commands/hello_world.md
27
+ - commands/configure-gem-ci.md
25
28
  - exe/claude_code_slash_commands
26
29
  - lib/claude_code_slash_commands.rb
27
30
  - lib/claude_code_slash_commands/cli.rb
@@ -42,7 +45,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
42
45
  requirements:
43
46
  - - ">="
44
47
  - !ruby/object:Gem::Version
45
- version: 3.1.0
48
+ version: 3.2.0
46
49
  required_rubygems_version: !ruby/object:Gem::Requirement
47
50
  requirements:
48
51
  - - ">="
@@ -1,7 +0,0 @@
1
- ---
2
- description: A simple hello world example command
3
- ---
4
-
5
- Say hello to the world! This is an example slash command that demonstrates the basic structure of a Claude Code slash command.
6
-
7
- Respond with a friendly greeting and explain what slash commands are.