Web application
Phoenix + its generated HTTP/asset defaults
Coherent routing, contexts and generated application structure.
Limits: Phoenix is unnecessary for a CLI or a service without HTTP; preserve existing architecture.
Connected products, live updates and background work in one application.
Phoenix · LiveView · Ecto · PostgreSQL
These recipes and dependency combinations need checking in your actual project before you rely on them.
Paste the guide address into your agent chat, together with what you want to build.
Use cases: Connected browser products and portals; Real-time collaboration interfaces; JSON APIs for native clients; Durable application background work.
Generator documentation reviewed: 2026-10-18. Evidence: documentation-reviewed; commands not executed.
Use when: A new connected browser application uses this profile. Generate the skeleton before adding application code.
Working directory: chosen local workspace
Inspect the active Elixir and Erlang/OTP versions
elixir --versionWorking directory: chosen local workspace
Inspect the active Mix runtime
mix --versionWorking directory: chosen local workspace
Install Hex only when missing; review the installation prompt
mix local.hex --if-missingWorking directory: chosen local workspace; only if installer is missing or a deliberate update is needed
Install the Phoenix generator; select/record a compatible version according to project policy
mix archive.install hex phx_newWorking directory: chosen local workspace
Record the installed Phoenix generator version
mix phx.new --versionWorking directory: chosen local workspace
Confirm installed options and defaults
mix help phx.newWorking directory: parent directory of the new my_app directory
Generate the Phoenix application, including LiveView and asset defaults
mix phx.new my_app --database postgresWorking directory: my_app project root, after inspecting the generated alias and configuring local database access
Run the generated setup alias
mix setupUse when: The deliverable is an HTTP API with a separate client and does not need generated browser UI.
Working directory: parent directory of the new my_app directory
Generate an API skeleton without HTML views or asset build tools
mix phx.new my_app --database postgres --no-html --no-assetsUse when: The project needs Elixir without a Phoenix web application. Choose the variant from process-lifecycle requirements.
Working directory: chosen local workspace
Inspect installed Mix generator options
mix help newWorking directory: parent directory of the new my_library directory
Generate a plain Elixir project without an application callback/supervisor
mix new my_libraryWorking directory: parent directory of the new my_service directory
Alternative: generate an OTP application callback and supervision tree
mix new my_service --supUse when: Application-owned browser accounts are required, after Phoenix setup.
Working directory: my_app project root (directory containing mix.exs)
Phoenix authentication
mix phx.gen.auth Accounts User users --liveUse when: A new browser CRUD resource should follow Phoenix conventions.
Working directory: my_app project root (directory containing mix.exs)
LiveView resource
mix phx.gen.live Catalog Product products name:stringUse when: The resource uses conventional server-rendered controllers/templates rather than LiveView.
Working directory: my_app project root (directory containing mix.exs)
Controller HTML resource
mix phx.gen.html Catalog Product products name:stringUse when: The resource is exposed as JSON.
Working directory: my_app project root (directory containing mix.exs)
JSON API resource
mix phx.gen.json Catalog Product products name:stringUse when: The application needs a new domain resource/API boundary without generated HTTP or LiveView files.
Working directory: my_app project root (directory containing mix.exs)
Domain context without web UI
mix phx.gen.context Catalog Product products name:stringUse when: A schema and migration are needed within a deliberately maintained domain boundary.
Working directory: my_app project root (directory containing mix.exs)
Ecto schema without context scaffolding
mix phx.gen.schema Catalog.Product products name:stringUse when: An existing persisted resource requires a schema change, without duplicating its resource generator.
Working directory: my_app project root (directory containing mix.exs)
Ecto migration
mix ecto.gen.migration add_product_statusUse when: Release-based deployment has been selected.
Working directory: my_app project root (directory containing mix.exs)
Phoenix release helpers
mix phx.gen.releaseChoose the tools your application needs. The brief includes your selections, their purpose and their limits; the complete guide keeps all recommendations and sources.
Phoenix + its generated HTTP/asset defaults
Coherent routing, contexts and generated application structure.
Limits: Phoenix is unnecessary for a CLI or a service without HTTP; preserve existing architecture.
usage_rules for selected dependency guidance
Discover dependency documentation and synchronize selected upstream usage rules for agents
Limits: Development-only tool; inspect installed-version options and review generated content. Preserve Phoenix-generated guidance by default. An explicit README-only repository may configure file: "docs/dependency-rules.md" in mix.exs and link it from README; this destination is an optional project convention, not an upstream default.
LiveView + HEEx components
Shared server-side business operations and interactive screens suit connected forms, portals and collaboration.
Limits: Offline-first state, high-frequency local interactions and rich canvas editors can justify a dedicated client. LiveView does not remove HTML/CSS or all JavaScript.
Ecto + PostgreSQL
Explicit queries, changesets and database transactions fit shared application data.
Limits: Changeset validation is not a replacement for database constraints or authorization; database operations and migrations need operational ownership. Current Ecto documentation deprecates Repo.transaction/2 in favor of Repo.transact/2. Follow the installed-version API and callback/result semantics; do not mechanically rename an existing transaction without tests.
phx.gen.auth + scoped context authorization
Generated first-party authentication keeps application-owned code; contexts authorize operations.
Limits: Check permission both on mount/navigation and each operation. Test revoked access and reconnect behavior; magic-link delivery needs a configured mail provider.
Oban with the existing Ecto/PostgreSQL database
Persist jobs and enqueue alongside domain changes in one transaction.
Limits: Task is only for explicitly disposable work and does not satisfy crash-durable delivery. Oban engine support and guarantees must be checked against the selected version; Redis is not a shipped Oban persistence engine. Oban Pro is an optional licensed extension, not a replacement for persistence.
ExUnit + Ecto SQL Sandbox + LiveViewTest
Test contexts, data invariants, denied access and server-side UI behavior.
Limits: LiveViewTest does not establish browser JavaScript, accessibility or visual correctness. Inline/manual job tests are not a production recovery simulation.
PhoenixTest.Playwright for critical browser flows
Exercise hooks, navigation, reconnects and actual browser behavior omitted by server-side tests.
Limits: Adds Node/package-manager/browser binaries and sandbox configuration; verify supported wrapper features. It is an editorial extension, not a Phoenix generator default.
Mix formatter and compiler warnings; Credo when selected
Fast local feedback plus consistency checks; select checks appropriate to project size.
Limits: Static analysis does not prove domain correctness. Dialyxir adds analysis/PLT maintenance and is not a mandatory starter dependency.
Hex audit + Sobelow, alongside permission tests
Hex reports retired packages and known advisories; Sobelow finds common risky code patterns.
Limits: Use the installed Hex version’s behavior. Scan findings need review; configure a non-zero Sobelow exit threshold and do not blanket-suppress findings. Neither proves the application secure.
Mix release + runtime configuration
Package application and runtime with explicit migration/server entry points.
Limits: Build for the target OS/architecture and native libraries. Host choice, secrets, migrations, TLS, backups, restore and rollback remain separate responsibilities.
Platform-native clients consuming Phoenix APIs
Preserve native UI/platform ownership while sharing server-side domain operations.
Limits: Do not advertise Elixir as a complete native mobile default: LiveView Native’s inspected README uses release-candidate dependencies and platform-specific clients. Validate target support, offline behavior, accessibility and signing independently.
README navigation + generated Phoenix agent guidance
Keep generated stack conventions available to coding agents
Limits: Preserve maintained repository rules; --no-agents-md is an optional project choice, not the Phoenix default.
Swoosh + selected provider adapter
Mailer adapters and test delivery fit generated Phoenix account flows
Limits: Configure adapter/client dependencies and sender credentials; keep test/local adapters in development only. Use Oban for required queued delivery; a Task has no durable retry guarantee.
LiveView uploads
Built-in upload configuration and consumption fit connected forms
Limits: Configure allow_upload limits and authorize attachment association; persist consumed files before temp cleanup. External storage integration and content validation remain application work.
Phoenix.PubSub
Local/distributed publication updates connected views and channels
Limits: Supervise PubSub and subscribe to scoped topics; authorize each subscription/action and test reconnect. PubSub is transient broadcast, not durable replay or a message queue.
Build with the stack’s strengths
Phoenix web modules call application contexts; Ecto supplies persistence boundaries. LiveView maintains connected server-side interaction, while Channels expose a client-facing realtime protocol. Recommendation: model domain operations through contexts and supervised responsibilities rather than translating every old controller, global singleton or database serialization bottleneck literally.
Version scope: Fetched documentation: Phoenix 1.8.15, LiveView 1.2.12, PubSub 2.4.1, Plug 1.20.3, Ecto 3.14.2 / Ecto SQL 3.14.0, Oban 2.24.1, Exq 0.25.0 and OTP 29.1.1 ETS. Installed dependency compatibility is unqualified; pin the actual application before using version-specific APIs. · Reviewed 2026-10-11 · Evidence: documentation-reviewed · Source: inputs/research/migrations-server.json
For an existing application
These are documented options and proposed checks. Inspect the actual source application before adopting a transition.
Inventory schema, constraints, record identifiers and callbacks previously triggered by writes. Ecto schemas and changesets must preserve the intended domain semantics, not simply the old table shapes.
Recommendation: keep the source application as the authoritative writer while Phoenix contexts read fixtures; move a tenant or domain operation with one named writer. Use additive schema changes and a single migration runner during shared-table operation.
Contexts calling Ecto Repo with explicit validation and transaction boundaries. Ecto.Multi composes related Repo operations in one database transaction; cross-store side effects require a separate delivery design.
Recommendation: return the domain writer to the source while preserving additive schema and reconciling accepted new writes; delay destructive contractions until the rollback window closes.
Recommendation: a context boundary can expose one reusable domain operation to LiveView, controllers and workers.
Requires: Resource authorization, constraints and side effects moved with that operation.
Tradeoffs: Shared-schema coexistence limits schema changes; external effects do not become part of a database transaction.
Rails workers currently own Ruby job execution, including Active Job/GlobalID serializers and backend retry/scheduling behavior. Record the actual Redis-backed backend and every backlog state rather than inferring it from the word Rails.
Recommendation, retain/wrap path: keep Ruby workers and their broker; expose a narrow producer endpoint or durable outbox relay for Phoenix. Ruby remains the only consumer and scheduler for retained categories, and the interface names payload version, business idempotency key and enqueue acknowledgement.
Phoenix web/domain code with retained Ruby worker ownership is a valid permanent composition when queue interoperability or Ruby libraries remain necessary.
Recommendation: restore the old web producer while retaining the same workers; reconcile accepted interface/outbox entries before disabling the relay.
Recommendation: the web layer can transfer before job execution without transforming the old backlog.
Requires: Defined producer interface, monitored delivery and retained worker deployment.
Tradeoffs: Two runtimes and the broker remain operated; domain write plus broker enqueue is not a shared SQL transaction.
A retained Redis broker may carry Sidekiq/Resque-shaped jobs; framework wrappers, class names, serializer tags and version-sensitive timestamps are still part of the execution contract.
Recommendation, broker-retaining replacement path: qualify Exq for selected job types on isolated queues. Keep unsupported Ruby types on Ruby consumers; map only deliberately supported payload versions, and give each category one consumer family and schedule owner.
Selected Elixir workers using Exq's documented Redis-backed Resque/Sidekiq-compatible format. This is a candidate for qualification, not a claim that arbitrary Active Job payloads are interoperable.
Recommendation: stop new consumption and return only backward-readable queued work to Ruby; preserve both consumers for payloads accepted during the transition.
Recommendation: selected job execution can move to Elixir while preserving the broker boundary.
Requires: Fixture-tested serialization, queue isolation, retry mapping and scheduler ownership.
Tradeoffs: Redis remains; compatibility and unsupported Ruby argument types require explicit maintenance.
Legacy Redis jobs and a proposed SQL queue have distinct payload/storage formats and retry/schedule state. A backend change does not copy the backlog or the recurring schedule.
Recommendation, SQL replacement path: run Oban alongside the legacy broker and route selected categories exclusively to one system. Keep old ready, retry, delayed, failed and running work accounted for. Transfer each schedule once; use a recoverable relay/outbox while domain data and queue insertion span stores.
Oban workers on the chosen supported SQL engine. With the same Repo/transaction, Oban.insert in Ecto.Multi can join domain changes; a separate database cannot gain that atomicity merely from both databases being SQL.
Recommendation: pause new producers/consumption, keep accepted Oban payloads executable, and reconcile effects before moving routing back. Do not blindly copy all rows into the old broker.
Atomic domain-write-and-job-insert is available within a shared transaction.
Requires: One supported database transaction/Repo for both writes and business idempotency for execution.
Tradeoffs: Queue load shares the database; SQL atomic insertion does not guarantee exactly-once external effects.
Recommendation: broker retirement can reduce the operated service inventory.
Requires: All Redis uses transferred, all backlog states reconciled and recovery/rollback checks passed.
Tradeoffs: Redis plus SQL coexistence temporarily adds operational work; no service reduction occurs while Redis remains needed.
Record old cookie encoding, serializer, keys/salts, expiration and session revocation; shared account IDs alone do not establish cookie compatibility. Plug COOKIE defaults its serializer to external_term_format and exposes rotating cryptographic options.
Recommendation: retain the existing identity authority through a qualified session exchange or compatibility decoder. Map authorization rules into Phoenix contexts and LiveView mount/events; keep account and revocation ownership explicit.
Phoenix identity with the selected session store and LiveView authorization in mount/on_mount and actions. Recommendation: choose planned reauthentication when cookie compatibility is not worth maintaining.
Recommendation: retain the old decoder/exchange until routing can return; never reverse revocation merely to restore traffic.
Recommendation: users can preserve access while a connected feature moves.
Requires: Qualified decoder/exchange, shared revocation and event-level authorization.
Tradeoffs: Long-lived sockets need explicit disconnect/recheck behavior when access changes; sharing secrets alone is insufficient.
Action Cable, Phoenix Channels and LiveView are different protocols. Capture subscription identity, event envelope, authorization, ordering and missed-message recovery. Channels documents at-most-once client delivery without server persistence.
Recommendation: retain old client endpoints and bridge versioned domain events into each renderer. A room/tenant cohort owns its subscriptions and reconnects. Choose Redis PubSub or a qualified distributed-Elixir cluster deliberately; sharing Redis does not translate the wire protocol.
LiveView for connected server-owned screens or Channels for explicit realtime clients, with durable domain state and an application catch-up mechanism when missed events matter.
Recommendation: preserve the old endpoint/event envelope and cohort routing through reconnects; rebuild UI from persisted state instead of duplicating broadcasts.
Recommendation: connected UI and domain operations can share Phoenix contexts.
Requires: Authorized subscriptions, working multi-node fanout and persisted state/cursors for recovery requirements.
Tradeoffs: Live protocol/client changes and cluster operations remain; PubSub does not supply a durable user-message history.
Classify every Redis use as cache, session, limiter, lock, job or PubSub. ETS tables are node-local and their ownership lifetime matters; they do not provide Redis's cross-node boundary.
Recommendation: move only reconstructible cache entries into supervised local ownership, with explicit TTL/invalidation and bounded memory. Keep shared identity, coordination, queues and broadcast infrastructure until their own transitions qualify.
ETS for deliberately local reconstructed values, or a retained shared cache where consistency across nodes is required. Recommendation: state stale-read tolerance and rebuilding behavior in the application contract.
Recommendation: switch those reads back to the qualified shared store or authoritative data; retain Redis until every remaining capability is reconciled.
Recommendation: a local cache can remove a remote dependency from selected reads.
Requires: Acceptable node-local semantics, bounded memory and verified invalidation/rebuild behavior.
Tradeoffs: Each node maintains separate contents; owner/node failure loses local state. Performance benefit requires measurement.
Record endpoint, worker, scheduler, Repo, assets and cluster/PubSub ownership. Phoenix runtime configuration, release build and schema migrations have distinct deployment steps.
Recommendation: maintain both releases with stable cohort routing and a single schedule/writer owner per responsibility. Monitor queue age, retry effects, node connectivity and authorization failures against application-specific promotion thresholds.
A Phoenix release with runtime.exs configuration, built assets, named migration runner and supervised workers. Recommendation: make cluster formation, backups and restore ordering explicit instead of assuming VM startup establishes them.
Recommendation: retain the previous release and compatible database reads; return cohort routing and role ownership separately, reconciling new jobs and external effects.
Recommendation: explicit supervised roles and release inputs make restart behavior reviewable.
Requires: Configured children, deployment inventory and exercised recovery procedures.
Tradeoffs: Durable recovery still depends on the chosen databases/queues; supervision alone cannot recreate lost external state.
Run these in the configured application. They are instructions, not recorded passes.
mix hex.audit
mix format --check-formatted
mix compile --warnings-as-errors
mix test
mix credo --strict # only after installing/configuring Credo
mix sobelow --strict --exit low # only after installing/configuring Sobelow; review findings
mix dialyzer # optional, after Dialyxir/PLT configuration
mix phx.server # interactive smoke check, not an automated assertion
MIX_ENV=prod mix assets.deploy # release qualification, after production prerequisites
MIX_ENV=prod mix release # after release configuration; not deployment proofOriginal source review: 2026-10-10. Core guidance rechecked: 2026-10-13. Check scope.
The full Markdown and JSON include the attributed Elixir Menu optional libraries, runtime and other application paths. Read the maintained Elixir Menu reference →