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 creating Hanami 2.x Views.
Core principle: Views are objects, not template files. They encapsulate presentation logic and expose data to templates.
| Scenario | Approach |
|---|---|
| Create a View | Class inherits from Hanami::View in app/views/ |
| Define exposures | Use expose :name to declare what the template receives |
| Expose with transformation | expose :user { |user| UserPresenter.new(user) } |
| Render a template | View automatically looks up templates/<path>.html.erb |
| Pass context | expose :current_user, as: :current_user |
| Define a layout | layout "application" in the View class |
| Set template format | format :html (default) or format :json |
| Access exposures in template | <%= user.name %> (locals passed to ERB) |
Create the View file in the app or slice:
# app/views/users/show.rb
# frozen_string_literal: true
module MyApp
module Views
module Users
class Show < MyApp::View
expose :user
end
end
end
endCreate the template alongside the View:
<!-- app/templates/users/show.html.erb -->
<h1><%= user.name %></h1>
<p><%= user.email %></p>Expose data from the Action:
def handle(request, response)
user = user_repo.by_id(request.params[:id]).one
response.render(view, user: user)
endTransform exposures within the View:
class Show < MyApp::View
expose :user do |user|
{
name: "#{user.first_name} #{user.last_name}",
email: user.email,
member_since: user.created_at.strftime("%B %Y")
}
end
endUse Parts for decorator-style logic (decorate-with-parts):
class Show < MyApp::View
expose :user, as: :user_part
endDefine a layout:
class Show < MyApp::View
layout "application"
end<!-- app/templates/layouts/application.html.erb -->
<!DOCTYPE html>
<html>
<head><title>MyApp</title></head>
<body>
<%= yield %>
</body>
</html>Keep Views focused on presentation. No database queries, no business logic. Views receive prepared data from Actions.
Use explicit exposures. Do not pass raw params or unparsed data to Views.
| Mistake / Red Flag | Reality |
|---|---|
| Database queries in View classes or templates | Views are for presentation only. All data fetching happens in Actions via Repositories. |
@instance_variables in templates | Templates receive locals from expose. No instance variables. |
| Skipping the View class and rendering templates directly | Always define a View class. It encapsulates presentation logic and makes templates testable. |
| Template path mismatched from View namespace | Templates follow the View namespace: app/views/users/show.rb → app/templates/users/show.html.erb. |
| Related Skill | When to chain |
|---|---|
| create-action | Actions render Views and pass exposures. Master Action structure first. |
| decorate-with-parts | Use Parts for complex decorator-style logic in Views. |
| create-repository | Actions fetch data from Repositories before passing to Views. |
| write-request-spec (testing) | Test the full stack: request → Action → View → template. |
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
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