herdr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHerdr
Herdr
Herdr is terminal orchestration, not native agent-to-agent communication or shared memory. Agents call the CLI, which controls panes through Herdr's local socket. This works across Pi, Codex, Claude Code, Cursor CLI, and other terminal agents. Native integrations only improve detection, status accuracy, and session restoration.
herdrHerdr是终端编排工具,而非原生Agent间通信或共享内存工具。Agent通过调用 CLI,借助Herdr的本地套接字来控制窗格。它适用于Pi、Codex、Claude Code、Cursor CLI及其他终端Agent。原生集成仅能提升检测能力、状态准确性和会话恢复功能。
herdrPreconditions
前置条件
The controlling agent must run inside Herdr in Ghostty. Verify access and workspace scope:
bash
test "${HERDR_ENV:-}" = "1"
test -n "${HERDR_WORKSPACE_ID:-}"If either fails, do not pretend to access other agents; tell the user the agent must be launched inside Herdr.
One-time installation:
bash
npx skills add ogulcancelik/herdr --skill herdr -g控制Agent必须在Ghostty的Herdr内部运行。请验证访问权限和工作区范围:
bash
test "${HERDR_ENV:-}" = "1"
test -n "${HERDR_WORKSPACE_ID:-}"如果任一验证失败,请勿假装可以访问其他Agent;请告知用户该Agent必须在Herdr内部启动。
一次性安装命令:
bash
npx skills add ogulcancelik/herdr --skill herdr -gCLI workflow
CLI 工作流
bash
undefinedbash
undefinedDiscover pane IDs in this workspace; never guess them
发现当前工作区中的窗格ID;请勿猜测
herdr pane list --workspace "$HERDR_WORKSPACE_ID"
herdr pane list --workspace "$HERDR_WORKSPACE_ID"
Read the target's recent context
读取目标的近期上下文
herdr pane read <pane-id> --source recent-unwrapped --lines 120
herdr pane read <pane-id> --source recent-unwrapped --lines 120
Send a prompt and press Enter
发送提示并按下回车
herdr pane run <pane-id> "Check the failing tests and report back."
herdr pane run <pane-id> "Check the failing tests and report back."
Wait for completion; use idle instead if that integration reports idle
等待完成;如果集成支持idle状态,则改用idle
herdr wait agent-status <pane-id> --status done --timeout 120000
herdr wait agent-status <pane-id> --status done --timeout 120000
Read the result
读取结果
herdr pane read <pane-id> --source recent-unwrapped --lines 120
Stay inside the current workspace. Read before messaging; for inspection-only requests, send nothing. After messaging, wait for `done`, `idle`, or `blocked`, then read the output again. Never assume the prompt was acted on.
Do not close, rename, move, resize, or reconfigure panes you did not create. Do not create or close panes unless the user explicitly asks. “Use the Herdr skill” means execute these CLI operations, not merely explain them.herdr pane read <pane-id> --source recent-unwrapped --lines 120
请保持在当前工作区内操作。发送消息前先读取内容;对于仅需检查的请求,请勿发送任何消息。发送消息后,等待状态变为`done`、`idle`或`blocked`,然后再次读取输出内容。请勿假设提示已被执行。
请勿关闭、重命名、移动、调整大小或重新配置非你创建的窗格。除非用户明确要求,否则请勿创建或关闭窗格。“使用Herdr技能”意味着执行这些CLI操作,而非仅仅解释它们。Sharp edges (empirically verified)
注意事项(经验证)
Hard-won facts from driving herdr in production. Trust these over intuition.
这些是在生产环境中使用Herdr总结出的重要结论,请优先遵循这些规则而非凭直觉操作。
Sessions & targeting
会话与目标定位
- Always append to every command. The
--session <name>env var alone silently falls back to whatever server is already running.HERDR_SESSION - Destructive ops only via /
herdr session stop <name>(explicit positional name). Neverherdr session delete <name>— it acts on whatever server is ambient.herdr server stop - Target shape is ; the pane id itself contains a colon (
<session>:<pane-id>). Split on the FIRST colon only.w1:p2 - A bare CLI call does not auto-start a server. Start headless with .
herdr server --session <name> - Every herdr-managed process gets and
HERDR_ENV=1. Inside nested tmux,HERDR_PANE_IDwins — treat that pane as tmux.$TMUX
- 请始终在每个命令后追加。仅依赖
--session <name>环境变量会静默回退到当前运行的任意服务器。HERDR_SESSION - 仅通过/
herdr session stop <name>执行破坏性操作(需明确指定会话名称)。切勿使用herdr session delete <name>——它会作用于当前运行的任意服务器。herdr server stop - 目标格式为;窗格ID本身包含冒号(如
<session>:<pane-id>)。请仅按第一个冒号进行拆分。w1:p2 - 直接调用CLI不会自动启动服务器。请使用启动无头服务器。
herdr server --session <name> - 每个由Herdr管理的进程都会获得和
HERDR_ENV=1。在嵌套的tmux中,HERDR_PANE_ID优先级更高——请将该窗格视为tmux窗格。$TMUX
Sending input
发送输入
- types but does NOT submit — follow with
pane send-text.pane send-keys <pane> enter= text + Enter in one call.pane run - is reliable into a shell prompt, but TUI agent composers (Claude Code, Cursor CLI) treat its text+Enter burst as a paste and swallow the Enter — text sits typed but unsubmitted. To message a TUI agent:
pane run, sleep ~1s, then a separatesend-text.send-keys <pane> enter - C0 control bytes (e.g. ASCII 0x1f) are consumed as terminal control actions and can erase already-typed text. For invisible markers use U+2063 INVISIBLE SEPARATOR — it travels as text.
- Slash commands open an autocomplete popup; the first Enter may only close the popup or fill an argument placeholder, not submit. dismisses the popup and keeps the text.
escape - Never verify a submit by "pane content changed". Confirm via native agent status flipping to /
workingafter Enter.blocked
- 仅输入文本但不提交——需后续执行
pane send-text。pane send-keys <pane> enter= 输入文本+回车一步完成。pane run - 在shell提示符下是可靠的,但TUI Agent编辑器(如Claude Code、Cursor CLI)会将其文本+回车的连续输入视为粘贴操作并忽略回车——文本已输入但未提交。要向TUI Agent发送消息:先执行
pane run,等待约1秒,再单独执行send-text。send-keys <pane> enter - C0控制字节(如ASCII 0x1f)会被当作终端控制操作消耗,可能会删除已输入的文本。如需使用不可见标记,请使用U+2063不可见分隔符——它会作为文本传输。
- 斜杠命令会打开自动补全弹窗;第一次回车可能仅关闭弹窗或填充参数占位符,而非提交。会关闭弹窗并保留文本。
escape - 请勿通过“窗格内容已更改”来验证提交是否成功。请通过Enter后原生Agent状态切换为/
working来确认。blocked
Reading panes
读取窗格
- returns COMPLETELY EMPTY output when N is smaller than the pane's viewport height. Always request >=200 lines and trim locally (
pane read --lines N).tail -n N pane getis frozen at pane creation. Use.cwdfor the live working directory..foreground_cwd- preserves styling. Ghost/placeholder composer text (rotating suggestions, hints) renders dim (SGR-2) or dark truecolor; real typed input renders normal. This is the only reliable way to tell an empty composer from a human draft.
pane read --format ansi
- 当N小于窗格视口高度时,会返回完全空的输出。请始终请求至少200行,然后在本地修剪(如
pane read --lines N)。tail -n N pane get的值在窗格创建时就固定了。请使用.cwd获取实时工作目录。.foreground_cwd- 会保留样式。Ghost/占位符编辑器文本(轮换建议、提示)会以暗淡(SGR-2)或深色真彩色显示;实际输入的文本会以正常样式显示。这是区分空编辑器和人工草稿的唯一可靠方法。
pane read --format ansi
Agent state
Agent状态
- reports
herdr agent get <pane>/working/idle/done/blocked— native detection, better than regex-guessing.unknown - Known gap: status reads during a long-running foreground tool call (the model finished its turn; the tool is still grinding). Corroborate an
idleverdict with pane text (busy banners like "esc to interrupt") before treating a pane as free or stale.idle - Blocking waits exist: and
herdr agent wait <pane> --status <s> --timeout MS.herdr wait output <pane> --match <text> - Push events over the socket (protocol >=16): ,
pane.agent_status_changed. Use as the fast path; keep polling as the backstop.pane.output_matched - Any script can register itself as an agent via and report idle/working/blocked.
pane report-agent
- 会报告
herdr agent get <pane>/working/idle/done/blocked——这是原生检测,比正则猜测更准确。unknown - 已知缺陷:在长时间运行的前台工具调用期间,状态会显示为(模型已完成其轮次,但工具仍在运行)。在将窗格视为空闲或失效前,请结合窗格文本(如“esc to interrupt”等忙碌提示)来确认
idle状态的准确性。idle - 支持阻塞等待:和
herdr agent wait <pane> --status <s> --timeout MS。herdr wait output <pane> --match <text> - 套接字推送事件(协议版本>=16):、
pane.agent_status_changed。请将其作为快速路径;将轮询作为后备方案。pane.output_matched - 任何脚本都可以通过注册为Agent,并报告idle/working/blocked状态。
pane report-agent
Workspace / tab lifecycle
工作区/标签页生命周期
- NO label uniqueness anywhere: workspaces and tabs can share labels. Do your own duplicate checks; find-by-label adopts the first match. An unlabeled workspace displays its cwd basename as its label — a real collision hazard (once caused an adapter to kill a live agent pane it wrongly adopted).
- seeds one default tab labeled
workspace create. Closing a workspace's LAST tab deletes the workspace. Closing a tab's only pane closes the tab.1 - is respected on workspace/tab create, except the very first workspace in an empty session (always focuses).
--no-focusstill shrinks the host tab's viewport — the flag governs focus, not geometry.pane split --no-focus - Workspace/tab/pane IDs and labels survive a server restart within a named session. The processes and agent registrations do NOT — panes return as husks (fresh shell, reports
agent get). Close-and-replace husks; don't treat them as live duplicates.agent_not_found
- 任何地方都不保证标签唯一性:工作区和标签页可以共享相同的标签。请自行检查重复项;按标签查找会采用第一个匹配项。未标记的工作区会将其当前工作目录的基名显示为标签——这存在实际冲突风险(曾导致适配器错误地终止了它错误识别的活跃Agent窗格)。
- 会创建一个标记为
workspace create的默认标签页。关闭工作区的最后一个标签页会删除该工作区。关闭标签页的唯一窗格会关闭该标签页。1 - 在创建工作区/标签页时,参数会被遵守,但空会话中的第一个工作区除外(始终会获得焦点)。
--no-focus仍会缩小宿主标签页的视口——该参数控制焦点,而非几何尺寸。pane split --no-focus - 在命名会话中,工作区/标签页/窗格的ID和标签在服务器重启后会保留。但进程和Agent注册不会保留——窗格会变为空壳(全新shell,会报告
agent get)。请关闭并替换空壳窗格;不要将它们视为活跃的重复项。agent_not_found
Misc
其他
- inside a script launched via
tput colsreports a stale default (80). Never trust it for layout math.pane run - For risky experiments use an isolated named session (never ), and re-check
defaultimmediately before any stop/delete.herdr session list --json - (claude, codex, cursor, pi, ...) enables native status detection per agent.
herdr integration install <harness>fires a desktop-style alert.herdr notification show <title>
- 通过启动的脚本内,
pane run会报告过时的默认值(80)。请勿依赖它进行布局计算。tput cols - 进行风险实验时,请使用独立的命名会话(切勿使用),并在执行任何stop/delete操作前立即重新检查
default。herdr session list --json - (claude、codex、cursor、pi等)可为每个Agent启用原生状态检测。
herdr integration install <harness>会触发桌面样式的提醒。herdr notification show <title>
Launching agents in new panes (when the user asks)
在新窗格中启动Agent(当用户要求时)
ALWAYS launch agents with auto-approval — a worker in an unattended pane stalls forever on a y/n prompt nobody answers:
- Cursor CLI: (alias for
cursor-agent --yolo "task")--force - Codex CLI:
codex --yolo "task" - Claude Code:
claude --dangerously-skip-permissions "task"
This is safe only if a global agent guardrails deny-list hook is installed across all agents. First-run trust dialogs may still appear despite these flags — peek the pane after launch. (once each) enables native agent-status detection.
herdr integration install <cursor|codex|claude>NEVER verify a launch with — that is a non-herdr antipattern. Use the native waits: (agent picked up the task) or , then read the pane.
sleep N && pane readherdr agent wait <pane> --status working --timeout MSherdr wait output <pane> --match <text>请始终以自动批准模式启动Agent——无人值守窗格中的Worker会因无人应答y/n提示而永久停滞:
- Cursor CLI: (
cursor-agent --yolo "task"的别名)--force - Codex CLI:
codex --yolo "task" - Claude Code:
claude --dangerously-skip-permissions "task"
仅当所有Agent都安装了全局Agent防护禁用列表钩子时,此操作才是安全的。即使使用这些标志,首次运行的信任对话框仍可能出现——启动后请查看窗格内容。(每个Agent执行一次)可启用原生Agent状态检测。
herdr integration install <cursor|codex|claude>切勿使用来验证启动是否成功——这是非Herdr的反模式。请使用原生等待:(Agent已接手任务)或,然后读取窗格内容。
sleep N && pane readherdr agent wait <pane> --status working --timeout MSherdr wait output <pane> --match <text>Cursor CLI specifics
Cursor CLI 特定说明
The real binary is ( is an alias/new docs name — don't rely on it in scripts). The user's shorthand = : fine to type into an interactive pane, but use the full binary in scripts — aliases don't expand there. Launch into an existing pane:
cursor-agentagentcurcursor-agent --yolobash
herdr pane run <pane-id> "cd <worktree> && cursor-agent --model gpt-5.3-codex-high --yolo 'fix the failing tests'"- Interactive: (or no arg for empty session). Headless:
cursor-agent "task".cursor-agent -p "task" --output-format text|json|stream-json - Permissions: runs commands without per-command approval (alias
--force);--yolo. Auth for scripts:--sandbox enabled|disabledenv var.CURSOR_API_KEY - Model: at launch,
--model <slug>in-session. Enumerate with/model— slugs are version/account-dependent, never hardcode from memory.cursor-agent --list-models - Reasoning effort: there is NO flag — effort is baked into the slug suffix:
--effort/-low/-medium/-high(e.g.-xhigh,gpt-5.3-codex-xhigh).claude-opus-4-8-thinking-highis speed, not effort. Bracket syntax-fastshown inmodel[effort=high]is NOT actually supported — always use full slugs.--help - Known bug (mid-2026): some CLI builds silently drop the reasoning suffix passed via and fall back to default effort. Verify with
--modelafter launch;/modelkeeps a working build stable.--disable-auto-update - Resume: (latest),
cursor-agent resume,--resume <chatId>to list.cursor-agent ls
真实的二进制文件是(是别名/新文档名称——请勿在脚本中依赖它)。用户的简写 = :在交互式窗格中输入是可行的,但在脚本中请使用完整的二进制文件名——别名不会在脚本中展开。在现有窗格中启动:
cursor-agentagentcurcursor-agent --yolobash
herdr pane run <pane-id> "cd <worktree> && cursor-agent --model gpt-5.3-codex-high --yolo 'fix the failing tests'"- 交互式: (或无参数启动空会话)。无头模式:
cursor-agent "task"。cursor-agent -p "task" --output-format text|json|stream-json - 权限: 会无需逐命令批准即可运行命令(别名
--force);--yolo。脚本认证:使用--sandbox enabled|disabled环境变量。CURSOR_API_KEY - 模型: 启动时使用,会话内使用
--model <slug>。可通过/model枚举模型——slug依赖于版本/账号,切勿凭记忆硬编码。cursor-agent --list-models - 推理力度: 没有标志——力度已内置在slug后缀中:
--effort/-low/-medium/-high(例如-xhigh、gpt-5.3-codex-xhigh)。claude-opus-4-8-thinking-high代表速度,而非力度。-fast中显示的括号语法--help实际上不受支持——请始终使用完整的slug。model[effort=high] - 已知bug(2026年年中): 部分CLI版本会静默丢弃通过传递的推理后缀,并回退到默认力度。启动后请通过
--model验证;/model可保持可用版本的稳定性。--disable-auto-update - 恢复会话: (恢复最近会话)、
cursor-agent resume、--resume <chatId>列出会话。cursor-agent ls
Prompt patterns
提示模板
- Inspect: “Use the Herdr skill. Inspect every agent in this workspace, read its recent output, and summarize its task and status. Do not send anything.”
- Ask: “Use Herdr to find the testing agent, read its context, ask whether the test suite passes, wait for its response, and report back.”
- Coordinate: “Act as lead agent. Inspect all agents, share missing context, prevent duplicate work, wait for results, and give me one combined summary.”
- 检查: “使用Herdr技能。检查此工作区中的所有Agent,读取其近期输出,总结其任务和状态。请勿发送任何消息。”
- 询问: “使用Herdr找到测试Agent,读取其上下文,询问测试套件是否通过,等待其回复并反馈结果。”
- 协调: “作为主Agent,检查所有Agent,共享缺失的上下文,避免重复工作,等待结果,并向我提供一份合并后的总结。”
Direct shortcuts
快捷方式
Most defaults use the prefix. Prefer direct shortcuts, which rarely conflict. Add to :
Ctrl+BCtrl+Alt~/.config/herdr/config.tomltoml
[keys]
new_workspace = "ctrl+alt+n"
workspace_picker = "ctrl+alt+w"
goto = "ctrl+alt+g"
new_tab = "ctrl+alt+c"Apply changes:
bash
herdr server reload-configTo keep prefixed shortcuts but change the prefix, set under .
prefix = "ctrl+a"[keys]大多数默认快捷方式使用前缀。建议使用直接的快捷方式,它们很少冲突。请将以下内容添加到:
Ctrl+BCtrl+Alt~/.config/herdr/config.tomltoml
[keys]
new_workspace = "ctrl+alt+n"
workspace_picker = "ctrl+alt+w"
goto = "ctrl+alt+g"
new_tab = "ctrl+alt+c"应用更改:
bash
herdr server reload-config如果要保留带前缀的快捷方式但更改前缀,请在下设置。
[keys]prefix = "ctrl+a"