MCPcopy Index your code
hub / github.com/codeaashu/claude-code / cleanupTeamDirectories

Function cleanupTeamDirectories

src/utils/swarm/teamHelpers.ts:641–683  ·  view source on GitHub ↗
(teamName: string)

Source from the content-addressed store, hash-verified

639 * Called when a swarm session is terminated.
640 */
641export async function cleanupTeamDirectories(teamName: string): Promise<void> {
642 const sanitizedName = sanitizeName(teamName)
643
644 // Read team file to get worktree paths BEFORE deleting the team directory
645 const teamFile = readTeamFile(teamName)
646 const worktreePaths: string[] = []
647 if (teamFile) {
648 for (const member of teamFile.members) {
649 if (member.worktreePath) {
650 worktreePaths.push(member.worktreePath)
651 }
652 }
653 }
654
655 // Clean up worktrees first
656 for (const worktreePath of worktreePaths) {
657 await destroyWorktree(worktreePath)
658 }
659
660 // Clean up team directory (~/.claude/teams/{team-name}/)
661 const teamDir = getTeamDir(teamName)
662 try {
663 await rm(teamDir, { recursive: true, force: true })
664 logForDebugging(`[TeammateTool] Cleaned up team directory: ${teamDir}`)
665 } catch (error) {
666 logForDebugging(
667 `[TeammateTool] Failed to clean up team directory ${teamDir}: ${errorMessage(error)}`,
668 )
669 }
670
671 // Clean up tasks directory (~/.claude/tasks/{taskListId}/)
672 // The leader and teammates all store tasks under the sanitized team name.
673 const tasksDir = getTasksDir(sanitizedName)
674 try {
675 await rm(tasksDir, { recursive: true, force: true })
676 logForDebugging(`[TeammateTool] Cleaned up tasks directory: ${tasksDir}`)
677 notifyTasksUpdated()
678 } catch (error) {
679 logForDebugging(
680 `[TeammateTool] Failed to clean up tasks directory ${tasksDir}: ${errorMessage(error)}`,
681 )
682 }
683}
684

Callers 2

callFunction · 0.85
cleanupSessionTeamsFunction · 0.85

Calls 10

readTeamFileFunction · 0.85
destroyWorktreeFunction · 0.85
getTeamDirFunction · 0.85
rmFunction · 0.85
logForDebuggingFunction · 0.85
getTasksDirFunction · 0.85
notifyTasksUpdatedFunction · 0.85
sanitizeNameFunction · 0.70
errorMessageFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected