Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

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.

Licencja
MIT
Ostatnia zmiana repozytorium
24.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 24.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

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

this rails controller is too fatactiverecord is doing n+1 queriesclean up this rspec suiterubocop keeps complaining
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

  1. Purpose
  2. When to Use
  3. Capabilities
  4. Inputs
  5. Outputs
  6. Workflow
  7. Best Practices
  8. Examples
  9. Notes
Sekcje z nagłówków SKILL.md, w oryginale · 88 linii, 466 słów
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

RepozytoriumWynikLicencja
Ta strona · nimadorostkar/Claude-Skills-collection100MIT
ericrisco/rsc-harness100MIT
sorah/config100MIT
appwrite/claude-plugin100BSD-3-Clause
G1Joshi/Agent-Skills100MIT
el-feo/ai-context100MIT
sorah/config90MIT
dkbnull/hello-skill86MIT

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.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.