ruby
/ruby
Pomaga pisać Ruby i pracować w projektach Rails: idiomatyczny projekt obiektów, service objects, wydajność zapytań ActiveRecord, struktura RSpec i styl zgodny z RuboCop.
- Autor
- nimadorostkar ↗
- Repozytorium
- Claude-Skills-collection ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 24.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 24.10.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Pomaga pisać Ruby i pracować w projektach Rails: idiomatyczny projekt obiektów, service objects, wydajność zapytań ActiveRecord, struktura RSpec i styl zgodny z RuboCop.
Wyzwalacze z opisu
Oryginalny opis (EN)
Use when writing Ruby or working in Rails codebases. Covers idiomatic object design, service objects, ActiveRecord query performance, RSpec structure, and RuboCop-clean style. Trigger on "this rails controller is too fat", "activerecord is doing n+1 queries", "clean up this rspec suite", "rubocop keeps complaining". Do not use for language-agnostic job queue design — see the background-jobs skill.
Jak działa
- Purpose
- When to Use
- Capabilities
- Inputs
- Outputs
- Workflow
- Best Practices
- Examples
- Notes
Podgląd SKILL.md
---
name: ruby
description: Use when writing Ruby or working in Rails codebases. Covers idiomatic object design, service objects, ActiveRecord query performance, RSpec structure, and RuboCop-clean style. Trigger on "this rails controller is too fat", "activerecord is doing n+1 queries", "clean up this rspec suite", "rubocop keeps complaining". Do not use for language-agnostic job queue design — see the background-jobs skill.
metadata:
category: languages
version: 1.0.0
tags: [ruby, rails, activerecord, rspec, rubocop]
---
# Ruby
## Purpose
Write Ruby that stays readable as it grows: small objects with clear responsibilities, controllers that stay thin, and ActiveRecord queries that do not quietly issue a query per row.
## When to Use
- Writing or reviewing Ruby and Rails code.
- Refactoring fat models or fat controllers.
- Diagnosing slow endpoints caused by ActiveRecord.
- Structuring an RSpec suite.
- Designing background jobs and their retry semantics.
## Capabilities
- Object design: service objects, form objects, query objects, value objects.
- ActiveRecord: eager loading, scopes, batching, index-aware querying.
- Background processing with Sidekiq or Active Job, including idempotency.
- RSpec structure: request specs, model specs, factories, shared examples.
- RuboCop and Sorbet/RBS typing where valuable.
## Inputs
- Application source, Gemfile, Rails version.
- Slow-query or profiling data when performance is the concern.
## Outputs
- Controllers that authenticate, authorize, delegate, and render — nothing else.
- Named scopes and eager-loaded queries with no N+1.
- Specs that describe behavior rather than restate implementation.
## Workflow
1. **Locate the responsibility** — If a method touches HTTP, business rules, and persistence, split it before changing it.
2. **Extract a service object** — One public `call`, explicit dependencies, no global state.
3. **Fix the queries** — Add `includes`, convert loops into set operations, batch with `find_each`.
4. **Make jobs idempotent** — Retries are guaranteed; double-execution must be harmless.
5. **Gate** — RSpec, RuboCop, and Bullet (or equivalent) to fail the build on N+1.
## Best Practices
- Controllers do not contain business logic. If a controller action exceeds ten lines, extract.
- Callbacks (`after_save`, `before_create`) create action at a distance. Prefer explicit service calls.
- Use `find_each` for anything that could exceed a few thousand rows; `all.each` loads the table into memory.
- Every background job should be safe to run twice. Key the side effect, not the invocation.
- `rescue => e` without re-raising swallows bugs. Rescue the specific class.
- Freeze constants and prefer immutable value objects for domain concepts.
## Examples
**Service object with explicit failure:**
```ruby
# frozen_string_literal: true
class RefundOrder
Result = Struct.new(:success?, :refund, :error, keyword_init: true)
def initialize(gateway: PaymentGateway.new)
@gateway = gateway
end
def call(order:, amount_cents:)
return failure("order not refundable") unless order.refundable?
return failure("amount exceeds order total") if amount_cents > order.total_cents
refund = @gateway.refund(order.charge_id, amount_cents)
order.update!(refunded_cents: order.refunded_cents + amount_cents)
Result.new(success?: true, refund: refund)
rescue PaymentGateway::Error => e
failure(e.message)
end
private
def failure(message) = Result.new(success?: false, error: message)
end
```
## Notes
- Bullet in the test environment, configured to raise, turns N+1 queries into failing tests.
- `frozen_string_literal: true` is worth adding to every file; string allocation is a real cost in hot paths.
- Sidekiq retries with exponential backoff by default. Set `sidekiq_options retry:` explicitly rather than relying on the default for anything that touches money.
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · nimadorostkar/Claude-Skills-collection | 100 | MIT |
| ericrisco/rsc-harness | 100 | MIT |
| sorah/config | 100 | MIT |
| appwrite/claude-plugin | 100 | BSD-3-Clause |
| G1Joshi/Agent-Skills | 100 | MIT |
| el-feo/ai-context | 100 | MIT |
| sorah/config | 90 | MIT |
| dkbnull/hello-skill | 86 | MIT |
Migawka bazy z 13.11.2026 · wersja paczki 7d12124152a8 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 90ruby-rails
Pomaga budować aplikacje Ruby on Rails: kontrolery, ActiveRecord, obiekty serwisowe, tryb API, zadania w tle i testy RSpec. - 100programming-ruby
Podpowiada praktyki Ruby i Rails: obiekty, serwisy, zapis w ActiveRecord, transakcje oraz granice Active Job. - 100ruby-rails
Opisuje konwencje budowy aplikacji w Ruby on Rails: generatory, modele ActiveRecord i migracje, Hotwire, Turbo i Stimulus, zadania w tle, cache oraz testy w RSpec i Minitest. - 100rails-dev
Podpowiada wzorce wydajności i utrzymywalności w Ruby on Rails dla kontrolerów, zapytań ActiveRecord, cache, widoków, API, bezpieczeństwa i zadań w tle. - 100rails-idioms
Stosuje wzorce Ruby on Rails: scope'y ActiveRecord, zapobieganie N+1, walidacje, routing RESTful oraz testy w RSpec i Minitest, przy budowie i audycie aplikacji. - 100rails-patterns
Opisuje wzorce Rails 7.1+ i 8.x: układ katalogów, cienkie kontrolery z service objects, form i query objects, ActiveRecord, zadania w tle, ViewComponent, Hotwire i stos Solid.