> ## Documentation Index
> Fetch the complete documentation index at: https://docs.remotemux.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Workflow Patterns

> Day-to-day workspace commands and common workflow patterns.

Once an environment exists, day-to-day RemoteMux usage comes down to workspace commands.

<Info>
  The current directory is the selector. Re-enter the same local directory before using `workspace` or `env` commands so RemoteMux can load the binding from `.rmux/state.json`.
</Info>

## Basics

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
rmux workspace attach              # reconnect to the default main workspace
rmux workspace attach server       # reconnect to a named workspace
rmux workspace ls                  # list all workspaces
rmux env status                    # environment overview
```

## Running Commands Remotely

Send commands to a workspace without opening an interactive terminal:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
rmux workspace run bun test
rmux workspace run -w server bun install
rmux workspace run -w server bun run dev
```

## Named Workspaces

Create isolated workspaces for parallel work:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
rmux workspace new server
rmux workspace new agent-a
rmux workspace new agent-b
```

For git repos, named workspaces use remote git worktrees. For non-git directories, RemoteMux creates copied folders. `main` always uses the shared `/workspace` root.

Remove a workspace when done:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
rmux workspace rm server            # may prompt if uncommitted changes exist
rmux workspace rm server --force    # skip confirmation
```

## Background Servers

Keep a dev server in its own workspace so `main` stays clean:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
rmux workspace new server
rmux workspace run -w server bun run dev
rmux env expose 3000
rmux env ports
```

The server stays running even when you detach from all workspaces.

## Logs

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
rmux workspace logs                    # default workspace
rmux workspace logs server --follow    # tail a named workspace
```

## Secrets

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
echo 'your-value' | rmux env secrets set OPENAI_API_KEY
rmux env secrets ls
rmux env secrets rm OPENAI_API_KEY
```

Secrets are available as environment variables in all workspaces.

## Ports

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
rmux env expose 3000    # returns the generated URL immediately
rmux env ports          # list all exposed ports and URLs
```

## Code Sync

`rmux workspace new main` performs the initial seed. After that:

* Use **git** to move code between local and remote (recommended).
* Use `rmux env sync` to push the current local directory into the environment root.

## Common Patterns

### Resume after disconnect

Close your laptop, switch machines, or lose Wi-Fi. The `tmux` session survives:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
cd my-project
rmux workspace attach
# Same session, same scrollback, same running processes.
```

### Code review in isolation

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
rmux workspace new review-pr-42
rmux workspace attach review-pr-42
# Inside: git fetch && git checkout pr-branch
# Review, then clean up:
rmux workspace rm review-pr-42
```

### Long test suites

Run the full suite remotely while you keep working locally:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
rmux workspace new tests
rmux workspace run -w tests bun test -- --coverage
rmux workspace logs tests --follow
```
