Article URL: https://hamvocke.com/blog/task-runners/ Comments URL: https://news.ycombinator.com/item?id=49158287 Points: 26 # Comments: 5

You can make your software developer life suck a bit less by using task runners to run common coding tasks consistently across multiple repositories (Originally published in 2019. I pulled this one from the archives and gave it a fresh makeover after a reader reached out to tell me they misses this article.) In my day to day as a software developer I often switch between different code repositories. Each repository can be written in a different tech stack but there are common tasks I need to run in all of these repositories, regardless of the stack: I need to install dependencies, build the source code, lint my code, format it, run tests, run database migrations, deploy to a staging environment, create a new version, start dependent services, you get the idea. Depending on the exact tooling used in each repo, I’d have to remember a few clunky incantations to invoke from my command line. Was it rust fmt to format? mix deps.update to update dependencies? Was it ./gradlew build or did we switch back to mvn again? Was it yarn or npm or pnpm after all these years? Do I need to pass any arguments to npm run prettier? And what was that three-step command to run all migrations from scratch again? I want to be able to say “build the code”, “lint it”, “format it”, “run migrations”, “install dependencies”. To make my life just a little bit easier, I often create convenience tooling that allows me to run common tasks the same way no matter the repository I’m in. This allows me to apply muscle memory to do the things I do a dozen times each day. There are a few ways we can pull this off, from good old bash scripts and make to more modern tools like mise and just. Some people have started calling these tools “task runners” so I guess that’s the name I’m going to stick with here. Let’s take a quick look at these options together. We can write a simple shell script (or ask our LLM of choice for help) to act as a small wrapper for commonly run commands we need for messing with our code.