You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Include multiple task files, while file remain in the included tasks directory #2878
Taskfile is great! I split my task files into multiple tasks, and they behave like a namespace. I have multiple modules in my application, and one root taskfile. I want to call certain tasks per module, and in the root file, I want to call them anyway, kinda like a namespace.
module/
taskfile.yaml
taskfile.yaml
In i can call:
task module:do-something
Or from the module I can
cd module/
task do-something
The problem is, with current taskfile syntax, when I include those files, I need to pass in the path of the file twice, once as a taskfile, and once as a dir:
include:
taskfile: module/
dir: module/
It's very tedious, redundant, and it's error-prone. It happened to me multiple times that by mistake I typed in incorrect path for the taskfile and dir.
It would be awesome, if there was another key word like include, maybe we can name it namespace, that allows to inlucde the taskfile with the dir that's already in that taskfile. It would help be greatly. Here's a screenshort from my actual project, and what it would look like:
You can see it greatly increases readability, and makes it less error-prone.
With a caveat that the working dir of the included taskfiles will be the current dir. However, that can be circumvented by setting the dir of included tasks to TASKFILE_DIR like this:
tasks:
foo:
dir: '{{.TASKFILE_DIR}}'
cmd: pwd
Now, if you would like to keep your namespace idea, that is possible too. Write a simple yq script/task to convert your namespace into the formal includes schema. Run that task and rewrite your main taskfile. CoPilot or some other AI agent can help you write that yq script, its very effective.
With a caveat that the working dir of the included taskfiles will be the current dir.
I know it already exists. In the screenshot, on the righthand-side, I included the usages of includes.
However, that can be circumvented by setting the dir of included tasks to TASKFILE_DIR like this:
tasks:
foo:
dir: '{{.TASKFILE_DIR}}'
cmd: pwd
Now, if you would like to keep your namespace idea, that is possible too. Write a simple yq script/task to convert your namespace into the formal includes schema. Run that task and rewrite your main taskfile. CoPilot or some other AI agent can help you write that yq script, its very effective.
The solution you proposed just moves the dir: from one place to the other. Previously it was in the including task, and now it's in the included task. But the purpose behind this namespace feature, is that I'd like to remove usage of dir: all together, to make it more reliable, easier, more streamlined and less errorprone.
It would be helpful, if there was a way to set dir: '{{.TASKFILE_DIR}}' for all tasks in the taskfile, in the top level. But adding that one by one, remembering to include it in other/new tasks, added syntax which increases the volume of it, that's not good.
Please, notice in my first post, the current taskfile I have to deal with. The paths are getting longer, and I already had hases where I mixed up the include path and the dir path.
I need the feature for namespace, because I literally have zero use-case for including a task, that should work in my current directory.
All my task files operate on files that are in directories, that the taskfiles reside. Including them with the directory of the current one, in my use-case makes no sense; and it's an additional trouble for me to keep including dir everytime.
People in my team are pushing for leaving task all together, and moving to something like nx because of this very issue.
Activity
trulede commentedon Jun 12, 2026
This already exists in task:
https://taskfile.dev/docs/guide#including-other-taskfiles
With a caveat that the working dir of the included taskfiles will be the current dir. However, that can be circumvented by setting the dir of included tasks to
TASKFILE_DIRlike this:Now, if you would like to keep your
namespaceidea, that is possible too. Write a simpleyqscript/task to convert yournamespaceinto the formalincludesschema. Run that task and rewrite your main taskfile. CoPilot or some other AI agent can help you write thatyqscript, its very effective.danon commentedon Jun 12, 2026
I know it already exists. In the screenshot, on the righthand-side, I included the usages of
includes.The solution you proposed just moves the
dir:from one place to the other. Previously it was in the including task, and now it's in the included task. But the purpose behind thisnamespacefeature, is that I'd like to remove usage ofdir:all together, to make it more reliable, easier, more streamlined and less errorprone.It would be helpful, if there was a way to set
dir: '{{.TASKFILE_DIR}}'for all tasks in the taskfile, in the top level. But adding that one by one, remembering to include it in other/new tasks, added syntax which increases the volume of it, that's not good.andreynering commentedon Jun 13, 2026
Reopening as on Discord we’re discussing about improving UX in this.
danon commentedon Jun 14, 2026
Please, notice in my first post, the current taskfile I have to deal with. The paths are getting longer, and I already had hases where I mixed up the include path and the dir path.
I need the feature for
namespace, because I literally have zero use-case for including a task, that should work in my current directory.All my task files operate on files that are in directories, that the taskfiles reside. Including them with the directory of the current one, in my use-case makes no sense; and it's an additional trouble for me to keep including
direverytime.People in my team are pushing for leaving task all together, and moving to something like
nxbecause of this very issue.