agentleFS
AgentBullAgentBull/ankole/.agents/skills/elixir-coding/SKILL.md

elixir

Skill91 starsChanged 4 months agoApache-2.0View on GitHub

Ankole-specific Elixir, OTP, Ecto, Phoenix-shell, Rustler-boundary, and Torque guidance. Use when editing Elixir under app/control_plane, app/kernel, libs/feishu_openapi, or Elixir plugin code.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. Mindrally/skills★ 266same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository5 other files it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

44 rules. About 0 are common, 15 are distinctive, and 29 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈15

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 29

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Use this skill when changing Elixir code, tests, docs, or examples in:

    line 15
  2. Distinctive:

    Do not treat this skill as permission to introduce unrelated ecosystem pieces.

    line 28
  3. Distinctive:

    Do not add LiveView, Tailwind, esbuild, Ash, Commanded, Broadway, Flow, GenStage, Nerves, Tauri, Membrane, Zigler, Credo, Dialyzer, …

    line 29
  4. Distinctive:

    Do the requested change, not a broad cleanup.

    line 49
  5. Distinctive:

    Prefer deletion and reuse over a new abstraction.

    line 51
  6. Very specific:

    Keep public APIs small. Promote a private helper to def only when another module genuinely owns that call.

    line 52
  7. Very specific:

    Treat old project code as reference material only.

    line 57
  8. Distinctive:

    Use normal functional Elixir.

    line 62
  9. Very specific:

    Use case for one result, with for two or more {:ok, _} / {:error, _} steps.

    line 66
  10. Very specific:

    Use if only for simple boolean checks.

    line 68
  11. Very specific:

    Use Enum, for, Map.new/2, Enum.into/2, and Enum.reduce_while/3 before hand-written recursion.

    line 74
  12. Very specific:

    Use %{struct | field: value} for struct updates so unknown fields fail loudly.

    line 78
  13. Very specific:

    Put @impl true on every callback implementation.

    line 80
  14. Very specific:

    Put @derive before defstruct or schema.

    line 82
  15. Very specific:

    Prefer alias and qualified calls.

    line 83
  16. Very specific:

    Keep module order conventional: moduledoc, use/import/alias/require, module attributes, types, schema/struct, public functions, private …

    line 85
  17. Very specific:

    Do not add Jason examples, dependencies, derives, or protocol assumptions.

    line 92
  18. Very specific:

    Do not invent Torque.Encoder or Jason-style derive patterns.

    line 100
  19. Distinctive:

    Keep Phoenix as the HTML shell plus backend control plane.

    line 111
  20. Very specific:

    Do not reintroduce LiveView, Tailwind, or esbuild.

    line 113
  21. Very specific:

    Keep AnkoleWeb.Assets responsible for dev-server versus manifest asset URLs.

    line 117
  22. Very specific:

    Use open_api_spex patterns already present when changing JSON API surfaces.

    line 119
  23. Very specific:

    Use changesets for external input.

    line 123
  24. Very specific:

    Prefer context functions over direct Repo calls from controllers or web boundary modules.

    line 125
  25. Very specific:

    Use Repo.transact/1 or Repo.transact/2 in this repo, matching nearby code.

    line 127
  26. Very specific:

    Do not introduce new Repo.transaction/2 usage.

    line 128
  27. Very specific:

    Use Postgres deliberately: constraints, indexes, JSONB, generated values, on_conflict, and locking are acceptable when they simplify the …

    line 131
  28. Distinctive:

    Avoid get-then-insert races.

    line 133
  29. Very specific:

    Do not preload inside loops.

    line 135
  30. Very specific:

    Keep migrations narrow and reversible when practical.

    line 136
  31. Distinctive:

    Treat migration metadata and generated DB artifacts as generated.

    line 138
  32. Very specific:

    Use Registry + DynamicSupervisor for per-entity processes.

    line 145
  33. Very specific:

    Prefer GenServer.call/3 with explicit timeouts when the caller needs a result.

    line 148
  34. Distinctive:

    Do not block GenServer callbacks on long HTTP, DB, or native work.

    line 150
  35. Very specific:

    Use handle_continue/2 for post-init work.

    line 152
  36. Distinctive:

    Keep large read-heavy state out of a single GenServer.

    line 154
  37. Distinctive:

    Test through public APIs. Do not expose private functions only for tests.

    line 164
  38. Very specific:

    Use async: true unless the test mutates global state, named processes, Application env, Oban state, or shared DB assumptions.

    line 165
  39. Very specific:

    Use SQL sandbox patterns from test/support for database tests.

    line 167
  40. Very specific:

    Use start_supervised! for test-owned processes so ExUnit cleans them up.

    line 168
  41. Very specific:

    Use assert_receive / refute_receive with explicit timeouts instead of Process.sleep/1.

    line 169
  42. Distinctive:

    Prefer focused regression tests for the touched behavior.

    line 171
  43. Distinctive:

    Run commands from the package you changed, after sourcing the 1.20 toolchain when needed.

    line 176
  44. Distinctive:

    Do not read all reference files by default.

    line 189

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Ankole Elixir Skill

This is a project-local working guide, not a general Elixir manual. Start from the live code, local tests, and current mix.exs files. If a linked reference or generic Elixir habit conflicts with Ankole's live shape, Ankole wins.

When to Use This Skill

Use this skill when changing Elixir code, tests, docs, or examples in:

  • app/control_plane
  • app/kernel
  • libs/feishu_openapi
  • plugins/*/lib or internals/plugins/*/lib

Also load the more specific skill when the task is primarily about that surface:

  • Phoenix routing/controllers/views/assets: use the phoenix skill too.
  • Rustler/Rust NIF code: use the rust-nif skill too.
  • Current library/API/CLI syntax: use Context7 per the repo instructions.

Do not treat this skill as permission to introduce unrelated ecosystem pieces. Do not add LiveView, Tailwind, esbuild, Ash, Commanded, Broadway, Flow, GenStage, Nerves, Tauri, Membrane, Zigler, Credo, Dialyzer, Sobelow, Archdo, Mox, ExMachina, or StreamData unless the dependency already exists for the touched package or the user explicitly asks.

Current Project Shape

  • app/control_plane is the main Phoenix 1.8 application. It is not API-only: Phoenix owns routing, auth/session state, the HTML shell, static asset serving, Ecto/Postgres, Oban, OpenAPI, plugins, and operator-facing endpoints. Vite owns the SPA entrypoints under app/webapps.
  • app/control_plane uses Torque through the local Ankole.JSON adapter for Phoenix/Plug compatibility. Phoenix expects encode_to_iodata!/1; Torque's native API is not exactly that shape.
  • app/kernel is the Rustler-facing kernel package. Elixir owns the API shape; Rust owns native mechanics. Keep maps crossing the NIF boundary explicit and boring.

Local Defaults

  • Do the requested change, not a broad cleanup.
  • Inspect the existing module and tests before adding patterns.
  • Prefer deletion and reuse over a new abstraction.
  • Keep public APIs small. Promote a private helper to def only when another module genuinely owns that call.
  • Comments and docs should explain Ankole-specific meaning, boundary choices, failure modes, or operator-visible behavior. Do not teach generic Elixir, Phoenix, CRUD, or pattern matching in code comments.
  • Treat old project code as reference material only. Ankole's current code and docs are the source of truth.

Elixir Style

Use normal functional Elixir. The rules below are the default unless nearby code has a clear local convention.

  • Dispatch on data shape with pattern matching and multi-clause functions.
  • Use case for one result, with for two or more {:ok, _} / {:error, _} steps.
  • Use if only for simple boolean checks; do not build structural dispatch out of nested if.
  • Return tagged tuples for expected failures. Reserve raise for programmer errors and startup/configuration failures.
  • Reserve try/rescue for real boundaries around unsafe external code. To guard GenServer.call/3 to an optional or external process, catch exits explicitly.
  • Use Enum, for, Map.new/2, Enum.into/2, and Enum.reduce_while/3 before hand-written recursion. Use recursion for tree/graph traversal or state machines where it is the clearest tool.
  • Build strings as interpolation or IO data. Avoid repeated <> in loops.
  • Use %{struct | field: value} for struct updates so unknown fields fail loudly. Use Map.put/3 only when the key is dynamic.
  • Put @impl true on every callback implementation. Use @impl Behaviour when a module implements multiple behaviours with overlapping callbacks.
  • Put @derive before defstruct or schema.
  • Prefer alias and qualified calls. Use full imports only for intended DSLs such as Ecto.Query, Ecto.Changeset, test helpers, and guard macros.
  • Keep module order conventional: moduledoc, use/import/alias/require, module attributes, types, schema/struct, public functions, private helpers.

JSON Rules

Ankole uses Torque, not Jason.

  • Do not add Jason examples, dependencies, derives, or protocol assumptions.
  • In app/control_plane, prefer Ankole.JSON at Phoenix/Plug/application boundaries.
  • In libs/feishu_openapi and app/kernel, follow nearby code: usually Torque.encode!/1, Torque.encode/1, Torque.decode!/1, or Torque.decode/1.
  • External JSON maps have string keys. Convert to atom-keyed structs/maps only at a deliberate boundary.
  • Do not invent Torque.Encoder or Jason-style derive patterns. Convert structs to boundary maps explicitly when JSON shape matters.
  • In libs/feishu_openapi, keep Req response decoding explicit. The SDK sets decode_body: false; decode response bodies before Feishu envelope or rate-limit handling when the body may be JSON.

Phoenix and Web Boundaries

For Phoenix-specific changes, load the Phoenix skill and then apply these local constraints:

  • Keep Phoenix as the HTML shell plus backend control plane. Do not drift it toward API-only unless the user asks.
  • Do not reintroduce LiveView, Tailwind, or esbuild. The frontend entrypoints live under app/webapps and are served through the Phoenix/Vite integration.
  • Controllers should route, authenticate, translate parameters, and call domain contexts. Put durable behavior in context modules.
  • Keep AnkoleWeb.Assets responsible for dev-server versus manifest asset URLs.
  • Preserve the React Refresh preamble order when touching Vite tag injection.
  • Use open_api_spex patterns already present when changing JSON API surfaces.

Ecto and PostgreSQL

  • Use changesets for external input. Use change/2 only for trusted internal data.
  • Prefer context functions over direct Repo calls from controllers or web boundary modules.
  • Use Repo.transact/1 or Repo.transact/2 in this repo, matching nearby code. Do not introduce new Repo.transaction/2 usage.
  • Separate validations from constraints. Validations run before the DB write; constraints document and enforce DB truth.
  • Use Postgres deliberately: constraints, indexes, JSONB, generated values, on_conflict, and locking are acceptable when they simplify the system.
  • Avoid get-then-insert races. Prefer constraints and upserts where uniqueness matters.
  • Do not preload inside loops. Batch with query preloads or Repo.preload/2.
  • Keep migrations narrow and reversible when practical. Use mix ecto.gen.migration for new migrations.
  • Treat migration metadata and generated DB artifacts as generated. Do not hand-edit generated metadata unless the user explicitly asks.

OTP and Runtime Processes

  • Supervise long-running processes. Avoid bare spawn/spawn_link for durable work.
  • Use Registry + DynamicSupervisor for per-entity processes. Address a Registry-registered process through the same {:via, Registry, ...} tuple or local via/1 helper it used at startup.
  • Prefer GenServer.call/3 with explicit timeouts when the caller needs a result. Use cast only for fire-and-forget work where loss is acceptable.
  • Do not block GenServer callbacks on long HTTP, DB, or native work. Move slow work to a supervised task, Oban job, or a clearly isolated process.
  • Use handle_continue/2 for post-init work. If that work calls another process, confirm supervision ordering and set explicit timeouts.
  • Keep large read-heavy state out of a single GenServer. Use ETS or the database when that is the simpler operational truth.
  • Implement format_status/1 for processes holding secrets, credentials, tokens, or sensitive runtime state.
  • For actor-runtime work, keep Elixir as the owner of PG-backed durable state, admission, reconciliation, and operator-visible control. Rust/native code owns transport/protocol mechanics and should not grow direct Postgres ownership.

Testing

  • Test through public APIs. Do not expose private functions only for tests.
  • Use async: true unless the test mutates global state, named processes, Application env, Oban state, or shared DB assumptions.
  • Use SQL sandbox patterns from test/support for database tests.
  • Use start_supervised! for test-owned processes so ExUnit cleans them up.
  • Use assert_receive / refute_receive with explicit timeouts instead of Process.sleep/1.
  • Prefer focused regression tests for the touched behavior. Broaden coverage when changing shared runtime, schema, adapter, or web contracts.

Validation Commands

Run commands from the package you changed, after sourcing the 1.20 toolchain when needed.

For app/control_plane:

mix format
MIX_ENV=test mix compile --warnings-as-errors
MIX_ENV=test mix test

Optional Reference Files

Do not read all reference files by default. Open the smallest relevant file only when the task needs it:

  • code-style.md: formatter, module/function ordering, readability patterns.
  • architecture-reference.md: larger context or supervision boundary changes.
  • ecto-reference.md: Ecto query, migration, custom type, and Repo details.
  • otp-reference.md: OTP callback signatures, child specs, Registry, ETS.
  • testing-reference.md: ExUnit, SQL sandbox, process tests.
  • documentation.md: ExDoc, @doc, @spec, doctests.
  • type-system.md: compiler type warnings and specs.
  • debugging-profiling.md: tracing, memory, message queues, profiling.
  • networking.md: only for TCP/UDP socket work.

Low-probability topics such as event sourcing, Broadway/Flow/GenStage, desktop, embedded, multimedia, and heavy static-analysis tools are intentionally absent from this entrypoint. Reintroduce them only when the project actually uses them or the user asks for them.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.