TL;DR — Quick Summary
Just is a modern command runner and Makefile alternative. Learn justfile syntax, variables, conditional recipes, and cross-platform project automation.
Just is a command runner that saves and executes project-specific commands. Unlike Make, it has no file-building semantics — it simply runs the commands you define. This makes it perfect for development workflows: building, testing, deploying, linting, and any repetitive task.
Prerequisites
- Any operating system (Linux, macOS, Windows)
- Terminal access
Installation
# macOS
brew install just
# Debian/Ubuntu
sudo apt install just
# Fedora
sudo dnf install just
# Arch
sudo pacman -S just
# Any platform via Rust
cargo install just
# Verify
just --version
Basic Justfile
Create a file named justfile (no extension) in your project root:
# Default recipe - runs when you type just "just"
default: build
# Build the project
build:
npm run build
# Run tests
test *args:
npm test {{args}}
# Start development server
dev:
npm run dev
# Deploy to a specific environment
deploy env='staging':
echo "Deploying to {{env}}..."
./scripts/deploy.sh {{env}}
# Clean build artifacts
clean:
rm -rf dist node_modules/.cache
# Run linter and formatter
lint:
npm run lint
npm run format:check
# Database migrations
db-migrate:
npx prisma migrate deploy
# Full CI pipeline locally
ci: lint test build
Run with:
just # runs default recipe (build)
just test # runs test recipe
just deploy production # deploys to production
just test -- --watch # passes --watch to npm test
Key Features
Arguments and Defaults
# Required argument
greet name:
echo "Hello, {{name}}!"
# Default value
serve port='3000':
npm run dev -- --port {{port}}
# Variadic arguments
test *args:
npm test {{args}}
Environment Variables
# Load from .env file
set dotenv-load
# Export variables to recipes
export DATABASE_URL := "postgres://localhost/myapp"
# Use environment variables
backup:
pg_dump $DATABASE_URL > backup.sql
Conditional Recipes
# OS-specific recipes
install:
#!/usr/bin/env bash
if [[ "$(uname)" == "Darwin" ]]; then
brew install dependencies
else
sudo apt install dependencies
fi
# Conditional execution
deploy env='staging':
#!/usr/bin/env bash
if [[ "{{env}}" == "production" ]]; then
echo "Production deploy requires approval"
read -p "Continue? [y/N] " confirm
[[ "$confirm" == "y" ]] || exit 1
fi
./deploy.sh {{env}}
Recipe Dependencies
# Run lint before test, test before build
build: lint test
npm run build
lint:
npm run lint
test:
npm test
Comparison
| Feature | Just | Make | npm scripts | Task (Taskfile) |
|---|---|---|---|---|
| Syntax | Simple | Complex | JSON | YAML |
| Arguments | Native | Difficult | Limited | Native |
| Default values | Yes | No | No | Yes |
| .env loading | Built-in | Manual | dotenv | Manual |
| Dependencies | Yes | Yes | pre/post only | Yes |
| Cross-platform | Yes | Unix-focused | Yes | Yes |
| Discoverability | --list | Manual | Manual | --list |
Real-World Justfile
# Project automation for a full-stack web app
set dotenv-load
set positional-arguments
default:
@just --list
# Development
dev:
npm run dev
# Build for production
build:
npm run build
# Run all tests
test *args:
npm test {{args}}
# Type checking
typecheck:
npx tsc --noEmit
# Full quality check
check: typecheck lint test
# Lint and format
lint:
npx eslint src/
npx prettier --check src/
# Fix lint issues
fix:
npx eslint src/ --fix
npx prettier --write src/
# Docker commands
docker-build tag='latest':
docker build -t myapp:{{tag}} .
docker-run tag='latest':
docker run -p 3000:3000 myapp:{{tag}}
# Database
db-reset:
npx prisma migrate reset --force
npx prisma db seed
# Deploy
deploy env='staging':
#!/usr/bin/env bash
echo "Deploying to {{env}}..."
if [[ "{{env}}" == "production" ]]; then
git tag -a "v$(date +%Y%m%d-%H%M%S)" -m "Production deploy"
fi
npm run deploy:{{env}}
Summary
- Just is a command runner focused on saving and executing project commands — no build-system complexity
- Recipes support arguments with defaults, variadic arguments, and documentation comments
- Built-in
.envfile loading, environment variable export, and cross-platform support just --listshows all available recipes with descriptions for easy discoverability- Recipe dependencies chain tasks together:
build: lint testruns lint, then test, then build - Cross-platform: works on Linux, macOS, and Windows with per-recipe interpreter selection