Just Command Runner
just is a handy way to save and run project-specific commands. It's a command runner, not a build system, avoiding much of make's complexity.
Instructions
Prerequisites
- •
justmust be installed:brew install just - •Commands are stored in a
justfile(orJustfile).
Common Settings (set ...)
You can configure just behavior at the top of your justfile:
- •
set shell := ["bash", "-c"]: Change the default shell. - •
set dotenv-load: Automatically load.envfiles. - •
set allow-duplicate-recipes: Allow overriding recipes. - •
set fallback: Search forjustfilein parent directories. - •
set quiet: Don't echo commands by default.
Example Justfiles
For complete reference, see these templates:
Workflow
- •
Create a
justfile: Define recipes at the top level of your project. Always include adefaultrecipe that lists available commands:justdefault: @just --list
just# The default recipe (runs when calling `just` with no args) default: just --list # A basic recipe test: cargo test # A recipe with parameters build target: echo "Building {{target}}..." cc main.c -o {{target}} - •
Run Recipes:
- •Run the default recipe:
just - •Run a specific recipe:
just <recipe> - •Pass arguments to a recipe:
just build my-app - •List all available recipes:
just --list
- •Run the default recipe:
- •
Advanced Features:
- •Dependencies:
test: build(runsbuildbeforetest). - •Shebang Recipes: Use other languages like Python or Node inside a recipe.
just
python-task: #!/usr/bin/env python3 print("Hello from Python!") - •Dotenv:
set dotenv-loadat the top of the file to load.env.
- •Dependencies:
Examples
Example 1: Standard Development Justfile
User request:
code
Create a justfile for my Node project to handle lint, test, and dev
You would:
- •Create a
justfile:justdefault: @just --list lint: npm run lint test: npm test dev: npm run dev
- •Tell the user they can now run
just devorjust test.
Example 2: Recipe with Parameters
User request:
code
Add a recipe to just to deploy to a specific environment
You would:
- •Edit the
justfile:justdeploy env: echo "Deploying to {{env}}..." ./scripts/deploy.sh --target {{env}} - •Inform the user they can run
just deploy production.
Example 3: Listing Recipes
User request:
code
What commands are available in this project?
You would:
- •Run
just --listto see available recipes and their comments.