ucli agent guide
CLI: INLINECODE0
Recommended defaults
CODEBLOCK0
- -
--output json for machine-readable output - INLINECODE2 to suppress decorative text
- INLINECODE3 to shrink payloads
- INLINECODE4 and
--sort to shape data before it hits your context
Guardrails
- - Prefer read-only commands first. Inspect before acting.
- Use
--yes only in deliberate automation paths, never speculatively. - Pair destructive actions with explicit identifiers. No fuzzy matching in the shell.
- Re-fetch state after any mutation. Do not trust a prior cache.
- Treat exit code
0 as success. Non-zero: capture stderr, retry only on transient failures.
Command groups
| Group | Typical use |
|---|
| INLINECODE8 | INLINECODE9 , health, status, resources, INLINECODE13 |
| INLINECODE14 |
status,
devices,
parity, parity-check actions |
|
disks | Inventory, SMART, temp, usage, mount |
|
containers |
list,
inspect,
logs,
stats, lifecycle actions |
|
notifications |
list,
latest,
get,
create,
archive |
|
vms |
list,
inspect, lifecycle actions |
|
shares |
list,
get, usage |
|
logs |
list,
get,
system,
tail,
search |
|
services |
list,
get,
status |
|
network | Interfaces, status |
|
schema | API introspection |
|
diagnostics |
ping,
latency,
env,
doctor |
Workflow: health check
CODEBLOCK1
- 1. Fetch each separately. Fail fast on non-zero exits.
- Summarize array state, service state, resource pressure, warnings.
- Only pull logs if the snapshot shows trouble.
Workflow: container management
CODEBLOCK2
- 1. Resolve target by
id or names. - Inspect current state.
- Execute with
--yes when confirmation would block automation. - Re-read status after mutation.
Anti-patterns
- - Don't parse human-readable output. Always use
--output json. - Don't assume partial success from human-readable text. Check exit codes.
- Don't retry on non-transient errors (auth, bad arguments, missing resources).
- Don't skip
--fields on large result sets. Token waste adds up fast. - Don't chain mutations without re-fetching state between them.
- Don't use
--force unless you understand exactly what it skips.
Configuration
Default config path: INLINECODE59
CODEBLOCK3
Prefer --host and --api-key explicitly for isolated jobs, --profile <name> for stable environments.
ucli agent guide
CLI: INLINECODE63
Recommended defaults
CODEBLOCK4
- -
--output json for machine-readable output - INLINECODE65 to suppress decorative text
- INLINECODE66 to shrink payloads
- INLINECODE67 and
--sort to shape data before it hits your context
Guardrails
- - Prefer read-only commands first. Inspect before acting.
- Use
--yes only in deliberate automation paths, never speculatively. - Pair destructive actions with explicit identifiers. No fuzzy matching in the shell.
- Re-fetch state after any mutation. Do not trust a prior cache.
- Treat exit code
0 as success. Non-zero: capture stderr, retry only on transient failures.
Command groups
| Group | Typical use |
|---|
| INLINECODE71 | INLINECODE72 , health, status, resources, INLINECODE76 |
| INLINECODE77 |
status,
devices,
parity, parity-check actions |
|
disks | Inventory, SMART, temp, usage, mount |
|
containers |
list,
inspect,
logs,
stats, lifecycle actions |
|
notifications |
list,
latest,
get,
create,
archive |
|
vms |
list,
inspect, lifecycle actions |
|
shares |
list,
get, usage |
|
logs |
list,
get,
system,
tail,
search |
|
services |
list,
get,
status |
|
network | Interfaces, status |
|
schema | API introspection |
|
diagnostics |
ping,
latency,
env,
doctor |
Workflow: health check
CODEBLOCK5
- 1. Fetch each separately. Fail fast on non-zero exits.
- Summarize array state, service state, resource pressure, warnings.
- Only pull logs if the snapshot shows trouble.
Workflow: container management
CODEBLOCK6
- 1. Resolve target by
id or names. - Inspect current state.
- Execute with
--yes when confirmation would block automation. - Re-read status after mutation.
Anti-patterns
- - Don't parse human-readable output. Always use
--output json. - Don't assume partial success from human-readable text. Check exit codes.
- Don't retry on non-transient errors (auth, bad arguments, missing resources).
- Don't skip
--fields on large result sets. Token waste adds up fast. - Don't chain mutations without re-fetching state between them.
- Don't use
--force unless you understand exactly what it skips.
Configuration
Default config path: INLINECODE122
CODEBLOCK7
Prefer --host and --api-key explicitly for isolated jobs, --profile <name> for stable environments.
ucli agent guide
CLI: ucli [global flags] [args...]
推荐默认设置
bash
ucli --output json --quiet
- - --output json 用于机器可读的输出
- --quiet 用于抑制装饰性文本
- --fields 用于缩减数据负载
- --filter 和 --sort 用于在数据进入上下文之前进行数据整形
安全护栏
- - 优先使用只读命令。先检查再操作。
- 仅在明确的自动化路径中使用 --yes,切勿随意使用。
- 破坏性操作必须配合明确的标识符。shell 中不允许模糊匹配。
- 任何变更操作后都要重新获取状态。不要信任之前的缓存。
- 将退出码 0 视为成功。非零退出码:捕获 stderr,仅在临时故障时重试。
命令组
| 组 | 典型用途 |
|---|
| system | info、health、status、resources、uptime |
| array |
status、devices、parity、奇偶校验操作 |
| disks | 清单、SMART、温度、使用情况、挂载 |
| containers | list、inspect、logs、stats、生命周期操作 |
| notifications | list、latest、get、create、archive |
| vms | list、inspect、生命周期操作 |
| shares | list、get、使用情况 |
| logs | list、get、system、tail、search |
| services | list、get、status |
| network | 接口、状态 |
| schema | API 内省 |
| diagnostics | ping、latency、env、doctor |
工作流程:健康检查
bash
ucli system info --output json --quiet
ucli system health --output json --quiet
ucli array status --output json --quiet
ucli services status --output json --quiet
- 1. 分别获取每个信息。遇到非零退出码立即失败。
- 汇总阵列状态、服务状态、资源压力、警告信息。
- 仅在快照显示问题时才拉取日志。
工作流程:容器管理
bash
列出运行中的容器
ucli containers list --output json --quiet --fields id,names,state,status --sort names:asc
检查单个容器
ucli containers inspect
--output json --quiet
重启
ucli containers restart --yes --output json --quiet
- 1. 通过 id 或 names 解析目标。
- 检查当前状态。
- 当确认会阻塞自动化时使用 --yes 执行。
- 变更后重新读取状态。
反模式
- - 不要解析人类可读的输出。始终使用 --output json。
- 不要从人类可读的文本中假设部分成功。检查退出码。
- 不要在非临时性错误上重试(认证、错误参数、资源缺失)。
- 不要在大结果集上跳过 --fields。令牌浪费会迅速累积。
- 不要在变更操作之间跳过重新获取状态而直接链式操作。
- 除非你完全了解 --force 跳过了什么,否则不要使用它。
配置
默认配置路径:~/.config/ucli/config.yaml
yaml
default_profile: lab
profiles:
lab:
host: http://192.168.1.10:7777
apiKey: YOURAPIKEY
output: json
timeout: 30
对于独立任务,优先明确使用 --host 和 --api-key;对于稳定环境,使用 --profile 。