analyze
免费Analyze a legacy app in any language before rewriting it in Elixir: inventory, features as goals, why each mechanism exists, runtime topology, external contracts. Use to start or refresh a rewrite.
中文简介正在准备中。当前显示原文说明。
OTP/BEAM patterns and Elixir idioms — GenServer, Supervisor, Task, Registry, pattern matching, with chains, pipes. Use when designing processes or debugging BEAM issues.
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
Reference for writing idiomatic Elixir code with BEAM-aware patterns.
and/or/not — Never use short-circuit operators in guards (guards require boolean operands)cast/4 for user input, change/2 for internalString.to_atom(user_input) causes memory leak (atoms aren't GC'd)@external_resourceGenServer.start_link/Agent.start_link in production. Use supervision treesMix.Task.run("app.config") + Application.ensure_all_started/1, never Mix.Task.run("app.start") (boots the FULL tree: endpoint port, Oban consuming)case, then cond{:ok, _}/{:error, _} for expected errors, raise for bugsNeed patterns? → case (or function heads)
Multiple operations? → with
Boolean conditions? → cond (multiple) or if (single)
Expected failure? → {:ok, _}/{:error, _} tuples
Unexpected/bug? → raise exception (let supervisor handle)
External library? → rescue (only here!)
Need state?
├─ No → Plain functions
├─ Simple get/update → Agent or ETS
├─ Complex messages/timeouts → GenServer
└─ One-off async → Task
# Pattern match in function head
def process(%{status: :active} = user), do: activate(user)
def process(%{status: :inactive} = user), do: deactivate(user)
# with for happy path
with {:ok, user} <- get_user(id),
{:ok, order} <- create_order(user) do
{:ok, order}
end
# Task for async
Task.Supervisor.async_nolink(TaskSup, fn -> work() end)
|> Task.yield(5000) || Task.shutdown(task)
| Wrong | Right |
|---|---|
length(list) == 0 | list == [] or Enum.empty?(list) |
list ++ [item] | [item | list] |> Enum.reverse() |
String.to_atom(input) | String.to_existing_atom(input) |
spawn(fn -> log(conn) end) | ip = conn.ip; spawn(fn -> log(ip) end) |
unless condition | if !condition (unless deprecated in 1.18) |
For detailed patterns, see:
${CLAUDE_SKILL_DIR}/references/pattern-matching.md - Pattern matching, guards, binary matching${CLAUDE_SKILL_DIR}/references/otp-patterns.md - GenServer, Supervisor, Task, Registry${CLAUDE_SKILL_DIR}/references/error-handling.md - Tagged tuples, rescue, with${CLAUDE_SKILL_DIR}/references/with-and-pipes.md - When to use with and |> (idiomatic patterns)${CLAUDE_SKILL_DIR}/references/troubleshooting.md - Production BEAM debugging (memory, performance, crashes)${CLAUDE_SKILL_DIR}/references/anti-patterns.md - Common mistakes and fixes${CLAUDE_SKILL_DIR}/references/mix-tasks.md - Mix task naming, option parsing, shell output${CLAUDE_SKILL_DIR}/references/elixir-118-features.md - Duration module, dbg improvements (1.18+)${CLAUDE_SKILL_DIR}/references/elixir-120-type-system.md - Gradual type checker, dynamic(), verified bugs as compile warnings (1.20+, OTP 27+)还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Analyze a legacy app in any language before rewriting it in Elixir: inventory, features as goals, why each mechanism exists, runtime topology, external contracts. Use to start or refresh a rewrite.
中文简介正在准备中。当前显示原文说明。
Design the idiomatic Elixir architecture for a rewrite: set the compatibility bar (ADR-000), consult phx specialists on open questions, then build contexts, ledger and ADRs. Use after /rewrite:analyze.
中文简介正在准备中。当前显示原文说明。
Ash Framework — resources, actions, policies, aggregates; Use when generating resources via mix ash.codegen, editing…
中文简介正在准备中。当前显示原文说明。
Ash Framework — resources, actions, policies, aggregates, calculations, AshPhoenix.Form, LiveView, migrations. Use when generating resources via mix ash.codegen, editing changes, checks, types, validations, or domain code interfaces.
中文简介正在准备中。当前显示原文说明。
Compatibility alias for the Elixir/Phoenix plugin's LiveView assigns audit. Invoke explicitly with /lv:assigns.
中文简介正在准备中。当前显示原文说明。
Inspect LiveView socket assigns for memory bloat — missing temporary_assigns, unused assigns, unbounded lists needing streams, memory estimates. Use when LiveView memory grows or you need to add temporary_assigns.
中文简介正在准备中。当前显示原文说明。