[FEATURE] Add cwd parameter to Agent and Bash tools
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
When using the Agent tool to work across multiple workspace directories (e.g., a commit-push skill that commits/pushes in parallel across repos), each spawned agent must prefix every Bash command with cd /path/to/repo && ... to target the correct directory.
This causes a UX problem: commands like cd /path && git status don't match auto-approve permission rules that would normally match git status. Users end up manually approving every single command, which defeats the purpose of parallel agents.
Proposed Solution
Add an optional cwd (or working_directory) parameter to:
- Agent tool — sets the working directory for the spawned agent's entire session
- Bash tool — sets the working directory for that specific command execution
// Agent tool
{
"description": "Commit and push repo",
"prompt": "Run git status, stage files, commit, and push...",
"cwd": "/Users/me/Desktop/my-other-repo"
}
// Bash tool
{
"command": "git status",
"cwd": "/Users/me/Desktop/my-other-repo"
}
This would allow agents to run plain git status instead of cd /some/path && git status, making auto-approve rules work as expected.
Alternative Solutions
- Broader auto-approve rules: Users can widen their Bash permission patterns to match
cd ... && git ..., but this is less secure and more fragile. - Separate Claude sessions: Run one Claude session per repo, but this loses the parallel coordination benefit.
- Related: #23669 requests per-teammate working directory for Agent Teams — this issue generalizes the ask to the Agent tool and Bash tool broadly.
Priority
High - Significant impact on productivity
Feature Category
Developer tools/SDK
Use Case Example
- I have a multi-repo workspace with a primary Rails app and a companion dashboard repo
- I invoke a
/commit-pushskill that launches parallel agents — one per repo - The primary repo agent works fine (inherits parent cwd), but the secondary repo agent must prefix every command with
cd /path/to/dashboard && ... - Every one of those prefixed commands requires manual approval because they don't match my auto-approve rule for bare
gitcommands - With a
cwdparameter, the secondary agent would run plaingit status,git add,git commit, etc. — matching auto-approve rules and requiring zero manual intervention
Additional Context
This is especially impactful for skills/workflows that spawn multiple agents in parallel across repos. The cd prefix workaround negates the speed benefit of parallelism by requiring serial manual approvals.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗