# Herdr

Herdr is an open-source app that runs coding agents in tabs. The agents run in herdr-core, a server on your machine, so they continue when you close the window. Herdr has no model settings of its own. Each agent that it runs uses its own provider.

To use the exchange in Herdr, start each agent with the [Arc CLI](https://liquidinference.ai/docs/cli.md). This guide adds `arc` commands to the menu that starts agents in Herdr.

This guide follows the `AGENTS.md` file that Herdr writes in `~/.config/herdr-app`. Check each step against your Herdr release.

## Before you start

- A workspace with a balance. See [API keys](https://liquidinference.ai/docs/keys.md).
- The Arc CLI, with a saved key:

  ```bash
  curl -fsSL https://inference.ai.exchange/cli/install.sh | bash
  arc login
  ```

- Herdr from [herdr.dev](https://herdr.dev/download/).
- For the status of Claude Code in Herdr, Claude Code 2.1.326 or newer.

## 1. Start an agent in a tab

Open a terminal tab in Herdr and start an agent with `arc`:

```bash
arc claude
```

`arc` sets the base URL, the key and the model for that process only. A plain `claude` in another tab still uses your own account.

Put the flags of `arc` before the flags of the agent. `arc` reads its own flags (`--model`, `--cap`, `--filter`) until the first flag that it does not know. It sends the rest to the agent.

```bash
arc claude --cap 0.50 -p "explain this repository"   # correct
arc claude -p "explain this repository" --cap 0.50   # Claude Code refuses --cap
```

## 2. Add the agents to the menu

The **+** menu in the tab bar starts agents. Herdr reads its entries from `~/.config/herdr-app/programs.json`. Run this command to add an entry for each agent that `arc` starts and that is on your `PATH`:

```bash
arc desktop herdr
```

- Each entry is named `arc-<tool>`, such as `arc-claude-code`. It runs `arc <tool>` with the full path of `arc`, so Herdr finds it without your shell's `PATH`.
- The file holds no key. `arc` reads the saved key, model and cap each time that it starts an agent.
- Add `--model` or `--cap` to put that flag on each entry. `--print` shows the change and does not make it.
- Run the command again after you install another agent.
- `arc desktop remove herdr` takes out only these entries. Your other entries stay.

Herdr reads the file again when it changes. Run `herdr-app status` to see an error in the file.

### Write the entries yourself

To start an agent with other flags, add an entry by hand. For example, this entry starts Claude Code with Auto, ranked by price:

```json
{
  "programs": {
    "claude-cheap": {
      "name": "Claude, cheapest (Architect)",
      "icon": "icons/claude.svg",
      "run": ["arc", "claude", "--model", "architect.auto:cheapest", "--cap", "0.50"]
    }
  }
}
```

- Do not name an entry `arc-<tool>` with a tool id from `arc tools`, such as `arc-opencode`. `arc desktop herdr` replaces and removes the entries with those names.
- `run` must name a program or a shell function. The launcher does not expand an alias.
- If Herdr cannot find `arc`, write its full path in `run`. `which arc` shows it.

## 3. Check it works

1. Open **+** in the tab bar and choose **Claude Code (Architect)**.
2. Send a short request.
3. Open **Credits → Receipts** and check for the charge.

The tab shows the status of the agent: working, done, or waiting for you. Herdr gets the status from the agent through the OSC 7501 control sequence. Claude Code before 2.1.326 stops this report, and Herdr then shows the tab as a shell.

## Control the cost

Herdr does not stop an agent when you close the window. An agent continues to send requests, and the exchange continues to charge for them.

- `--cap` limits what one request can cost. It does not limit a session.
- To limit the total, give Herdr its own key with a spend limit. See [API keys](https://liquidinference.ai/docs/keys.md).

## Agents on other machines

Herdr can add a machine over SSH with `hc machine add`. An agent on that machine uses the `arc` and the key of that machine. Install the Arc CLI and run `arc login` there too.

## Troubleshooting

| Symptom                               | Cause and fix                                                                                                                            |
| ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| The **+** menu has no `arc` entry     | Run `arc desktop` to check that Herdr is set up. Run `herdr-app status` to see an error in `programs.json`.                              |
| An agent is not in the menu           | Install the agent, then run `arc desktop herdr` again. Only agents on `PATH` get an entry.                                               |
| The tab closes with an error at start | Herdr cannot find `arc`. If `arc` moved, run `arc desktop herdr` again. For an entry that you wrote, use the full path in `run`.         |
| `unknown option '--cap'`              | Put the flags of `arc` before the flags of the agent.                                                                                    |
| The tab shows a shell and no status   | Update Claude Code to 2.1.326 or newer. If you have two copies, run `which -a claude` in a login shell. The launcher uses the first one. |
| `401`                                 | Run `arc login` again on that machine.                                                                                                   |
| `402`                                 | Add credit to the workspace or check the key's spend limit.                                                                              |

See [Errors](https://liquidinference.ai/docs/errors.md) for the exchange's error codes.

## Next steps

- [Arc CLI](https://liquidinference.ai/docs/cli.md): the models, the caps and the settings of `arc`.
- [Claude Code](https://liquidinference.ai/docs/connect-claude-code.md): what `arc claude` sets.
- [API keys](https://liquidinference.ai/docs/keys.md): key scope and spend limits.
