Task documentation for coding agents
Task is a cross-platform task runner and build tool. Its configuration file is normally named Taskfile.yml, and new files should use schema version 3.
Every page linked below is also available as raw Markdown: append .md to its URL. The curated index is at /llms.txt and the full corpus at /llms-full.txt.
Where to look
- Quick Start: the shape of a Taskfile.
- Taskfile Schema: the source of truth for keys, types and accepted values. Check here before assuming a field exists.
- CLI: commands, flags and exit codes.
- Templating: every template function and special variable. Check here before inventing one.
- Guide: task definitions, inputs, execution and shared Taskfiles.
- Errors and cleanup: failure handling and
defer. - Secret variables: masking and its limits.
- Resolution order and Task dependencies: for when the behaviour matters more than the procedure.
Semantics that are easy to get wrong
varsare not exported tocmds: use templates to read them there. Dynamic variables (sh:) also receive previously resolved scalar variables in their shell environment.envis exported to commands. Root-levelenvalso participates in templates; task-levelenvdoes not. A template keeps any value resolved from other sources, or renders empty if none exists.- A constant in a task's own
vars:overrides the command line. Put the default in globalvars:, or use a template such asNAME: '{{.NAME | default "World"}}'to preserve caller input. - The included Taskfile's own
vars:are applied afterincludes.vars. A constant overrides the include's value; a self-referencing template withdefaultcan preserve it. - Everything in
depsmay run concurrently and in any order. Atask:reference insidecmdsruns at its position and blocks the next command. If order matters, usecmds. - Each command runs in its own shell. Nothing carries over between them, not
cdand not an exported variable. Use Task'sdir:andenv:instead. - A template renders text. Use
ref:to pass an array or a map without flattening it to a string. - A passing
status:means the task is already up to date and is skipped. A failingpreconditions:means the task must not run at all. They are not interchangeable. defer:commands run in reverse order of declaration, and run whether the task succeeded or failed.- Remote Taskfiles execute code from wherever they are fetched. See Remote Taskfiles for the trust and checksum rules.
- Portability is about every command inside a task, not just Task itself. A task is only cross-platform if its commands are.
Before writing a Taskfile
- Confirm the feature exists in the schema for the version in use.
- Prefer plain, readable tasks over dense templating.
- Use
depsonly where concurrent execution is actually correct. - Never embed credentials. Read them from the environment or a secret manager.
secret: truemasks a value in Task's own logs, but it only works onvars:, not onenv:, and it never masks what a command itself prints. Treat it as one less place a secret is echoed, not as protection. - Give tasks a
desc:so they show up intask --list, and validate inputs withrequires:orpreconditions:.