Delete a workspace and its git worktrees
Deletes a workspace and its git worktrees, checking for uncommitted changes before removal.
/plugin marketplace add openshift-eng/ai-helpers/plugin install workspaces@ai-helpers<workspace-name>workspaces:delete
/workspaces:delete <workspace-name>
The workspaces:delete command removes a workspace directory and its associated git worktrees. Before deletion, it checks the status of all repositories in the workspace to detect uncommitted changes or unpushed commits, prompting the user for confirmation when issues are found.
This command helps clean up task workspaces created by /workspaces:create while ensuring no work is accidentally lost.
- [ ] Step 1: Identify workspace and check configuration
- [ ] Step 2: Execute deletion
Get available workspaces (includes configuration check):
${CLAUDE_PLUGIN_ROOT}/commands/delete/list.sh
If the output contains STATUS: NOT_CONFIGURED:
Use AskUserQuestion to ask the user for:
/home/user/git-repos or ~/work/repos)/home/user/workspaces or ~/dev/workspaces)Run list again with the user's paths:
${CLAUDE_PLUGIN_ROOT}/commands/delete/list.sh --repos-root <REPOS_PATH> --workspaces-root <WORKSPACES_PATH>
Verify the output shows CONFIGURATION SAVED before proceeding to Step 2
Match user's input against the workspace list:
Use the workspace NAME (not full path) from Step 1.
Example: If the workspace is at /home/user/workspaces/feature-azure-template-field, use feature-azure-template-field (not the full path).
Execute the deletion script:
${CLAUDE_PLUGIN_ROOT}/commands/delete/execute.sh {WORKSPACE_NAME}
The script will:
Case A: Exit code 0 (success)
The workspace was clean and has been deleted successfully. Report completion to user.
Case B: Exit code 2 (user input required)
The workspace has uncommitted changes or unpushed commits. The status has already been displayed to the user.
Use AskUserQuestion with these options:
Then execute based on user's choice:
If user chose "Keep branches":
${CLAUDE_PLUGIN_ROOT}/commands/delete/execute.sh {WORKSPACE_NAME} --keep-branches
If user chose "Delete branches":
${CLAUDE_PLUGIN_ROOT}/commands/delete/execute.sh {WORKSPACE_NAME} --delete-branches
If user chose "Abort":
Case C: Exit code 1 (error)
An error occurred (e.g., workspace not found, configuration issue). Report the error to the user.