two tall building during daytime

Why your project should have a Justfile

If you’re like me, you’ve got a folder full of side projects in various states of completion. Some you worked on last week, others haven’t been touched in months. And every time you come back to one, there’s always that moment of “Wait, how do I run this again?”

That’s where Justfiles come in. They’re a simple but powerful tool that can make managing your side projects a whole lot easier.

What’s a Justfile?

A Justfile is basically a runnable cheat sheet for your project. It’s a single file where you can define all the common commands you use in your project. Think of it as a simpler, more user-friendly version of a Makefile.

Why Justfiles Are Awesome

  1. Easy to Pick Up Where You Left Off With a Justfile, you don’t need to remember how your project works. Just run just --list to get the list of commands.
  2. Less Complicated Than Makefiles If you’ve ever struggled with Makefile syntax, you’ll appreciate how straightforward Justfiles are. You can also use Python and other code directly in Justfile.
  3. Handles Environment Variables Justfiles can load your environment variables automatically.
  4. Consistent Across Projects Once you get used to using Justfiles, you can use the same command structure across all your projects.

A Real-World Example

Here’s an example of a Justfile I use for one of my Django projects:

set dotenv-load
set positional-arguments

# Run Django app
run:
    poetry run python manage.py runserver

# Install Poetry dependencies
install:
    poetry install

# Deploy app with CapRover
deploy:
    caprover deploy --default

backup file="backup.gz":
    just manage dbbackup -z -O {{file}}
    echo Generated backup {{file}}
    echo "You can restore it with: just restore {{file}}"

restore file:
    just manage dbrestore -I {{file}} -z

test *args='':
    poetry run pytest $@

# manage.py
manage *args='':
    poetry run python manage.py $@

With this Justfile, I can run my Django server with just run, install dependencies with just install, or even create a database backup with just backup. It’s simple, but it saves me from having to remember or look up these commands every time I come back to the project.

Here’s what it looks like when I use it:

$ just --list                                                                                                                 
Available recipes:
    backup file="backup.gz"
    deploy                  # Deploy app with CapRover
    install                 # Install Poetry dependencies
    manage *args=''         # manage.py
    restore file
    run                     # Run Django app
    test *args=''

Getting Started

Adding a Justfile to your project is easy. Just create a file named Justfile (no extension) in your project root and start adding your commands. You can install just with Homebrew: brew install just

Wrap Up

Justfiles aren’t going to revolutionize the way you code, but they will make your life a little easier. They’re especially useful for side projects that you might not work on consistently. Give them a try in your next project – I think you’ll be pleasantly surprised at how helpful they can be.