Dev tools and workflow · Beginner · 16 min
Run project tasks with just, a command runner
By Padding · Updated 18 Nov 2026
Ubuntu 26.04 · just 1.59.0 (official release binary)
You will install just 1.59 and write a justfile for a small site project, with recipes that take parameters, depend on each other, read variables and a .env file, run Python, ask before deleting and list themselves as help.
On this page
Most projects collect a handful of commands that everyone has to remember: how to build, how to run the tests, how to deploy to staging, how to wipe the build folder. They end up in a README, a shell history or one person's head. just is a command runner that keeps them in one file, called justfile, at the root of the project. Each named block of commands is a recipe, and just build or just test runs it.
just borrows its look from make, but it is not a build system. It does not compare file dates or decide what is out of date; it runs the commands you ask for, every time. That makes it a good fit for "run these commands" tasks, which is most of what teams put in Makefiles anyway. If you want file-based rebuilds, read Automate tasks with a Makefile instead.
You will build a justfile for a tiny static site in a throwaway folder, ~/just-demo, adding one feature per step. Every output shown is one you can reproduce on your own machine.
Step 1 · Install just 1.59
just is a single binary. The project publishes builds for Linux, macOS and Windows on its GitHub releases page, with a SHA256SUMS file to check the download against. This downloads the build for your processor (x86_64 or aarch64, from uname -m), checks it and installs it to /usr/local/bin. The python3 package is for a recipe later on; most Ubuntu servers already have it.
sudo apt update
sudo apt install -y curl ca-certificates python3
JUST_TMP=$(mktemp -d)
cd "$JUST_TMP"
JUST_VERSION=1.59.0
ARCH=$(uname -m)
curl -fsSLO "https://github.com/casey/just/releases/download/${JUST_VERSION}/just-${JUST_VERSION}-${ARCH}-unknown-linux-musl.tar.gz"
curl -fsSLO "https://github.com/casey/just/releases/download/${JUST_VERSION}/SHA256SUMS"
sha256sum --check --ignore-missing SHA256SUMS
tar -xzf "just-${JUST_VERSION}-${ARCH}-unknown-linux-musl.tar.gz"
sudo install -m 755 just /usr/local/bin/just
cd ~ && rm -rf "$JUST_TMP"sha256sum prints the archive name followed by OK. If it prints FAILED, delete the files and download again; do not install a binary that fails the check.
A binary installed by hand gets no updates from apt. To upgrade later, run the same commands with a newer JUST_VERSION from the releases page; install replaces the old file. Ubuntu's archive also has a just package, but it can lag behind the upstream release (apt-cache policy just shows which version it offers). On macOS, brew install just installs the current release.
The binary is a few megabytes and has no dependencies. If you pay for data by the megabyte, download it once and copy the same file to other Linux machines with the same processor type.
Check it worked
just --versionThe output is just 1.59.0.
Step 2 · Write your first recipes
Create the demo project with two pages in src/:
mkdir -p ~/just-demo/src
cd ~/just-demo
printf '<h1>Home</h1>\n<p>Welcome to the demo site.</p>\n' > src/index.html
printf '<h1>About</h1>\n<p>A small site built with just.</p>\n' > src/about.htmlNow write the justfile. A recipe is a name followed by a colon, with its commands indented underneath (spaces or tabs, as long as you are consistent). A comment on the line above a recipe becomes its description.
cat > justfile <<'EOF'
# List the recipes in this justfile
default:
@just --list
# Copy the pages in src/ into dist/
build:
mkdir -p dist
cp src/*.html dist/
@echo "Built dist/"
EOFRun the build:
just buildjust prints each command before it runs it, so you see mkdir -p dist and cp src/*.html dist/ followed by Built dist/. A leading @ turns that echo off for one line, which is why the echo command itself is not shown. Each line runs in its own sh -cu shell, so a cd on one line does not carry over to the next, and using an unset variable is an error.
Running just with no recipe name runs the first recipe in the file. Here that is default, which calls just --list:
justCheck it worked
The just output looks something like this, sorted by name, with your comments as descriptions:
Available recipes:
build # Copy the pages in src/ into dist/
default # List the recipes in this justfilels dist shows about.html and index.html. That list is the help page for your project: a new teammate runs just and sees every task and what it does. To keep a helper recipe out of the list, start its name with an underscore.
Step 3 · Give recipes parameters
Recipes can take parameters, written after the name. A parameter with = has a default; one without must be given. Inside the commands, {{name}} inserts the value. Add two recipes to the end of the file:
cat >> justfile <<'EOF'
# Say hello to someone
greet name="world":
@echo "Hello, {{name}}"
# Create src/NAME.html with a heading
new-page name:
printf '<h1>%s</h1>\n' "{{name}}" > "src/{{name}}.html"
EOFPass arguments after the recipe name, separated by spaces:
just greet
just greet Amaka
just new-page contactThe first prints Hello, world, the second Hello, Amaka. The third creates src/contact.html. Running just new-page with no name stops with an error, something like "got 0 arguments but takes 1", before any command runs.
Quote the {{name}} in commands, as here, so a value with a space in it stays one argument for the shell.
Check it worked
cat src/contact.htmlThe file holds <h1>contact</h1>. just --list now shows greet name="world" and new-page name, so the list documents the parameters too.
Step 4 · Make one recipe depend on another
Put other recipe names after the colon and just runs them first. A test that needs a fresh build can say so:
cat >> justfile <<'EOF'
# Build, then check every page has a heading
test: build
for page in dist/*.html; do grep -q '<h1>' "$page" || { echo "No heading in $page"; exit 1; }; done
@echo "All pages have a heading"
EOFjust testThe output shows the build commands first, then All pages have a heading. Each dependency runs once per just call, even if several recipes on the command line depend on it. If any command fails, just stops and the recipes after it do not run, which is what you want before a deploy.
Check it worked
ls distdist now includes contact.html, because test rebuilt it from src/ before checking.
Step 5 · Add variables and backtick expressions
A line like name := "value" sets a variable for the whole file. Text in backticks runs as a shell command when just starts, and its output becomes the value. Add a version, the build date, and a release recipe that stamps the build:
cat >> justfile <<'EOF'
version := "0.3.0"
build_date := `date -u +%Y-%m-%d`
# Test, then stamp dist/ with the version and date
release: test
echo "version={{version}} built={{build_date}}" > dist/build-info.txt
@cat dist/build-info.txt
EOFVariables in a justfile do not need to come before the recipes that use them; just reads the whole file first. Most people still keep them near the top.
just releaseThe last line of output is version=0.3.0 built= and today's date in UTC. You can override any variable for one run by putting NAME=VALUE before the recipe name:
just version=0.4.0 releaseTo see every variable's value without running anything, use just --evaluate.
Check it worked
cat dist/build-info.txtIt shows version=0.4.0 and the date. The justfile still says version := "0.3.0"; the override lasted for that one command.
Step 6 · Load settings from a .env file
Settings that differ per machine, such as the host to deploy to, belong in a .env file rather than in the justfile. The dotenv-load setting tells just to read .env from the project folder and pass its values to every recipe as environment variables. A missing .env is not an error.
If .env will ever hold a password or API token, add .env to .gitignore before your first commit, and create the file private from the start with install -m 600 /dev/null .env before writing to it. Commit a .env.example with the variable names and dummy values instead. If you already use direnv, load project environment variables with direnv covers the same idea for your whole shell.
Create the file and add the setting and a deploy recipe. Settings can go anywhere in the file; appending keeps this step short.
cat > .env <<'EOF'
DEPLOY_HOST=deploy.example.internal
EOF
cat >> justfile <<'EOF'
set dotenv-load
# Release, then show where it would go (staging by default)
deploy target="staging": release
@echo "Deploying {{version}} to {{target}} at $DEPLOY_HOST"
EOF$DEPLOY_HOST is a shell variable, not a just variable, so it is written with $ rather than braces. A parameter with a default can still be followed by dependencies after the colon.
just deploy
just deploy productionCheck it worked
The two deploy commands end with Deploying 0.3.0 to staging at deploy.example.internal and Deploying 0.3.0 to production at deploy.example.internal.
Step 7 · Write a recipe in Python
A recipe whose first line starts with #! is a script. just saves the body to a temporary file and runs it with the program named on that line, so the whole recipe runs as one script in that language rather than line by line in sh. This one counts the words on each page with Python:
cat >> justfile <<'EOF'
# Count the words on each page (written in Python)
stats:
#!/usr/bin/env python3
import re
from pathlib import Path
for page in sorted(Path("src").glob("*.html")):
text = re.sub(r"<[^>]+>", " ", page.read_text())
words = len(text.split())
unit = "word" if words == 1 else "words"
print(f"{page.name}: {words} {unit}")
EOFjust removes the recipe's indentation before saving the script, so Python sees the code starting at column 0 and the loop body indented by four spaces. {{ }} interpolation still works inside a script recipe if you need a variable.
just statsCheck it worked
The output is:
about.html: 7 words
contact.html: 1 word
index.html: 6 wordsStep 8 · Ask before a destructive recipe
The [confirm] attribute on the line above a recipe makes just ask before running it. Anything but y or yes cancels the recipe and nothing runs. You can give your own question:
cat >> justfile <<'EOF'
# Delete dist/ after asking
[confirm("Delete the dist folder?")]
clean:
rm -rf dist
EOFRun it and type y at the prompt:
just cleanScripts and CI jobs have nobody to answer. --yes confirms every [confirm] recipe in that run, so use it only where you mean it:
just build
just --yes cleanCheck it worked
lsThe project folder lists justfile and src, with no dist. Running just clean and answering n leaves dist in place and exits with an error, so a script that calls it stops there too.
Step 9 · Run tasks from any folder and pick the right runner
You do not have to be in the project root. just looks for a justfile in the current folder, then in each parent folder, and runs recipes from the folder that holds the justfile. From inside src/, a build still writes to the top-level dist/:
cd ~/just-demo/src
just build
ls ../dist
cd ~/just-demoIf a recipe needs to run where you typed the command instead, for example to format the files in the current folder, put [no-cd] on the line above it. The invocation_directory() function gives that folder as a value too.
Check it worked
ls ../dist lists about.html, contact.html and index.html, and just from src/ shows the same recipe list as from the project root.
When to use make, just or npm scripts
- make is the right tool when the output depends on files: it rebuilds a target only when its inputs are newer, which saves time on compiled code or generated assets. It is installed on most Unix systems already. For plain command lists it brings baggage:
.PHONYtargets, tab-only indentation and awkward arguments. - just suits a list of commands that people run by name: parameters with defaults, a readable
--list,.envloading, recipes in any language and a prompt on dangerous ones. The cost is one more tool every developer and CI runner has to install, so add the install step to your README and CI setup. - npm scripts (
"scripts"inpackage.json) are already there in a JavaScript project and every Node developer knowsnpm run. They suit short commands. They have no comments, defaults or confirmation, and long ones turn into hard-to-read JSON strings. Many teams keep npm scripts for the JavaScript toolchain and call them from a justfile that also covers databases, Docker and deploys.
When you have finished, delete the demo project. Keep /usr/local/bin/just if you will use it; otherwise remove it with sudo rm /usr/local/bin/just.
cd ~
rm -rf ~/just-demoNext steps
- Compare with make's file-based rebuilds in Automate tasks with a Makefile.
- Load per-project settings into your shell automatically with direnv.
- Add a recipe that reads JSON output with jq on the command line.
- Run your
just testrecipe before each commit with pre-commit.
Related tutorials
- Work on two branches at once with git worktreeYou will fix an urgent bug in a second working tree without stashing your half-finished feature, merge the fix, and clean up every extra tree afterwards.
- Version releases with semantic versioning, Git tags and a changelogYou will take a small shell library from 1.0.0 to 1.1.0 with written version rules, Conventional Commits, a Keep a Changelog file, annotated Git tags, a build stamped by git describe and release notes drafted from the commits since the last tag.
- Search files and shell history interactively with fzfYou will have fzf 0.75 wired into your shell for history search, file insertion and directory jumps, fed by fd with a preview pane, plus two small pickers that switch Git branches and stop processes.
Need this done for you?
Padding does this work for growing companies, from the first diagnosis to a system that keeps working.
Get new tutorials