[FEATURE] Add cwd parameter to Task tool for setting subagent working directory (to support Git worktrees)

Open 💬 13 comments Opened Nov 30, 2025 by YPares

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Use case: Launching parallel agents in different Git worktrees or JJ workspaces, where each agent should work in its dedicated workspace directory throughout its execution.

When launching subagents with the Task tool, it would be useful to specify a working directory. Currently, subagents inherit the parent's PWD and need to prefix every Bash command with cd /path &&, which is verbose and error-prone.

Proposed Solution

  Task(
    subagent_type="general-purpose",
    description="Complete Feature A",
    prompt="...",
    cwd="/path/to/workspace-a"  # ← new parameter
  )

Priority

Medium - Would be very helpful

Feature Category

Developer tools/SDK

Use Case Example

I use a top-level agent to devise a graph of tasks (with JJ), and start sub-agents to work on each of them, possibly several in parallel when tasks do not depend on each other (see https://github.com/YPares/agent-skills/tree/master/jj-todo-workflow).

Using subagents in parallel means that each one should have its own folder (worktree), and asking them to prefix each command by cd .../project-worktreeXXX is cumbersome and error-prone.

View original on GitHub ↗

This issue has 13 comments on GitHub. Read the full discussion on GitHub ↗