rails-service-patterns

rails-service-patterns is a skill for Claude Code, Codex from ag0os/rails-dev-plugin. It costs 70 tokens per session (971 once invoked), scanned A, original, MIT.

A guide to service objects in Ruby on Rails, which move business rules out of controllers and models into focused objects. It covers command, result, form, query, policy, and external-API patterns.

In plain words
What is it for?
Use it when extracting business logic, coordinating workflows, handling multi-model forms, building reusable queries, making authorization decisions, or integrating external APIs.
Why use it?
It helps choose a suitable place for multi-step or complex application logic instead of letting controllers and models become difficult to maintain.

Skill for Claude CodeCodex

Part of the rails-dev-plugin plugin — 19 skills, 11 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/ag0os/rails-dev-plugin/rails-service-patterns
Any agent
npx skills add ag0os/rails-dev-plugin --skill rails-service-patterns
Clone the repo
git clone --depth 1 https://github.com/ag0os/rails-dev-plugin

Made for: Claude Code, Codex.

Or install rails-dev-plugin, the plugin that ships this one along with the rest of its 19 skills, 11 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for rails-service-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/ag0os/rails-dev-plugin/rails-service-patterns.svg)](https://agentmods.dev/skills/ag0os/rails-dev-plugin/rails-service-patterns)
Your own site
<a href="https://agentmods.dev/skills/ag0os/rails-dev-plugin/rails-service-patterns"><img src="https://agentmods.dev/badge/skills/ag0os/rails-dev-plugin/rails-service-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 70 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 971 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00070 $0.00971
Opus 5 $0.00035 $0.00485
Sonnet 5 $0.00014 $0.00194
Haiku 4.5 $0.00007 $0.00097

Measured 5d ago against content hash d41e55814364, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

rails-service-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/rails-service-patterns/SKILL.md · 94 lines

How it starts

The opening of the file, as written. The whole thing — 94 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Rails Service Object Patterns

Analyze and recommend patterns for extracting and organizing business logic in Rails applications.

Resolve the axis first

This skill forks on Axis A — logic placement. Before recommending where logic goes:

  1. If the axes are already resolved this session, use them.
  2. Otherwise resolve via rails-stack-profiles (Axis A only — native or extracted).
  3. Then read the matching extraction guide:

If the axis cannot be resolved, default to native and state the assumption.

Everything else in this file is invariant — it holds regardless of axis.

Quick Reference

Pattern Use When Entry Point
Basic Service Single operation with transaction CreateOrder.new(...).call
Result Object Caller needs success/failure + data Result.new(success?: true, data:)
Form Object Multi-model form submissions RegistrationForm.new(params).save
Query Object Complex reusable queries UserSearchQuery.new(scope).call
Policy Object Authorization decisions PostPolicy.new(user, post).update?

Supporting Documentation

Core Principles

  1. VerbNoun naming: CreateOrder, SendInvitation -- never OrderService or UserManager
  2. One public method: Expose only call (or perform)
  3. Explicit return values: Use Result objects, never exceptions for expected flow control
  4. Axis-aware extraction: Whether a given operation becomes a service at all depends on Axis A. Read the matching extraction guide above before recommending a service.

Result Object Pattern

Read the full file on GitHub · 94 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 94 lines · 70 tokens per session scan A d41e55814364

Subscribe to this mod's changes

rails-service-patterns is a skill published in the GitHub repository ag0os/rails-dev-plugin (5 stars, last pushed 3mo ago), licensed MIT. It adds 70 tokens to every session and 971 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.