5 Justfile Patterns You'll Use Every Day¶
I've been using just for three months across 12 projects. These five patterns show up in every single one.
Copy them. Use them. Thank me later.
Pattern 1: The Default List¶
Problem: New team members don't know what commands exist.
Solution:
Usage:
Why it works: When someone types just, they immediately see what's available. No documentation reading required.
Pattern 2: The Safety Check¶
Problem: Deploying without running tests. We've all been there.
Solution:
# Run all checks before deploying
check: lint test
@echo "โ All checks passed"
# Deploy only if checks pass
deploy ENV: check
@echo "Deploying to {{ENV}}..."
./scripts/deploy.sh {{ENV}}
Usage:
Why it works: Safety built into the command. Can't deploy without passing checks.
Pattern 3: The Smart Dev Command¶
Problem: Starting development requires multiple commands.
Solution:
# Start everything for development
dev: install
@echo "๐ Starting development environment..."
docker-compose up -d
@echo "โณ Waiting for database..."
sleep 3
uv run python manage.py migrate
@echo "โ Ready! Starting server..."
uv run python manage.py runserver
Usage:
Why it works: New developers run one command and everything starts. No 10-step setup guide.
Pattern 4: The Clean Slate¶
Problem: Build artifacts everywhere. Tests failing for no reason.
Solution:
# Nuclear option - clean everything
clean:
@echo "๐งน Cleaning..."
rm -rf __pycache__ .pytest_cache .ruff_cache .mypy_cache
find . -type f -name "*.pyc" -delete
find . -type d -name "__pycache__" -delete
rm -rf .coverage htmlcov
rm -rf dist build *.egg-info
@echo "โ Squeaky clean"
# Clean and reinstall
reset: clean
rm -rf .venv
uv sync
@echo "โ Fresh start"
Usage:
Why it works: When things break mysteriously, just reset gives you a fresh start.
Pattern 5: The Environment Switcher¶
Problem: Need to test against different Python versions or environments.
Solution:
# Python version
python_version := "3.12"
# Test with specific Python version
test-py VERSION=python_version:
@echo "Testing with Python {{VERSION}}"
uv run --python {{VERSION}} pytest tests/
# Test all supported versions
test-all:
just test-py 3.10
just test-py 3.11
just test-py 3.12
@echo "โ All versions pass"
Usage:
Why it works: Easy to verify compatibility across Python versions.
Bonus: Combine Them All¶
Here's my starter justfile with all five patterns:
# Python version
python_version := "3.12"
# Show available commands
default:
@just --list
# Install dependencies
install:
uv sync
# Run tests
test:
uv run pytest tests/ -v
# Check code quality
lint:
uv run ruff check .
uv run mypy .
# Run all checks
check: lint test
@echo "โ Ready to commit"
# Start development
dev: install
@echo "๐ Starting dev environment..."
uv run python manage.py runserver
# Clean artifacts
clean:
@echo "๐งน Cleaning..."
rm -rf __pycache__ .pytest_cache .ruff_cache
find . -type f -name "*.pyc" -delete
@echo "โ Clean"
# Fresh start
reset: clean
rm -rf .venv
uv sync
@echo "โ Fresh environment"
# Deploy with safety checks
deploy ENV: check
@echo "Deploying to {{ENV}}..."
./scripts/deploy.sh {{ENV}}
# Test specific Python version
test-py VERSION=python_version:
uv run --python {{VERSION}} pytest tests/
Copy this. Adjust to your project. Start automating.
Why These Patterns Work¶
Pattern 1 (Default List): Self-documenting
Pattern 2 (Safety Check): Prevents mistakes
Pattern 3 (Smart Dev): Reduces friction
Pattern 4 (Clean Slate): Fixes weird issues
Pattern 5 (Environment Switch): Tests compatibility
Common theme: They solve real problems I hit weekly.
What to Add Next¶
Once you have these basics, add:
CI/CD Integration:
Database Commands:
Docker Commands:
The Pattern That Changed Everything¶
Before these patterns, my workflow:
- Open 3 terminal tabs
- Run 5 different commands
- Wait and hope nothing breaks
- Repeat when it does
After:
just dev- Code
just checkjust deploy staging
From 10 minutes to 10 seconds.
Start Today¶
Pick one pattern. Add it to your justfile. Use it tomorrow.
Next week, add another. In a month, you'll wonder how you worked without them.
Most valuable? Pattern 2 (Safety Check). It's saved me from broken production deploys at least a dozen times.
Most used? Pattern 1 (Default List). Team members love it.
What's yours? Got a pattern I should try? Email me - I'm always looking for new ones.
Previously: Getting Started with just: The Task Runner You Need