projectmux

module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 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, including linked git worktrees in the conventional directories.
  • 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

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 the configuration schema and the command surface may change before 1.0, and there is no migration support for v0.x configuration. The versioned JSON envelope and the documented exit codes are the compatibility contracts.

Project status

The command surface is complete; the contracts are not yet stable. ProjectMux opens, attaches to, stops, and reports on workspaces, starts containers at boot, and diagnoses its own installation. Every command listed below works.

Expect breaking changes to the configuration schema and the command surface while the version remains below 1.0. There is no migration support, and v0.x builds are published as prereleases.

Two things are compatibility contracts even during the alpha:

  • The JSON output of the reporting commands, which carries a schema_version field.
  • The exit codes listed below.

Human-readable output is deliberately not a contract. Parse --json instead.

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.3.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.

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, and a formatting check the same way CI does:

test -z "$(gofmt -l .)"
go vet ./...
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 worktree; 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 primary worktrees 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, including linked worktrees in the conventional .worktrees/ and .claude/worktrees/ directories.

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

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. Workspace lookup resolves linked worktrees, including those in the conventional .worktrees/ and .claude/worktrees/ directories, and workspace identity is collision-safe across them. A linked worktree shares its parent repository's configuration.

Does it create or manage worktrees?

No. Managing project source and creating worktrees are explicit non-goals. ProjectMux opens worktrees that already exist; git and your existing tools remain responsible for creating them.

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.
  • 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
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 per-workspace filesystem lock (design §9).
Package lock provides the per-workspace filesystem lock (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 worktree and the identity derived from it.
Package resolve turns a workspace name or a working directory into the canonical worktree 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.
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