Include multiple task files, while file remain in the included tasks directory · Issue #2878 · go-task/task · GitHub
Skip to content

Include multiple task files, while file remain in the included tasks directory #2878

Description

@danon

Description

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:

Image

You can see it greatly increases readability, and makes it less error-prone.

Activity

  1. added theissue type on Jun 12, 2026
  2. trulede commented on Jun 12, 2026

    @trulede
    Contributor

    This already exists in task:
    https://taskfile.dev/docs/guide#including-other-taskfiles

    version: '3'
    
    includes:
      docs: ./documentation 
      docker: ./docker
    

    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.

  3. danon commented on Jun 12, 2026

    @danon
    Author

    This already exists in task: https://taskfile.dev/docs/guide#including-other-taskfiles

    version: '3'
    
    includes:
      docs: ./documentation 
      docker: ./docker
    

    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.

  4. andreynering commented on Jun 13, 2026

    @andreynering
    Member

    Reopening as on Discord we’re discussing about improving UX in this.

  5. danon commented on Jun 14, 2026

    @danon
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for support.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions