High-Level Overview
When you run a prompt with Uzi, the following happens:Core Components
1. Git Worktrees
Each agent operates in its own Git worktree - a separate working directory linked to your repository. This enables:- Isolation: Multiple agents work on different branches simultaneously without conflicts
- Branch management: Each worktree has its own branch derived from your main branch
- Storage: Worktrees are stored in
~/.local/share/uzi/worktrees/
2. Tmux Sessions
Each agent runs in a dedicated Tmux session that provides:- Persistence: Sessions continue running even if you disconnect
- Multi-window support: Separate windows for the agent and development server
- Session naming: Format
agent-{projectDir}-{gitHash}-{agentName}
3. AI Agents
Agents are AI-powered development assistants that:- Execute autonomously: Run commands and make code changes in their worktree
- Have unique identities: Each agent gets a random name (john, sarah, etc.)
- Support multiple models: Claude, Codex, or custom agent commands
4. State Management
Uzi tracks all active agents in a central state file located at~/.local/share/uzi/state.json. This state includes:
The state manager automatically cleans up entries when sessions are killed, ensuring your state file stays synchronized with active agents.
Data Flow
Here’s how data flows through Uzi when you create an agent:Step 1: Prompt Submission
You runuzi prompt "implement feature X" with an agent specification:
Step 2: Worktree Creation
Uzi creates a new worktree in~/.local/share/uzi/worktrees/:
- Branch name:
{agentName}-{projectDir}-{gitHash}-{timestamp} - Worktree path:
~/.local/share/uzi/worktrees/{worktreeName} - Base branch: Automatically detected (main/master)
Worktrees are created with
git worktree add -b {branchName} {worktreePath}, ensuring they’re properly linked to your repository.Step 3: Tmux Session Setup
Uzi creates a Tmux session with the following structure:Step 4: Agent Execution
The AI agent receives the prompt and begins working:- Commands run in the agent’s isolated worktree
- All changes are tracked on the agent’s unique branch
- Development server (if configured) runs on a dedicated port
Step 5: Checkpoint and Merge
When you’re ready to integrate changes:Storage Locations
Uzi uses the following directories (all under~/.local/share/uzi/):
| Directory | Purpose | Example |
|---|---|---|
worktrees/ | Git worktree storage | worktrees/sarah-myapp-a1b2c3d-1234/ |
worktree/{sessionName}/ | Per-session metadata | worktree/agent-myapp-a1b2c3d-sarah/tree |
state.json | Active agent state | Single JSON file with all sessions |
Port Allocation
When a development server is configured, Uzi automatically allocates ports:- Ports are allocated from the configured range (e.g.,
3000-4000) - Each agent gets a unique port to prevent collisions
- Port assignments are tracked in state and displayed by
uzi ls
Isolation Benefits
The Git worktree + Tmux architecture provides:- No context switching: Each agent has its own complete environment
- Parallel development: Multiple agents work on different features simultaneously
- Clean separation: Changes in one agent don’t affect others
- Easy cleanup:
uzi kill {agent}removes all associated resources
Next Steps
Worktrees
Deep dive into Git worktrees and isolation
Sessions
Learn about Tmux session management
Agents
Understand agent naming and commands
State Management
Explore how Uzi tracks agent state