skills/coding/coding-ruby/SKILL.md
Ruby 3.x: blocks/procs/lambdas, metaprogramming, modules, bundler, gems, Rails, RSpec
npx skillsauth add alphaonedev/openclaw-graph coding-rubyInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill allows the AI to generate, debug, and optimize Ruby 3.x code, focusing on advanced constructs like blocks, procs, lambdas, metaprogramming, modules, gem management with Bundler, Rails web apps, and RSpec testing.
Use this skill for tasks involving Ruby scripting, such as building web applications with Rails, managing dependencies via Bundler, writing unit tests with RSpec, or applying metaprogramming for dynamic code generation. Apply it when users request code for e-commerce sites, API backends, or custom gems.
define_method or method_missing for dynamic class creation.module MyModule; end.To accomplish tasks, structure code with Ruby's idioms: use procs for callbacks, modules for reusable code, and metaprogramming for automation. For Rails, follow the MVC pattern; for RSpec, use describe/it blocks. Always check Ruby 3.x syntax, like pattern matching with case statements. To define a lambda: my_lambda = ->(x) { x * 2 }. Invoke it as my_lambda.call(5). For metaprogramming, add methods dynamically: class MyClass; define_method(:greet) { puts 'Hello' }; end. Integrate Bundler by running bundle install after editing Gemfiles.
Use these exact commands for Ruby tasks:
ruby -v to verify version (e.g., 3.2.2), or start IRB with irb for interactive testing.bundle install --path vendor/bundle to install gems from a Gemfile; update with bundle update gem_name.gem 'rspec', '~> 3.12'; then run bundle install.rails new my_app --database=postgresql; create a controller: rails generate controller Users index.rspec spec/, or a specific file: rspec spec/models/user_spec.rb --format documentation.config/routes.rb, e.g., resources :users; access via /users in code.
Config formats: Use YAML for Rails configs, e.g., in config/database.yml: default: &default adapter: postgresql username: user. For authentication in gems, set env vars like $RAILS_MASTER_KEY for encrypted credentials.Integrate this skill by setting up a Ruby environment first: Install Ruby 3.x via rbenv with rbenv install 3.2.2 and set it globally with rbenv global 3.2.2. For Rails, add to Gemfile and run bundle exec rails server to start on port 3000. Use Bundler for gem isolation: Create a new gem set with bundle init and require gems in code like require 'rspec'. If external APIs are involved (e.g., via gems), handle auth with env vars: Set $GEM_API_KEY and access it in code as ENV['GEM_API_KEY']. For database integration, configure ActiveRecord in Rails models, e.g., class User < ApplicationRecord; end, and migrate with rails db:migrate.
Handle Ruby errors prescriptively: Use begin/rescue blocks for exceptions, e.g.:
begin
File.open('nonexistent.txt')
rescue Errno::ENOENT => e
puts "File not found: #{e.message}"
end
For Rails, check logs in log/development.log and use rescue_from in controllers for custom errors. In RSpec, expect errors with expect { code }.to raise_error(SomeError). Common issues: Gem conflicts—resolve with bundle clean --force; syntax errors in Ruby 3.x—use ruby -c file.rb to check. For metaprogramming, catch NoMethodError with method_missing to define fallback behavior.
tools
Root web development: project structure, tooling selection, deployment decisions
development
WebAssembly: Rust/Go/C to WASM, wasm-bindgen, Emscripten, WASM Component Model
development
Vue 3: Composition API script setup, Pinia, Vue Router 4, SFCs, Vite, Nuxt 3
tools
Tailwind CSS 4: utility classes, config, JIT, arbitrary values, darkMode, plugins, shadcn/ui