[BUG] Agent Teams: EEXIST error when spawning teammates after TeamCreate

Resolved 💬 2 comments Opened Feb 23, 2026 by deadczarvc Closed Mar 23, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When using Agent Teams, spawning teammates via the Task tool with team_name immediately after TeamCreate fails with an EEXIST error. The internal mkdir call for the task directory does not use { recursive: true }, so it fails when the directory already exists (created by TeamCreate).

This happens consistently — even with parallel spawning of multiple teammates.

What Should Happen?

Task with team_name should succeed immediately after TeamCreate without any intermediate cleanup steps. The directory creation should use { recursive: true } or check for existence before creating.

Steps to Reproduce

  1. Enable Agent Teams: CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
  2. Call TeamCreate("my-team")
  3. Immediately call Task with team_name: "my-team" to spawn a teammate
  4. Observe EEXIST error

Workaround

The only reliable workaround is a delete-recreate pattern:

TeamCreate("my-team") → TeamDelete → TeamDelete → TeamCreate("my-team") → Task(team_name: "my-team")

The double TeamDelete is required because a single call doesn't fully clear the in-memory state (related to #23428).

This workaround has been validated across 3 battle tests (v1, v2, v3) with up to 3 concurrent teammates.

Error Messages/Logs

EEXIST: file already exists, mkdir '~/.claude/tasks/my-team'

(The exact path varies by team name)

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.1.50

Platform

Anthropic API

Operating System

Windows 11 Pro (Git Bash / MSYS2)

Terminal/Shell

Bash (Git for Windows)

Additional Information

  • Tested on Windows 11, in-process teammate mode
  • The root cause appears to be in the task directory creation code path — it uses fs.mkdirSync() without { recursive: true }
  • The TeamCreate tool creates ~/.claude/teams/{name}/ and ~/.claude/tasks/{name}/, then Task with team_name tries to create the same task directory again
  • This has been a known issue since at least v2.1.34 (February 2026)
  • Battle test reports with detailed reproduction data available

View original on GitHub ↗

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