/rh-virt:vm-deletefrom rh-virt
Permanently delete virtual machines and their associated resources from OpenShift Virtualization. Use when: - "Delete VM [name]" - "Remove virtual machine [name]" - "Destroy VM [name]" - "Clean up VM [name]" This skill handles permanent VM deletion with strict safety confirmations and typed verification. NOT for power management (use vm-lifecycle-manager to stop VMs).
Ships in rh-virt. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Permanently delete virtual machines and their associated resources (storage, DataVolumes) from OpenShift Virtualization clusters. This skill enforces strict safety protocols including typed confirmation and pre-deletion validation.
Required MCP Server: openshift-virtualization (OpenShift MCP Server)
Required MCP Tools:
resources_get (from openshift-virtualization) - Verify VM exists and get detailsresources_delete (from openshift-virtualization) - Delete Kubernetes resourcesresources_list (from openshift-virtualization) - List dependent resources (PVCs, DataVolumes)resources_create_or_update (from openshift-virtualization) - Update resources (e.g., remove finalizers)vm_lifecycle (from openshift-virtualization) - Stop running VMs before deletionpods_list_in_namespace (from openshift-virtualization) - List pods for diagnosticsRequired Environment Variables:
KUBECONFIG - Path to Kubernetes configuration file with cluster accessRequired Cluster Setup:
Before executing:
openshift-virtualization exists in mcps.json → If missing, report setupKUBECONFIG is set (presence only, never expose value) → If missing, reportHuman Notification Protocol: ❌ Cannot execute vm-delete: MCP server not available. Setup: Add to mcps.json, set KUBECONFIG, restart Claude Code. Docs: https://github.com/openshift/openshift-mcp-server
⚠️ SECURITY: Never display KUBECONFIG path or credential values.
Trigger when:
/vm-delete commandUser phrases:
Do NOT use when:
/vm-lifecycle-manager/vm-create/vm-inventoryCRITICAL: Complete ALL validation BEFORE user confirmation.
Required from user: VM Name, Namespace
1.1: Verify VM Exists
MCP Tool: resources_get (apiVersion="kubevirt.io/v1", kind="VirtualMachine", namespace=<ns>, name=<vm>)
Errors:
1.2: Check Protection Label
Check metadata.labels for protected: "true".
If protected: Report: ❌ Cannot Delete Protected VM. VM has protected label. Remove: oc label vm <vm> -n <ns> protected-. Operation cancelled. STOP workflow.
1.3: Check Running State
Check status.printableStatus (Running/Starting/Migrating = running, Stopped/Halted = stopped).
If running: Report: ⚠️ VM Running. Must stop before deletion. Options: stop-and-delete / cancel Wait for response.
1.4: Stop VM (if applicable)
ONLY if user chose "stop-and-delete".
MCP Tool: vm_lifecycle (namespace=<ns>, name=<vm>, action="stop")
Report: ⏸️ Stopping VM... Wait 10-30s. Wait 10s, verify stopped.
1.5: Discover Storage
MCP Tool: resources_list
DataVolumes: apiVersion="cdi.kubevirt.io/v1beta1", kind="DataVolume", namespace=<ns>, labelSelector="vm.kubevirt.io/name=<vm>"
PVCs (if no DVs): apiVersion="v1", kind="PersistentVolumeClaim", namespace=<ns>, labelSelector="vm.kubevirt.io/name=<vm>"
Parse: Extract names, calculate total storage size.
Display deletion scope in this format:
## ⚠️ VM Deletion - Review Scope
**VM**: `<vm>` | **Namespace**: `<ns>` | **Status**: <Stopped/Running>
**Resources**: VM `<vm>` (Age: <age>, vCPU: <cpu>, Memory: <mem>)
**Storage**: DataVolume `<dv>` (30Gi), PVC `<pvc>` (30Gi) - Total: 30Gi
OR **Storage**: None (ephemeral)
### Deletion Options
**1: VM Only** - Preserves storage for reuse
**2: VM + Storage** ← Recommended (test/dev) - Frees storage
**3: Cancel**
Select (1, 2, or 3):
Wait for selection. Handle: 3→Cancel, 1→delete_storage=false, 2→delete_storage=true
CRITICAL: User MUST type exact VM name.
Display typed confirmation prompt (adjust based on delete_storage flag):
## 🔴 PERMANENT DELETION - Typed Confirmation Required
**CANNOT BE UNDONE**
**Will delete**:
✗ VirtualMachine: `<vm>` (namespace: `<ns>`)
[If delete_storage=true, show:]
✗ DataVolume: `<dv>` | ✗ PVC: `<pvc>` | ✗ All data lost
[If delete_storage=false, show:]
✓ Storage PRESERVED
Type `<vm>` to confirm: _____
Validation:
❌ Confirmation Failed. You typed: <input>. Expected: <vm>. Cancelled. STOP.ONLY AFTER: ✓ Validation ✓ Option selected ✓ Typed name confirmed
4.1: Delete VM
MCP Tool: resources_delete (apiVersion="kubevirt.io/v1", kind="VirtualMachine", namespace=<ns>, name=<vm>)
Errors: Fails → Report, don't delete storage; Not found → Continue
Report: 🗑️ Deleting VM... ✓ Deleted
4.2: Delete Storage (if delete_storage=true)
For each DataVolume:
MCP Tool: resources_delete (apiVersion="cdi.kubevirt.io/v1beta1", kind="DataVolume", namespace=<ns>, name=<dv>)
For each PVC:
MCP Tool: resources_delete (apiVersion="v1", kind="PersistentVolumeClaim", namespace=<ns>, name=<pvc>)
Errors: Report which failed, continue with others
Report: 🗑️ Deleting storage... ✓ DV deleted (storage freed) ✓ PVC deleted
Success (with storage):
## ✓ VM Deleted (Complete Cleanup)
**Deleted**: VM + DataVolume + PVC | **Freed**: <size>
**Impact**: Permanent removal. Cannot recover.
**Verify**: "List VMs in namespace <ns>" - VM should not appear
Success (storage preserved):
## ✓ VM Deleted (Storage Preserved)
**Deleted**: VM | **Preserved**: DataVolume + PVC (<size>)
**Reuse**: Create new VM with existing DV/PVC
**Delete later**: `oc delete datavolume <dv> -n <ns>`
Partial failure (storage failed):
OPTIONAL: Read storage-errors.md for PVC cleanup. Output: "Consulted storage-errors.md for failure."
## ⚠️ Partial Deletion
**Deleted**: VM | **Failed**: DV/PVC (error: <error>)
**Action**: Manual cleanup: `oc delete datavolume <dv> -n <ns>`
Complete failure:
OPTIONAL: Read lifecycle-errors.md for deletion failures. Output: "Consulted lifecycle-errors.md for failure causes."
## ❌ VM Deletion Failed
**Error**: <error>
**Troubleshooting**: Check permissions, verify VM exists, check finalizers (see lifecycle-errors.md)
Error: "VirtualMachine not found" Solution: Verify name/namespace with vm-inventory. Check spelling.
Error: "Forbidden: Cannot delete VirtualMachines"
Solution: Verify delete permissions for VirtualMachine and PVC. Contact admin. Check: oc auth can-i delete virtualmachines -n <ns>
Error: "VM deletion blocked by finalizers"
Solution: Consult lifecycle-errors.md "VM Stuck in Terminating" for MCP-first approach using resources_get to check finalizers, resources_create_or_update to remove if needed.
Error: "PVC deletion failed: resource in use"
Solution: Verify VM deleted first. Consult storage-errors.md for MCP-first diagnostics using pods_list_in_namespace to check mounts, resources_get for PVC status.
Error: "Names do not match" Solution: Type exact VM name (case-sensitive). Copy-paste from deletion scope. Retry.
Error: "VM has protected label"
Solution: Remove: oc label vm <vm> -n <ns> protected-. Retry deletion.
openshift-virtualization - OpenShift MCP with KubeVirt toolset (https://github.com/openshift/openshift-mcp-server)resources_get - Get VM (apiVersion, kind, namespace, name)resources_delete - Delete resources (apiVersion, kind, namespace, name)resources_list - List resources (apiVersion, kind, namespace, labelSelector)resources_create_or_update - Update resources (resource JSON) - for finalizer removalvm_lifecycle - VM lifecycle (namespace, name, action: stop)pods_list_in_namespace - List pods (namespace) - for PVC mount diagnosticsvm-lifecycle-manager - Stop VMs | vm-inventory - List VMs | vm-create - Create VMs | vm-clone - Clone VMsCRITICAL: IRREVERSIBLE operations. You MUST:
Pre-Deletion Validation (Execute FIRST)
resources_get)protected: "true")Safety Checks
Typed Confirmation (MANDATORY)
Deletion Options
Never Auto-Execute
Why: Permanent data loss, service impact, accidental deletion prevention
protected: "true" blocks deletion--force or --grace-period=0User: "Delete test-vm in dev"
Agent: [Validates ✓, discovers 30Gi storage]
[Shows deletion scope - see Step 2 format]
User: "2" [VM+Storage]
Agent: [Shows typed confirmation - see Step 3 format]
User: "test-vm"
Agent: [Executes: VM ✓, DV ✓, PVC ✓]
[Shows success report - see Step 5 format]
## ✓ VM Deleted (Complete Cleanup) | Freed: 30Gi
User: "Remove web-server but keep storage"
Agent: [Validates, shows scope]
User: "1" [VM only]
Agent: [Typed confirmation]
User: "web-server"
Agent: [Executes deletion]
## ✓ VM Deleted (Storage Preserved) | Preserved: 50Gi
User: "Delete production-db"
Agent: [Validates: protected label found]
❌ Cannot Delete Protected VM. Remove label: oc label vm production-db protected-
User: "Delete api-server"
Agent: [Validates: VM running]
⚠️ VM Running. Options: stop-and-delete / cancel
User: "stop-and-delete"
Agent: [Stops VM, waits, continues with deletion]
User: "Delete test-vm"
Agent: [Shows typed confirmation]
Type `test-vm` to confirm:
User: "wait, cancel"
❌ Confirmation Failed. You typed: wait, cancel. Expected: test-vm. Cancelled.
User: "What would be deleted if I delete test-vm?"
Agent: [Execute Step 1-2 only, stop before confirmation]
## 🔍 Deletion Preview
**Would delete (Option 2)**: VM + DV + PVC (30Gi freed)
This is preview only. No resources deleted.
Delete multiple VMs: "Delete VMs test-01, test-02, test-03 in dev" → Process each VM individually through the full workflow (Steps 1-5), requiring typed confirmation of each VM name separately. Never use a generic batch confirmation — each VM must be confirmed by its exact name.
Show deletion scope without executing: Execute Step 1-2, skip Steps 3-4. User request: "Show what would be deleted if I delete VM xyz"
Automatic enforcement: If VM has protected: "true" label, refuse deletion in Step 1.2. Example YAML: metadata.labels.protected: "true"
references/README.md (opens in a new tab)references/SOURCES.md (opens in a new tab)references/troubleshooting/INDEX.md (opens in a new tab)references/troubleshooting/lifecycle-errors.md (opens in a new tab)references/troubleshooting/network-errors.md (opens in a new tab)references/troubleshooting/runtime-errors.md (opens in a new tab)references/troubleshooting/scheduling-errors.md (opens in a new tab)references/troubleshooting/storage-errors.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
inheritOther plugins' skills for the same job
npx claudepluginhub rhecosystemappeng/agentic-catalog --plugin rh-virt10 skills in this plugin
/vm-cloneClone existing virtual machines for testing, scaling, or creating templates.
Use when:
- "Clone VM [source] to [target]"
- "Create a copy of VM [name]"
- "Duplicate VM [name] for testing"
- "Create 3 copies of template-vm"
This skill clones VM configuration and optionally creates new storage or references existing storage.
NOT for snapshots (use vm-snapshot for point-in-time backups).
/vm-createCreate new virtual machines in OpenShift Virtualization with automatic instance type resolution and OS selection.
Use when:
- "Create a new VM"
- "Deploy a virtual machine with [OS]"
- "Set up a VM in namespace [name]"
- "Provision a [size] VM"
This skill handles VM creation with intelligent defaults for OpenShift Virtualization.
NOT for managing existing VMs (use vm-lifecycle-manager or vm-delete instead).
/vm-inventoryList and view virtual machines across namespaces with status, resource usage, and health information.
Use when:
- "List all VMs"
- "Show VMs in namespace [name]"
- "What VMs are running?"
- "Get details of VM [name]"
This skill provides comprehensive VM inventory and status reporting.
NOT for creating or modifying VMs (use vm-create or vm-lifecycle-manager instead).
/vm-lifecycle-managerManage virtual machine lifecycle operations including start, stop, and restart.
Use when:
- "Start VM [name]"
- "Stop the virtual machine [name]"
- "Restart VM [name]"
- "Power on/off VM [name]"
This skill handles VM state transitions safely with user confirmation for each action.
NOT for creating VMs (use vm-create) or deleting VMs (use vm-delete).
/vm-rebalanceOrchestrate VM migrations across cluster nodes for load balancing, maintenance, and resource optimization.
Use when:
- "Move VM database-01 to worker-03"
- "Rebalance VMs to optimize CPU load"
- "Drain worker-02 for maintenance"
- "Automatically rebalance the cluster"
Supports Manual (user-driven) and Automatic (AI-driven) modes.
NOT for creating VMs (use vm-create) or lifecycle only (use vm-lifecycle-manager).
/vm-snapshot-createCreate virtual machine snapshots for backup and recovery.
Use when:
- "Create a snapshot of VM [name]"
- "Backup VM [name] before upgrade"
- "Take a snapshot of [vm]"
Validates storage class snapshot support, CSI driver capabilities, and guest agent status before snapshot creation.
NOT for VM cloning (use vm-clone to create independent copies).