Skip to content

Task (go-task) - Modern Task Runner Cheatsheet

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

PlatformCommand
Scriptsh -c "$(curl -sSL https://taskfile.dev/install.sh)"
macOS/Linux (Homebrew)brew install go-task
Arch Linuxsudo pacman -S go-task
Go installgo install github.com/go-task/task/v3/cmd/task@latest
Windows (Scoop)scoop install task
Verifytask --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

CommandDescription
taskRun the default task
task buildRun a named task
task test buildRun several tasks in order
task --list (-l)List tasks with descriptions
task --list-allList all tasks (incl. no-desc)
task --summary buildShow a task’s detail
task VAR=value buildPass a variable
task -- arg1 arg2Forward CLI args to the task ({{.CLI_ARGS}})

Dependencies & Ordering

KeyBehavior
deps: [a, b]Run a and b (in parallel) before this task
cmds: [{task: x}]Call another task as a step (sequential)
deps parallelismDependencies run concurrently by default
--parallelRun given tasks in parallel

Up-to-Date Checks (Skip Unneeded Work)

tasks:
  build:
    sources:
      - "**/*.go"
    generates:
      - myapp
    cmds:
      - go build -o myapp ./cmd/app
KeyEffect
sourcesInputs to fingerprint
generatesExpected outputs
`method: checksumtimestamp
status: [ ... ]Custom shell checks for up-to-date

If sources are unchanged, Task skips the command.

Variables & Templating

FeatureExample
Task/global varsvars: { NAME: value }
Env varsenv: { CGO_ENABLED: "0" }
Dotenvdotenv: ['.env']
Templating{{.NAME}}, {{.CLI_ARGS}}, Go template funcs
Dynamic varssh: to compute a var from a command

Includes & Watching

FeatureHow
Includesincludes: { docs: ./docs/Taskfile.yml }task docs:build
NamespacingIncluded tasks are called namespace:task
Watch modetask --watch build (rerun on source changes)
-wShort 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

AspectTaskMakejust
SyntaxYAMLMakefilejust recipes
LanguageGo (single binary)C (ubiquitous)Rust
Up-to-date checksYes (sources/generates)Yes (timestamps)No (command runner)
File watchingBuilt-in (--watch)NoNo (pair with watchexec)
Best forYAML fans, cross-platformClassic build graphsSimple command running

See also just for a command-runner alternative and watchexec for standalone file watching.

Resources