Ruby programming patterns and idioms
- version
- 1.0.0
- GitHub stars
- 26
Add marketplace
/plugin marketplace add miles990/claude-software-skillsRun it inside Claude Code once, then install the plugin below.
Install
/plugin install ruby@claude-software-skillsRun it inside Claude Code after adding the marketplace.
Files
Discovered from sourceRuby
Overview
Ruby programming patterns including blocks, metaprogramming, and idiomatic Ruby code.
Core Ruby Patterns
Classes and Modules
# Class definition
class User
attr_accessor :name, :email
attr_reader :id
attr_writer :password
# Class variable
@@count = 0
# Class method
def self.count
@@count
end
# Initialize
def initialize(name, email)
@id = SecureRandom.uuid
@name = name
@email = email
@@count += 1
end
# Instance method
def display_name
"#{name} <#{email}>"
end
# Private methods
private
def validate_email
email.include?('@')
end
end
# Inheritance
class Admin < User
attr_accessor :permissions
def initialize(name, email, permissions = [])
super(name, email)
@permissions = permissions
end
def has_permission?(perm)
permissions.include?(perm)
end
end
# Modules for mixins
module Timestampable
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def timestamped_attrs
[:created_at, :updated_at]
end
end
def touch
@updated_at = Time.now
end
def created_at
@created_at ||= Time.now
end
end
# Including module
class Document
include Timestampable
include Comparable
attr_accessor :title, :content
def <=>(other)
title <=> other.title
end
end
# Module for namespacing
module MyApp
module Services
class UserService
def create(params)
# ...
end
end
end
end
Blocks, Procs, and Lambdas
# Block usage
[1, 2, 3].each { |n| puts n }
[1, 2, 3].map do |n|
n * 2
end
# Yield to block
def with_timing
start = Time.now
result = yield
elapsed = Time.now - start
puts "Elapsed: #{elapsed}s"
result
end
with_timing { sleep(0.1) }
# Block with arguments
def transform_items(items)
items.map { |item| yield(item) }
end
transform_items([1, 2, 3]) { |n| n * 2 }
# Check if block given
def optional_block
if block_given?
yield
else
"No block provided"
end
end
# Convert block to proc
def with_block(&block)
block.call(42)
end
# Proc
my_proc = Proc.new { |x| x * 2 }
my_proc.call(21) # => 42
# Lambda
my_lambda = ->(x) { x * 2 }
my_lambda.call(21) # => 42
# Proc vs Lambda differences
proc_example = Proc.new { |x, y| x }
proc_example.call(1) # Works, y is nil
lambda_example = ->(x, y) { x }
# lambda_example.call(1) # ArgumentError
# Symbol to proc
['a', 'b', 'c'].map(&:upcase)
# Equivalent to: ['a', 'b', 'c'].map { |s| s.upcase }
Enumerable and Iterators
# Array operations
numbers = [1, 2, 3, 4, 5]
# Map/collect
doubled = numbers.map { |n| n * 2 }
# Select/filter
evens = numbers.select(&:even?)
# Reject
odds = numbers.reject(&:even?)
# Reduce/inject
sum = numbers.reduce(0) { |acc, n| acc + n }
sum = numbers.reduce(:+)
# Each with index
numbers.each_with_index do |n, i|
puts "#{i}: #{n}"
end
# Find
found = numbers.find { |n| n > 3 }
# Any/all/none
numbers.any?(&:even?) # true
numbers.all? { |n| n > 0 } # true
numbers.none? { |n| n > 10 } # true
# Group by
users = [
{ name: 'Alice', role: 'admin' },
{ name: 'Bob', role: 'user' },
{ name: 'Charlie', role: 'admin' }
]
grouped = users.group_by { |u| u[:role] }
# => { 'admin' => [...], 'user' => [...] }
# Partition
passed, failed = scores.partition { |s| s >= 60 }
# Flat map
nested = [[1, 2], [3, 4]]
flat = nested.flat_map { |arr| arr.map { |n| n * 2 } }
# Lazy evaluation
(1..Float::INFINITY).lazy
.select(&:even?)
.map { |n| n * 2 }
.take(10)
.to_a
# Custom iterator
class Countdown
include Enumerable
def initialize(start)
@start = start
end
def each
@start.downto(0) { |n| yield n }
end
end
Countdown.new(5).to_a # => [5, 4, 3, 2, 1, 0]
Metaprogramming
# Method missing
class DynamicProxy
def initialize(target)
@target = target
end
def method_missing(method, *args, &block)
puts "Calling #{method} with #{args}"
@target.send(method, *args, &block)
end
def respond_to_missing?(method, include_private = false)
@target.respond_to?(method) || super
end
end
# Define method dynamically
class User
ROLES = %w[admin moderator user]
ROLES.each do |role|
define_method("#{role}?") do
@role == role
end
end
end
# Class macro
class MyModel
def self.attribute(name, type)
define_method(name) do
instance_variable_get("@#{name}")
end
define_method("#{name}=") do |value|
instance_variable_set("@#{name}", value)
end
end
attribute :name, :string
attribute :age, :integer
end
# Hook methods
class Base
def self.inherited(subclass)
puts "#{subclass} inherits from #{self}"
end
def self.method_added(method_name)
puts "Method #{method_name} added"
end
end
# Instance eval / class eval
class Config
def self.configure(&block)
instance_eval(&block)
end
def self.setting(name, value)
define_singleton_method(name) { value }
end
end
Config.configure do
setting :api_key, 'abc123'
setting :timeout, 30
end
# Send / public_send
obj.send(:private_method) # Can call private
obj.public_send(:public_method) # Only public
# Refinements (safer monkey patching)
module StringExtensions
refine String do
def to_slug
downcase.gsub(/\s+/, '-')
end
end
end
class MyClass
using StringExtensions
def process(title)
title.to_slug
end
end
Error Handling
# Basic exception handling
begin
risky_operation
rescue StandardError => e
puts "Error: #{e.message}"
puts e.backtrace.first(5).join("\n")
ensure
cleanup
end
# Multiple rescue clauses
begin
parse_file(path)
rescue Errno::ENOENT
puts "File not found"
rescue JSON::ParserError => e
puts "Invalid JSON: #{e.message}"
rescue => e
puts "Unknown error: #{e.class}"
end
# Retry
attempts = 0
begin
attempts += 1
connect_to_server
rescue ConnectionError
retry if attempts < 3
raise
end
# Custom exceptions
class AppError < StandardError
attr_reader :code
def initialize(message, code: nil)
super(message)
@code = code
end
end
class ValidationError < AppError
attr_reader :errors
def initialize(errors)
super("Validation failed")
@errors = errors
end
end
# Raise with custom exception
raise ValidationError.new({ email: ['is invalid'] })
# Re-raise with context
begin
process_order(order)
rescue => e
raise "Failed to process order #{order.id}: #{e.message}"
end
# Result object pattern
class Result
attr_reader :value, :error
def self.success(value)
new(value: value)
end
def self.failure(error)
new(error: error)
end
def initialize(value: nil, error: nil)
@value = value
@error = error
end
def success?
error.nil?
end
def failure?
!success?
end
def then
return self if failure?
yield(value)
end
end
# Usage
def create_user(params)
return Result.failure('Email required') unless params[:email]
user = User.create(params)
Result.success(user)
rescue ActiveRecord::RecordInvalid => e
Result.failure(e.message)
end
Testing with RSpec
# spec/models/user_spec.rb
require 'rails_helper'
RSpec.describe User, type: :model do
describe 'validations' do
it { is_expected.to validate_presence_of(:email) }
it { is_expected.to validate_uniqueness_of(:email) }
end
describe 'associations' do
it { is_expected.to have_many(:posts) }
it { is_expected.to belong_to(:organization) }
end
describe '#display_name' do
subject(:user) { build(:user, name: 'John', email: 'john@example.com') }
it 'returns formatted name with email' do
expect(user.display_name).to eq('John <john@example.com>')
end
end
describe '.active' do
let!(:active_user) { create(:user, active: true) }
let!(:inactive_user) { create(:user, active: false) }
it 'returns only active users' do
expect(User.active).to contain_exactly(active_user)
end
end
context 'when user is admin' do
subject(:admin) { build(:user, :admin) }
it 'has admin privileges' do
expect(admin).to be_admin
end
end
end
# spec/services/user_service_spec.rb
RSpec.describe UserService do
describe '#create' do
subject(:service) { described_class.new }
let(:params) { { email: 'test@example.com', name: 'Test' } }
let(:email_service) { instance_double(EmailService) }
before do
allow(EmailService).to receive(:new).and_return(email_service)
allow(email_service).to receive(:send_welcome)
end
it 'creates a user' do
expect { service.create(params) }.to change(User, :count).by(1)
end
it 'sends welcome email' do
service.create(params)
expect(email_service).to have_received(:send_welcome)
end
context 'with invalid params' do
let(:params) { { email: '' } }
it 'raises validation error' do
expect { service.create(params) }.to raise_error(ValidationError)
end
end
end
end
Concurrency
# Threads
threads = []
results = []
mutex = Mutex.new
5.times do |i|
threads << Thread.new do
result = heavy_computation(i)
mutex.synchronize { results << result }
end
end
threads.each(&:join)
# Thread pool with Concurrent Ruby
require 'concurrent'
pool = Concurrent::FixedThreadPool.new(5)
futures = urls.map do |url|
Concurrent::Future.execute(executor: pool) do
fetch_url(url)
end
end
results = futures.map(&:value)
# Async/await with Async gem
require 'async'
Async do
results = urls.map do |url|
Async do
fetch_url(url)
end
end.map(&:wait)
end
# Fiber (cooperative concurrency)
fiber = Fiber.new do
puts "Start"
Fiber.yield 1
puts "Middle"
Fiber.yield 2
puts "End"
end
fiber.resume # "Start", returns 1
fiber.resume # "Middle", returns 2
fiber.resume # "End", returns nil
# Ractor (Ruby 3.0+ parallel execution)
ractor = Ractor.new do
val = Ractor.receive
val * 2
end
ractor.send(21)
result = ractor.take # => 42
Related Skills
- [[backend]] - Ruby on Rails
- [[testing]] - RSpec, Minitest
- [[automation-scripts]] - Ruby scripting
From the miles990/claude-software-skills README
Claude Software Skills
55 modular software development skills for Claude Code - from architecture to deployment
┌─────────────────────────────────────────────────────────────────┐
│ Claude Software Skills │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Software │ │ Software │ │ Development │ │
│ │ Design │ │ Engineering │ │ Stacks │ │
│ │ 6 │ │ 8 │ │ 8 │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Tools & │ │ Domain │ │ Programming │ │
│ │ Integrations │ │ Applications │ │ Languages │ │
│ │ 9 │ │ 12 │ │ 12 │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
│ AI 自動識別任務 → 載入對應領域知識 │
└─────────────────────────────────────────────────────────────────┘
Features
- MCP Compatible - Works with Claude Code, Cursor, and other MCP clients
- Semantic Search - Claude automatically finds relevant skills for your task
- Cross-Domain Integration - Skills work together seamlessly
- Best Practices Built-In - Each skill includes patterns and anti-patterns
- Modular Architecture - Use only what you need
- Sharp Edges - Proactive warnings about common pitfalls with detection patterns
- Validations - Executable code quality rules with regex/ast patterns
- Collaboration - Skills declare relationships for smart delegation and context passing
Installation
Plugin Marketplace (Recommended)
# 1. Add marketplace (GitHub format: owner/repo)
/plugin marketplace add miles990/claude-software-skills
# 2. Open plugin management interface, view available plugins in Discover tab
/plugin
# 3. Install specific skills (choose what you need)
/plugin install frontend@claude-software-skills
/plugin install backend@claude-software-skills
/plugin install api-design@claude-software-skills
# Or mention skill name in conversation, Claude will auto-load
Supported GitHub formats:
# Short format (recommended)
/plugin marketplace add miles990/claude-software-skills
# HTTPS URL
/plugin marketplace add https://github.com/miles990/claude-software-skills.git
# Specify branch or tag
/plugin marketplace add miles990/claude-software-skills#main
Plugin commands:
| Command | Description |
|---|---|
/plugin | Open interactive plugin management interface |
/plugin install <name>@<marketplace> | Install specific plugin |
/plugin disable <name>@<marketplace> | Temporarily disable plugin |
/plugin uninstall <name>@<marketplace> | Completely remove plugin |
Available Skills
Software Design (6 skills)
| Skill | Description |
|---|---|
architecture-patterns | Software architecture patterns and best practices |
design-patterns | Classic and modern software design patterns |
api-design | RESTful, GraphQL, gRPC, and API best practices |
system-design | Scalability, availability, and distributed systems design |
data-design | Data modeling, schema design, and data architecture |
ux-principles | User experience design principles for developers |
Software Engineering (8 skills)
| Skill | Description |
|---|---|
code-quality | Clean code principles, SOLID, and code review practices |
testing-strategies | Unit, integration, E2E testing and TDD practices |
devops-cicd | CI/CD pipelines, infrastructure as code, and deployment |
performance-optimization | Profiling, optimization techniques, and best practices |
security-practices | OWASP Top 10, authentication, and secure coding |
reliability-engineering | SRE principles, observability, and incident management |
documentation | Technical writing, API docs, and documentation best practices |
internationalization | i18n/l10n architecture design and multi-language support |
Development Stacks (8 skills)
| Skill | Description |
|---|---|
frontend | Modern frontend with React, Vue, and web technologies |
backend | Backend with Node.js, Express, NestJS, and server patterns |
mobile | Mobile with React Native, Flutter, and native patterns |
database | Database design, SQL, NoSQL, and data management |
cloud-platforms | AWS, GCP, Azure services and cloud-native development |
ai-ml-integration | AI/ML APIs, LLM integration, and intelligent apps |
realtime-systems | WebSocket, real-time communication, event-driven |
edge-iot | Edge computing, IoT protocols, and embedded systems |
Tools & Integrations (9 skills)
| Skill | Description |
|---|---|
git-workflows | Git version control, branching, and collaboration |
project-management | Agile, Scrum, Kanban, and issue tracking |
development-environment | IDE setup, dev containers, and local development |
monitoring-logging | Application monitoring, logging, and alerting |
api-tools | API testing, documentation, and development tools |
automation-scripts | Build automation, task runners, and scripting |
auto-dev-setup | Auto-Dev workflow for Human-in-the-Loop automation |
claude-code-plugin | Claude Code Plugin development and marketplace management |
claude-code-sdk | Claude Code SDK for AI-powered applications |
Domain Applications (12 skills)
| Skill | Description |
|---|---|
application-patterns | Common application development patterns |
e-commerce | E-commerce platforms, payments, shopping cart |
saas-platforms | SaaS architecture, multi-tenancy, subscriptions |
content-platforms | CMS, blogging platforms, content management |
communication-systems | Email, notifications, messaging systems |
developer-tools | CLI tools, SDKs, developer experience |
game-development | Game development patterns and architectures |
flame | Flame Engine 2D game development for Flutter |
flame-core | Flame Engine core - components, input, collision |
flame-systems | Flame Engine 14 game systems |
flame-templates | Game templates - RPG, Platformer, Roguelike |
desktop-apps | Desktop apps with Electron and Tauri |
Programming Languages (12 skills)
| Skill | Description |
|---|---|
javascript-typescript | Modern JavaScript and TypeScript patterns |
python | Python programming patterns and best practices |
go | Go programming patterns and idioms |
rust | Rust patterns and ownership concepts |
java-kotlin | Java and Kotlin programming patterns |
csharp-dotnet | C# and .NET development patterns |
cpp | Modern C++ programming patterns and idioms |
ruby | Ruby programming patterns and idioms |
php | Modern PHP programming patterns |
swift | Swift patterns for iOS and macOS |
shell-bash | Shell scripting and Bash programming |
sql | SQL patterns for database querying and design |
Other Installation Methods
Clone to Skills Directory
# Clone to your skills directory
git clone https://github.com/miles990/claude-software-skills.git ~/.claude/skills/software-skills
Claude will automatically discover and use the skills when relevant to your tasks.
With MCP Server
This repository is compatible with claude-skills-mcp:
# Install the MCP server
pip install claude-skills-mcp
# Add this repository as a skill source
# The server will load skills from ~/.claude/skills/
Cursor IDE
Add to your Cursor MCP settings:
{
"mcpServers": {
"software-skills": {
"command": "npx",
"args": ["-y", "claude-skills-mcp"],
"env": {
"SKILLS_PATH": "/path/to/claude-software-skills"
}
}
}
}
Manual Reference
Simply clone and reference the SKILL.md files in your prompts:
git clone https://github.com/miles990/claude-software-skills.git
Auto-Dev: Automated Development Workflow
One-click setup for GitHub Actions automated development workflow, let Claude help you complete development tasks.
Quick Setup
Using API Key:
curl -fsSL https://raw.githubusercontent.com/miles990/claude-software-skills/main/scripts/setup-auto-dev-apikey.sh | bash
Using Claude Max (OAuth):
curl -fsSL https://raw.githubusercontent.com/miles990/claude-software-skills/main/scripts/setup-auto-dev-max.sh | bash
Post-Installation Setup
| Version | Setup Method |
|---|---|
| API Key | Get Key from console.anthropic.com, set in GitHub Secrets ANTHROPIC_API_KEY |
| Claude Max | Run claude /install-github-app for auto OAuth Token setup |
Usage
- Issue Trigger: Create Issue → Add
auto-devlabel - Comment Trigger: Comment
@claude [instruction]on any Issue/PR
Detailed docs: AUTO-DEV.md
Usage Examples
User: Help me design a microservices architecture for an e-commerce platform
Claude: [Automatically uses architecture-patterns + e-commerce + api-design skills]
User: Review this Python code for performance issues
Claude: [Automatically uses python + performance-optimization + code-quality skills]
User: Set up CI/CD for a React + Node.js monorepo
Claude: [Automatically uses devops-cicd + frontend + backend + git-workflows skills]
Directory Structure
claude-software-skills/
├── .claude-plugin/ # Plugin configuration
│ └── marketplace.json # Lists all 55 skills as individual plugins
├── .github/
│ └── workflows/ # CI/CD automation
├── software-design/ # Architecture & design skills
├── software-engineering/ # Development practices
├── development-stacks/ # Tech stack skills
├── tools-integrations/ # Developer tools
├── domain-applications/ # Domain-specific patterns
├── programming-languages/ # Language-specific skills
├── docs/
│ ├── SKILL-TEMPLATE.md # Template for new skills
│ └── software-skills.md
├── CONTRIBUTING.md
├── LICENSE
└── README.md
How It Works
Each skill module contains a SKILL.md file with:
- Metadata - Name, description, tags for semantic search
- Key Concepts - Core knowledge and terminology
- Best Practices - Recommended approaches with examples
- Common Pitfalls - What to avoid and why
- Patterns & Anti-patterns - Do's and don'ts with code
- Tools & Resources - Recommended tools and references
- Decision Guide - When to use this skill
When you describe a task, Claude:
- Searches for relevant skills using semantic matching
- Loads the appropriate SKILL.md files
- Applies the knowledge to your specific context
- Follows best practices while avoiding common pitfalls
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Adding a New Skill
- Create a directory under the appropriate category
- Add a
SKILL.mdfollowing our template - Include practical examples and best practices
- Submit a pull request
License
MIT License - See LICENSE for details.
Related Projects
- claude-domain-skills - Non-technical domain skills
- claude-skills-mcp - MCP server for skill discovery
Built for developers, by developers, with Claude
Details
- Marketplace
- miles990/claude-software-skills
- Source
- programming-languages/ruby
- Category
- Community
- Listed since
- Apr 6, 2026
More from miles990/claude-software-skills
All 56- rustv1.0.0
- saas-platformsv1.0.0
- security-practicesv1.0.0
- shell-bashv1.0.0
- sqlv1.0.0
- swiftv1.0.0
- system-designv1.0.0
- testing-strategiesv1.0.0
- ux-principlesv1.0.0
- ai-ml-integrationv1.0.0
- analyze-repov1.0.0
- api-designv1.0.0
- api-toolsv1.0.0
- application-patternsv1.0.0
- architecture-patternsv1.0.0
- auto-dev-setupv1.0.0
- automation-scriptsv1.0.0
- backendv1.0.0
- claude-code-pluginv1.0.0
- claude-code-sdkv1.0.0
- cloud-platformsv1.0.0
- code-qualityv1.0.0
- communication-systemsv1.0.0
- content-platformsv1.0.0
Similar to ruby
pythonmiles990/claude-software-skills26 starsPython programming patterns and best practices
gomiles990/claude-software-skills26 starsGo programming patterns and idioms
jutsu-rubyTheBushidoCollective/han201 starsAdvanced Ruby skills for object-oriented programming, metaprogramming, blocks, and gems.
functional-programmingwshobson/agents42.8K starsFunctional programming with Elixir, OTP patterns, Phoenix framework, and distributed systems
python-expertrohitg00/awesome-claude-code-toolkit2.8K starsPython-specific development with type hints and idiomatic refactoring
systems-programmingwshobson/agents42.8K starsSystems programming with Rust, Go, C, and C++ for performance-critical and low-level development
