Worktrees & Plan Mode
Use git worktrees for isolated experimentation and plan mode for read-only exploration.
noumen includes tools for structured planning workflows: plan mode restricts the agent to read-only operations, while worktrees provide isolated git branches for parallel or experimental work.
Plan mode
Why opt-in?
Plan mode adds two tools (EnterPlanMode, ExitPlanMode) that let the agent switch itself into a read-only state. This changes the agent's permission model at runtime, which may be surprising if you're not expecting it — the agent could enter plan mode mid-task and stop making progress. The extra tools also add to the context cost of every request.
Configuration
const code = new Agent({
provider,
sandbox,
options: {
enablePlanMode: true,
},
});Tools
| Tool | Description |
|---|---|
| EnterPlanMode | Switch to read-only mode. File writes and edits are denied. |
| ExitPlanMode | Return to the previous permission mode, optionally with a plan summary. |
When in plan mode, the permission system automatically denies write operations. The agent can still read files, search, and use other read-only tools.
Git worktrees
Why opt-in?
Worktree tools create real git worktrees on disk, which has filesystem and git side-effects beyond the normal sandbox scope. The agent might create branches and directories you don't expect. Keeping this opt-in ensures worktrees are only used when you've designed your workflow around them.
Configuration
const code = new Agent({
provider,
sandbox,
options: {
enableWorktrees: true,
},
});Tools
| Tool | Description |
|---|---|
| EnterWorktree | Create a new git worktree on a fresh branch and switch into it. |
| ExitWorktree | Leave the worktree, optionally keeping or removing it. |
How it works
EnterWorktreecreates a worktree viagit worktree addon a new branch- The agent's working directory is switched to the worktree
- Changes are isolated from the main branch
ExitWorktreereturns to the original directory and optionally cleans up
Utility functions
The worktree module also exports utility functions for programmatic use:
import {
findGitRoot,
createWorktree,
removeWorktree,
listWorktrees,
getWorktreeChanges,
sanitizeWorktreeSlug,
} from "noumen";| Function | Description |
|---|---|
findGitRoot(computer, cwd) | Find the git repository root from a working directory. |
createWorktree(computer, root, name, branch?) | Create a new worktree. |
removeWorktree(computer, root, path) | Remove a worktree. |
listWorktrees(computer, root) | List all worktrees in a repository. |
getWorktreeChanges(computer, worktreePath) | Get a diff of changes in a worktree. |
sanitizeWorktreeSlug(name) | Clean a name for use as a worktree directory. |