Curated library of AI agent skills for Ruby on Rails development. Covers code review, architecture, security, testing (RSpec), engines, service objects, DDD patterns, and workflow automation.
98
99%
Does it follow best practices?
Impact
98%
1.38xAverage score across 26 eval scenarios
Passed
No known issues
An e-commerce startup is scaling up its engineering team and wants to establish code quality standards before onboarding three new backend engineers. The tech lead has noticed that the order processing module has grown organically and suspects it has accumulated some structural problems that will slow the new hires down. She wants a written architecture review that can be shared with the team to inform a future refactoring sprint and establish what "healthy Rails code" looks like in this codebase.
The review should focus on the kinds of structural problems that cause bugs as the system grows — misplaced responsibilities, tight coupling, and logic that ends up in the wrong layer — rather than surface-level style preferences. The team wants concrete, ranked findings they can use to plan work, not a catalogue of every possible improvement.
Produce an architecture review of the code below. Save the review as architecture-review.md.
The following files are provided as inputs. Extract them before beginning.
=============== FILE: app/controllers/orders_controller.rb =============== class OrdersController < ApplicationController def create @order = Order.new(order_params) @order.user = current_user
ActiveRecord::Base.transaction do
@order.save!
@order.line_items.each do |item|
item.product.decrement!(:stock_quantity, item.quantity)
end
payment = PaymentGateway.charge(
amount: @order.total_cents,
token: params[:payment_token],
description: "Order ##{@order.id}"
)
@order.update!(payment_reference: payment.id, status: :paid)
OrderMailer.confirmation(@order).deliver_now
Segment.track(user_id: current_user.id, event: "order_placed", properties: { order_id: @order.id })
end
redirect_to @orderrescue PaymentGateway::ChargeError => e @order.update(status: :payment_failed) flash[:error] = e.message render :new end
private
def order_params params.require(:order).permit(:shipping_address, :billing_address, line_items_attributes: [:product_id, :quantity]) end end
=============== FILE: app/models/order.rb =============== class Order < ApplicationRecord belongs_to :user has_many :line_items, dependent: :destroy has_many :products, through: :line_items
accepts_nested_attributes_for :line_items
before_save :calculate_total after_create :reserve_inventory after_commit :sync_to_warehouse, on: [:create, :update]
scope :recent, -> { where("created_at > ?", 30.days.ago) } scope :for_reporting, -> { joins(:line_items, :products) .select("orders.*, SUM(line_items.quantity * products.unit_price) as computed_total, COUNT(line_items.id) as item_count") .group("orders.id") .having("SUM(line_items.quantity * products.unit_price) > 0") }
def calculate_total self.total_cents = line_items.sum { |i| i.quantity * i.product.unit_price_cents } end
def reserve_inventory line_items.each { |i| i.product.decrement!(:reserved_quantity, i.quantity) } end
def sync_to_warehouse WarehouseApi.push_order(self.as_json(include: :line_items)) end end
=============== FILE: app/models/concerns/auditable.rb =============== module Auditable extend ActiveSupport::Concern
included do after_create :log_creation after_update :log_changes after_destroy :log_deletion end
def log_creation AuditLog.create!(event: "created", record_type: self.class.name, record_id: id, payload: self.as_json) Slack.notify("#audit", "#{self.class.name} #{id} created") UserMailer.admin_alert("Record created: #{self.class.name} #{id}").deliver_later end
def log_changes AuditLog.create!(event: "updated", record_type: self.class.name, record_id: id, payload: self.previous_changes) Slack.notify("#audit", "#{self.class.name} #{id} updated") end
def log_deletion AuditLog.create!(event: "deleted", record_type: self.class.name, record_id: id, payload: {}) Slack.notify("#audit", "#{self.class.name} #{id} deleted") end end
api-rest-collection
create-prd
ddd-boundaries-review
ddd-rails-modeling
ddd-ubiquitous-language
docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
scenario-11
scenario-12
scenario-13
scenario-14
scenario-15
scenario-16
scenario-17
scenario-18
scenario-19
scenario-20
scenario-21
scenario-22
scenario-23
scenario-24
scenario-25
scenario-26
generate-tasks
mcp_server
rails-architecture-review
rails-background-jobs
rails-bug-triage
rails-code-conventions
rails-code-review
rails-engine-compatibility
rails-engine-docs
rails-engine-extraction
rails-engine-installers
rails-engine-release
rails-engine-reviewer
rails-engine-testing
rails-graphql-best-practices
rails-migration-safety
rails-review-response
rails-security-review
rails-skills-orchestrator
rails-stack-conventions
rails-tdd-slices
refactor-safely
rspec-best-practices
rspec-service-testing
ruby-service-objects
strategy-factory-null-calculator
ticket-planning
yard-documentation