elixir-knowledge-patch
Elixir 1.19–1.20, Phoenix 1.8, LiveView 1.0–1.1: type system inference, map key typing, colocated hooks, portals, scopes, magic link auth, new APIs and breaking changes.
What this skill does
# Elixir Knowledge Patch (1.19–1.20, Phoenix 1.8, LiveView 1.0–1.1)
**Baseline**: Elixir 1.16, OTP 26, Phoenix 1.7, LiveView 0.x (pre-1.0), Ecto 3.11, GenServer, Supervisor, mix, ExUnit, dbg macro.
This patch covers Elixir 1.19–1.20-rc, Phoenix 1.8, and LiveView 1.0–1.1 (2024-12 to 2026-01).
## Index
| Topic | File | Key Features |
|-------|------|--------------|
| Type System & Inference | [references/elixir-type-system.md](references/elixir-type-system.md) | Full expression inference, map key typing, struct update deprecation |
| APIs, Mix & Compilation | [references/elixir-apis-and-mix.md](references/elixir-apis-and-mix.md) | New stdlib APIs, mix commands, lazy module loading, deprecations |
| LiveView JS & Hooks | [references/liveview-js-and-hooks.md](references/liveview-js-and-hooks.md) | JS command targeting, colocated hooks, ViewHook class, programmable JS |
| LiveView Templates & Streams | [references/liveview-templates-and-streams.md](references/liveview-templates-and-streams.md) | Keyed comprehensions, portals, `ignore_attributes`, LazyHTML migration |
| Phoenix 1.8 | [references/phoenix-1-8.md](references/phoenix-1-8.md) | Scopes, magic link auth, simplified layouts, security headers |
---
## Quick Reference
### Elixir 1.20 Type Inference
The compiler infers types from all expressions (not just patterns). Backward inference narrows argument types:
```elixir
def sum_to_string(a, b), do: Integer.to_string(a + b)
# Infers a, b must be integer() (not float) because Integer.to_string requires integer
```
Cross-clause inference — later clauses know what previous clauses matched:
```elixir
case System.get_env("VAR") do
nil -> :not_found
value -> String.upcase(value) # value is binary(), not nil
end
```
### Map Key Typing (1.20)
```elixir
Map.put(map, :key, 123) #=> %{..., key: integer()}
Map.delete(map, :key) #=> %{..., key: not_set()}
Map.replace(map, :key, 123) #=> %{..., key: if_set(integer())}
```
### Struct Update Deprecation (1.19)
```elixir
# Deprecated — requires prior pattern match:
def update(uri), do: %URI{uri | path: "/foo"}
# Correct:
def update(%URI{} = uri), do: %{uri | path: "/foo"}
```
### New APIs at a Glance
| API | Version | Purpose |
|-----|---------|---------|
| `Access.values/0` | 1.19 | Traverse all values in maps/keyword lists |
| `String.count/2` | 1.19 | Count pattern occurrences in string |
| `min/2`, `max/2` in guards | 1.19 | Guard-compatible min/max |
| `Integer.ceil_div/2` | 1.20 | Ceiling division |
| `Integer.popcount/1` | 1.20 | Count set bits |
| `IO.iodata_empty?/1` | 1.20 | Check if iodata is empty |
| `List.first!/1`, `List.last!/1` | 1.20 | Raise on empty list |
### Breaking Changes (1.20)
```elixir
# map.foo() with parens now RAISES (not warns) — use map.foo
# mod.foo without parens now RAISES — use mod.foo()
# File.stream! arg order swapped:
File.stream!(path, lines_or_bytes, modes) # NEW order
# Bitstring size requires pin:
<<data::size(^size)>> # was <<data::size(size)>>
```
### LiveView Colocated Hooks (1.1)
```elixir
<div id="sortable" phx-hook=".Sortable">...</div>
<script :type={Phoenix.LiveView.ColocatedHook} name=".Sortable">
export default {
mounted() { /* JS code here */ }
}
</script>
```
Setup: add `:phoenix_live_view` to `compilers:` in `mix.exs`, import in `app.js`:
```javascript
import {hooks as colocatedHooks} from "phoenix-colocated/my_app"
const liveSocket = new LiveSocket("/live", Socket, {hooks: {...colocatedHooks}})
```
### LiveView Portals (1.1)
```heex
<.portal id="my-tooltip" target="body">
<div class="tooltip">Content here</div>
</.portal>
```
### Phoenix 1.8 Scopes
```elixir
# Generated context functions take scope as first arg
def list_posts(%Scope{} = scope) do
Repo.all(from p in Post, where: p.user_id == ^scope.user.id)
end
# LiveViews use socket.assigns.current_scope
def mount(_params, _session, socket) do
Blog.subscribe_posts(socket.assigns.current_scope)
{:ok, stream(socket, :posts, Blog.list_posts(socket.assigns.current_scope))}
end
```
### Phoenix 1.8 Simplified Layouts
```heex
<Layouts.app flash={@flash}>
<:breadcrumb><.link navigate={~p"/posts"}>Posts</.link></:breadcrumb>
<p>My content</p>
</Layouts.app>
```
Single `root.html.heex` layout. Multiple app layouts: `<Layouts.admin>`, `<Layouts.cart>`, etc.
### JS Command Targeting (LiveView 1.0)
```elixir
<button phx-click={JS.add_class("highlight", to: {:closest, "tr"})}>Select</button>
<div phx-click={JS.show(to: {:inner, ".details"})}>Expand</div>
```
### Keyed Comprehensions (LiveView 1.1)
```heex
<li :for={item <- @items} :key={item.id}>{item.name}</li>
```
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.