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
Use this skill when building JSON API endpoints in Hanami 2.x Actions.
Core principle: JSON APIs must produce predictable, parseable output. Implement round-trip parse → serialize → parse verification for all serializers.
Set the response format to JSON:
def handle(request, response)
response.format = :json
# ...
endUse dedicated serializers to encode response bodies: Isolate serialization representation from your Actions. Instantiating a dedicated serializer class keeps action handlers clean. For implementation details and conventions, see SERIALIZERS.md.
def handle(request, response)
response.format = :json
user = user_repo.by_id(request.params[:id]).one
response.body = MyApp::Serializers::UserSerializer.new(user).to_json
endVerify round-trip serialization: Always assert that a serialized object can be parsed back into equivalent data to prevent schema regressions. For the step-by-step troubleshooting workflow, see the SERIALIZERS.md Verification Guide.
# In tests:
serialized = UserSerializer.new(user).to_json
parsed = JSON.parse(serialized, symbolize_names: true)
assert_equal user.email, parsed[:email]Handle request body parsing via request.params:
JSON request payloads are automatically parsed by the framework and accessible directly under params.
def handle(request, response)
response.format = :json
attrs = request.params[:user]
result = user_repo.create(attrs)
response.status = 201
response.body = UserSerializer.new(result).to_json
endReturn consistent error shapes: Ensure all error responses conform to a unified structure:
halt 422, { error: { message: "Validation failed", details: [...] } }.to_jsonInclude pagination metadata for collections:
Expose pagination fields inside a meta block sibling to data:
{
data: users.map { |u| UserSerializer.new(u).to_h },
meta: {
page: request.params[:page] || 1,
per_page: request.params[:per_page] || 20,
total: user_repo.count
}
}.to_jsonRescue parse errors and return bad request (400) status:
rescue JSON::ParserError
halt 400, { error: "Invalid JSON body" }.to_json
endresponse.format = :json is set on every JSON action.iso8601{ error: { message: ..., details: ... } })JSON::ParserError rescued with 400 responsedocs
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