Task (go-task) - Modern Task Runner Cheatsheet
Task (a.k.a. go-task) is a task runner and build tool that aims to be a simpler Make alternative. You define tasks in a YAML Taskfile.yml — with dependencies, variables, includes, and up-to-date checks — and run them with task <name>. It is written in Go and ships as a single dependency-free binary, with cross-platform behavior and built-in file watching. It is a strong choice when your team prefers YAML over Make’s syntax.
Installation
| Platform | Command |
|---|
| Script | sh -c "$(curl -sSL https://taskfile.dev/install.sh)" |
| macOS/Linux (Homebrew) | brew install go-task |
| Arch Linux | sudo pacman -S go-task |
| Go install | go install github.com/go-task/task/v3/cmd/task@latest |
| Windows (Scoop) | scoop install task |
| Verify | task --version |
A Basic Taskfile
# Taskfile.yml
version: '3'
vars:
BINARY: myapp
tasks:
build:
desc: Build the binary
cmds:
- go build -o {{.BINARY}} ./cmd/app
test:
desc: Run tests
cmds:
- go test ./...
ci:
desc: Lint, test, build
deps: [test]
cmds:
- task: build
Running Tasks
| Command | Description |
|---|
task | Run the default task |
task build | Run a named task |
task test build | Run several tasks in order |
task --list (-l) | List tasks with descriptions |
task --list-all | List all tasks (incl. no-desc) |
task --summary build | Show a task’s detail |
task VAR=value build | Pass a variable |
task -- arg1 arg2 | Forward CLI args to the task ({{.CLI_ARGS}}) |
Dependencies & Ordering
| Key | Behavior |
|---|
deps: [a, b] | Run a and b (in parallel) before this task |
cmds: [{task: x}] | Call another task as a step (sequential) |
deps parallelism | Dependencies run concurrently by default |
--parallel | Run given tasks in parallel |
Up-to-Date Checks (Skip Unneeded Work)
tasks:
build:
sources:
- "**/*.go"
generates:
- myapp
cmds:
- go build -o myapp ./cmd/app
| Key | Effect |
|---|
sources | Inputs to fingerprint |
generates | Expected outputs |
| `method: checksum | timestamp |
status: [ ... ] | Custom shell checks for up-to-date |
If sources are unchanged, Task skips the command.
Variables & Templating
| Feature | Example |
|---|
| Task/global vars | vars: { NAME: value } |
| Env vars | env: { CGO_ENABLED: "0" } |
| Dotenv | dotenv: ['.env'] |
| Templating | {{.NAME}}, {{.CLI_ARGS}}, Go template funcs |
| Dynamic vars | sh: to compute a var from a command |
Includes & Watching
| Feature | How |
|---|
| Includes | includes: { docs: ./docs/Taskfile.yml } → task docs:build |
| Namespacing | Included tasks are called namespace:task |
| Watch mode | task --watch build (rerun on source changes) |
-w | Short form of --watch |
Common Workflows
# Discover what a project can do
task --list
# Run CI locally exactly as the pipeline does
task ci
# Iterate: rebuild on every source change
task --watch build
# Pass through arguments
task test -- -run TestLogin
Task vs Make vs just
| Aspect | Task | Make | just |
|---|
| Syntax | YAML | Makefile | just recipes |
| Language | Go (single binary) | C (ubiquitous) | Rust |
| Up-to-date checks | Yes (sources/generates) | Yes (timestamps) | No (command runner) |
| File watching | Built-in (--watch) | No | No (pair with watchexec) |
| Best for | YAML fans, cross-platform | Classic build graphs | Simple command running |
See also just for a command-runner alternative and watchexec for standalone file watching.
Resources