website/src/docs/reference/schema.md
This page documents all available properties and types for the Taskfile schema version 3, based on the official JSON schema.
The root Taskfile schema defines the structure of your main Taskfile.yml.
versionstring or number"3", 3, or any valid semver stringversion: '3'
outputstring or objectinterleavedinterleaved, group, prefixed# Simple string format
output: group
# Advanced object format
output:
group:
begin: "::group::{{.TASK}}"
end: "::endgroup::"
error_only: false
methodstringchecksumchecksum, timestamp, nonemethod: timestamp
includesmap[string]Includeincludes:
# Simple string format
docs: ./Taskfile.yml
# Full object format
backend:
taskfile: ./backend
dir: ./backend
optional: false
flatten: false
internal: false
aliases: [api]
excludes: [internal-task]
vars:
SERVICE_NAME: backend
checksum: abc123...
varsmap[string]Variablevars:
# Simple values
APP_NAME: myapp
VERSION: 1.0.0
DEBUG: true
PORT: 8080
FEATURES: [auth, logging]
# Dynamic variables
COMMIT_HASH:
sh: git rev-parse HEAD
# Variable references
BUILD_VERSION:
ref: .VERSION
# Map variables
CONFIG:
map:
database: postgres
cache: redis
envmap[string]Variableenv:
NODE_ENV: production
DATABASE_URL:
sh: echo $DATABASE_URL
tasksmap[string]Tasktasks:
# Simple string format
hello: echo "Hello World"
# Array format
build:
- go mod tidy
- go build ./...
# Full object format
deploy:
desc: Deploy the application
cmds:
- ./scripts/deploy.sh
silentboolfalsesilent: true
dotenv[]stringdotenv:
- .env.local # Highest priority
- .env # Lowest priority
runstringalwaysalways, once, when_changedrun: once
intervalstring100ms^[0-9]+(?:m|s|ms)$interval: 1s
set[]stringallexport, a, errexit, e, noexec, n, noglob, f,
nounset, u, xtrace, x, pipefailset: [errexit, nounset, pipefail]
shopt[]stringexpand_aliases, globstar, nullglobshopt: [globstar]
Configuration for including external Taskfiles.
taskfilestringincludes:
backend: ./backend/Taskfile.yml
# Shorthand for above
frontend: ./frontend
dirstringincludes:
api:
taskfile: ./api
dir: ./api
optionalboolfalseincludes:
optional-tasks:
taskfile: ./optional.yml
optional: true
flattenboolfalseincludes:
common:
taskfile: ./common.yml
flatten: true
internalboolfalse--listincludes:
internal:
taskfile: ./internal.yml
internal: true
aliases[]stringincludes:
database:
taskfile: ./db.yml
aliases: [db, data]
excludes[]stringincludes:
shared:
taskfile: ./shared.yml
excludes: [internal-setup, debug-only]
varsmap[string]Variableincludes:
deploy:
taskfile: ./deploy.yml
vars:
ENVIRONMENT: production
checksumstringincludes:
remote:
taskfile: https://example.com/tasks.yml
checksum: c153e97e0b3a998a7ed2e61064c6ddaddd0de0c525feefd6bba8569827d8efe9
Variables support multiple types and can be static values, dynamic commands, references, or maps.
vars:
# String
APP_NAME: myapp
# Number
PORT: 8080
# Boolean
DEBUG: true
# Array
FEATURES: [auth, logging, metrics]
# Null
OPTIONAL_VAR: null
sh)vars:
COMMIT_HASH:
sh: git rev-parse HEAD
BUILD_TIME:
sh: date -u +"%Y-%m-%dT%H:%M:%SZ"
ref)vars:
BASE_VERSION: 1.0.0
FULL_VERSION:
ref: .BASE_VERSION
map)vars:
CONFIG:
map:
database:
host: localhost
port: 5432
cache:
type: redis
ttl: 3600
Variables can reference previously defined variables:
vars:
GREETING: Hello
TARGET: World
MESSAGE: '{{.GREETING}} {{.TARGET}}!'
Individual task configuration with multiple syntax options.
tasks:
# String command
hello: echo "Hello World"
# Array of commands
build:
- go mod tidy
- go build ./...
# Object with cmd shorthand
test:
cmd: go test ./...
cmds[]Commandtasks:
build:
cmds:
- go build ./...
- echo "Build complete"
cmdstringcmds)tasks:
test:
cmd: go test ./...
deps[]Dependencytasks:
# Simple dependencies
deploy:
deps: [build, test]
cmds:
- ./deploy.sh
# Dependencies with variables
advanced-deploy:
deps:
- task: build
vars:
ENVIRONMENT: production
- task: test
vars:
COVERAGE: true
cmds:
- ./deploy.sh
# Silent dependencies
main:
deps:
- task: setup
silent: true
cmds:
- echo "Main task"
# Loop dependencies
test-all:
deps:
- for: [unit, integration, e2e]
task: test
vars:
TEST_TYPE: '{{.ITEM}}'
cmds:
- echo "All tests completed"
descstring--listtasks:
test:
desc: Run unit tests
cmds:
- go test ./...
summarystring--summarytasks:
deploy:
desc: Deploy to production
summary: |
Deploy the application to production environment.
This includes building, testing, and uploading artifacts.
promptstring or []stringtasks:
# Single prompt
deploy:
prompt: "Deploy to production?"
cmds:
- ./deploy.sh
# Multiple prompts
deploy-multi:
prompt:
- "Are you sure?"
- "This will affect live users!"
cmds:
- ./deploy.sh
aliases[]stringtasks:
build:
aliases: [compile, make]
cmds:
- go build ./...
methodstringchecksumchecksum, timestamp, nonemethod root property for details.tasks:
build:
sources:
- go.mod
method: timestamp
sources[]string or []Globtasks:
build:
sources:
- '**/*.go'
- go.mod
# With exclusions
- exclude: '**/*_test.go'
cmds:
- go build ./...
generates[]string or []Globtasks:
build:
sources: ['**/*.go']
generates:
- './app'
- exclude: '*.debug'
cmds:
- go build -o app ./cmd
status[]stringtasks:
install-deps:
status:
- test -f node_modules/.installed
cmds:
- npm install
- touch node_modules/.installed
preconditions[]Preconditiontasks:
# Simple precondition (shorthand)
build:
preconditions:
- test -d ./src
cmds:
- go build ./...
# Preconditions with custom messages
deploy:
preconditions:
- sh: test -n "$API_KEY"
msg: 'API_KEY environment variable is required'
- sh: test -f ./app
msg: "Application binary not found. Run 'task build' first."
cmds:
- ./deploy.sh
ifstringtasks:
# Task only runs in CI environment
deploy:
if: '[ "$CI" = "true" ]'
cmds:
- ./deploy.sh
# Using Go template expressions
build-prod:
if: '{{eq .ENV "production"}}'
cmds:
- go build -ldflags="-s -w" ./...
dirstringdir is
ROOT_DIR. For included Taskfiles, the default dir is the value specified in
their respective includes.*.dir field (if any).tasks:
current-dir:
dir: '{{.USER_WORKING_DIR}}'
cmd: pwd
requiresRequirestasks:
deploy:
requires:
vars: [API_KEY, ENVIRONMENT]
cmds:
- ./deploy.sh
advanced-deploy:
requires:
vars:
- API_KEY
- name: ENVIRONMENT
enum: [development, staging, production]
- name: LOG_LEVEL
enum: [debug, info, warn, error]
cmds:
- echo "Deploying to {{.ENVIRONMENT}} with log level {{.LOG_LEVEL}}"
- ./deploy.sh
# Requirements with enum from variable reference
reusable-deploy:
requires:
vars:
- name: ENVIRONMENT
enum:
ref: .ALLOWED_ENVS
cmds:
- ./deploy.sh
See Prompting for missing variables interactively for information on enabling interactive prompts for missing required variables.
watchboolfalsetasks:
dev:
watch: true
cmds:
- npm run dev
platforms[]stringtasks:
windows-build:
platforms: [windows]
cmds:
- go build -o app.exe ./cmd
unix-build:
platforms: [linux, darwin]
cmds:
- go build -o app ./cmd
Individual command configuration within a task.
tasks:
example:
cmds:
- echo "Simple command"
- ls -la
tasks:
example:
cmds:
- cmd: echo "Hello World"
silent: true
ignore_error: false
platforms: [linux, darwin]
set: [errexit]
shopt: [globstar]
tasks:
example:
cmds:
- task: other-task
vars:
PARAM: value
silent: false
tasks:
with-cleanup:
cmds:
- echo "Starting work"
# Deferred command string
- defer: echo "Cleaning up"
# Deferred task reference
- defer:
task: cleanup-task
vars:
CLEANUP_MODE: full
tasks:
greet-all:
cmds:
- for: [alice, bob, charlie]
cmd: echo "Hello {{.ITEM}}"
tasks:
process-files:
sources: ['*.txt']
cmds:
- for: sources
cmd: wc -l {{.ITEM}}
- for: generates
cmd: gzip {{.ITEM}}
tasks:
process-items:
vars:
ITEMS: 'item1,item2,item3'
cmds:
- for:
var: ITEMS
split: ','
as: CURRENT
cmd: echo "Processing {{.CURRENT}}"
tasks:
test-matrix:
cmds:
- for:
matrix:
OS: [linux, windows, darwin]
ARCH: [amd64, arm64]
cmd: echo "Testing {{.ITEM.OS}}/{{.ITEM.ARCH}}"
tasks:
build-all:
deps:
- for: [frontend, backend, worker]
task: build
vars:
SERVICE: '{{.ITEM}}'
Use if to conditionally execute a command. If the shell command exits with a
non-zero code, the command is skipped.
tasks:
build:
cmds:
# Only run in production
- cmd: echo "Optimizing for production"
if: '[ "$ENV" = "production" ]'
# Using Go templates
- cmd: echo "Feature enabled"
if: '{{eq .ENABLE_FEATURE "true"}}'
# Inside for loops (evaluated per iteration)
- for: [a, b, c]
cmd: echo "processing {{.ITEM}}"
if: '[ "{{.ITEM}}" != "b" ]'
Available set options for POSIX shell features:
allexport / a - Export all variableserrexit / e - Exit on errornoexec / n - Read commands but don't executenoglob / f - Disable pathname expansionnounset / u - Error on undefined variablesxtrace / x - Print commands before executionpipefail - Pipe failures propagate# Global level
set: [errexit, nounset, pipefail]
tasks:
debug:
# Task level
set: [xtrace]
cmds:
- cmd: echo "This will be traced"
# Command level
set: [noexec]
Available shopt options for Bash features:
expand_aliases - Enable alias expansionglobstar - Enable ** recursive globbingnullglob - Null glob expansion# Global level
shopt: [globstar]
tasks:
find-files:
# Task level
shopt: [nullglob]
cmds:
- cmd: ls **/*.go
# Command level
shopt: [globstar]