Skip to content
Latchkey

just: Recipe Parameters and Arguments

just recipes can take parameters declared after the recipe name and supplied on the command line.

Parameters turn a recipe into a small reusable command. A deploy recipe can take the target environment as an argument instead of hardcoding it.

What it does

A recipe declares parameters after its name: "deploy env:". Callers pass them positionally: just deploy staging. Parameters can have defaults (env="staging"), and a final variadic parameter (+args or *args) collects the rest of the command line.

Common usage

justfile
# justfile
deploy env="staging":
    ./deploy.sh {{env}}

# variadic: pass any number of extra args through
test +args:
    go test {{args}}

# run them
just deploy production
just test -run TestFoo -v ./pkg/...

Syntax

FormWhat it does
recipe name:Declare a required positional parameter
recipe name="x":Parameter with a default value
recipe +args:Variadic: one or more arguments required
recipe *args:Variadic: zero or more arguments
just recipe valPass val as the first parameter
{{ name }}Interpolate a parameter inside the recipe

In CI

Variadic +args / *args lets one recipe forward arbitrary flags from the pipeline (for example a matrix value) without rewriting the recipe. Defaults keep the local call short while CI passes the explicit value.

Common errors in CI

"error: Recipe deploy got 0 arguments but takes at least 1" means a required parameter was omitted; add a default or pass the value. "error: Recipe deploy got 2 arguments but takes 1" means extra args with no variadic parameter to absorb them. Quote arguments that contain spaces when calling from a YAML step.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →