Task: Define Tasks in a Taskfile.yml
Task is a task runner that executes tasks declared in a YAML Taskfile.yml.
Task (the go-task project at taskfile.dev) is a make alternative configured entirely in YAML. Each task is a named list of commands you run by name.
What it does
Task reads Taskfile.yml from the working directory. The top-level tasks map names each task; its cmds list holds the shell commands to run. Running task <name> runs that task; task with no argument runs the task named default. The version key declares the Taskfile schema version (use "3").
Common usage
# Taskfile.yml
version: '3'
tasks:
default:
cmds:
- task: build
build:
cmds:
- go build ./...
test:
cmds:
- go test ./...
# run them
# task build
# task testSyntax
| Key / command | What it does |
|---|---|
| version: '3' | Declares the Taskfile schema version |
| tasks: | Top-level map of task name to definition |
| cmds: | List of shell commands the task runs |
| task <name> | Run the named task |
| task | Run the task named default |
| -t <file> / --taskfile | Use a specific Taskfile |
In CI
Keep one Taskfile.yml at the repo root and call task lint, task test, task build as steps. Because the YAML is in the repo, the pipeline and local runs execute the exact same commands. Pin the Task version on the runner so schema features behave consistently.
Common errors in CI
"task: No Taskfile found. Walked up to the root directory" means there is no Taskfile.yml in the tree; add --taskfile or fix the working directory. "task: Task X does not exist" is a typo or a task in an unincluded file. A YAML indentation mistake gives "yaml: line N: ..." before any task runs.