vibe clean
The clean command removes the current worktree and returns you to the main repository.
vibe cleanOptions
Section titled “Options”--force, -f
Section titled “--force, -f”Skip confirmation prompt when uncommitted changes exist.
vibe clean --force--delete-branch
Section titled “--delete-branch”Delete the branch after removing the worktree.
vibe clean --delete-branch--keep-branch
Section titled “--keep-branch”Keep the branch after removing the worktree. This overrides the delete_branch config setting.
vibe clean --keep-branch-V, --verbose
Section titled “-V, --verbose”Show detailed output including git commands being executed.
vibe clean --verbose-q, --quiet
Section titled “-q, --quiet”Suppress non-essential output.
vibe clean --quiet--claude-code-worktree-hook v0.23.0+
Section titled “--claude-code-worktree-hook ”Claude Code WorktreeRemove hook mode. Reads worktree path from stdin and removes the worktree.
vibe clean --claude-code-worktree-hook --forceSee Claude Code Integration for setup details.
Configuration
Section titled “Configuration”Configure default behavior in .vibe.toml:
[clean]delete_branch = true # Delete branch by default when cleaning| Option | Default | Description |
|---|---|---|
delete_branch | false | Delete branch after worktree removal |
Fast Remove (Performance Optimization)
Section titled “Fast Remove (Performance Optimization)”By default, vibe uses a fast removal strategy that moves the worktree directory to a temporary location and deletes it asynchronously in the background. This makes vibe clean feel instant even for large repositories.
Configure this in ~/.config/vibe/settings.json:
{ "version": 3, "clean": { "fast_remove": true }}| Option | Default | Description |
|---|---|---|
fast_remove | true | Use fast async deletion (move + background delete) |
How it works:
The behavior differs by platform:
- macOS: Items are moved to the system Trash via Finder. This allows recovery if needed and ensures reliable cleanup managed by the OS.
- Linux/Windows: Items are moved to the system temp directory (
/tmpor%TEMP%) and deleted in the background usingnohup. Temp directories are automatically cleaned on system reboot.
Detailed process:
- The worktree directory is instantly moved (O(1) rename operation)
- Git worktree metadata is cleaned up on the now-empty directory
- The actual file deletion happens asynchronously in the background
- Previous
.vibe-trash-*directories are automatically cleaned up
Note: If the fast move fails for any reason (e.g., cross-device link error), it automatically falls back to traditional deletion.
Behavior
Section titled “Behavior”Safety Checks
Section titled “Safety Checks”Before removing a worktree, vibe clean:
- Checks for uncommitted changes
- Prompts for confirmation if changes exist
- Runs pre-clean hooks
- Removes the worktree
- Runs post-clean hooks
- Changes directory to the main repository
Uncommitted Changes Warning
Section titled “Uncommitted Changes Warning”$ vibe cleanYou have uncommitted changes. Are you sure you want to clean? (y/N)If you have uncommitted changes, vibe will:
- Show a warning
- Ask for confirmation
- Only proceed if you explicitly confirm
The clean command supports hooks for cleanup tasks:
[hooks]pre_clean = ["git stash"]post_clean = ["echo 'Cleanup complete'"]| Hook | When | Working Directory |
|---|---|---|
pre_clean | Before worktree removal | Current worktree |
post_clean | After worktree removal | Main repository |
Pre-clean Hook Example
Section titled “Pre-clean Hook Example”Save your work before cleaning:
[hooks]pre_clean = [ "git stash --include-untracked", "echo 'Changes stashed'"]Post-clean Hook Example
Section titled “Post-clean Hook Example”Clean up shared resources:
[hooks]post_clean = [ "docker-compose down", "echo 'Cleanup complete'"]Workflow
Section titled “Workflow”worktree (current) │ ├── pre_clean hooks run │ ├── git worktree remove │ ├── post_clean hooks run │ └── cd to main repository │ ▼main repository (new current)