[BUG] TeamDelete fails on stale teams after session crash - must delete files manually to remove/reuse team name

Resolved 💬 1 comment Opened Apr 25, 2026 by mpercy Closed May 28, 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 a Claude Code session crashes (e.g., machine reboot, OOM), the team config at ~/.claude/teams/{name}/config.json retains the dead session's leadSessionId. In a new session, neither TeamCreate nor TeamDelete can operate:

  • TeamDelete returns "No team name found" — the new session's ID doesn't match the stale leadSessionId in the config
  • TeamCreate returns "Team already exists" — the directory is still on disk

This creates a deadlock where the only workaround is manually rm -rf ~/.claude/teams/{name}, which loses task history and member registry.

This creates friction if you are running agent teams set up to generate fomulaic team names.

What Should Happen?

Probably one of:

  • TeamCreate --force overwrites stale config
  • TeamDelete accepts a --team-name parameter to delete by name without session context
  • Auto-detection of stale sessions (check if leadSessionId process is alive) with automatic cleanup

Error Messages/Logs

Steps to Reproduce

  1. Claude Code agent creates a team with the TeamCreate tool
  2. Spawn agents with the Agent tool using team_name
  3. Kill the session (e.g., machine reboot, kill -9 claude, etc
  4. Start a new Claude Code session
  5. Try TeamDelete → "No team name found"
  6. Try TeamCreate with the same name → "already exists"

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.1.119

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗