Repository navigation
Releases
v0.4.0: adopt existing worktrees with private env files
This release adds mkwt adopt for linked worktrees already created by T3 Code or Git.
What's new
- Adopt an existing registered worktree, persist its caller-supplied identity, and generate a fresh private env file without checkout, symlinks, or hooks.
- Retry safely with
already_configuredwhen the identity, recorded env path, exact file contents, ownership, and mode0600match. - Reserve no numeric slot when an unattended template does not use
{n}. The stored slot and managed marker are0;{id}still substitutes the worktree identity. - Support relative Git registrations and symlink aliases, and avoid blocking allocation because an unrelated worktree directory is inaccessible.
- Correct the Rails dotenv 3.x guidance for overwrite precedence and development/test file loading.
Contract and usage
- Executable version:
0.4.0 - Source revision:
e5ea3c47cb9c169dacca0e0483aba900bf2e60ce - CLI, configuration, JSON, recovery, and locking contract
- Implementation and reviewed fixes: PR #12
flock /srv/locks/project-worktrees.lock mkwt adopt \
--repo /srv/repos/project \
--path /home/t3/.t3/worktrees/project/run-123 \
--config /etc/orchestrator/project-mkwt.conf \
--worktree-id a82c4d9e10 \
--non-interactive --jsonThe caller must still hold one exclusive repository lock for identity checks and persistence, including templates without numeric slots. All callers using the same Git common directory must use the same lock. flock is an example caller tool, not a runtime requirement.
Automation configuration is parsed as literal assignments and never sourced. Env files use exclusive creation and mode 0600; unsafe paths and existing destinations are refused. Initial adoption preflights collisions before reserving an identity. Interrupted or failed writes can still require inspection and repair; the README names the remaining recovery limits.
The human mkwt <branch> workflow and existing create/remove contracts remain supported. JSON schema version stays 1. Automation requires Bash 4.4+ and Git 2.48+, with standard base-system utilities. mkwt runs as the invoking user and needs no root privileges. Database creation, migrations, application startup, and database cleanup remain the caller's responsibility.
For Rails, a generated .env.development.local is not loaded in test. Explicitly load the generated file in both environments or have the caller link it to .env.test.local, as documented.
Install and verify
git clone --branch v0.4.0 --depth 1 https://github.com/EdoMon93/mkwt.git mkwt-v0.4.0
cd mkwt-v0.4.0
./setup.sh
mkwt --version --jsonThe attached standalone mkwt executable embeds the source revision and can report it without the source checkout.
Validation: all three local CI commands passed, with four human-workflow checks and 75 automation tests: 74 passed and one root-only ownership fixture skipped. The fixture requires root only to construct a file owned by another user; the host denied that test's elevation. GitHub Actions passed on the final PR head. Additional reverted-code checks confirmed the alias and relative-registration regression tests detect the original defects.
v0.3.0: unattended worktree identities and environment generation
This release adds caller-supplied worktree identities and private environment-file generation to detached unattended creation.
Contract
- Executable version:
0.3.0 - Source revision:
7cf064f3b06413b12edc1ead1fb50f85d306058a - CLI, configuration, JSON, error, and locking contract
- Implementation PR #11
- Tracking issue #10
mkwt create \
--repo /srv/repos/project \
--path /srv/workspaces/run-123/reviewer \
--commit FULL_COMMIT_SHA \
--detach \
--config /etc/orchestrator/project-mkwt.conf \
--worktree-id 5f38b9a814f348dfab1a39945fd574d0 \
--non-interactive --jsonExample declarative external configuration, using literal newlines for multiple assignments:
SYMLINKS=""
POST_CREATE_HOOK=""
OPEN_IN_VSCODE="never"
WORKTREE_ENV_FILE=".env.worktree"
WORKTREE_ENV='WORKTREE_ID={id}
TEST_ENV_NUMBER={n}'{id} uses the exact validated caller ID or an automatically allocated decimal identity. {n} remains an independently allocated numeric slot. IDs contain 1–128 ASCII characters, start with a letter or digit, and otherwise allow letters, digits, underscore, dot, and hyphen. They remain reserved in Git's worktree registration until removal or explicit pruning, independent of environment filenames or file deletion.
The caller must hold one exclusive repository lock for the whole operation. Every caller using the same Git common directory, including human workflows and direct Git worktree mutations, must participate in that lock. Unsynchronized allocation is unsupported. mkwt adds no locking-tool runtime dependency.
Environment files are fresh and private with mode 0600; new parent directories use mode 0700. Unattended creation never copies a main-checkout env file. Unsafe paths, symlink parents, and existing destinations are refused. Generation failures preserve discoverable registrations and report truthful partial-failure and ownership metadata. Inspect and explicitly remove surviving worktrees before retrying.
JSON schema version remains 1, with additive worktree_id and worktree_env_path fields. Empty-config behavior and the human copy-and-append workflow remain supported. Unattended symlinks and post-create hooks remain disabled. Bash 4.4+ and Git 2.48+ are required for automation.
Orchestrator remains responsible for dependencies, database creation and migrations, startup, host-wide ports, isolation verification, and database cleanup.
Install and verify
git clone --branch v0.3.0 --depth 1 https://github.com/EdoMon93/mkwt.git mkwt-v0.3.0
cd mkwt-v0.3.0
MKWT_INSTALL_DIR="$PWD/release-bin" ./setup.sh
./release-bin/mkwt --version --jsonThe attached standalone mkwt executable embeds the source revision and does not require a source checkout to report it. The existing v0.2.0 tag and release remain unchanged.
Validation: 40 integration tests and four human-workflow checks passed locally and in GitHub Actions. Coverage includes explicit/automatic identities, numeric templates, multiline literal configuration, caller-locked concurrent allocations and duplicate detection, identities across filename changes/moves/missing worktrees, private permissions, unsafe paths and existing files, and checkout/environment failures. Copilot reviewed the final PR head before merge.
v0.2.0: unattended worktree lifecycle
This release adds explicit unattended worktree creation and removal for an orchestrator. The existing human command and VS Code workflow remain unchanged.
Pin and contract
- Source commit:
9b0610857bd4f82921401512a0ab428c5e0f7463 - Version identifier:
0.2.0 - Final CLI/config/JSON contract
- Implementation PR #8
- Tracking issue #2
This is the current stable release. The previous human-workflow baseline remains available at v0.1.0. The implementation was merged through PR #8; PR #9 sets the stable executable version and documents pinned installation.
Preserve everyday usage
Continue using mkwt <branch> with the existing repository-local Bash config, configured setup, fetching, plain-path stdout, and VS Code settings. The literal branch names create and remove also retain their legacy behavior unless automation flags are supplied.
Automation interface
mkwt create \
--repo /srv/repos/project \
--path /srv/workspaces/run-123/claude \
--commit FULL_COMMIT_SHA \
--detach \
--config /etc/orchestrator/mkwt.conf \
--non-interactive \
--json
mkwt remove \
--repo /srv/repos/project \
--path /srv/workspaces/run-123/claude \
--non-interactive \
--json
mkwt --version --jsonUse an external server config with literal settings:
SYMLINKS=""
WORKTREE_ENV=""
POST_CREATE_HOOK=""
OPEN_IN_VSCODE="never"Automation requires Bash 4.4+ and Git 2.48+; those requirements do not change the legacy workflow. Unattended config is data, not executable Bash, and requires setup actions to be disabled. Automation suppresses Git hooks, filters, fsmonitor, automatic maintenance, and lazy fetching. Git LFS pointer files remain pointers. The orchestrator owns fetching, locking, further workspace preparation, inspection, and retention.
Dirty worktrees include staged/unstaged changes, untracked files, and ignored files. Explicit --force permits discarding them; branches are preserved. Main checkouts, unrelated or mismatched worktrees, locked worktrees, symlink targets, and stale registrations remain protected. Repeated removal succeeds with the distinct status already_absent.
With --json, stdout is one schema-version-1 object and diagnostics go to stderr. Success, including already_absent, exits 0. Errors and partial creation failures exit 1 with stable codes and surviving-resource details. The full contract lists all fields and error codes.
Install without replacing your daily command
git clone --branch v0.2.0 --depth 1 https://github.com/EdoMon93/mkwt.git mkwt-v0.2.0
cd mkwt-v0.2.0
MKWT_INSTALL_DIR="$PWD/release-bin" ./setup.sh
./release-bin/mkwt --version --jsonThe attached standalone mkwt executable embeds the source revision and can also be installed to a chosen directory. Its version metadata remains available without a source checkout. Install from the tagged Git checkout when using setup.sh; source archives without Git metadata report an unknown revision.
Validation
Bash syntax and diff checks passed. All 23 automation integration tests and the four existing VS Code/config tests passed. Tests cover same-SHA detached worktrees, closed stdin, missing/invalid configuration and commits, path collisions including races, failures after registration and during partial-clone checkout without fetching, safe/forced/repeated removal, branch preservation, wrong-repository and replaced-Gitfile refusal, path escaping, bare and SHA-256 repositories, legacy reserved branch names/VS Code, and installed revision metadata after source removal. GitHub Actions runs both suites.
Rollback
The existing v0.1.0 tag is unchanged. From a clean mkwt source checkout:
git fetch origin tag v0.1.0
git switch --detach v0.1.0
./setup.shv0.1.0: current human workflow
This release preserves the existing mkwt workflow at commit 7fc39e1b01a3ddfaabc940f336f5f1ea67e51b3d. It provides a pinned installation and rollback point before the planned orchestrator features.
Everyday usage
Continue using mkwt as usual from a product repository:
mkwt fix/my-branchThe existing branch-oriented CLI, repository-local .worktrees/mkwt.conf, configured setup, and VS Code settings remain unchanged. VS Code launches follow the existing OPEN_IN_VSCODE setting and --vscode / --no-vscode overrides. Plain stdout remains the absolute worktree path, so command substitution still works:
cd "$(mkwt fix/my-branch)"Configured setup includes symlinks, per-worktree environment files, and the optional post-create hook. First use retains the interactive setup wizard.
Install this pinned version
Clone the tag into a new directory, then install:
git clone --branch v0.1.0 --depth 1 https://github.com/EdoMon93/mkwt.git mkwt-v0.1.0
cd mkwt-v0.1.0
./setup.shThe installer writes ~/.local/bin/mkwt. Ensure ~/.local/bin is on PATH. GitHub also provides source ZIP and tar.gz downloads for this tag.
Restore this version from an existing source checkout
Run these commands in a clean mkwt source checkout:
git fetch origin tag v0.1.0
git switch --detach v0.1.0
./setup.shThe tag is a fixed baseline and must not be moved to future code. The source revision can be checked with git rev-parse HEAD; this baseline executable does not yet provide a --version flag.
Validation
Verified a fresh clone of the published tag resolves to the full commit above. Bash syntax checks passed, and all four existing VS Code/config tests passed against that checkout.
Planned automation work
Exact-commit creation, explicit external config, unattended operation, JSON results, safe removal, and an installed version identifier are tracked in #2. Those capabilities are not included in this baseline release.
Future automation behavior must be explicitly selected. Preserving mkwt <branch> and its configured VS Code behavior is a requirement of the next release. Automation changes will use a later version, with a prerelease for validation before the next regular release.