mix-tasks-generators
Installation
SKILL.md
Mix Tasks & Generators
RULES — Follow these with no exceptions
- Always call
Mix.Task.run("app.start")first — tasks that access the database or Repo need the app started - Create custom tasks for project-specific workflows — don't override standard Mix tasks
- Use
OptionParser.parse/2for argument parsing — never use rawSystem.argv()for complex arguments - Add
@shortdocto every task — tasks appear inmix helpusing this attribute - Register
preferred_cli_envin mix.exs — set environment for custom tasks (dev/test/prod) - Use transactions for data modifications — wrap
Repo.insert_all,Repo.delete_allinRepo.transaction() - Test custom tasks with
Mix.Project.in_project/4— ensure tasks work correctly in isolation - Follow
Mix.Tasks.Namespace.TaskNamenaming — file path must match:lib/mix/tasks/namespace.task_name.ex
End-to-End Workflow
Follow this sequence when creating a custom Mix task: