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 writing or running Sequel database migrations in Hanami 2.x.
Core principle: Sequel migration DSL is provided by jeremyevans/sequel — not ActiveRecord. Never use ActiveRecord syntax here.
| Scenario | Approach |
|---|---|
| Create a new table | create_table(:table_name) { ... } inside Sequel.migration { change { ... } } |
| Add a column to existing table | alter_table(:table_name) { add_column :col, :type } |
| Remove a column | alter_table(:table_name) { drop_column :col } |
| Add an index | alter_table(:table_name) { add_index :col } |
| Rename a column | alter_table(:table_name) { rename_column :old, :new } |
| Reversible migration | Use change { } block — Sequel infers the inverse automatically |
| Irreversible migration | Use up { } / down { } blocks explicitly |
| Generate migration file | hanami generate migration create_users |
| Run pending migrations | hanami db migrate |
| Roll back last migration | hanami db rollback |
Generate the migration file using the Hanami CLI:
hanami generate migration <migration_name>This creates db/migrate/<timestamp>_<migration_name>.rb.
Open the generated file and write the migration body inside the
Sequel.migration block. Prefer change { } for reversible operations.
Define the schema change using the Sequel DSL. Always specify column types explicitly — do not rely on inference.
Run the migration:
hanami db migrateVerify the schema change in the database or via hanami console:
Hanami.app["db.rom"].relations[:users].schema.to_hUpdate the ROM Relation (define-relation) to reflect any new
or removed columns. The Relation schema must stay in sync with the database.
Update Entities and Structs (define-entity) if
attribute lists change.
Run the test suite to confirm nothing is broken.
| Mistake / Red Flag | Reality | Severity |
|---|---|---|
ActiveRecord syntax in migration files (e.g. add_column :users, :email, :string) | Sequel uses alter_table(:users) { add_column :email, :text }. Column types are Sequel generic types (:text, :integer), not Rails types (:string, :bigint). | 🔴 Blocker |
Missing null: false on required columns | Sequel does not add NOT NULL by default. Always declare null: false for required columns — omitting it allows NULL values silently. | 🔴 Blocker |
Using change { } for drop_column or rename_column | These operations are not automatically reversible by Sequel. Use explicit up { } / down { } blocks. | 🔴 Blocker |
| Schema changes without corresponding ROM Relation updates | After adding or removing columns, the ROM Relation schema must be updated. If using schema :table, infer: true, the schema is re-inferred at boot, but explicit attribute declarations will be stale. | 🟠 High |
Running migrations without checking HANAMI_ENV | hanami db migrate uses DATABASE_URL from the current environment. Always confirm HANAMI_ENV is set correctly before running in staging or production. | 🟠 High |
Using :timestamp without timezone | Use :timestamptz (PostgreSQL) rather than :timestamp to avoid timezone-naive storage bugs. | 🟡 Medium |
| Migration files with duplicate timestamps | Sequel applies migrations in timestamp order; duplicates cause undefined behaviour. | 🟡 Medium |
| Related Skill | When to chain |
|---|---|
| define-relation | After every migration that adds, removes, or renames columns — update the Relation schema |
| define-entity | When column changes affect the Entity attribute list |
| create-repository | When new columns require new query methods or write operations |
| add-table-column (workflow) | Use the full workflow when adding a column end-to-end: migration → Relation → Entity → Repository → tests |
| hanami-manage-database | For hanami db create, hanami db rollback, and hanami db seed CLI reference |
# db/migrate/20240601120000_create_users.rb
Sequel.migration do
change do
# create_table takes a symbol matching the intended table name
create_table(:users) do
# primary_key generates an auto-incrementing integer PK named :id
primary_key :id
# column :name, :type — always specify type explicitly
column :email, :text, null: false
column :first_name, :text, null: false
column :last_name, :text, null: false
column :role, :text, null: false, default: "member"
column :created_at, :timestamptz, null: false
column :updated_at, :timestamptz, null: false
# unique constraint on a single column
unique [:email]
end
end
end# db/migrate/20240602090000_add_bio_to_users.rb
Sequel.migration do
change do
# alter_table wraps all modifications to an existing table
alter_table(:users) do
# add_column :name, :type, options
add_column :bio, :text, null: true
end
end
end# db/migrate/20240603100000_remove_legacy_token_from_users.rb
Sequel.migration do
up do
alter_table(:users) do
drop_column :legacy_token
end
end
down do
alter_table(:users) do
add_column :legacy_token, :text, null: 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