Lesson 04 · Using Herdr Effectively

Remote Work and Restore

Attach from anywhere without losing track of where the work runs

Your tangible win

After this lesson, you can choose the correct Herdr connection path for a remote project and predict what will survive a detach, a server restart, or an update.

The operating model

Run Herdr where the work lives. Your terminal client is only a view. The machine running the Herdr server owns the panes, processes, agents, code, and credentials.

Three ways to attach

flowchart TB L["Local project"] --> LH["herdr"] S["Remote project"] --> SSH["ssh, then herdr"] S --> RC["herdr --remote"] LH --> LP["Local server owns work"] SSH --> RP["Remote server owns work"] RC --> RP style L fill:#dbeafe,stroke:#2563eb,stroke-width:2px style S fill:#faf5ff,stroke:#9333ea,stroke-width:2px style LH fill:#f0fdf4,stroke:#16a34a,stroke-width:2px style SSH fill:#f0fdf4,stroke:#16a34a,stroke-width:2px style RC fill:#f0fdf4,stroke:#16a34a,stroke-width:2px style LP fill:#fef9c3,stroke:#ca8a04,stroke-width:2px style RP fill:#fef9c3,stroke:#ca8a04,stroke-width:2px
Figure 1: The client can be local or remote; the server should stay with the project, credentials, and agents.

Local work

From the project directory, run:

cd ~/your-project
herdr

Herdr starts or attaches to the local background session. Run shells, servers, tests, and agents normally inside its panes.

SSH first, Herdr second

Use this when you already work in a remote shell, use a phone SSH client, or want the simplest mental model:

ssh you@server
herdr

The shell, Herdr server, panes, and agents all run on the remote server. Detach with Ctrl+B, then Q; disconnect SSH; reconnect later and run herdr again.

Local thin client

Use this when you want the remote session to feel local:

herdr --remote workbox
herdr --remote ssh://you@server:2222

Your local Herdr is only the client. The remote host still owns the Herdr server and the work. Local desktop features such as image clipboard bridging can work through this path.

SituationUseWork runs on
Local repositoryherdrLocal machine
Already inside SSHssh ..., then herdrRemote server
Want a local-feeling remote UIherdr --remote workboxRemote server
Phone or tabletSSH, then herdrRemote server

Detach is not stop

Detach the client with:

Ctrl+B, then Q

That closes your view, not the Herdr server. Panes, shells, agents, servers, tests, and commands continue running. Reattach with:

herdr

To actually stop the session and its panes:

herdr server stop

Named sessions

Named sessions provide independent Herdr servers with their own panes, tabs, workspaces, sockets, and runtime state:

herdr session list
herdr session attach work
herdr session attach side-project
herdr session stop work
herdr session delete side-project

Use a named session when you want a strong boundary between unrelated projects or operational contexts.

What survives?

flowchart TB D["Detach"] --> P["Processes keep running"] R["Server restart"] --> S["Layout restores"] R --> X["Processes stop"] I["Native integration"] --> A["Agent conversation may resume"] H["Live handoff"] --> L["Live panes may continue"] style D fill:#dbeafe,stroke:#2563eb,stroke-width:2px style P fill:#f0fdf4,stroke:#16a34a,stroke-width:2px style R fill:#faf5ff,stroke:#9333ea,stroke-width:2px style S fill:#dbeafe,stroke:#2563eb,stroke-width:2px style X fill:#fef9c3,stroke:#ca8a04,stroke-width:2px style I fill:#faf5ff,stroke:#9333ea,stroke-width:2px style A fill:#f0fdf4,stroke:#16a34a,stroke-width:2px style H fill:#faf5ff,stroke:#9333ea,stroke-width:2px style L fill:#f0fdf4,stroke:#16a34a,stroke-width:2px
Figure 2: Detach preserves the original runtime. Restart reconstructs state; integrations and handoff provide stronger, separate restore paths.

Detach and reattach

This is the strongest persistence path because the original processes never stop:

Ctrl+B, then Q
herdr

Server restart

After the server stops and starts, Herdr restores the saved shape: workspaces, tabs, panes, working directories, layout, and focus. Ordinary shells, servers, tests, and commands are gone; panes return as new shells.

Native agent session restore

Supported official integrations can report native agent session references. Herdr can use those references to resume an agent conversation after a server restart. Check the current integration state:

herdr integration status

Without a valid native session reference, the pane falls back to a normal shell in its saved directory.

Pane history replay

Optional pane history restores recent terminal contents, not the old process. It is off by default because terminal output can contain secrets, tokens, prompts, and command output. If you enable it:

[experimental]
pane_history = true

Treat the Herdr config/session directory like terminal history.

Live handoff

Live handoff is an experimental, opt-in path for replacing a running server while trying to keep live panes and processes:

herdr update --handoff
herdr --remote workbox --handoff

It can preserve live PTYs and processes when it succeeds, but in-flight CLI requests, waits, subscriptions, client sockets, and pane-to-pane messages may be interrupted. Reconnect and retry those operations.

Decision rule

If the work must not stop, detach instead of stopping the server. Treat restart restore as reconstruction, not time travel. Use native integration restore or live handoff only when their specific guarantees fit your case.

Checkpoint: choose the remote path

  1. Identify where the repository and credentials live.
  2. Run Herdr on that machine.
  3. Choose SSH-first if you want a simple remote terminal.
  4. Choose herdr --remote if you want a local-feeling client.
  5. Detach with Ctrl+B, then Q.
  6. Reconnect and verify the agent state before sending new input.
Your code and credentials are on a remote server. Which path keeps the Herdr runtime there while giving you a local-feeling UI?

Remember this

Run Herdr where the work lives. Attach from wherever you are. Detach to preserve live work; restart only when reconstruction is acceptable.

Primary sources

This lesson follows Herdr's official How to work, Persistence and remote access, Session state and restore, and CLI Reference. Use the remote work and restore cheat sheet for retrieval practice.