Curated library of atomic AI agent skills for Hanami, dry-rb, and ROM Ruby development. Covers actions, slices, repositories, relations, changesets, providers, DI, operations, TDD, CLI, views, routing, and validation. Shared Ruby process skills have moved to ruby-core-skills. Uses Markdown + Front-matter architecture.
92
94%
Does it follow best practices?
Impact
92%
1.33xAverage score across 35 eval scenarios
Passed
No known issues
This document details advanced database patterns using ROM Repositories: transactions and custom entity mappings.
Use database transactions to wrap multi-step writes. ROM automatically rolls back changes if a StandardError exception is raised inside the block.
# Example of transaction wrapper returning Success/Failure monads
def transfer_funds(from_id, to_id, amount)
transaction do
from_account = accounts.by_id(from_id).one
to_account = accounts.by_id(to_id).one
# Guard against missing records before mutating state
return Failure(:account_not_found) if from_account.nil? || to_account.nil?
return Failure(:insufficient_funds) if from_account.balance < amount
accounts.update(from_id, balance: from_account.balance - amount)
accounts.update(to_id, balance: to_account.balance + amount)
Success(true)
end
rescue => e
Failure(e.message)
endRepositories retrieve data from Relations and map it to Entities (ROM Structs). By default, ROM returns generic ROM::Struct instances. To map to your own typed domain models:
struct_namespace to point to your Entities module.auto_struct true.# app/repos/user_repo.rb
# frozen_string_literal: true
module MyApp
module Repos
class UserRepo < Hanami::DB::Repo[:users]
# Map database records to MyApp::Entities namespace
struct_namespace MyApp::Entities
auto_struct true
end
end
enddocs
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
scenario-27
scenario-28
scenario-29
scenario-30
scenario-31
scenario-32
scenario-33
scenario-34
scenario-35
skills
actions
build-json-api
create-action
handle-errors
validate-params
context
load-context
db
create-changeset
create-repository
define-relation
write-migration
dry-monads
handle-result-pattern
dry-rb
create-operation
create-validation-contract
providers
configure-providers
implement-di
review-security
routing
define-routes
slices
configure-slice
create-slice
extract-slice
review-slice-boundaries
test-slice