Attributes

Recipes, mod statements, and aliases may be annotated with attributes that change their behavior.

NameTypeDescription
[confirm]1.17.0recipeRequire confirmation prior to executing recipe.
[confirm('PROMPT')]1.23.0recipeRequire confirmation prior to executing recipe with a custom prompt.
[doc('DOC')]1.27.0module, recipeSet recipe or module’s documentation comment to DOC.
[extension('EXT')]1.32.0recipeSet shebang recipe script’s file extension to EXT. EXT should include a period if one is desired.
[group('NAME')]1.27.0module, recipePut recipe or module in in group NAME.
[linux]1.8.0recipeEnable recipe on Linux.
[macos]1.8.0recipeEnable recipe on MacOS.
[no-cd]1.9.0recipeDon’t change directory before executing recipe.
[no-exit-message]1.7.0recipeDon’t print an error message if recipe fails.
[no-quiet]1.23.0recipeOverride globally quiet recipes and always echo out the recipe.
[positional-arguments]1.29.0recipeTurn on positional arguments for this recipe.
[private]1.10.0alias, recipeMake recipe, alias, or variable private. See Private Recipes.
[script]1.33.0recipeExecute recipe as script. See script recipes for more details.
[script(COMMAND)]1.32.0recipeExecute recipe as a script interpreted by COMMAND. See script recipes for more details.
[unix]1.8.0recipeEnable recipe on Unixes. (Includes MacOS).
[windows]1.8.0recipeEnable recipe on Windows.

A recipe can have multiple attributes, either on multiple lines:

[no-cd]
[private]
foo:
    echo "foo"

Or separated by commas on a single line1.14.0:

[no-cd, private]
foo:
    echo "foo"

Enabling and Disabling Recipes1.8.0

The [linux], [macos], [unix], and [windows] attributes are configuration attributes. By default, recipes are always enabled. A recipe with one or more configuration attributes will only be enabled when one or more of those configurations is active.

This can be used to write justfiles that behave differently depending on which operating system they run on. The run recipe in this justfile will compile and run main.c, using a different C compiler and using the correct output binary name for that compiler depending on the operating system:

[unix]
run:
  cc main.c
  ./a.out

[windows]
run:
  cl main.c
  main.exe

Disabling Changing Directory1.9.0

just normally executes recipes with the current directory set to the directory that contains the justfile. This can be disabled using the [no-cd] attribute. This can be used to create recipes which use paths relative to the invocation directory, or which operate on the current directory.

For example, this commit recipe:

[no-cd]
commit file:
  git add {{file}}
  git commit

Can be used with paths that are relative to the current directory, because [no-cd] prevents just from changing the current directory when executing commit.

Requiring Confirmation for Recipes1.17.0

just normally executes all recipes unless there is an error. The [confirm] attribute allows recipes require confirmation in the terminal prior to running. This can be overridden by passing --yes to just, which will automatically confirm any recipes marked by this attribute.

Recipes dependent on a recipe that requires confirmation will not be run if the relied upon recipe is not confirmed, as well as recipes passed after any recipe that requires confirmation.

[confirm]
delete-all:
  rm -rf *

Custom Confirmation Prompt1.23.0

The default confirmation prompt can be overridden with [confirm(PROMPT)]:

[confirm("Are you sure you want to delete everything?")]
delete-everything:
  rm -rf *