ruby-service-objects

Enforce Rails service object structure with .call, namespacing, and YARD documentation.

22|6|Updated Mar 11, 2026
One-click install
npx skills add https://github.com/igmarin/rails-agent-skills --skill ruby-service-objects
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ruby-service-objects
Source: https://github.com/igmarin/rails-agent-skills/tree/main/ruby-service-objects
Command: npx skills add https://github.com/igmarin/rails-agent-skills --skill ruby-service-objects

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Creating and maintaining Rails service objects is error-prone without a consistent structure; this guide codifies best practices to ensure predictable APIs, strong tests, and clear documentation.

Core Features & Use Cases

  • Enforces the .call pattern and module namespacing to keep services predictable and reusable.
  • Requires YARD documentation on public methods and applies the frozen_string_literal pragma for consistency.
  • Supports orchestrator delegation, transaction wrapping, and robust error handling across multi-step operations.

Quick Start

Create a new service under app/services with a modular namespace, implement a public .call method, and document the API with YARD.

Frequently Asked Questions about ruby-service-objects

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure Rails service objects to keep business logic maintainable?

Consistent Rails service objects keep business logic maintainable by enforcing the .call entry point, module namespacing, and YARD documentation. This predictable API structure ensures services remain reusable and safe across multi-step operations.

What is the best way to enforce test-first discipline when refactoring Ruby code into services?

Enforcing test-first discipline when refactoring Ruby code into services requires strict gating during the creation process. Standardized responses and transactional handling ensure your service code remains safe and thoroughly tested before deployment.

How do you handle transactions and error handling in Ruby service objects?

Handling transactions and errors in Ruby service objects requires wrapping multi-step operations in transaction blocks and applying orchestrator delegation. This ensures robust error handling and standardized responses across complex service interactions.

Does this service object pattern work with existing RSpec tests?

Yes, this service object pattern works with existing RSpec tests by enforcing strict test-first gating. The standardized API responses and modular namespacing make it straightforward to integrate and test within your current Rails testing suite.

When should I use orchestrator delegation in Rails service objects?

Use orchestrator delegation in Rails service objects when coordinating multi-step operations across distinct services. This pattern safely manages transactional handling and standardized responses without bloating a single service class with nested business logic.