praisonai run --worktree runs an agent on a fresh git branch and worktree, then commits, keeps, or discards the result — your working tree is never touched.
Quick Start
1
Run a prompt in isolation
The agent edits a fresh branch — your working tree stays clean.
2
Run a YAML file in isolation
The YAML file is resolved to an absolute path before isolation, so an untracked or git-ignored
agents.yaml still loads.3
Keep the worktree for review
Both the worktree checkout and the branch stay in place after the run so you can inspect the files directly.
How It Works
--worktree provisions a per-run branch and directory, chdirs into it for the run, then decides what to keep based on whether the agent produced changes.
The worktree is named after the run target plus a random token, then hashed into a git-ref-safe slug. Two runs of the same prompt or YAML file never clobber each other’s uncommitted changes.
Teardown Matrix
What survives after the run depends on whether the agent changed anything and whether you passed--keep.
What Gets Rejected
--worktree is scoped to direct prompt and YAML file runs. These combinations fail fast with exit code 1.
CI / JSON Mode
Under--output json, the isolation status messages are suppressed but isolation still happens.
Isolated run on branch ..., Committed changes ...) are silenced so your JSON payload stays clean.
Best Practices
Use --worktree for risky or exploratory edits
Use --worktree for risky or exploratory edits
Isolation means a bad run never dirties your working tree. Run the agent, inspect the branch, then
git merge only if you like the result.Add --keep when you want to inspect files, not just the diff
Add --keep when you want to inspect files, not just the diff
Without
--keep, changed runs commit and prune the checkout — you review via git merge <branch>. With --keep, the checkout stays on disk under .praisonai/worktrees/ so you can open the files directly.Configure a git identity so commits succeed
Configure a git identity so commits succeed
On teardown, changes are committed with
git commit --no-verify. If no user.name / user.email is set, the commit fails and the worktree is kept in place for manual review instead. Set a git identity to get the clean commit-and-merge path.Clean up kept worktrees when you're done
Clean up kept worktrees when you're done
--keep and commit-failure paths leave a worktree on disk. Remove it with git worktree remove <path> once you’ve reviewed or merged the branch.Related
Workspace Isolation
The SDK
GitWorktreeAdapter this CLI flag wraps.Kanban Worktree Isolation
Per-task git worktrees for kanban workers.
Run Command
Full
praisonai run CLI reference.
