Rails Jobs
Apply best practices for Rails background jobs using simple orchestration, idempotency...
Install
npx skills add marckohlbrugge/37signals-skills --skill rails-jobs -g -a claude-code -y- Repository
- marckohlbrugge/37signals-skills730
- Category
- Testing
- Updated
- 5mo ago
- License
- See repository
- Context cost
- Lightabout 1,126 tokens
- Runs scripts
- No, instructions only
What it does
Apply best practices for Rails background jobs using simple orchestration, idempotency, and safe retries. Use when creating, refactoring, or debugging Active Job and queue-backed workflows.
Rails Jobs
Use for background job design and review. Patterns from Campfire (Resque, 4 thin jobs) and Fizzy (Solid Queue, multi-queue).
Defaults
- Keep jobs shallow; the job body is one line calling a model method:
def perform(card) = card.notify_recipients. - Make jobs idempotent and safe to retry (e.g. rescue
RecordNotUniquein the domain op). - Fail loudly on real errors; avoid silent rescue patterns.
- Set
ActiveJob::Base.enqueue_after_transaction_commit = truein app defaults, fixes job-before-data races at the root. - Prefer Solid Queue (database-backed) over Redis-backed queues for new apps; co-locate with Puma (
SOLID_QUEUE_IN_PUMA) in small deployments.
Naming Convention
_laterenqueues, plain name does the work,_nowwhen you need an explicit synchronous twin:
def notify_recipients # the work, public API the job calls
def notify_recipients_later # enqueues NotifyRecipientsJob (often private, called from callbacks)
- Capture enqueue-time context as keyword args (
Mention::CreateJob.perform_later(self, mentioner: Current.user)), don't rely onCurrentat perform time. - In multi-tenant apps, serialize tenant context into every job: prepend an ApplicationJob extension that captures
Current.accountat enqueue (as a GlobalID) and wrapsperform_nowinCurrent.with_account.


