Create a custom mix task:

# lib/mix/tasks/mytask.ex
defmodule Mix.Tasks.MyTask do
  use Mix.Task

  @shortdoc "A simple mix task"
  def run(_) do
    IO.puts "YO!"
  end
end

Compile and run it:

> mix compile
> mix my_task
"YO!"

mix help lists out all available mix tasks for the project.