projectmux

module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2026 License: MIT

README

ProjectMux — declarative tmux workspaces

Latest ProjectMux release CI status MIT license

ProjectMux turns a YAML workspace definition into a reconciled tmux session with windows running on the host or in Dev Containers.

ProjectMux is a declarative tmux workspace manager for Linux and WSL. Define a project's windows in YAML — shells, commands, and CLI coding agents — and choose whether each one runs on the host or inside the repository's Dev Container.

You describe a workspace once: its windows, what each one runs, where it runs, and which one gets focus. ProjectMux observes what tmux and the container runtime are actually doing, then makes the machine match that description.

Why ProjectMux

  • One workspace definition. Layer shared defaults, per-repository configuration, and machine-local overrides without repeating every window.
  • Host and container windows. Each tmux window runs on the host or inside the repository's Dev Container, decided per window.
  • Reconciliation, not a startup script. ProjectMux observes what exists, explains the drift, and converges toward the declared workspace instead of blindly recreating it.
  • Worktree-aware lookup. Open a repository by name from configured roots; working inside a linked git worktree resolves to the repository it belongs to.
  • Readable by humans and machines. Concise terminal reports, or a versioned JSON envelope with documented exit codes.
  • No replacement ecosystem. Your tmux configuration, container runtime, editor, shell, and devcontainer.json stay exactly as they are.

Quick start

You need git and tmux on PATH, on Linux or WSL2. Container-backed windows need more; see Platform support.

Install:

go install github.com/gambtho/projectmux/cmd/projectmux@latest

Create a minimal set of defaults:

mkdir -p ~/.config/projectmux

cat > ~/.config/projectmux/defaults.yaml <<'YAML'
version: 1

repository_roots:
  - /home/you/workspace

devcontainer:
  enabled: auto

windows:
  - name: shell
    shell: true
    focus: true
YAML

Every window opens with a second shell pane beside it by default — same directory, same container if the window runs in one. Add panes: [] to a window to keep it single-pane, or declare your own panes list.

Then open any repository under a configured root:

cd ~/workspace/my-project
projectmux config --validate
projectmux open

You attach, detach, and navigate with tmux exactly as you normally would.

[!IMPORTANT] ProjectMux is alpha. Every documented command works, but nothing it emits is a compatibility contract below 1.0 — the configuration schema, the command surface, the JSON envelopes, and the exit codes may all change, and there is no migration support for v0.x configuration.

Project status

The command surface is complete; nothing about it is frozen. ProjectMux opens, attaches to, stops, and reports on workspaces, starts containers at boot, and diagnoses its own installation. Every command listed below works.

Nothing is a compatibility contract below 1.0. Expect breaking changes to the configuration schema, the command surface, the JSON envelopes, and the exit codes while the version remains below 1.0. There is no migration support, and v0.x builds are published as prereleases.

Releases up to v0.4.0 named the JSON output and the exit codes as contracts that held even during the alpha. That claim is withdrawn. It was made before anything pinned those shapes, and only the config --json envelope is checked against a fixed set of keys today. ProjectMux emits ten envelope shapes across nine commands — config emits two, one for its digest report and one for --validate — so a field in any of the other nine could be renamed by accident without a test noticing.

Human-readable output remains the least stable of the three outputs: human text, --json, and the exit codes. Parse --json if you automate against ProjectMux — but pin the version you tested against.

Platform support

Linux and WSL2 are the supported platforms for v1. macOS and native Windows are not supported and are not currently being tested.

ProjectMux requires git and tmux on PATH. Container-backed windows additionally require a Docker-compatible runtime and the Dev Containers CLI; workspaces that keep every window on the host need neither.

projectmux doctor reports which of these it can find, and their versions.

Install

From a release

Releases publish static linux/amd64 and linux/arm64 binaries with a SHA256SUMS file. Download both, verify, then install:

VERSION=v0.6.0
ARCH=amd64   # or arm64
BASE=https://github.com/gambtho/projectmux/releases/download/$VERSION

curl -fsSLO $BASE/projectmux-linux-$ARCH
curl -fsSLO $BASE/SHA256SUMS

sha256sum --check --ignore-missing SHA256SUMS

mkdir -p ~/.local/bin
install -m 0755 projectmux-linux-$ARCH ~/.local/bin/projectmux

--ignore-missing lets you verify the one binary you downloaded against the file covering both. Verification is the point of publishing checksums — if sha256sum does not print OK, do not install the binary.

While the version is below 1.0, releases are marked as prereleases.

Upgrading from v0.5.0

Install the new binary. Nothing else is required.

v0.6.0 adds a nullable bind column, moving the stored schema to version 3. ALTER TABLE ADD COLUMN rewrites no rows, so the migration runs on first open and every existing session stays bound to nothing — its previous behavior. No workspace ID changes: a session recorded before v0.6.0 carries no session component, which reads back as the empty string, and that is exactly what a default session is. rebuild is not needed.

An older binary refuses a database this migration has touched, reporting the schema version it found and the one it supports. Downgrading therefore means restoring a copy of the database taken before the upgrade.

--json consumers need no changes: schema_version stays 2, because bind is an added field on existing objects and is omitted when unset.

Upgrading from v0.4.0

Run projectmux rebuild once after installing. It is a required step, not an optional one.

v0.5.0 keys workspaces and containers on the repository rather than the git worktree, which changes both the stored schema and every workspace ID. The schema migration moves each stored row verbatim, treating its recorded path as a repository root, because telling a main worktree from a linked one needs to ask git and a migration must never fail because a directory moved. The result is deliberately over-counted, never wrong: one repository per path until rebuild collapses the linked worktrees into their parents and retags live sessions onto their repository. status reports a repository whose recorded root is not a main worktree as needing this run. See rebuild for what it reports and refuses.

--json consumers should read the conventions first: schema_version is 2, the workspace path field is now repo_root rather than worktree, is_primary is gone, and session is new.

With go install
go install github.com/gambtho/projectmux/cmd/projectmux@latest

The binary reports its version correctly when installed this way; see version.

From source
git clone https://github.com/gambtho/projectmux
cd projectmux
CGO_ENABLED=0 go build -o projectmux ./cmd/projectmux

Go 1.25 or newer is required. The binary is statically linked and has no runtime dependency on cgo.

Run the tests, the vet pass, the linter, and a formatting check the same way CI does:

test -z "$(gofmt -l .)"
go vet ./...
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2 run ./...
go test -race ./...

The configuration and resolver tests are hermetic: they create throwaway git repositories in temporary directories and require no live tmux session, Docker daemon, or Dev Containers CLI.

Configuration

Configuration lives under $XDG_CONFIG_HOME/projectmux (falling back to ~/.config/projectmux when XDG_CONFIG_HOME is unset), and state under $XDG_STATE_HOME/projectmux (falling back to ~/.local/state/projectmux).

Three environment variables override where ProjectMux looks. Each is intended for tests, and for running a second ProjectMux beside a working one without disturbing it:

Variable Overrides
PROJECTMUX_CONFIG_ROOT the configuration directory
PROJECTMUX_STATE_ROOT the state directory holding state.db
PROJECTMUX_TMUX_SOCKET the tmux server, passed to tmux as -L <name>

Set together, they give a fully separate installation: it cannot see or change the sessions or records of the default one. Because tmux cannot move a client between servers, open and attach refuse with exit code 6 when your terminal is attached to a different server than PROJECTMUX_TMUX_SOCKET names — detach first, or use open --no-attach.

Three layers are read, in order, and later layers override earlier ones:

Layer Path Purpose
Defaults defaults.yaml settings shared by every workspace
Workspace workspaces/<slug>.yaml settings for one repository
Local workspaces/<slug>.local.yaml machine-specific overrides, not usually committed

Every layer is optional. A missing file, an empty file, and a comment-only file are all treated as an empty document.

<slug> is the repository name. A linked git worktree inherits its parent repository's slug, so every worktree of a project shares one configuration.

Windows merge by name, not by position. An overriding layer that names an existing window edits that window in place and leaves the base ordering alone; a window whose name is new is appended. repository_roots may only be set in defaults.yaml, because it is what makes lookup by workspace name possible in the first place.

Configuration is validated strictly and fails before anything is mutated. Unknown fields, invalid enum values, durations without units, unsupported schema versions, duplicate window names, more than one focused window, and a window that does not name exactly one of agent, command, or shell are all errors.

Example
version: 1

# Only meaningful in defaults.yaml. Directories searched when you name a
# workspace instead of running inside it.
repository_roots:
  - /home/you/workspace

devcontainer:
  enabled: auto        # auto | true | false
  start_timeout: 5m

environment:
  CGO_ENABLED: "1"

windows:
  - name: agent-1
    agent: claude
    focus: true
  - name: shell
    shell: true
  - name: build
    command: make test
    cwd: sub/dir       # relative to the repository root; may not escape it
    location: container

location is left unresolved when you omit it. It is decided later against the workspace's actual container binding rather than being defaulted to container or host at load time.

Usage

cd ~/workspace/my-project
projectmux open          # create the session if needed, then attach
projectmux status        # what is running, and what would change
projectmux stop          # end the session

projectmux <workspace> with no command is shorthand for open, so projectmux my-project opens that workspace from anywhere.

Commands
Command What it does
open observe, ensure, record, and attach the workspace session
attach attach to a live session; never creates one
stop end the session, and with --container its container
autostart start containers for registered repositories at boot
config print the merged configuration, or --validate it
list recorded workspaces and live identity-carrying sessions
status observe one workspace and explain drift
doctor diagnose dependencies, config, state, and drift
rebuild recover lost registrations from the identity keys live sessions carry
version print the version

Every command that produces a report accepts --json for a versioned envelope and --compact for that envelope on one line.

Full command reference → — flags, arguments, real output, and the exit code each command returns.

Commands that accept <workspace> resolve it from the current directory when you omit it, or look it up by name under the configured repository_roots. Either way the answer is a repository: a linked worktree — including the conventional .worktrees/ and .claude/worktrees/ directories — resolves to its parent repository rather than being a workspace of its own.

Exit codes
Code Meaning
0 success
1 unexpected or I/O failure
2 usage error
3 the workspace name matched more than one repository
4 the workspace name matched no repository
5 invalid configuration
6 the plan refused: a conflict or uncertainty; do not blindly retry

A mistyped bare command resolves as a workspace name rather than a usage error — projectmux opne exits 4 when no repository matches that name, not 2. Flag-shaped tokens and bad arguments to real commands still exit 2.

Relationship to tmux and Dev Containers

ProjectMux is a layer above both, and it owns neither.

tmux is the terminal multiplexer ProjectMux drives. ProjectMux does not replace it, wrap its key bindings, or manage your tmux.conf; it creates and reconciles sessions and windows and otherwise leaves tmux to you. You attach, detach, and navigate with tmux exactly as you normally would.

Dev Containers provide the optional container a window can run in. ProjectMux reads the standard devcontainer.json your editor already uses and delegates to the Dev Containers CLI rather than defining a competing container format:

  • devcontainer.enabled: auto uses a container when the repository has a Dev Container configuration.
  • devcontainer.enabled: true requires one and fails if it is missing.
  • devcontainer.enabled: false keeps every window on the host.

The design goal is that a workspace remains usable without ProjectMux. Removing it should leave a working repository, a working tmux, and a working Dev Container.

Questions

Does ProjectMux replace tmux?

No. It is a workspace controller built on tmux. Your existing key bindings, plugins, and tmux.conf keep working, and ProjectMux never edits them.

Does ProjectMux require Docker?

Only for container-backed windows. A workspace whose windows all run on the host needs just git and tmux — no container runtime and no Dev Containers CLI are involved.

Can it run CLI coding agents?

Yes. An agent window launches the configured command — claude, codex, or anything else on PATH — in an ordinary tmux window, on the host or in the Dev Container. ProjectMux manages the workspace lifecycle only: it does not assign tasks, coordinate models, or interpret agent output, and it is not an agent-orchestration platform.

Does it support git worktrees?

Yes, by treating the repository as the unit. Working in a linked worktree — including those in the conventional .worktrees/ and .claude/worktrees/ directories — resolves to the repository it belongs to, so every worktree of a project shares one workspace identity, one tmux session, and one Dev Container rather than each getting its own.

Does it create or manage worktrees?

No. Managing project source and creating worktrees are explicit non-goals. ProjectMux opens repositories that already exist; git and your existing tools remain responsible for creating and removing their worktrees. Working with git worktrees covers where to put them and how to reach them inside the container.

Which operating systems are supported?

Linux and WSL2. macOS and native Windows are not supported and are not currently tested.

Documentation

  • Command reference — every command, its flags, its output, and its exit codes.
  • Working with git worktrees — where to put them, why they share one session and one container, and how to reach them inside it.
  • Design — the full design document: architecture, identity and state, reconciliation, and the decisions behind them.

License

MIT. See LICENSE.

Directories

Path Synopsis
cmd
projectmux command
Command projectmux orchestrates declarative tmux workspaces whose windows may run on the host or inside a Dev Container.
Command projectmux orchestrates declarative tmux workspaces whose windows may run on the host or inside a Dev Container.
internal
bindpath
Package bindpath holds the path rules a session's bind obeys.
Package bindpath holds the path rules a session's bind obeys.
cli
Package cli parses commands, chooses human or JSON presentation, and maps typed errors to exit codes.
Package cli parses commands, chooses human or JSON presentation, and maps typed errors to exit codes.
config
Package config loads, merges, normalizes, validates, and digests the layered YAML that describes a workspace's desired state.
Package config loads, merges, normalizes, validates, and digests the layered YAML that describes a workspace's desired state.
container
Package container is the design-§5 container adapter: it owns every docker and devcontainer invocation, translating their output into domain observations.
Package container is the design-§5 container adapter: it owns every docker and devcontainer invocation, translating their output into domain observations.
controller
Package controller owns the workspace domain types, the interfaces it consumes, snapshot assembly (Observe), pure planning (BuildPlan), and reconciliation (Ensure, Stop).
Package controller owns the workspace domain types, the interfaces it consumes, snapshot assembly (Observe), pure planning (BuildPlan), and reconciliation (Ensure, Stop).
controller/fake
Package fake provides in-memory implementations of the controller's interfaces for tests in this and later slices.
Package fake provides in-memory implementations of the controller's interfaces for tests in this and later slices.
doctor
Package doctor diagnoses a projectmux installation: dependencies, configuration, the state database, and the drift between what the store records and what tmux and Docker actually hold.
Package doctor diagnoses a projectmux installation: dependencies, configuration, the state database, and the drift between what the store records and what tmux and Docker actually hold.
lock
Package lock provides the filesystem locks that serialize projectmux's mutating commands (design §9).
Package lock provides the filesystem locks that serialize projectmux's mutating commands (design §9).
rebuild
Package rebuild recovers lost workspace registrations from live tmux sessions.
Package rebuild recovers lost workspace registrations from live tmux sessions.
resolve
Package resolve turns a workspace name or a working directory into the canonical repository root and the identity derived from it.
Package resolve turns a workspace name or a working directory into the canonical repository root and the identity derived from it.
run
Package run executes subprocesses with contexts, timeouts, structured argv, bounded output capture, and retained exit status.
Package run executes subprocesses with contexts, timeouts, structured argv, bounded output capture, and retained exit status.
state
Package state owns the SQLite database holding current operational metadata.
Package state owns the SQLite database holding current operational metadata.
target
Package target parses the CLI's <target> argument, which is <repo> or <repo>/<session>.
Package target parses the CLI's <target> argument, which is <repo> or <repo>/<session>.
tmux
Package tmux is the read-only tmux adapter: it owns every tmux command this slice issues and translates tmux output into domain types.
Package tmux is the read-only tmux adapter: it owns every tmux command this slice issues and translates tmux output into domain types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL