Fork the session. Keep the cache warm.
opencode-fork-lane forks your OpenCode session into a
lane-style copy-on-write git worktree: a new branch, a new folder,
and every git-ignored path (node_modules,
target/, .env) cloned by reference with
reflink — so the new tree starts with warm caches instead of a
reinstall and a cold build.
Package
@bojackduy/opencode-fork-lane
One lane name becomes the git branch, the worktree folder
(.lane/trees/<name>), and the forked session
title. Run /fork-lane yourself, or let the agent call
the fork_lane tool to isolate its own risky work.
$ /fork-lane
? Fork lane from… Full session
? Lane name fix-login
✓ branch fix-login · .lane/trees/fix-login
git+reflink · 4612 ignored paths · 1.3 GiB shared, 0 copied
→ forked session "fix-login", moved into the lane.
Continue here — the old checkout is untouched.
Pick a fork point like native fork, name the lane, land in a warm worktree with full history.
# the agent isolates itself, no human shell needed
fork_lane(
name="risky-refactor",
task="Migrate auth to sessions; keep API stable"
)
{ "branch": "risky-refactor",
"directory": ".lane/trees/risky-refactor",
"moved": true, "via": "git+reflink" }
The fork_lane tool gives agents the same isolation TUI users get.
Copy-on-write worktrees
Delegates to the lane binary when installed, otherwise git worktree add plus reflink cloning of ignored files (APFS clonefile, Linux reflink, plain-copy fallback).
Session fork with history
Fork from the full session or a specific prompt — the same choice native fork offers — then the fork is moved into the new worktree and retitled with the lane name.
Agent-callable
The fork_lane tool (name, task, base, messageID, moveChanges) lets the model isolate risky, experimental, or parallel work by itself.
Why not plain git worktree?
| git worktree add | lane new | fork-lane | |
|---|---|---|---|
| Tracked files | checked out | checked out | checked out |
| node_modules, target/, .env | absent | by reference | by reference |
| OpenCode session | you're on your own | terminal only | forked with history, moved in |
| Agent self-isolation | no | no | fork_lane tool |
| Cost of a new tree | reinstall + cold build | ~0 B, warm | ~0 B, warm |
Install
Add the same package to both config files — opencode resolves the server and TUI entrypoints from each:
// opencode.jsonc
{ "plugin": ["@bojackduy/opencode-fork-lane"] }
// tui.json
{ "plugin": ["@bojackduy/opencode-fork-lane"] }
Restart OpenCode, open any session in a git repo, run
/fork-lane (or ctrl+f), pick a fork
point, name the lane. Requires git and bun; the optional
lane binary (curl -fsSL https://lane.lukeed.com | sh)
is used when present.
FAQ
Where do lanes live?
Under <gitRoot>/.lane/trees/<name> on branch <name> — the same layout lane uses, so lane ls, lane note, and lane merge all work inside fork-lane trees.
Does it work without the lane binary?
Yes. The plugin reimplements the copy-on-write step: worktree plus reflink cloning of every git-ignored path.
What if moving the session fails?
The fork keeps full history in the old directory and the worktree is still ready — the tool response tells the agent to use absolute paths under the new tree, and TUI users can Move session manually.