Use when creating Hanami Slices — generate a slice with `hanami generate slice [name]`, register it in `config/app.rb` via `slice :name, at: "/path"`, define slice routes in `slices/[name]/config/routes.rb`, configure inter-slice dependencies with `import`/`export` (avoid circular deps: if A imports from B, B must not import from A), and keep slices self-contained for distinct bounded contexts like API, admin, or billing, the main web application. Covers slice directory generation, route configuration, cross-slice dependency management, and slice-level container access.
Installation
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Use when creating Hanami Slices — generate a slice with `hanami generate slice [name]`, register it in `config/app.rb` via `slice :name, at: "/path"`, define slice routes in `slices/[name]/config/routes.rb`, configure inter-slice dependencies with `import`/`export` (avoid circular deps: if A imports from B, B must not import from A), and keep slices self-contained for distinct bounded contexts like API, admin, or billing, the main web application. Covers slice directory generation, route configuration, cross-slice dependency management, and slice-level container access.
Define Slice routes in slices/<name>/config/routes.rb:
# slices/api/config/routes.rbmoduleMyAppmoduleSlicesmoduleApiclassRoutes < Hanami::Routes
get "/users", to:"users.index"
get "/users/:id", to:"users.show"endendendend
Routes map to action files under slices/api/actions/ (e.g. /api/users → slices/api/actions/users/index.rb).
Verify: Run hanami routes and confirm /api/users and /api/users/:id are listed.
Import dependencies from another Slice:
# config/app.rbmoduleMyAppclassApp < Hanami::App
slice :api, at:"/api"do
import from::maindo# Import specific components from the main sliceendendendend
Verify: Boot the app (hanami console) and resolve the imported component: MyApp::Slices::Api::Container["main.repositories.users"].
Verify: In hanami console, confirm the consuming slice can resolve the exported key.
Keep Slices self-contained and minimize cross-slice dependencies. Use import/export as the formal contract between slices.
Use Slices for bounded contexts — each slice encapsulates a distinct domain concern such as a public API, admin dashboard, billing, or main web application.
Common Mistakes
Circular slice dependencies: Slices should be acyclic. If Slice A imports from Slice B, Slice B must not import from Slice A.
Direct container access across slices: Use import/export for cross-slice communication. Never access Hanami.app["slices.other.component"] directly.
Misaligned namespaces: Slice components live under MyApp::Slices::Api::. File paths and module namespaces must align.
Integration
Related Skill
When to chain
define-routes
Slices define their own routes. Master routes before creating slices.
inject-dependencies
Cross-slice dependencies use import/export and are injected via Deps.
configure-slice
Configure slice-level settings and providers after creating the slice.
create-new-slice (workflow)
Full workflow for creating and configuring a new slice.