一键导入
ruby-workflow
Ruby project workflow guidelines. Activate when working with Ruby files (.rb), Gemfile, bundler, or Ruby-specific tooling.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Ruby project workflow guidelines. Activate when working with Ruby files (.rb), Gemfile, bundler, or Ruby-specific tooling.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Language-agnostic API design patterns covering REST and GraphQL, including resource naming, HTTP methods, status codes, versioning, pagination, filtering, authentication, error handling, and schema design. Activate when working with APIs, REST endpoints, GraphQL schemas, API documentation, OpenAPI/Swagger, JWT, OAuth2, endpoint design, API versioning, rate limiting, or GraphQL resolvers.
Git workflow and commit guidelines. Trigger keywords: git, commit, push, .git, version control. MUST be activated before ANY git commit, push, or version control operation. Includes security scanning for secrets (API keys, tokens, .env files), commit message formatting with HEREDOC, logical commit grouping (docs, test, feat, fix, refactor, chore, build, deps), push behavior rules, safety rules for hooks and force pushes, and CRITICAL safeguards for destructive operations (filter-branch, gc --prune, reset --hard). Activate when user requests committing changes, pushing code, creating commits, rewriting history, or performing any git operations including analyzing uncommitted changes.
Testing workflow patterns and quality standards. Activate when working with tests, test files, test directories, code quality tools, coverage reports, or testing tasks. Includes zero-warnings policy, targeted testing during development, mocking patterns, and best practices across languages.
Ansible automation workflow guidelines. Activate when working with Ansible playbooks, ansible-playbook, inventory files (.yml, .ini), or Ansible-specific patterns.
Claude Code AI-assisted development workflow. Activate when discussing Claude Code usage, AI-assisted coding, prompting strategies, or Claude Code-specific patterns.
Guidelines for containerized projects using Docker, Dockerfile, docker-compose, container, and containerization. Covers multi-stage builds, security, signal handling, entrypoint scripts, and deployment workflows.
| name | ruby-workflow |
| description | Ruby project workflow guidelines. Activate when working with Ruby files (.rb), Gemfile, bundler, or Ruby-specific tooling. |
| location | user |
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
| Task | Tool | Command |
|---|---|---|
| Lint | StandardRB | bundle exec standardrb |
| Format | StandardRB | bundle exec standardrb --fix |
| Type check | Sorbet | bundle exec srb tc |
| Semantic | Reek | bundle exec reek |
| Dead code | debride | bundle exec debride . |
| Complexity | Flog | bundle exec flog lib/ |
| Test | RSpec | bundle exec rspec |
| Test | Minitest | bundle exec rake test |
.ruby-version file MUST be present in project root--yjit flag or RUBY_YJIT_ENABLE=1)Pattern matching SHOULD be used for complex conditionals:
# Preferred
case response
in { status: 200, body: }
process(body)
in { status: 404 }
handle_not_found
in { status: 500.. }
handle_server_error
end
# Also valid for single patterns
response => { data: { users: } }
Data.define SHOULD be used for immutable value objects (Ruby 3.2+):
# Preferred over Struct for immutable data
Point = Data.define(:x, :y) do
def distance_from_origin
Math.sqrt(x**2 + y**2)
end
end
point = Point.new(3, 4)
point.x = 5 # => FrozenError (immutable by default)
it KeywordThe it keyword (Ruby 3.4+) SHOULD be used for single-parameter blocks:
# Preferred (Ruby 3.4+)
users.map { it.name.upcase }
# Also acceptable
users.map { _1.name.upcase }
# Legacy (still valid)
users.map { |user| user.name.upcase }
Gemfile MUST be present for all projectsGemfile.lock MUST be committed to version control# Preferred - pessimistic version constraint
gem "rails", "~> 7.1"
# Acceptable - exact version for critical deps
gem "pg", "1.5.4"
# Avoid - no version constraint
gem "nokogiri" # May break unexpectedly
| Command | Use Case |
|---|---|
bundle install | Install dependencies |
bundle update GEM | Update specific gem |
bundle exec CMD | Run command with bundled gems |
bundle outdated | Check for updates |
bundle audit | Security vulnerability check |
All Ruby commands MUST use bundle exec prefix to ensure correct gem versions.
| Element | Convention | Example |
|---|---|---|
| Files | snake_case | user_service.rb |
| Classes/Modules | PascalCase | UserService |
| Methods | snake_case | find_by_email |
| Variables | snake_case | current_user |
| Constants | SCREAMING_SNAKE | MAX_RETRIES |
| Predicates | trailing ? | valid?, empty? |
| Dangerous | trailing ! | save!, destroy! |
| Setters | trailing = | name= |
?!private keyword)StandardRB SHOULD be used over RuboCop for simplicity:
# .standard.yml (optional overrides)
ruby_version: 3.3
ignore:
- "db/schema.rb"
- "vendor/**/*"
# String literals - prefer double quotes
name = "Ruby"
# Symbol arrays
%i[foo bar baz]
# String arrays
%w[apple banana cherry]
# Heredocs for multiline strings
query = <<~SQL
SELECT * FROM users
WHERE active = true
SQL
# Safe navigation operator
user&.profile&.avatar_url
# Endless methods (Ruby 3.0+) for simple one-liners
def full_name = "#{first_name} #{last_name}"
# Keyword arguments SHOULD be preferred for optional params
def create_user(name:, email:, role: :member)
# ...
end
# Avoid positional arguments beyond 2-3 parameters
# Bad
def create_user(name, email, role, active, verified)
# Good
def create_user(name:, email:, role:, active:, verified:)
RSpec SHOULD be the default testing framework:
# spec/services/user_service_spec.rb
RSpec.describe UserService do
describe "#create" do
context "with valid attributes" do
it "creates a new user" do
result = described_class.new.create(name: "Test")
expect(result).to be_success
end
end
context "with invalid attributes" do
it "returns failure" do
result = described_class.new.create(name: "")
expect(result).to be_failure
end
end
end
end
describe for classes/methodscontext for conditions/scenariosit for specific behaviorslet for lazy-loaded test datalet! for eager-loaded test databefore for setup (use sparingly)# test/services/user_service_test.rb
class UserServiceTest < Minitest::Test
def test_create_with_valid_attributes
result = UserService.new.create(name: "Test")
assert result.success?
end
end
# Preferred: blocks
users.each { |user| notify(user) }
# Acceptable: lambda for callbacks
validator = ->(value) { value.present? }
# Lambda with arguments
process = ->(x, y) { x + y }
# Avoid: Proc.new unless needed
callback = Proc.new { |x| x * 2 } # Different arity handling
# Symbol to proc (preferred for simple cases)
names = users.map(&:name)
# Method reference
def process(item)
item.upcase
end
items.map(&method(:process))
define_method over method_missing when possible# Acceptable: documented DSL
class Validator
# Defines validation methods for each attribute
# @param attrs [Array<Symbol>] attribute names to validate
def self.validates(*attrs)
attrs.each do |attr|
define_method("validate_#{attr}") do
# validation logic
end
end
end
end
# Document what methods are generated
# Generated methods: validate_name, validate_email
validates :name, :email
# Avoid: unbounded method_missing
def method_missing(name, *args)
# Hard to debug, no autocomplete
end
# Prefer: explicit delegation or define_method
# Custom errors SHOULD inherit from StandardError
class ServiceError < StandardError; end
class ValidationError < ServiceError; end
# Rescue specific exceptions
begin
risky_operation
rescue ValidationError => e
handle_validation(e)
rescue ServiceError => e
handle_service_error(e)
rescue StandardError => e
handle_unexpected(e)
end
# Result objects SHOULD be used for expected failures
Result = Data.define(:success, :value, :error) do
def success? = success
def failure? = !success
def self.success(value) = new(true, value, nil)
def self.failure(error) = new(false, nil, error)
end
project/
lib/ # Application code
spec/ # RSpec tests
test/ # Minitest tests
bin/ # Executables
Gemfile # Dependencies
Gemfile.lock # Locked versions
.ruby-version # Ruby version
.standard.yml # StandardRB config (optional)
rails-workflowhanami-workflowgem-publishing