Why you should use a task runner and not a command runner. Seriously!

David Danier
2 min readMay 5, 2024

--

Today most projects use a task/command runner to execute common jobs like the project setup or to run tests, or anything like that. As I have written two task runners myself I may be biased, but I see a great difference between simple command runners and actual task runners. My recommendation would be to always choose a task runner….but lets start with some background.

What is the difference between a task runner and a command runner?

I don’t think there is an official definition about those two terms. If yoou ask CHatGPT the answer could be:

A task runner is a tool that automates repetitive tasks in a project, such as compiling code, running tests, and minifying files. It’s often used in web development workflows to streamline processes.

A command runner, on the other hand, is a tool that executes specific commands or scripts.

The main difference from my perspective is that as command runner is mainly meant to run commands you already have on your system. This most of the time might be completely sufficient and solves most requirements like to run cargo build or pytest . This also means that you don’t need to have any control structures like if or any kind of loops in a command runner.

As task runner on the other hand allows you to define actual tasks, like iterating over all the files in some directory and doing something to it. This means it needs to allow writing some actual code to accomplish the task.

Why always use a task runner

I think this difference is very important. As when your task get more complex a command runner just won’t cut it any more. More complex tasks will need you to run external scripts as your command, which leads you to having to learn an additional scripting language (like bash), ensure the script works on all devs machines and maintain this script separate from your normal task/command runner configuration.

In general this lead to things getting way more complex when you hit the limits of a command runner. A task runner allows you to gradually growing your tasks while not having to deal with hitting this wall at all.

Also a task runner will always be able to just execute some commands like a command runner would. The opposite is just not true.

So my recommendation would be to always use a task runner simplify your coding workflows. It will allows you to let your task grow more and be more versatile.

Examples … runners

Command runners

Task runners

--

--

David Danier

Python Web Developer from Germany, focusing on FastAPI and Django.