算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
staff-level-elixir【设计与创意】Use this skill when writing, reviewing, or refactoring Elixir, OTP, Ecto, or Phoenix/LiveView code. It corrects the staff-level judgment calls a capable model gets wrong by default — reaching for a GenServer as the universal tool, rescuing instead of letting processes crash, N+1 Ecto access, non-atomic writes, unbounded/linked Task fan-out, atom exha…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Distilled staff-level judgment for Elixir on the BEAM — the design decisions Elixir, OTP, Ecto, and Phoenix force, and how an experienced engineer settles them, written so an agent applies them while writing or reviewing code. Each rule corrects a specific wrong default; there is no rule for things the model already gets right (syntax, basic idioms, the standard library).
with, and letting a process crash| # | Category | Prefix | Covers |
|---|---|---|---|
| 1 | Process & OTP Design | otp- | Whether a problem needs a process, and which one; supervision |
| 2 | Error Handling & Let-It-Crash | err- | Signalling failure; when to raise, rescue, or crash |
| 3 | Idioms & Design Choices | data- | Pattern matching, Stream/Enum, iolists, pipes, macros |
| 4 | Concurrency & the Scheduler | conc- | Bounded/isolated parallelism; atom-table safety |
| 5 | Ecto & Data Access | ecto- | N+1, atomic writes, constraint races, large sets |
| 6 | Phoenix & LiveView | phx- | Context boundaries, socket memory, mount lifecycle |
otp-genserver-not-default — a GenServer is a serialization point, not the default abstractionotp-ets-for-shared-reads — read-heavy shared state belongs in ETS, not behind a GenServer.getotp-supervise-over-manual-restart — child specs + DynamicSupervisor/Registry, not hand-rolled restart logicotp-handle-continue-init — defer heavy startup to handle_continue; init/1 blocks the supervisorerr-tagged-tuples-vs-raise — {:ok/:error} for expected failures, raise only for invariant violationserr-let-it-crash — don't rescue to mask bugs; let the supervisor restart clean stateerr-with-happy-path — chain fallible steps with with; keep the error term intactdata-pattern-match-over-conditionals — function clauses + guards over if/cond on argument shapedata-stream-vs-enum — Stream for large/lazy/early-exit, Enum for small concrete listsdata-iolists-over-concat — build large output as iolists; <> in a loop is O(n²)data-pipe-idioms — pipe a data subject through transformations, not to save a variabledata-functions-over-macros — solve it with a function before reaching for a macroconc-async-stream-bounded — Task.async_stream with max_concurrency + explicit timeoutconc-task-supervised-nolink — supervised, unlinked Task for fire-and-forget workconc-atom-exhaustion — never build atoms from external input; use to_existing_atomecto-preload-n-plus-one — preload up front, never inside an Enum loopecto-multi-for-transactions — Ecto.Multi for atomic multi-step writes with failure attributionecto-db-constraints-over-validation — DB constraint + unique_constraint, not a racy validation queryecto-stream-large-sets — Repo.stream/batch large sets; Repo.all OOMs at scaleecto-atomic-counters — update_all with inc: for counters; read-modify-write loses updatesphx-context-boundary — web layer calls contexts, never Repo or schemas directlyphx-liveview-streams — streams for large/growing collections, not full lists in assignsphx-mount-twice-connected — gate side effects on connected?/1; mount runs twiceRead a reference file when its decision comes up. Each rule names the wrong default it corrects, then shows the canonical way (with an incorrect/correct contrast only where the wrong way is a real trap).
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and source references |