Phoenix Multi Column Setup
Use this skill when the user wants to create a new Phoenix LiveView app, or retrofit an existing one, with:
- narrow sidebar + vertical menu multi-column layout
InitLive+PreserveScroll- group-based
live_sessionrouting - auth-aware or no-auth layout mode
- a local
mix multi_column.generatecommand driven by a navigation DSL
Default behavior
- Treat
mix compileandmix precommitas part of the skill. Do not ask the user whether to run them. - Default to the human DSL spec format.
- Always show the generator dry-run plan before writing generated files, unless the user explicitly asks to skip the preview.
- Keep the generator honest: managed blocks plus fail-on-conflict, not best-effort router surgery.
Inputs to collect
Before changing files, determine:
- app name
- whether this is a fresh app in an empty folder or an existing app
- auth mode:
with_authorwithout_auth - navigation DSL
If the user does not provide a DSL, use the default fallback spec from references/multi-column-layout.md.
Fresh app workflow
When the user starts from an empty folder:
- Follow
references/setup-phx-project.md. - Create the Phoenix app.
- Run
mix setup. - Run
mix assets.build. - If auth was requested and auth is not already present, run
mix phx.gen.auth Accounts User users, thenmix ecto.migrate. - Remove DaisyUI only if it is present. Follow
references/remove-daisyui.md. - Install shared foundation assets:
assets/components/core_components.exassets/components/base_components.exassets/components/layouts/app.html.heexassets/components/layouts/home.html.heexassets/components/layouts/root.html.heexassets/controllers/page_controller.exassets/controllers/page_html/home.html.heexassets/controllers/error_html.exassets/controllers/error_html/404.html.heexassets/controllers/error_html/500.html.heexassets/test/page_controller_test.exsassets/live/init_live.exassets/js/hooks/preserve-scroll.js- If auth mode is
with_auth, also install auth LiveView style overrides:assets/live/user_live/login.exassets/live/user_live/registration.exassets/live/user_live/confirmation.exassets/live/user_live/settings.ex
- Install the local generator pipeline into the target app:
- copy
assets/generator/lib/mix/tasks/multi_column.generate.extolib/mix/tasks/multi_column.generate.ex - copy rendered
assets/generator/lib/app/multi_column/*.extolib/<app>/multi_column/*.ex - copy
assets/generator/lib/app/multi_column/README.mdtolib/<app>/multi_column/README.md - copy
assets/generator/priv/multi_column/README.mdtopriv/multi_column/README.md - copy rendered
assets/generator/priv/multi_column/templates/**topriv/multi_column/templates/**
- copy
- Render every copied
.ex,.exs,.heex, or.eexasset that contains placeholders:- replace
{{app_module}}with the target app module, for exampleOpsHub - replace
{{web_module}}with the target web module, for exampleOpsHubWeb - replace
{{otp_app}}with the target OTP app atom name, for exampleops_hub
- replace
- Ensure
lib/<app>_web.eximportsBaseComponents. - Run the generator dry-run:
mix multi_column.generate --spec priv/navigation.dsl --auth <mode> --dry-run
- Show the plan.
- If the task is to build the app, run:
mix multi_column.generate --spec priv/navigation.dsl --auth <mode> --apply
- Run
mix compile. - Run
mix precommit.
Existing app workflow
When the target app already exists:
- Inspect the app first:
router.exassets/js/app.jslib/<app>_web.ex- auth presence (
user_auth.ex, auth routes,mount_current_scope)
- Install the shared foundation assets only if missing or stale.
- If auth mode is
with_auth, also install or refreshassets/live/user_live/*.exoverrides so auth pages use the shared auth layout pattern.
- If auth mode is
- Install the local generator pipeline if missing.
- Run generator dry-run.
- Review the plan and fail on conflicts instead of hand-waving them away.
- Apply only after the plan is acceptable.
- Run
mix compile. - Run
mix precommit.
Generator contract
The installed local command is:
mix multi_column.generate --spec priv/navigation.dsl --auth with_auth --dry-run
mix multi_column.generate --spec priv/navigation.dsl --auth with_auth --apply
The generator is responsible for:
- parsing and validating the DSL
- deriving app and web modules from the target app
- generating sidebar, group menus, group layouts, and placeholder LiveViews
- ensuring generated sidebar includes a
Homeitem pointing to/(layout:home) - keeping initial generated page content intentionally minimal so placeholder pages do not invent detailed product copy or fake data
- patching
router.exwith managedlive_sessionblocks - patching
assets/js/app.jsto registerPreserveScrollonce - patching
lib/<app>_web.exto importBaseComponentsonce
The generator is not responsible for:
- creating the Phoenix app itself
- adding auth from scratch
- copying the shared foundation assets into the project for the first time
Those bootstrap steps stay in the skill workflow. The generator owns the fragile cross-file generation and patching after bootstrap.
Router policy
Generated routes must go inside top-level live_session blocks that each wrap:
scope "/", AppWebpipe_through :browser
Reason:
- these are browser LiveViews
InitLiveneeds to mount for@current_path- in
with_authmode, layouts need@current_scope
For with_auth, mount:
AppWeb.InitLive{AppWeb.UserAuth, :mount_current_scope}
Do not put generated sections under :require_authenticated_user unless the user explicitly asks for protected-only navigation. with_auth means auth-aware UI and current_scope, not mandatory login.
DSL notes
Use the human DSL from references/multi-column-layout.md.
Supported in this launch version:
[Group]## SECTIONLabelLabel -> /pathLabel -> /path | /aliasLabel { ... }
Current limitation:
- expandable parents with their own route (
Label -> /path {) are not supported in this launch version; fail clearly if encountered
Prompt shape
Good prompts look like:
Create a new Phoenix LiveView app named ops_hub in this empty folder with a multi-column layout and authentication.
Use the following navigation schema:
[Workspace]
Overview -> /workspace/overview
Activity -> /workspace/activity
[Management]
## OPERATIONS
Resources -> /management/resources
Settings -> /management/settings
Guides {
Getting Started -> /management/guides/getting-started
Best Practices -> /management/guides/best-practices
}
or:
Create a new Phoenix LiveView app named docs_portal in this empty folder with a multi-column layout and no authentication.
Use the following navigation schema:
[Workspace]
Overview -> /workspace/overview
Updates -> /workspace/updates
[Guides]
Getting Started -> /guides/getting-started
Reference -> /guides/reference
Resources
references/setup-phx-project.md: fresh-app bootstrap orderreferences/remove-daisyui.md: DaisyUI cleanupreferences/multi-column-layout.md: DSL and generated file contractassets/: shared components, layouts, JS hook, and generator payload