CtrlK
BlogDocsLog inGet started
Tessl Logo

igmarin/hanakai-yaku

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

1.33x
Quality

94%

Does it follow best practices?

Impact

92%

1.33x

Average score across 35 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

SKILL.mdskills/cross-cutting/manage-settings/

name:
manage-settings
license:
MIT
description:
Use when managing Hanami 2.x application settings, app config, or environment variables (env vars). Covers defining typed settings with dry-configurable, setting defaults, validating enum values, reading .env files, and injecting settings into components via Hanami's container. Use when declaring typed environment variable declarations, accessing configuration in Actions or providers, or migrating from Rails config to Hanami 2.x settings.
metadata:
{"ecosystem_sources":["hanami/hanami","dry-rb/dry-system"],"tags":["configuration","settings","environment","dry-configurable"],"version":"1.0.0"}

manage-settings

Use this skill when managing Hanami 2.x application settings.

Core principle: Settings are typed, validated, and loaded from environment variables. They are the single source of truth for configuration.


Quick Reference

ScenarioApproach
Define a settingsetting :database_url, constructor: Types::String
Define with defaultsetting :port, default: 2300, constructor: Types::Integer
Define optional settingsetting :api_key, constructor: Types::String.optional
Enum validationconstructor: Types::String.enum("debug", "info", "warn")
Access in ActionHanami.app[:settings].database_url
Access in providertarget[:settings].database_url
Inject via Depsinclude Deps["settings"]
Required settingOmit default: — missing env var raises at boot

Workflow: Define → Configure → Access → Verify

1. Define settings in config/settings.rb

# config/settings.rb
# frozen_string_literal: true

module MyApp
  class Settings < Hanami::Settings
    setting :database_url, constructor: Types::String
    setting :port, default: 2300, constructor: Types::Integer
    setting :host, default: "localhost", constructor: Types::String
    setting :session_secret, constructor: Types::String
    setting :api_key, constructor: Types::String.optional
    setting :log_level, default: "info", constructor: Types::String.enum("debug", "info", "warn", "error")
  end
end

2. Set environment variables (UPPER_SNAKE_CASE)

SettingEnvironment Variable
database_urlDATABASE_URL
portPORT
session_secretSESSION_SECRET
api_keyAPI_KEY

Use .env files for local development (supported via the dotenv gem).

3. Access settings in components

# In an Action
Hanami.app[:settings].database_url

# In a provider
target[:settings].session_secret

# In a service object (injected)
include Deps["settings"]
settings.database_url

4. Verify settings load correctly

Boot the app with hanami server or bundle exec hanami console to confirm all required settings are present and correctly typed. Required settings (no default:) raise immediately at boot if the corresponding environment variable is missing — this is the intended failure mode.

# Quick console check
bundle exec hanami console
Hanami.app[:settings].inspect

Slice-level settings override or extend app settings:

# slices/api/config/slice.rb
class Slice < Hanami::Slice
  config.settings do
    setting :api_key, constructor: Types::String
  end
end

Integration

Related SkillWhen to chain
register-providerProviders read settings via target[:settings]. Define settings before writing providers.
inject-dependenciesSettings can be injected via Deps["settings"].
configure-sliceSlices can define their own settings.
create-appGenerated apps include config/settings.rb. Define settings after scaffolding.

skills

cross-cutting

manage-settings

README.md

tile.json