Command-line tool
The taxilane command runs Taxilane’s worktree operations from a terminal, a script or an agent hook, without opening the desktop window. It lives in the cli module (cli/src/main/kotlin/dev/taxilane/cli) and calls the same core use cases as the app, so a worktree created or cleaned from the command line ends up exactly as if the app had done it.
Commands
Section titled “Commands”What each command does, its options and its output are in the command-line reference. This table maps each command to the core code it runs and notes the details that only matter when changing it.
| Command | Runs | Implementation notes |
|---|---|---|
new |
ResolveStartPointUseCase and ResolveBaseBranchUseCase on the same ref, then CreateWorktreeUseCase or CreateWorktreeFromBranchUseCase, with PrepareWorktreeEnvironmentUseCase and WriteEnvironmentFileUseCase as the environment preparer |
Without --from, the start point is HEAD resolved in the working directory, so a worktree created from a linked worktree branches from that worktree, as git worktree add -b does. An unknown ref fails before anything is created. Standard output holds only the path; for a new branch, standard error says the commit it starts at (branched from <ref> at <short hash> <subject>, without the ref when there’s no --from). |
provision |
ProvisionWorktreeUseCase |
|
status |
ListWorktreesUseCase, ResolveMainBranchUseCase, ReadWorktreeStatusUseCase, classifyOrigin, ReadBaseBranchesUseCase |
The JSON of --json is built in StatusJson.kt; its field names are a contract, see the CLI guide. Failing to read the bases leaves every base null. The main branch, the agents, the desktop turn, the build turn and the bases are read concurrently, then the worktree statuses at most 8 at a time, collected in listing order so the output doesn’t depend on which read ends first. |
base |
findWorktreeTarget (or the worktree containing the current directory), ReadBaseBranchesUseCase, SetBaseBranchUseCase |
Unlike remove, the target may be the main checkout. |
clean |
selectCleanupCandidates, CleanUpWorktreesUseCase, CloseHerdrWorkspacesUseCase, and per option StopGradleDaemonsUseCase, StopWorktreeEmulatorUseCase, DeleteSimulatorsUseCase, DeleteOrphanedDerivedDataUseCase |
Whatever removal deletes is read first: the Gradle daemons (for idleDaemonsOfRemovedWorktrees), the running emulators’ serials (ReadEmulatorStatesUseCase, then StopWorktreeEmulatorUseCase.stopSerials), the simulators’ UDIDs and the orphaned DerivedData. Orphaned simulators are looked for again after removing, so the simulator of a worktree whose folder was already gone is caught as an orphan; with only orphans the command still runs. A failed daemon stop, emulator stop or Herdr close goes to standard error without changing the exit code; a DerivedData folder that can’t be deleted exits with 1. |
gradle, gradle stop |
ListGradleDaemonsUseCase, CheckGradleBuildCacheUseCase, StopGradleDaemonsUseCase |
Works outside a repository. Kotlin daemons are kept while a Gradle build runs. A busy daemon’s holding build is printed on an indented line under it, and as holder in --json. |
pool status, pool trim |
ReadResourcePoolUseCase, TrimGradleDaemonsUseCase |
status reads the three pools against the limits of the capacity profile; trim stops idle Gradle daemons over the limit. Both accept --json (poolJson, poolTrimJson). |
project add, project list, project remove |
RegisterProjectUseCase, UnregisterProjectUseCase, ProjectRepository |
add builds the project with newProject, the same defaults ProjectConfigViewModel.chooseFolder uses (projectDefaultsFor), and only calls save for a repository with no project, compared by canonical path, so an existing project is never rewritten. remove matches by canonical path and, when the folder is gone, by the stored path. The JSON of --json is built in CommandJson.kt (projectJson, projectListJson). |
app |
ResolveRepositoryUseCase, RegisterProjectUseCase, AppInstanceLock, AppRequestChannel, AppLauncher |
Registers the repository, leaves an AppRequest (open-worktree when the path is inside a linked worktree, found with git rev-parse --show-toplevel) and launches the app only when nobody holds the app lock. See Reaching the desktop app. |
xcode, xcode clean |
ListDerivedDataUseCase, DeleteOrphanedDerivedDataUseCase |
Without the provider or off macOS it exits with 0. |
env |
ResolveWorktreeEnvironmentUseCase (reserving), formatEnvironment |
Reserves declared ports only; on-demand reservations (the emulator’s port, the simulator) are read, never acquired. |
emulator |
StartWorktreeEmulatorUseCase, StopWorktreeEmulatorUseCase, ReadEmulatorStatesUseCase |
start acquires the emulator through AcquireWorktreeResourceUseCase with the limits of the machine’s capacity profile, prints what it released on standard error and the export ANDROID_SERIAL=… line on every start (it also renews the lease). With --wait it passes a DeviceWait whose progress callback prints a line on standard error only when it changes, and prints waited <time> after a real wait (waited in --json). status never reserves a port and prints not acquired before the first start, followed by (released for <worktree> at <time>) when ReadReleaseRecordUseCase finds a release record (releasedFor in --json). Without the provider: EmulatorProviderNotDeclared. |
headless |
StartHeadlessAppUseCase, StopHeadlessAppUseCase, ReadHeadlessAppUseCase, CaptureHeadlessAppUseCase |
The worktree is the top level of the path’s Git checkout, registered as a project or not. .taxilane.json is read from the worktree itself. The ports HeadlessAppLauncher (GradleHeadlessAppLauncher: gradlew <module>:hotRunAsync with an init script) and AppWindowService (MacAppWindowService: a JavaScript for Automation helper and screencapture) are injected, so tests use fakes. A denied hide is a warning on standard error, not a failure. remove, clean and hook worktree-remove pass StopHeadlessAppUseCase to the removal, which stops the app before deleting the folder. |
desktop |
AcquireDesktopTurnUseCase, ReleaseDesktopTurnUseCase, ReadDesktopTurnUseCase |
acquire and release act on the worktree that is the top level of the path’s Git checkout; status needs no worktree. The DesktopTurnStore (NioDesktopTurnStore), the wait queue and the clock and pause are injected, so tests wait without sleeping. --wait and --wait-timeout are parsed like the device commands’. status reads the turn once to add desktop to each worktree, hook agent-state releases it on Stop and SessionEnd, and remove, clean and hook worktree-remove pass ReleaseDesktopTurnUseCase to the removal. |
build |
RunInBuildTurnUseCase, ReadBuildTurnUseCase |
Parsed in BuildCommand.kt and run by BuildTurnCommands, so the shared files only dispatch to them. run acts on the top level of the current directory’s Git checkout and runs the command in the current directory; the exit code is the command’s, 127 when it can’t start. status needs no worktree. The BuildTurnStore (NioBuildTurnStore), the ForegroundCommandRunner, the wait queue and the clock and pause are injected, so tests wait and run without processes. status reads the build turn once to add build to each worktree. |
simulator |
StartWorktreeSimulatorUseCase, StopWorktreeSimulatorUseCase, ReadSimulatorStatesUseCase, KmpTestWiring |
start acquires (creates) the simulator the same way and prints export IOS_SIMULATOR_UDID=… when it just did. status never creates a simulator and prints not acquired before the first start. Without the provider: IosSimulatorProviderNotDeclared; off macOS: IosSimulatorsNotSupported. |
simulator gradle-init |
KmpTestWiring |
install asks on standard input (readInput) unless --yes. |
hook worktree-create |
CreateWorktreeUseCase, or the existing worktree |
Reads name and cwd from the hook’s JSON and records the branch of cwd’s HEAD as the base; without a project the worktree goes to <repo>/.claude/worktrees. The path must be the only line on standard output. |
hook worktree-remove |
RemoveWorktreeUseCase (forced), DeleteMergedBranchUseCase, CloseHerdrWorkspacesUseCase |
Forcing the removal is what Claude Code would do without the hook. |
hook session-start |
ResolveWorktreeEnvironmentUseCase |
Only a repository registered as a project (ProjectRepository) gets its environment resolved and delivered; elsewhere it prints the workflow rules built without reading .taxilane.json. The context names the variables without values, and those awaiting approval separately. CLAUDE_ENV_FILE is read through an injected environment lookup. An unreadable .taxilane.json exits with 1 before writing. It reserves nothing: for a worktree without an emulator or simulator the context line says how to acquire it. |
hook agent-state |
AgentSessionStore (FileAgentSessionStore) |
Maps UserPromptSubmit, Notification (idle_prompt is done, auth_success is ignored, anything else is blocked), Stop and SessionEnd to a record of the worktree containing the hook’s cwd. The session’s pid is the first claude ancestor of the process (ProcessHandle), injected as agentProcessId. On a working state it also calls RenewWorktreeLeasesUseCase for the worktree. When the session goes from working to blocked or done, the app isn’t running and a notification switch is on, it schedules a notification through PendingAgentNotifications and starts hook notify-pending in the background (see Agent notifications). After a valid input it always exits with 0; every failure is swallowed so the hook never blocks Claude Code. |
hook desktop-turn |
AcquireDesktopTurnUseCase |
Acts only on the calls that drive the desktop: a Bash command classified by OrcaComputerUse, or a computer-use tool classified by ClaudeComputerUse (the acting tools under mcp__computer-use__ and mcp__remote-devices__computer_). It takes or renews the turn for the worktree of the hook’s cwd and lets the call run, or denies it with the holder, until when and how many wait when another worktree holds the turn or others wait first. Any other tool, a call that only looks (a screenshot), a session outside a repository or its own failure lets the call run with exit code 0. |
hook build-turn |
HeavyBuildCommand, ResolveResourceLimitsUseCase |
Acts only on a Bash command in which HeavyBuildCommand finds a heavy build outside taxilane build run, in a repository, with a build limit; it then prints the deny decision. Any failure reading its input or the settings lets the command run. |
hooks |
ClaudeCodeHooks |
Previews first (previewInstall / previewUninstall), asks through readAnswer unless --yes, then writes. CLAUDE_CONFIG_DIR comes from the injected environment lookup. An event can have several Taxilane hooks, each told apart by its command, matcher and if filter: PreToolUse has one for Bash commands mentioning computer and one whose matcher, ClaudeComputerUse.hookMatcher, lists the acting computer-use tools, so screenshots don’t launch the hook. |
hook herdr |
ProvisionWorktreeUseCase on worktree.created, DeleteMergedBranchUseCase on worktree.removed |
The event comes from HERDR_PLUGIN_EVENT and HERDR_PLUGIN_EVENT_JSON. On worktree.removed the repository comes from data.workspace.worktree.repo_root, or else from the project whose worktrees folder contains the path, and Herdr is never called. On worktree.created outside the project’s worktrees folder it runs $HERDR_BIN_PATH notification show (herdr when unset). Missing or invalid variables exit with 2. |
help, version |
version prints BuildInfo.VERSION, the same as the app’s. |
Errors are printed from the WorktreeError message. The hook commands receive standard input through TaxilaneCli’s readInput, so tests pass the JSON directly.
Repository and project
Section titled “Repository and project”Every command starts from a directory (the current one, or the path given to provision):
ResolveRepositoryUseCasefinds the base repository withgit rev-parse --git-common-dir, so it works from the main worktree, any subfolder or a linked worktree.- The project is the one in
~/.taxilane/projects.jsonwhose base repository path is the same directory, compared by canonical path (so/tmp/…and/private/tmp/…on macOS match). It provides the worktrees folder, the local files and the main branch. - Without a project, the CLI uses a configuration with no local files and a detected main branch. Only
newneeds a worktrees folder; it asks for--worktrees-root <dir>(relative paths are resolved against the current directory).
Structure
Section titled “Structure”CliCommand.ktdeclares the sealedCliCommand, andCliArguments.kthasparseArguments(args), which turns the arguments into aCliCommandor a usage error by dispatching each command name to its parser. The parsers are grouped by command family (WorktreeArguments.kt,ToolArguments.kt,HookArguments.kt,DeviceArguments.kt,MultirepoArguments.kt), and newer commands declare their type and parser in a file of their own (OverlapCommand.kt,BuildCommand.kt), so a new command only adds a line to the dispatch. Hand-written: a dozen commands with about twenty options, each with its own small rules (--fromnot with--branch,--avdonly withstart, aliases such as-y), don’t justify a parsing library and its startup cost.TaxilaneCli.kt—TaxilaneCli(engine, workingDirectory, out, err…).run(args): Intexecutes a command. It receives theTaxilaneEnginewith the use cases already wired, plus what only the command line uses (output streams, the terminal prompt, the app request channel and lock,CommandLineTool), soTaxilaneCliTestdrives every command with an engine built fromcore’s test fixtures and string buffers.Main.kt—mainandrunTaxilane(args)build the real ports withhostEnginePorts(the working directory as the folder physical devices locate the Android SDK from, without shared emulator-state reads), the engine on top of them, andTaxilaneCli. See One composition graph.
The module applies Gradle’s application plugin, so ./gradlew :cli:run --args="status" runs it during development and :cli:distZip builds the standalone zip.
End-to-end tests
Section titled “End-to-end tests”cli/src/e2eTest holds tests that run the command as a user does, without fakes: each test runs the :cli distribution’s launcher (bin/taxilane, bin/taxilane.bat on Windows) as a separate process against Git repositories made with the real git in a temporary folder, each with a local bare repository as origin. They cover creating, provisioning, listing, opening and cleaning worktrees and multirepo groups, with local files copied, linked and matched by patterns from .taxilane.json, .worktreeinclude and the project.
- Isolation: the temporary folder holds the home the command sees (
TAXILANE_OPTS=-Duser.home=…, since the JVM readsuser.homefrom the account rather than fromHOME, plusHOMEandUSERPROFILE), so~/.taxilaneand Git’s global configuration (GIT_CONFIG_GLOBAL,GIT_CONFIG_NOSYSTEM) are the test’s own. Variables that would make the command think it runs inside a runner or an agent (HERDR_*,ORCA_*,CLAUDE*,TAXILANE_*) aren’t inherited. - Runners:
herdrandorcaare a fake written in Kotlin (FakeRunner.kt), installed as launcher scripts in the sandbox folder that comes first on thePATHthe command is started with, so they win over a real Herdr or Orca on the machine. On Windows they areorca.cmdandherdr.exe, since Herdr’s client only runs an.exethere: a small C# program incli/src/e2eTest/windows, compiled with the .NET Framework’scsc.exeby the Windows-onlyfakeRunnerLaunchertask, which reads the Java command that starts the fake fromherdr.launchnext to it and passes its own arguments through unchanged. It records every call and answers like the real tool, so the tests check the commands an opening sends without Herdr or Orca being installed. - Running them:
./gradlew :cli:e2eTest../gradlew testdepends on it, so the Tests workflow runs them on Linux, macOS and Windows.
Reaching the desktop app
Section titled “Reaching the desktop app”taxilane app runs in a different process from a running app, so the order travels through two things in ~/.taxilane/, both new and ignored by versions that don’t know them:
app.lock: the running app holds an exclusive lock on it for its whole life (FileAppInstanceLock). The CLI probes it withtryLock: if it gets the lock nobody is running. The operating system releases the lock when the process dies, so a crash leaves nothing stale.app-requests/: one JSON file per request (AppRequest:version,createdAt,action,projectId,settings), written through a temporary file and an atomic move (FileAppRequestChannel). The actions areopen-appandopen-project.
The app polls the folder about every 500 ms from Main.kt once it owns the lock, oldest request first, and hands each one to AppRequestHandler, which refreshes the project list, brings the window forward and navigates through ShellViewModel (selectProject or editProject), so the unsaved-changes guard applies and a destination that is already open is left alone. Requests that are malformed, of an unknown version or action, name a missing project or are older than a minute are deleted without effect.
When nobody holds the lock the CLI leaves the request first and then launches the app (DesktopAppLauncher): on macOS open <bundle>, on Windows and Linux the launcher executable, resolved from the CLI’s own path. A command whose executable isn’t the app’s launcher (java, the standalone zip) fails with AppNotAvailable before registering or writing anything. The reasoning and the alternatives (socket, taxilane:// URL scheme) are in the cli-app-projects change’s design.md.
How it’s shipped
Section titled “How it’s shipped”The packaged desktop app has a jlink runtime without a java binary, so the CLI can’t be started by a script reusing it. Instead, the app’s own launcher is the command: desktopApp’s main(args) calls runTaxilane and exits when it receives arguments (ignoring macOS’s legacy -psn_… argument), and opens the window otherwise. The CLI path never loads AWT or Compose, so no window or Dock icon appears, and it starts in about a tenth of a second.
| Platform | How taxilane is installed |
|---|---|
| macOS (Homebrew) | The Cask links Taxilane.app/Contents/MacOS/Taxilane as taxilane. |
Linux (.deb) |
The launcher is /opt/taxilane/bin/Taxilane; link it as taxilane by hand (Installation shows how). |
| Windows, or anywhere with Java 21+ | taxilane-<version>.zip from the release: bin/taxilane and bin/taxilane.bat. The Windows .msi launcher has no console, so it can’t print. |
The reasoning and the startup measurements are in the taxilane-cli change’s design.md (openspec/changes/archive/).