claude-code - 💡(How to fix) Fix [BUG] TeamDelete fails on stale teams after session crash - must delete files manually to remove/reuse team name [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#53160Fetched 2026-04-26 05:22:51
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×4renamed ×1

Error Message

Error Messages/Logs

Fix Action

Fix / Workaround

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

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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

extent analysis

TL;DR

Implement a mechanism to automatically detect and clean up stale sessions, or introduce a --force flag for TeamCreate to overwrite existing configurations.

Guidance

  • Introduce a --force flag for TeamCreate to overwrite existing configurations when a stale session is detected.
  • Modify TeamDelete to accept a --team-name parameter, allowing deletion by team name without relying on the session context.
  • Implement auto-detection of stale sessions by checking if the process associated with the leadSessionId is alive, and automatically clean up the configuration if it's not.
  • Consider adding a warning or prompt when a stale session is detected, to inform the user of the potential issue and the available workarounds.

Example

# Example of how TeamCreate could be modified to accept a --force flag
TeamCreate --force --team-name myteam

Notes

The exact implementation details will depend on the internal workings of the Claude Code system, but the general approach should be to prioritize automatic detection and cleanup of stale sessions, with user-facing workarounds as a fallback.

Recommendation

Apply a workaround, such as introducing a --force flag for TeamCreate, as this is a more immediate and user-friendly solution than waiting for a potential fix in a future version.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] TeamDelete fails on stale teams after session crash - must delete files manually to remove/reuse team name [1 participants]