Synopsis
k
Description
Thekill command terminates an agent session and cleans up all associated resources, including:
- Tmux session
- Git worktree
- Git branch
- State entries
- Local storage directories
Arguments
The name of the agent to terminate (e.g.,
thoughtful-tesla), or the special keyword all to terminate all agents in the current repository.How It Works
Clean Local Storage
Removes directories from
~/.local/share/uzi/worktrees/ and ~/.local/share/uzi/worktree/.Examples
Kill Single Agent
Kill All Agents
Typical Cleanup Workflow
What Gets Deleted
Tmux Session
Tmux Session
The entire tmux session is terminated:
- Agent window (
:agent) - Dev server window (
:uzi-dev) if it exists - Any other windows created via
uzi run
tmux kill-session -t <session-name>Git Worktree
Git Worktree
The isolated working directory is removed:
- Location:
~/.local/share/uzi/worktrees/<worktree-name>/ - All files and uncommitted changes are lost
git worktree remove --force <path>Git Branch
Git Branch
The agent’s branch and all its commits are deleted:
- Uses force delete (
-D) to remove even unmerged branches - All agent commits are lost unless checkpointed first
git branch -D <branch-name>Local Storage
Local Storage
Uzi’s internal storage directories are cleaned:
~/.local/share/uzi/worktrees/<agent-name>/~/.local/share/uzi/worktree/<session-name>/
State Entry
State Entry
The agent’s metadata is removed from:
~/.local/share/uzi/state.json
Kill All Behavior
When usinguzi kill all:
- Retrieves all active sessions for the current repository
- Extracts agent name from each session
- Calls kill operation for each agent
- Shows summary of deleted agents
- Continues even if individual kills fail
Error Handling
uzi ls.If the tmux session doesn’t exist or can’t be killed, the error is logged but cleanup continues.
git branch -a.Preservation Before Killing
If you want to preserve the agent’s work before killing:Option 1: Checkpoint
Option 2: Manual Branch Save
Option 3: Export Diff
When to Kill Agents
Safe to kill:
- Agent completed its task and changes are checkpointed
- Agent produced unsatisfactory results
- Agent is stuck or unresponsive
- You’re done experimenting with parallel approaches
- You need to free system resources
Resource Cleanup
Killing agents frees:- Disk space: Worktree directories can be large
- Ports: Dev server ports become available for reuse
- Tmux sessions: Reduces session clutter
- Git branches: Keeps branch list clean
Comparison with Git Worktree
Uzi’s kill is similar to but more thorough thangit worktree remove:
| Operation | git worktree remove | uzi kill |
|---|---|---|
| Remove worktree | ✓ | ✓ |
| Delete branch | ✗ | ✓ |
| Kill tmux session | ✗ | ✓ |
| Clean local storage | ✗ | ✓ |
| Update state | ✗ | ✓ |
Recovery After Accidental Kill
However, if you killed an agent accidentally:Related Commands
prompt- Create agents that will later be killedls- See which agents exist before killingcheckpoint- Preserve agent work before killingreset- Nuclear option to delete all Uzi data
Notes
Use
uzi kill all carefully, especially if you have agents working on different features. It will terminate all agents in the current repository.