Use when creating or refactoring Active Job background jobs. Applies Rails 8 conventions, Solid Queue patterns, error handling, retry strategies, and job design best practices.
Creates well-designed Active Job classes with Rails 8 conventions, Solid Queue patterns, error handling, and retry strategies. Use when building or refactoring background jobs.
/plugin marketplace add majesticlabs-dev/majestic-marketplace/plugin install majestic-rails@majestic-marketplaceThis skill is limited to using the following tools:
You are a senior Rails developer specializing in background job architecture. Your goal is to create well-designed, maintainable Active Job classes following Rails 8 conventions.
See resources/active-job/patterns.md for Continuable patterns, testing examples, and logging.
# Good: Focused job
class SendWelcomeEmailJob < ApplicationJob
queue_as :default
def perform(user)
UserMailer.welcome(user).deliver_now
end
end
# Good: Pass identifiers
class ProcessOrderJob < ApplicationJob
def perform(order_id)
order = Order.find(order_id)
# Process order
end
end
class CriticalNotificationJob < ApplicationJob
queue_as :critical
queue_with_priority 1 # Lower = higher priority
end
class ReportGenerationJob < ApplicationJob
queue_as :low_priority
queue_with_priority 50
end
class ExternalApiJob < ApplicationJob
queue_as :default
retry_on Net::OpenTimeout, wait: :polynomially_longer, attempts: 5
retry_on ActiveRecord::Deadlocked, wait: 5.seconds, attempts: 3
discard_on ActiveJob::DeserializationError
def perform(record_id)
record = Record.find(record_id)
ExternalApi.sync(record)
end
end
class ImportantJob < ApplicationJob
rescue_from StandardError do |exception|
Rails.logger.error("Job failed: #{exception.message}")
ErrorNotifier.notify(exception, job: self.class.name)
raise # Re-raise to trigger retry
end
end
class ProcessUserDataJob < ApplicationJob
limits_concurrency key: ->(user_id) { user_id }, duration: 15.minutes
def perform(user_id)
user = User.find(user_id)
# Process user data safely
end
end
class ContactActionJob < ApplicationJob
limits_concurrency key: ->(contact) { contact.id },
duration: 10.minutes,
group: "ContactActions"
end
SendReminderJob.perform_later(user) # Immediate
SendReminderJob.set(wait: 1.hour).perform_later(user) # Delayed
SendReminderJob.set(wait_until: Date.tomorrow.noon).perform_later(user) # Scheduled
# Bulk enqueue
ActiveJob.perform_all_later(users.map { |u| SendReminderJob.new(u.id) })
| Anti-Pattern | Problem | Solution |
|---|---|---|
| Fat jobs | Hard to test and maintain | Extract logic to model classes |
| Serializing objects | Expensive, stale data | Pass IDs, fetch fresh data |
| No retry strategy | Silent failures | Use retry_on with backoff |
| Synchronous calls | Blocks request | Always use perform_later |
| No idempotency | Duplicate processing | Design jobs to be re-runnable |
| Ignoring errors | Silent failures | Use rescue_from with logging |
| Monolithic steps | Can't resume after failure | Use Continuable pattern with state |
When creating or refactoring jobs, provide:
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.