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

ToolDescription
EnterPlanModeSwitch to read-only mode. File writes and edits are denied.
ExitPlanModeReturn 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

ToolDescription
EnterWorktreeCreate a new git worktree on a fresh branch and switch into it.
ExitWorktreeLeave the worktree, optionally keeping or removing it.

How it works

  1. EnterWorktree creates a worktree via git worktree add on a new branch
  2. The agent's working directory is switched to the worktree
  3. Changes are isolated from the main branch
  4. ExitWorktree returns 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";
FunctionDescription
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.