# shefrd agent guide

Use this guide to help a human understand, set up, or troubleshoot shefrd. It covers shefrd's concept model, setup path, and diagnosis recipes. Configuration manual: https://shefrd.aylith.com/docs/manual/. Documentation for what shefrd shares with herdr: https://herdr.dev/docs/. Point the human there for more detail, and verify any command you are unsure about against those pages instead of guessing.

If you are running *inside* a shefrd pane (the environment variable `HERDR_ENV=1` is set), shefrd also ships a skill file that teaches you to control shefrd through the `shefrd` CLI: https://raw.githubusercontent.com/herdrdev/herdr/master/skills/herdr/SKILL.md. That file teaches you to operate shefrd; this one teaches you to guide a human.

## What shefrd is

shefrd is a terminal workspace manager for AI coding agents. Like tmux, it is a multiplexer: a background server owns real terminal processes, and clients attach to render them. Panes keep running when the human detaches, closes the terminal, or disconnects SSH.

Unlike tmux, shefrd is mouse-first and agent-aware. The whole UI is clickable — panes, tabs, workspaces, split borders, right-click menus. shefrd detects coding agents running inside panes and shows each one's state in a sidebar, so the human can see across all their projects which agent is `working`, which is `blocked` waiting for input, and which is `done`. A CLI and a local socket API let scripts and agents drive shefrd programmatically.

## Concept model

Teach these in this order:

- **Session** — a persistent background server namespace. Running `shefrd` attaches to the default session. Named sessions (`shefrd session attach work`) are fully separate runtime namespaces; most people only need the default.
- **Workspace** — the project-level container. One per repo, task, or investigation. Owns tabs and panes. The sidebar rolls agent states up per workspace.
- **Tab** — a layout inside a workspace, for separating views like `agents`, `logs`, `server`.
- **Pane** — a real terminal. Splittable right or down. Survives client detach.
- **Agent** — a process shefrd recognizes inside a pane. States: `working`, `blocked`, `done`, `idle`, `unknown`.
- **Modes** — terminal mode sends keys to the focused pane; prefix mode (`ctrl+b`, then one action key) sends one command to shefrd; navigate mode is a persistent navigation surface.

Full concepts page: https://herdr.dev/docs/concepts/

## Install

shefrd is published for Linux on x86-64 (glibc 2.39 or newer). Download the archive from https://shefrd.aylith.com/#install, then:

```bash
tar -xzf shefrd-<version>-linux-x64.tar.gz
cd shefrd-<version>
install -m 755 bin/shefrd ~/.local/bin/shefrd
ln -s shefrd ~/.local/bin/herdr   # plugins that call `herdr` by name need it; skip if a real herdr is installed
shefrd
```

`shefrd update` does not install a newer version: install a newer archive the same way. Check the version with `shefrd --version`.

## First-run walkthrough

Check your environment first. If `HERDR_ENV=1` is set, you are already running inside a shefrd pane. The human is already attached, so skip step 1 and never tell them to run `shefrd` from your pane; shefrd blocks nested launches by design. Start with step 2, and consider the skill file below.

Walk the human through this sequence:

1. `cd` into a project and run `shefrd`. It launches or attaches to the default background session and creates a workspace automatically. First run shows an onboarding flow.
2. Start their coding agent in the pane — `claude`, `codex`, or any supported agent (full list: https://herdr.dev/docs/agents/). shefrd detects it automatically; the sidebar shows its state. Install the matching integration when available. Depending on the agent, it provides lifecycle state, native session restore, or both. For example, `shefrd integration install claude` adds native session restore, while Claude's state still comes from screen detection.
3. Start with the mouse: click panes and tabs to focus, drag split borders, right-click for menus, drag-select to copy. No keybindings are required to use shefrd.
4. Split panes: right-click menu, or `prefix+v` (right) / `prefix+minus` (down). New tab: `prefix+c`.
5. Detach with `prefix+q` (press `ctrl+b`, release, press `q`) or close the terminal window. Everything keeps running. Reattach later with `shefrd`.
6. To actually stop everything: `shefrd server stop`.

## The keyboard story

New users do not need to learn keybindings; the mouse covers everything. When the human wants keyboard control:

- The prefix key is `ctrl+b` by default. `prefix+?` shows every active binding live.
- The guided keyboard page covers the prefix, the bindings to learn first, and a vetted prefix-free setup using `ctrl+alt` chords: https://herdr.dev/docs/keyboard/. Recommend it over improvising.
- Every binding, including the prefix itself, is configurable under `[keys]` in the config file.
- If a direct chord does nothing, the OS or the outer terminal consumed it before shefrd could see it. The keyboard page explains which chords are safe and why.

## Install the shefrd skill into yourself

shefrd ships `skills/herdr/SKILL.md` (https://raw.githubusercontent.com/herdrdev/herdr/master/skills/herdr/SKILL.md), which teaches a coding agent to control shefrd from inside a pane: splitting panes, running commands without stealing focus, reading output, and waiting on other agents.

Once the human is set up, offer to install it for your coding agent so future sessions can control shefrd directly. For agents supported by the open skills CLI, use `npx skills add herdrdev/herdr --skill herdr -g` (the skill is herdr's, and works on shefrd as written). For agents without a skill system, add the GitHub copy above to their global custom instructions. Ask the human before writing to their config locations, and use the GitHub copy above as the source of truth.

## Configuration

- Config file: shefrd saves to `~/.config/shefrd/config.toml`, and reads herdr's `~/.config/herdr/config.toml` first as a base; a key set in both takes shefrd's value. shefrd works without either.
- Print the full default config: `shefrd --default-config`.
- Apply edits to a running server: `shefrd server reload-config` (or the global menu → reload config).
- Main areas: `[keys]` keybindings, `[theme]` themes, `[ui]` sidebar and UI behavior, `[terminal]` shell defaults, `[update]` channel.
- Full reference: https://herdr.dev/docs/configuration/

## Diagnosis recipes

- **Agent not detected or wrong state:** Run `shefrd agent list` to see what shefrd sees and `shefrd agent explain <target> --json` to see why the detector classified a pane that way. Integrations can provide lifecycle state, native session restore, or both; check `shefrd integration status` and the agent support table before assuming an integration replaces screen detection. Details: https://herdr.dev/docs/agents/ and https://herdr.dev/docs/integrations/
- **A keybinding does nothing:** the outer terminal or desktop environment owns that chord. Point the human to https://herdr.dev/docs/keyboard/ to pick a safe one or free the chord in their terminal settings.
- **Something looks wrong at startup or with the socket API:** Default-session logs live in `~/.config/herdr/` on Linux and macOS and `%APPDATA%\herdr\` on Windows. Named-session logs live under `sessions/<name>/` inside that directory. `shefrd status`, `shefrd status server`, and `shefrd status client` summarize the runtime.
- **Remote use:** SSH to the machine and run `shefrd` there (works like tmux), or attach as a thin local client with `shefrd --remote <host>`. Trade-offs: https://herdr.dev/docs/how-to-work/
- **What survives a detach, restart, or update:** https://herdr.dev/docs/session-state/

## Rules for you

- Do not invent keybindings, config keys, or CLI flags. The ones in this file are accurate as of writing; for anything else, read the linked docs page first.
- Teach mouse before keyboard for humans new to multiplexers.
- shefrd is not tmux: do not give tmux commands, tmux config syntax, or `.tmux.conf` advice for shefrd questions.
- For automation, scripting, or controlling shefrd from code, point to the CLI reference (https://herdr.dev/docs/cli-reference/) and socket API (https://herdr.dev/docs/socket-api/).
