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/slices/configure-slice/

name:
configure-slice
license:
MIT
description:
Creates and configures Hanami 2.x Slices by registering providers, setting up container dependencies, customizing auto-registration paths, and managing slice-level settings. Use when configuring slice setup, modular app structure, Hanami component registration, dependency injection, provider registration, container imports/exports, or autoloading for a Hanami 2.x Slice.
metadata:
{"ecosystem_sources":["hanami/hanami","dry-rb/dry-system"],"tags":["slices","configuration","settings","providers"],"version":"1.0.0"}

configure-slice

Use this skill when configuring Hanami 2.x Slices.

Core principle: Each Slice configures its own container, settings, and providers independently of the main app.


Quick Reference

ScenarioApproach
Configure a SliceEdit slices/<name>/config/slice.rb
Define slice-level settingsUse config.settings in the Slice class
Register slice providersUse register_provider in the Slice class
Configure auto-registrationSet config.auto_register_paths
Exclude paths from auto-registrationSet config.no_auto_register_paths
Access slice settingstarget[:settings] in providers or slice.settings
Override main app configDefine config in the Slice that takes precedence
Container importsimport from: :other_slice
Container exportsexport ["component.key"]

Core Rules

  1. Create the Slice configuration file:

    # slices/api/config/slice.rb
    # frozen_string_literal: true
    
    module MyApp
      module Slices
        module Api
          class Slice < Hanami::Slice
            # Slice-level configuration
          end
        end
      end
    end
  2. Define slice-level settings:

    class Slice < Hanami::Slice
      config.settings do
        setting :api_key, constructor: Types::String
        setting :rate_limit, default: 100, constructor: Types::Integer
      end
    end
  3. Register slice-specific providers:

    class Slice < Hanami::Slice
      register_provider(:api_client) do
        start do
          client = ApiClient.new(
            api_key: target[:settings].api_key,
            base_url: "https://api.example.com"
          )
          register("api.client", client)
        end
      end
    end
  4. Configure auto-registration paths:

    class Slice < Hanami::Slice
      config.auto_register_paths = ["app/actions", "app/views", "app/repos"]
      config.no_auto_register_paths = ["app/relations", "app/structs", "app/entities"]
    end
  5. Import components from another Slice:

    class Slice < Hanami::Slice
      import from: :main do
        # Import all exported components from the main slice
      end
    end
  6. Export components for other slices:

    class Slice < Hanami::Slice
      export ["repositories.users", "services.auth"]
    end
  7. Override main app configuration for slice-specific needs:

    class Slice < Hanami::Slice
      # Use a different database for this slice
      config.database_url = target[:settings].database_url
    end
  8. Keep configuration minimal. Only override defaults when necessary. Prefer convention over configuration.

  9. Verify configuration after changes. Run bundle exec hanami console and confirm components resolve correctly:

    # Verify settings are loaded
    MyApp::Slices::Api::Slice[:settings].api_key  # => expected value
    
    # Verify a registered provider component is available
    MyApp::Slices::Api::Slice["api.client"]  # => #<ApiClient ...>
    
    # Verify an imported component resolves
    MyApp::Slices::Api::Slice["repositories.users"]  # => #<Repositories::Users ...>

Common Mistakes

MistakeReality
"I'll duplicate main app configuration in every slice"Slices inherit main app configuration. Only override when the slice genuinely needs different behavior.
"I'll forget to export components other slices depend on"If Slice B imports from Slice A, Slice A must export those components. Verify with Slice["component.key"] in the console.
"I'll use ENV directly instead of slice settings"Use config.settings for typed, validated configuration. Access via target[:settings].
"I'll configure auto-registration to include ROM-managed directories"Never auto-register relations/, structs/, or entities/. ROM manages these.

Integration

Related SkillWhen to chain
create-sliceConfiguration follows slice creation. Understand slices before configuring.
register-providerSlice-specific providers are registered in slice configuration.
manage-settingsSlice-level settings are defined in the Slice class.
inject-dependenciesConfigured components are injected via Deps[].
create-new-slice (workflow)Full workflow includes configuration step.

skills

slices

configure-slice

README.md

tile.json