5dive-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese5dive-cli
5dive-cli
This skill teaches you to drive the command on a 5dive runtime VM.
You are running inside one such VM. You can spawn additional agents on the
same host by shelling out to and parsing the JSON envelope
it emits when you pass .
5divesudo 5dive ...--json本技能将教你在5dive运行时VM上使用命令。你正运行在这样的VM中,你可以通过执行并解析其添加参数后输出的JSON包,在同一主机上创建额外的Agent。
5divesudo 5dive ...--jsonWhen to use this skill
何时使用本技能
Use it whenever the work in front of you would benefit from a second pair of
hands — for example:
- The user asks for a "worker", "sub-agent", "another agent", or "side task".
- A long task could fan out into independent pieces (e.g. audit each route in parallel, run a different model on the same prompt, A/B two implementations).
- You need to keep one agent on a hot context while a second one investigates something orthogonal.
- The user wants to inspect / restart / pair / tear down an agent that already exists on the host.
- You need a machine-readable health check of the host's coding-CLI stack.
If the user just wants you to do the work yourself, do not spawn an agent.
当你面前的工作需要额外的“帮手”时,就可以使用它——例如:
- 用户请求“worker”、“子Agent”、“另一个Agent”或“辅助任务”。
- 一项长任务可以拆分为独立的子任务并行处理(例如:并行审计每个路由、在同一提示词上运行不同模型、对两种实现进行A/B测试)。
- 你需要让一个Agent保持在热点上下文,同时让另一个Agent调查无关的内容。
- 用户想要检查/重启/配对/销毁主机上已存在的Agent。
- 你需要主机编码CLI栈的机器可读健康检查结果。
如果用户只是希望你自行完成工作,则无需创建Agent。
Mental model
心智模型
Everything the CLI does maps onto these resources on the host:
- One agent = one Linux user () + one systemd unit (
agent-<name>) + one tmux session (5dive-agent@<name>.service) running the chosen CLI in a restart loop.agent-<name> - Auth is decoupled. You authenticate a type once; every agent of that
type inherits the credentials via .
EnvironmentFile - A channel (/
telegram/discord) is the inbound message surface. Channels are only supported bynone,claude,openclaw.hermes - The CLI is idempotent and safe to call from another agent — your agent
user is in the group and has
claudewhitelisted.sudo 5dive ...
CLI的所有操作都对应主机上的以下资源:
- 一个Agent = 一个Linux用户() + 一个systemd单元(
agent-<name>) + 一个tmux会话(5dive-agent@<name>.service),会话中以重启循环的方式运行所选的CLI。agent-<name> - 认证是解耦的。你只需对一种Agent类型进行一次认证;该类型的所有Agent都会通过继承凭证。
EnvironmentFile - 一个通道(/
telegram/discord)是入站消息界面。仅none、claude、openclaw支持通道功能。hermes - CLI具有幂等性,可安全地从另一个Agent调用——你的Agent用户属于组,且拥有
claude的白名单权限。sudo 5dive ...
Output contract — always pass --json
--json输出约定——始终添加--json
参数
--jsonPass as a global flag (anywhere on the command line). Stdout
becomes a stable envelope; progress lines stay on stderr.
--jsonbash
sudo 5dive agent create scout --type=claude --jsonSuccess:
json
{ "ok": true, "data": { "name": "scout", "type": "claude", "created": true } }Failure (exit code matches ):
error.codejson
{ "ok": false, "error": { "code": 6, "class": "auth_required", "message": "..." } }Branch on , not on the human message. Classes:
, , , , , ,
, , , , , .
error.classokusagevalidationnot_foundconflictauth_requirednot_installednot_runningpairingpermissiontimeoutgenericSee for the full table.
references/exit-codes.md添加作为全局标志(可放在命令行任意位置)。标准输出将变为稳定的JSON包;进度信息将输出到标准错误流。
--jsonbash
sudo 5dive agent create scout --type=claude --json成功时输出:
json
{ "ok": true, "data": { "name": "scout", "type": "claude", "created": true } }失败时输出(退出码与匹配):
error.codejson
{ "ok": false, "error": { "code": 6, "class": "auth_required", "message": "..." } }根据进行分支处理,而非人类可读消息。错误类别包括:, , , , , , , , , , , 。
error.classokusagevalidationnot_foundconflictauth_requirednot_installednot_runningpairingpermissiontimeoutgeneric完整列表请参考。
references/exit-codes.mdRecipes
操作示例
Spawn a worker for a side task
为辅助任务创建worker
bash
undefinedbash
undefined1. Pick a unique name (lowercase letters/digits/hyphens, ≤16 chars,
1. 选择一个唯一名称(仅包含小写字母/数字/连字符,长度≤16字符,必须以字母开头)。如果在意名称是否已存在,可先检查注册表:
must start with a letter). Check the registry first if you care:
—
sudo 5dive agent list --json | jq '.data.agents | keys'
sudo 5dive agent list --json | jq '.data.agents | keys'
2. Create the worker. --workdir scopes its tmux cwd; default is
2. 创建worker。--workdir指定其tmux会话的工作目录;默认是/home/claude/projects。
/home/claude/projects.
—
sudo 5dive agent create worker-1
--type=claude
--workdir=/home/claude/projects/myrepo
--json
--type=claude
--workdir=/home/claude/projects/myrepo
--json
sudo 5dive agent create worker-1
--type=claude
--workdir=/home/claude/projects/myrepo
--json
--type=claude
--workdir=/home/claude/projects/myrepo
--json
3. Send it the task. tmux send-keys + Enter, so the text appears
3. 向其发送任务。tmux send-keys + Enter会将文本输入到worker正在运行的CLI提示符中。
in the worker's running CLI prompt.
—
sudo 5dive agent send worker-1
"audit the auth middleware for OWASP A01 issues; report back as a markdown bullet list"
"audit the auth middleware for OWASP A01 issues; report back as a markdown bullet list"
sudo 5dive agent send worker-1
"审计认证中间件的OWASP A01问题;以Markdown项目符号列表形式返回报告"
"审计认证中间件的OWASP A01问题;以Markdown项目符号列表形式返回报告"
4. Poll its output until it goes idle. --tmux dumps the scrollback.
4. 轮询其输出直到它进入空闲状态。--tmux参数会导出滚动缓冲区内容。
sudo 5dive agent logs worker-1 --tmux --lines=80
sudo 5dive agent logs worker-1 --tmux --lines=80
5. Tear it down when you're done — frees the systemd unit + Linux user.
5. 完成任务后销毁它——释放systemd单元和Linux用户。
sudo 5dive agent rm worker-1 --json
undefinedsudo 5dive agent rm worker-1 --json
undefinedSkill inheritance on agent-spawned children
Agent创建的子Agent的技能继承
When an agent (you, ) creates another claude-typed agent,
the CLI auto-installs the skill into the child so it inherits
inter-agent comms knowledge. Humans creating from the dashboard don't get this
default. Override either way:
SUDO_USER=agent-*5dive-cli- — explicit list. Each spec is a bare id (defaults to
--with-skills=<spec>[,<spec>...]) or5dive-com/skills. Example:<owner/repo>:<id>.--with-skills=5dive-cli,acme/skills:db-tools - — opt out, even when called from another agent.
--no-skills
当一个Agent(即你,)创建另一个claude类型的Agent时,CLI会自动将技能安装到子Agent中,使其继承跨Agent通信的知识。通过仪表板创建Agent的人类用户不会获得此默认设置。你可以通过以下方式覆盖默认行为:
SUDO_USER=agent-*5dive-cli- —— 显式指定技能列表。每个spec可以是纯ID(默认来自
--with-skills=<spec>[,<spec>...])或5dive-com/skills格式。示例:<owner/repo>:<id>。--with-skills=5dive-cli,acme/skills:db-tools - —— 选择不继承技能,即使是从另一个Agent调用创建。
--no-skills
Create-then-auth: --defer-auth
--defer-auth创建后认证:--defer-auth
--defer-authUse when you want the agent registered before its credentials are wired up
(e.g. the agent's own first-run UI will handle sign-in). Skips the auth gate
on ; combine with to bind a profile slot
that doesn't yet have a .
agent create--auth-profile=<name>combined.envbash
sudo 5dive agent create draft-bot --type=claude --defer-auth --json当你希望先注册Agent,再配置其凭证时使用(例如:Agent的首次运行UI将处理登录)。此参数会跳过时的认证检查;可与结合使用,绑定一个尚未配置的配置文件槽位。
agent create--auth-profile=<name>combined.envbash
sudo 5dive agent create draft-bot --type=claude --defer-auth --jsonFan out: same prompt, three different models
任务分发:同一提示词,三种不同模型
Useful for "let me see how Codex/Gemini/Claude each approach this".
bash
for type in claude codex gemini; do
sudo 5dive agent create "fan-${type}" --type="${type}" --json
sudo 5dive agent send "fan-${type}" "$PROMPT"
done适用于“让我看看Codex/Gemini/Claude分别如何处理这个任务”的场景。
bash
for type in claude codex gemini; do
sudo 5dive agent create "fan-${type}" --type="${type}" --json
sudo 5dive agent send "fan-${type}" "$PROMPT"
doneWait, then collect the last 200 lines of each:
等待任务完成,然后收集每个Agent的最后200行输出:
for type in claude codex gemini; do
echo "=== ${type} ==="
sudo 5dive agent logs "fan-${type}" --tmux --lines=200
done
for type in claude codex gemini; do
echo "=== ${type} ==="
sudo 5dive agent logs "fan-${type}" --tmux --lines=200
done
Cleanup.
清理资源。
for type in claude codex gemini; do
sudo 5dive agent rm "fan-${type}" --json
done
undefinedfor type in claude codex gemini; do
sudo 5dive agent rm "fan-${type}" --json
done
undefinedRecover from auth_required
auth_required从auth_required
错误中恢复
auth_requiredbash
undefinedbash
undefinedIf create fails with error.class=auth_required, the type isn't authenticated.
如果创建Agent时出现error.class=auth_required错误,说明该类型尚未完成认证。
Two paths — pick by what credentials you have:
有两种解决路径——根据你拥有的凭证选择:
A) Static API key in $KEY (preferred for automation)
A) 使用$KEY中的静态API密钥(自动化场景首选)
echo "$KEY" | sudo 5dive agent auth set claude --api-key=- --json
echo "$KEY" | sudo 5dive agent auth set claude --api-key=- --json
B) Device-code flow (when only a human can complete login)
B) 设备码流程(仅当需要人类完成登录时使用)
sudo 5dive agent auth start claude --json
sudo 5dive agent auth start claude --json
-> session id; give the URL from auth poll
to the user; they paste the
auth poll-> 返回会话ID;将auth poll
输出的URL提供给用户;用户通过auth submit
粘贴回调代码。
auth pollauth submitcallback code back via auth submit
.
auth submit—
Never call `5dive agent auth login <type>` from your own process — it
hands the TTY off to the upstream CLI's interactive flow and hangs your
agent. Use `auth start` / `auth set` instead.
切勿在你自己的进程中调用`5dive agent auth login <type>`——该命令会将TTY控制权转移给上游CLI的交互式流程,导致你的Agent挂起。请改用`auth start` / `auth set`。Multi-account: the account
noun
account多账户:account
名词
accountA 5dive account is a named auth profile — one bag of credentials that any
number of agents can share via . Use it when the host
has more than one human / billing identity (e.g. work + personal Anthropic
sign-ins) and different agents should use different ones.
--auth-profile=<name>5dive account ...agent auth start|poll|submit|cancelbash
undefined5dive的账户是一个命名的认证配置文件——一组凭证,可通过被任意数量的Agent共享。当主机拥有多个用户/计费身份(例如:工作和个人Anthropic登录),且不同Agent需要使用不同身份时,可使用此功能。
--auth-profile=<name>5dive account ...agent auth start|poll|submit|cancelbash
undefinedInventory: which named accounts exist, what types each is signed into,
查看清单:已存在哪些命名账户,每个账户已登录的类型,以及有多少Agent绑定到该账户。
and how many agents are bound to each.
—
sudo 5dive account list --json
sudo 5dive account list --json
Detail for one account, including which env keys are populated.
查看单个账户的详细信息,包括已填充的环境变量键。
sudo 5dive account show acme-prod --json
sudo 5dive account show acme-prod --json
Provision a new empty account, then sign it in (TTY-only — humans).
创建一个新的空账户,然后登录(仅支持TTY交互——供人类用户使用)。
sudo 5dive account add acme-prod
sudo 5dive account login acme-prod --type=claude
sudo 5dive account add acme-prod
sudo 5dive account login acme-prod --type=claude
Rebind an existing agent to a different account. Restarts the agent so
将现有Agent重新绑定到另一个账户。这会重启Agent,使新的EnvironmentFile生效。
the new EnvironmentFile takes effect.
—
sudo 5dive agent set-account worker-1 acme-prod --json
sudo 5dive agent set-account worker-1 default --json # clears the override
sudo 5dive agent set-account worker-1 acme-prod --json
sudo 5dive agent set-account worker-1 default --json # 清除覆盖设置,恢复默认
Rename / remove. remove
refuses while any agents are still bound.
remove重命名/删除账户。当仍有Agent绑定到该账户时,remove
命令会执行失败。
removesudo 5dive account rename acme-prod acme-staging --json
sudo 5dive account remove acme-staging --json
The reserved name `default` is rejected by `account add` / `rename` — at the
agent level, `auth-profile=default` already means "no override, use the shared
`/etc/5dive/connectors/<type>.env`".sudo 5dive account rename acme-prod acme-staging --json
sudo 5dive account remove acme-staging --json
保留名称`default`无法用于`account add` / `rename`命令——在Agent层面,`auth-profile=default`已表示“不使用覆盖设置,使用共享的`/etc/5dive/connectors/<type>.env`”。Pair a Telegram channel without a bot reply
无需机器人回复即可配对Telegram通道
agent pairbash
undefinedagent pairbash
undefinedA) Classic — return a pairing code, user DMs the bot, paste the bot reply.
A) 经典方式——返回配对码,用户向机器人发送私信,然后粘贴机器人的回复。
sudo 5dive agent pair worker-1 --json
sudo 5dive agent pair worker-1 --code=AB12CD --json
sudo 5dive agent pair worker-1 --json
sudo 5dive agent pair worker-1 --code=AB12CD --json
B) Auto-detect — long-poll Telegram for the next inbound message and
B) 自动检测——长轮询Telegram的下一条入站消息,并从第一个向机器人发送私信的用户那里生成access.json。适用于用户已打开机器人的引导流程。
seed access.json from whoever DMs the bot first. Useful in onboarding
—
flows where the user has the bot open already.
—
sudo 5dive agent telegram-discover --token="$BOT_TOKEN" --poll-secs=60 --json
sudo 5dive agent telegram-discover --token="$BOT_TOKEN" --poll-secs=60 --json
-> {found:true, userId, chatId, ...}; re-poll on {found:false}.
-> {found:true, userId, chatId, ...}; 当返回{found:false}时重新轮询。
sudo 5dive agent pair worker-1 --user-id=<userId> --chat-id=<chatId> --json
sudo 5dive agent pair worker-1 --user-id=<userId> --chat-id=<chatId> --json
C) Bot identity for deep links — fast getMe lookup so the dashboard can
C) 用于深度链接的机器人身份——快速执行getMe查询,以便仪表板在“发送/start”提示旁渲染可点击的t.me/<bot>链接。
render a tappable t.me/<bot> link alongside the "send /start" prompt.
—
sudo 5dive agent telegram-getme --token="$BOT_TOKEN" --json
sudo 5dive agent telegram-getme --token="$BOT_TOKEN" --json
-> {ok:true, data:{botId, username, firstName}}
-> {ok:true, data:{botId, username, firstName}}
`telegram-discover` and `telegram-getme` are read-only (no registry mutation,
no audit log) and do not require a bound agent.
`telegram-discover`和`telegram-getme`是只读操作(不会修改注册表,不会生成审计日志),且不需要绑定Agent。Talking to other agents (inter-agent comms)
与其他Agent通信(跨Agent通信)
agent sendagent askagent sendagent askSending: attribution is automatic
发送:自动添加来源标识
When you (an agent) shell out to , the CLI
sees that is and wraps the payload as:
sudo 5dive agent send <name> "..."$SUDO_USERagent-<you>[5dive-msg from=<you> id=<8-hex>] <your text>so the receiver can tell it's being pinged by a peer agent and which one.
Override the inferred name with . Skip wrapping with
(useful when you're piping a prompt that already has its own structure).
--from=<label>--rawHumans running directly never get auto-wrapped — only
sends from users do.
sudo 5dive agent sendagent-*当你(一个Agent)执行时,CLI会检测到是,并将消息内容包装为:
sudo 5dive agent send <name> "..."$SUDO_USERagent-<you>[5dive-msg from=<you> id=<8位十六进制>] <你的文本>这样接收方就能识别出这是来自对等Agent的消息,以及具体是哪个Agent。你可以使用覆盖自动推断的名称。使用参数可跳过包装(当你传递的提示词已有自己的结构时非常有用)。
--from=<label>--raw直接执行的人类用户不会获得自动包装——仅当发送者是用户时才会自动包装。
sudo 5dive agent sendagent-*Receiving: recognise the envelope and reply by name
接收:识别消息包并按名称回复
When a line like
[5dive-msg from=scout id=ab12cd34] please summarise the auth middleware auditappears as your input, treat it as an inter-agent request. To reply, send
back to the named sender:
bash
sudo 5dive agent send scout "[re=ab12cd34] auth middleware looks clean except for ..."The prefix is convention, not enforced — it lets the original
sender match your reply to their question when they're juggling several at
once. Drop it for casual back-and-forth.
[re=<id>]当出现如下格式的输入行时:
[5dive-msg from=scout id=ab12cd34] 请总结认证中间件的审计结果将其视为跨Agent请求。如需回复,发送消息给指定的发送者即可:
bash
sudo 5dive agent send scout "[re=ab12cd34] 认证中间件整体无问题,除了..."[re=<id>]One-shot synchronous calls: agent ask
agent ask一次性同步调用:agent ask
agent askIf you want a request/response in one CLI call (no manual polling of
), use :
agent logsaskbash
sudo 5dive agent ask scout \
"list the OWASP A01 issues you found, one per line" \
--timeout=180 --jsonIt sends the wrapped envelope, then watches after the
marker line and returns once the scrollback has been quiet for
(default 5s). Stdout (text mode) is just the reply body; in mode the
envelope is .
tmux capture-pane--idle-secs--json{ok:true, data:{name, from, msg_id, reply}}Caveats — read these before leaning on :
ask- Idle-by-stability is heuristic. A receiver that streams progress
continuously will keep awake until
askfires. If you're asking for something the receiver might narrate (long agentic work), prompt it for a terse final summary or use plain--timeout+send.logs - The reply is whatever was on screen. It includes any chrome the receiver CLI prints (cursor lines, status hints) — don't expect a clean JSON body unless the prompt asks for one.
- No retries, no delivery confirmation. If the receiver crashed mid- reply you'll get a partial slice or a timeout, nothing in between.
如果你希望通过一次CLI调用完成请求/响应(无需手动轮询),可使用命令:
agent logsaskbash
sudo 5dive agent ask scout \
"列出你发现的OWASP A01问题,每行一个" \
--timeout=180 --json该命令会发送包装后的消息包,然后在标记行之后监控的输出,当滚动缓冲区静默时间达到(默认5秒)时返回结果。文本模式下标准输出仅包含回复内容;模式下输出的包格式为。
tmux capture-pane--idle-secs--json{ok:true, data:{name, from, msg_id, reply}}注意事项——在依赖命令之前请阅读以下内容:
ask- 基于稳定性判断空闲状态是启发式的。如果接收方持续输出进度信息,会一直等待直到
ask超时。如果你请求的内容可能会让接收方逐步输出(例如长耗时的智能任务),请提示其返回简洁的最终总结,或使用普通的--timeout+send组合。logs - 回复内容就是屏幕上显示的内容。它包含接收方CLI输出的任何装饰信息(光标行、状态提示)——除非提示词明确要求,否则不要期望得到干净的JSON内容。
- 无重试,无送达确认。如果接收方在回复过程中崩溃,你会得到部分内容或超时错误,不会有中间状态的提示。
Rules of thumb
经验法则
- For "fire-and-forget delegate, I'll check later": + poll
agent sendwhen it suits you.agent logs --tmux - For "I need an answer to continue": .
agent ask - For broadcast / fan-out across N agents: loop (or
agent sendin parallel viaagent ask+&). Each call is independent.wait - Don't reuse labels for unrelated agents — pick a label that names you, so receivers can address replies correctly.
--from
- 对于“触发即遗忘的委托任务,稍后再检查结果”:使用+ 在合适的时候轮询
agent send。agent logs --tmux - 对于“我需要一个答案才能继续”:使用。
agent ask - 对于向N个Agent进行广播/任务分发:循环执行(或通过
agent send+&并行执行wait)。每个调用都是独立的。agent ask - 不要为无关的Agent重复使用标签——选择一个能标识你自己的标签,以便接收方能正确回复。
--from
Diagnose a sick host
诊断故障主机
bash
sudo 5dive doctor --jsonEnvelope is always with exit 0.
Branch on . Add to attempt reversible
fixes (apt installs, type installer recipes, registry reseed).
{ ok: true, data: { summary, checks } }data.summary.errors > 0--repairbash
sudo 5dive doctor --json输出包始终为,退出码为0。根据进行分支处理。添加参数可尝试可逆修复操作(如apt安装、类型安装脚本、注册表重新生成)。
{ ok: true, data: { summary, checks } }data.summary.errors > 0--repairRules of engagement
操作规则
- Always pass . Parse the envelope. Don't grep stderr.
--json - One name = one agent. Names are lowercase letters/digits/hyphens,
start with a letter, max 16 chars. Reuse a name only after .
agent rm - Don't share bot tokens. Two Telegram-channel agents on the same
bot will race each other on . Each agent needs its own.
getUpdates - Tear down what you spin up. A leaked agent stays running across reboots — it's a real systemd unit, not a thread. On task completion call
worker-N.5dive agent rm <name> - Don't shell out to the underlying CLI binaries directly. Going
around skips the systemd unit, the audit log, and the env injection — the agent will run with broken auth and no restart loop.
5dive - Read if a flag is rejected as unknown — the binary on the host may be newer or older than this skill. The help output is authoritative.
5dive --help - The path is interactive only. Never call it from your own session.
auth login <type>
- 始终添加参数。解析JSON包,不要通过grep标准错误流获取信息。
--json - 一个名称对应一个Agent。名称仅包含小写字母/数字/连字符,以字母开头,最大长度16字符。只有在执行后才能复用名称。
agent rm - 不要共享机器人令牌。同一机器人上的两个Telegram通道Agent会在时产生竞争。每个Agent需要独立的令牌。
getUpdates - 销毁你创建的资源。泄露的Agent会在重启后继续运行——它是真实的systemd单元,而非线程。任务完成后请调用
worker-N。5dive agent rm <name> - 不要直接调用底层CLI二进制文件。绕过会跳过systemd单元、审计日志和环境变量注入——Agent将在认证失效且无重启循环的状态下运行。
5dive - 如果某个标志被判定为未知,请阅读。主机上的二进制文件可能比本技能描述的版本更新或更旧。帮助输出是权威的。
5dive --help - 路径仅支持交互式操作。切勿在你自己的会话中调用该命令。
auth login <type>
Reference
参考资料
- — every subcommand and flag, copy/pasteable.
references/commands.md - — exit codes & error classes.
references/exit-codes.md - — on-disk state layout (only for debugging).
references/paths.md
- —— 所有子命令和标志,可直接复制粘贴使用。
references/commands.md - —— 退出码和错误类别。
references/exit-codes.md - —— 磁盘上的状态布局(仅用于调试)。
references/paths.md
Going further
延伸阅读
The full reference manual lives at https://5dive.com/docs. If a flag in
this skill conflicts with what the running binary accepts, trust the
binary — run or
directly and follow that.
sudo 5dive --helpsudo 5dive agent <sub> --help完整的参考手册请访问https://5dive.com/docs。如果本技能中描述的标志与运行中的二进制文件接受的标志冲突,请以二进制文件为准——直接运行或并遵循其说明。
sudo 5dive --helpsudo 5dive agent <sub> --help