Tak.Worktrees (tak v0.4.2)
View SourcePublic runtime API for Tak worktree lifecycle operations.
The supported surface is intentionally small:
create/3creates a worktree and returns%Tak.Worktree{}datalist/0reports the main repo and known worktrees with runtime statusremove/2removes a worktree and returns%Tak.RemoveResult{}datadoctor/0returns structured environment checks for CLI rendering
Tak uses three public data shapes:
Tak.Worktree, stable worktree identity and configurationTak.WorktreeStatus, transient runtime status layered on top of a worktreeTak.RemoveResult, removal outcome layered on top of a worktree
Summary
Functions
Creates a worktree. Returns {:ok, %Tak.Worktree{}} or {:error, reason}.
Runs doctor checks. Returns {passed, failed, results} where results is a
list of {:ok | :error | :warn, message} tuples.
Lists the main repository and all known worktrees.
Removes a worktree. Returns {:ok, %Tak.RemoveResult{}} or {:error, reason}.
Functions
Creates a worktree. Returns {:ok, %Tak.Worktree{}} or {:error, reason}.
When name is nil, the first available slot is picked automatically.
The core API does not raise for expected git or mix command failures. Those return tagged errors instead:
{:git_failed, command, output}{:bootstrap_failed, command, output}{:bootstrap_failed, command, output, :cleanup_failed}
Options
:create_db- whether to create the database (default: from config)
Runs doctor checks. Returns {passed, failed, results} where results is a
list of {:ok | :error | :warn, message} tuples.
Lists the main repository and all known worktrees.
Returns {main, worktrees} where main is a %Tak.WorktreeStatus{} for the
current repository and worktrees is a list of %Tak.WorktreeStatus{}
values for entries found in Tak.trees_dir/0.
Status is :running, :stopped, or :unknown.
Removes a worktree. Returns {:ok, %Tak.RemoveResult{}} or {:error, reason}.
Options
:force- force removal even with uncommitted changes (default: false):keep_db- keep the database instead of dropping it (default: false)