@metyatech/managed-worktree-system is a policy-driven Git worktree CLI for parallel human and AI task work. The executable is mwt.
- keep the seed checkout tracked-clean and synchronized to the remote target branch
- create isolated sibling task worktrees for human and AI edits
- preserve repository-relative filesystem topology such as
../shared-repo - make delivery explicit: rebase, verify, push, sync, and cleanup
- The seed is a normal non-bare repository checkout at the visible project root.
- The seed stays tracked-clean and acts as the bootstrap source for ignored local files such as
.env.local. - Every tracked edit happens in sibling task worktrees created by
mwt create. .mwt-worktree.jsonis a local runtime marker, not a file for version control.mwt deliveris the explicit integration step from a task worktree back to the target branch.
mwt 1.x used a bare-backed seed layout. mwt 2.x does not. There is no in-place migration command in 2.x.
- Start from a normal non-bare repository checkout that you want to keep as the seed.
- Confirm there are no active task worktrees you still need from the old 1.x layout.
- Run
mwt initin the normal repository checkout. - Recreate task worktrees from that seed with
mwt create.
- Windows PowerShell is the currently verified operator environment
- Git and Node.js 22 or later are required
- npm 11.12.1 or later is recommended for authenticated scoped-package install and
npxflows - the command surface is intended to remain cross-platform where Git behavior permits
Global install:
npm install -g @metyatech/managed-worktree-systemOne-shot execution without a global install:
npx @metyatech/managed-worktree-system --versionRepository-local development install:
- Install Node.js 22 or later.
- Install Git.
- Run
npm install. - Run
npm run verify.
@metyatech/managed-worktree-system also exports the core repository operations
for other tools such as orchestrators and repository managers.
Example:
import {
createTaskWorktree,
deliverTaskWorktree,
dropTaskWorktree,
loadConfig,
} from '@metyatech/managed-worktree-system';
const seedRoot = process.cwd();
await loadConfig(seedRoot);
const created = await createTaskWorktree(seedRoot, 'manager-task-123', {
createdBy: 'manager',
pathTemplate: '{{ seed_parent }}/{{ repo }}-mgr-{{ slug }}-{{ shortid }}',
branchTemplate: 'mgr/{{ slug }}/{{ shortid }}',
});
await deliverTaskWorktree(created.worktreePath, { target: 'main' });
await dropTaskWorktree(created.worktreePath, {
force: true,
deleteBranch: true,
forceBranchDelete: true,
});Programmatic create options:
base: override the configured base branch for this task worktree.target: override the configured target branch recorded in task metadata.bootstrap: force or skip bootstrap copying.copyProfile: choose a bootstrap profile from.mwt/config.toml.createdBy: record the logical creator in.mwt-worktree.json.pathTemplate: override the configured task worktree path template for this call.branchTemplate: override the configured task branch template for this call.
Programmatic delivery options:
target: override the delivery target branch for this call.allowDirtyTask: skip the tracked-clean guard inside the task worktree.resume: resume a previously interrupted or conflict-marked delivery.
Core flow:
-
Initialize an existing repository:
mwt init --base main --remote origin
-
Create a task worktree:
mwt create feature-auth -
Work and commit inside the task worktree, then deliver:
mwt deliver feature-auth --target main
-
If you no longer need an active task worktree, drop it explicitly:
mwt drop preview-auth --delete-branch --force-branch-delete
-
Prune delivered worktrees:
mwt prune --merged --with-branches
End-to-end example:
mwt init --base main --remote origin
mwt create feature-auth
mwt create preview-auth --dry-run --json
mwt list --kind task --status active --json
mwt deliver feature-auth --target main
mwt drop preview-auth --delete-branch --force-branch-delete
mwt sync --base main
mwt prune --merged --with-branches
mwt doctor --fixIf you prefer not to install globally, replace mwt with npm exec -- mwt inside a local clone or with npx @metyatech/managed-worktree-system.
Initialize the current normal non-bare repository for managed worktree operation.
Parameters:
--base <branch>: default target branch recorded in.mwt/config.toml.--remote <name>: default remote recorded in.mwt/config.toml.--force: allow initialization even when tracked files are already dirty.
Example:
mwt init --base main --remote origin --jsonCreate a sibling task worktree and branch from the configured remote base.
When the seed repository contains Git submodules, mwt create also runs
git submodule update --init --recursive inside the new task worktree before
project hooks execute, so hook/tooling paths backed by submodules are present.
Parameters:
<name>: task worktree name.--name <name>: alias for the positional worktree name.--base <branch>: override the configured base branch for this worktree.--copy-profile <profile>: choose a bootstrap copy profile from.mwt/config.toml.--run-bootstrap: force bootstrap copy even whenbootstrap.enabled = falsein config.--no-bootstrap: skip copying allowlisted ignored files such as.env.local.
Example:
mwt create feature-auth --base main --copy-profile localList the seed worktree and managed task worktrees.
Parameters:
--all: include external unmanaged Git worktrees in the listing.--kind <seed|task>: filter by worktree kind.--status <active|delivered|conflict|abandoned|healthy>: filter by managed status.
Example:
mwt list --kind task --status active --jsonRebase a task worktree onto the remote target branch, run verification, push, and sync the seed worktree.
deliver is not just "push this branch". It is the explicit integration gate that:
- fetches the target branch
- rebases the task worktree onto the latest target
- runs pre-deliver hooks
- runs the configured verify command in the rebased task worktree
- pushes
HEADto the target branch - fast-forwards the seed to the delivered target
This verify step is intentional. A pre-commit hook checks each commit in isolation, but deliver verifies the code after rebasing onto the latest target branch. That catches integration failures that a local pre-commit hook cannot see. Use both when possible: pre-commit for early feedback, deliver verify for the final integration gate.
Parameters:
<name>: task worktree name or worktree id. If omitted, the current task worktree is used.--target <branch>: override the configured delivery target branch.--allow-dirty-task: skip the pre-deliver tracked-clean task check.--resume: rerun delivery after a previously recorded conflict or interruption.
Example:
mwt deliver feature-auth --target main --jsonFast-forward the seed worktree to the configured remote branch.
Parameters:
--base <branch>: override the configured branch for this sync.
Example:
mwt sync --base mainRemove an active managed task worktree that you no longer need.
If branch deletion or another later cleanup step fails after the worktree
itself has already been detached, mwt drop still removes the task worktree
and registry entry before returning an error so the repository does not keep a
half-dropped managed task.
Parameters:
<name>: task worktree name or worktree id. If omitted, the current task worktree is used.--force: allow removal when tracked changes or unexpected untracked files remain.--delete-branch: delete the local task branch after removing the worktree.--force-branch-delete: use force branch deletion semantics when removing the local branch.
Example:
mwt drop feature-auth --delete-branch --force-branch-delete --jsonRemove managed task worktrees that are safe to delete.
When one prune target hits a later cleanup failure, mwt prune still finishes
the safe cleanup steps for that target and continues pruning the remaining
eligible worktrees before reporting the incomplete cleanup.
Parameters:
--merged: prune delivered task worktrees.--abandoned: prune abandoned task worktrees.--force: allow pruning when tracked changes or unexpected untracked files remain.--with-branches: delete the local task branch after confirming it is merged.
Example:
mwt prune --merged --with-branches --jsonValidate managed metadata and optionally repair registry drift.
Parameters:
--fix: repair missing or stale registry entries when possible, remove empty stale worktree directories, and delete stale local task branches that no longer contain unique commits. If one cleanup step still fails, doctor keeps any other safe repairs, then returns a structured incomplete-cleanup error so callers can show both the fixes that succeeded and the failures that remain.--deep: include lock files, orphan sibling directories, and seed topology checks.
With --deep --fix, mwt doctor also removes empty orphan sibling directories
that match the managed naming pattern but are no longer live worktrees.
Example:
mwt doctor --fix --jsonPrint the CLI version.
Example:
mwt version--json: emit a single JSON envelope on stdout.--output <path>: also write the JSON envelope to a file.--dry-run: return a non-mutating action plan instead of changing repository state.--yes: approve hook execution or other guarded automation steps.--quiet: suppress human-readable stderr summaries.--verboseor-v: reserve verbose logging for future expansion.--helpor-h: show help for the top-level CLI or a specific command.--versionor-V: print the CLI version.
Project policy lives in .mwt/config.toml.
default_branch: default base and delivery target branch, usuallymain.default_remote: default remote, usuallyorigin.task_worktree_dir_template: path template for sibling task worktrees. Available tokens arerepo,seed_root,seed_parent,slug, andshortid.task_branch_template: local task branch name template. Available tokens areslugandshortid.bootstrap.enabled: default on or off switch for ignored-file bootstrap copy.bootstrap.default_profile: default bootstrap profile name.bootstrap.profiles.<name>.include: allowlisted glob patterns to copy from the seed, such as.env.local.bootstrap.profiles.<name>.exclude: excluded globs inside that profile, such asnode_modules/ordist/.verify.command: command thatmwt deliverruns after rebasing onto the latest target branch.hooks.pre_create.*,hooks.post_create.*,hooks.pre_deliver.*,hooks.post_deliver.*: named project hooks for lifecycle automation.
The full schema and examples are documented in docs/managed-worktree-system-implementation-spec-v1.md.
npm run lintnpm run testnpm run package:checknpm run buildnpm run verifynpm run format
- None required.
Operational guidance lives in OPERATIONS.md. Read it before adopting mwt in a shared repository.
- Major releases change the CLI contract, JSON envelope, on-disk
.mwt/format, or seeded-worktree policy in a backward-incompatible way. - Minor releases add backward-compatible commands, flags, policy checks, or workflow automation.
- Patch releases fix bugs, tighten validation, or improve documentation without breaking an existing workflow contract.
Release flow for maintainers:
- Update version metadata and
CHANGELOG.md. - Run
npm run verify. - Push
main. - Create a Git tag that matches the package version, for example
v1.0.0. - Create a GitHub Release for that tag.
- Publish with
npm publish. - Verify the published artifact with
npm view,npx, and a global install or update.