# Getting started

This guide goes from an empty machine to a running stack that you watch in the TUI and steer from
a second terminal. It takes a few minutes with Homebrew, a few more when Cargo compiles `micromux`.

## Install

**Homebrew**

On macOS or Linux:

```sh
brew install --cask romnn/tap/micromux
```

**Cargo**

With a [Rust toolchain](https://rustup.rs), which compiles `micromux` and takes a few minutes:

```sh
cargo install --locked micromux-cli
```

The MCP server for [coding agents](https://romnn.github.io/micromux/docs/agent-control/) is part of the default
build. To leave it out of a smaller, TUI-only binary:

```sh
cargo install --locked --no-default-features micromux-cli
```

Check that it runs:

```console
$ micromux --version
micromux-cli 0.5.3 (protocol 4.0)
```

### Platforms

- **Linux and macOS:** everything works.
- **Windows:** the TUI runs, but the control plane does not yet, so `attach`, `ctl`, `mcp` and
  `serve` are not available, and stopping a service kills it at once instead of asking it to stop
  first.

## 1. Describe your services

`micromux` reads the first of these files that it finds in the directory you start it in:

- `micromux.yaml`
- `.micromux.yaml`
- `micromux.yml`
- `.micromux.yml`

Write one for your stack. This one runs a database, a migration job once the database is healthy,
and an API once the migration completed:

```yaml {title="micromux.yaml"}
version: "1"

# Restart a service that exits, unless you stopped it yourself.
restart: unless-stopped

services:
  postgres:
    command: postgres -D ./pgdata
    healthcheck:
      test: pg_isready -q

  # A job runs to completion. A service that depends on it waits
  # until it exits with status 0.
  migrate:
    kind: job
    command: ./scripts/migrate.sh
    depends_on:
      - name: postgres
        condition: healthy

  api:
    command: ./run-api
    env_file: .env
    depends_on:
      - migrate
    healthcheck:
      test: ["CMD-SHELL", "curl -fsS http://localhost:8080/health"]
```

Each service needs a `command`; everything else is optional. To keep a service from starting
with the others, mark it `disabled: true` and enable it when you need it, with `d` in the TUI or
`micromux ctl enable <service>`.

[Configuration](https://romnn.github.io/micromux/docs/configuration/) describes every key, and the
[reference](https://romnn.github.io/micromux/docs/configuration/reference/) has the comment that gives editors completion
and validation.

## 2. Run it

In the directory of the config:

```sh
micromux
```

`micromux` starts every service once its dependencies are ready and opens the TUI. Here `postgres`
starts first, `migrate` once `postgres` reports healthy, and `api` once `migrate` completed.

To use a config from another directory, name it:

```sh
micromux --config ../shop/micromux.yaml
```

## 3. Read the TUI

The sidebar lists the services, each with its state. The pane beside it shows the selected
service's output as it arrives. The screenshots here show the larger demo stack in
[`examples/demo`](https://github.com/romnn/micromux/tree/main/examples/demo):

![The micromux TUI: a sidebar of services, each with its state, such as HEALTHY, COMPLETED, UNHEALTHY, BLOCKED and IDLE, beside the API server's live logs](https://romnn.github.io/micromux/images/hero.png)

Each row shows a service's state: healthy, running, a completed job, unhealthy, blocked behind a dependency, or a manual job that has not run.


The keys you need first:

- **`j` and `k`:** select a service, as the arrow keys do.
- **`r`:** restart the selected service, or run a job again.
- **`d`:** disable the selected service, which stops it, or enable it again.
- **`H`:** show why a healthcheck fails: the probe's command, exit code and output.
- **`?`:** list every key.

![The healthcheck pane beside the logs of the unhealthy payments service, showing the failed probe's command, exit code 1 and its output, connect: connection refused](https://romnn.github.io/micromux/images/healthcheck.png)

`H` on an unhealthy service shows its last probe.


[The terminal UI](https://romnn.github.io/micromux/docs/tui/) describes every pane and key.

## 4. Steer it from the shell

A running session answers `micromux ctl` from any terminal in the same directory, so a script or a
second terminal can check on it. Restart a service, or read its latest output:

```console
$ micromux ctl restart api
$ micromux ctl logs api --tail 50
```

Ask why a healthcheck fails, here for the demo's `payments` service:

```console
$ micromux ctl health payments
attempt 1 `sh -c "echo 'connect: connection refused'; exit 1"` -> success=false exit_code=1
  connect: connection refused
```


A restart from the shell works as `r` in the TUI does. `api` waits for its dependencies again,
and picks up your edits to its definition in `micromux.yaml`.
[The control plane](https://romnn.github.io/micromux/docs/agent-control/control-plane/) lists every command, and
[Agent control](https://romnn.github.io/micromux/docs/agent-control/) lets Claude Code or Codex do the same.

## 5. Stop it

Press `q` in the TUI. `micromux` stops every service and exits. `Ctrl-C` does not quit, so a stray
one cannot end the session.

## Next steps

- **[Configuration](https://romnn.github.io/micromux/docs/configuration/):** dependencies, healthchecks, restart
  policies, logs, and ports and hostnames for several checkouts side by side.
- **[The terminal UI](https://romnn.github.io/micromux/docs/tui/):** every pane and key, the mouse, and attaching to a
  session that runs without a TUI.
- **[Agent control](https://romnn.github.io/micromux/docs/agent-control/):** let a coding agent read logs, restart
  services and wait for them.
