Purpose
Provide a stable, agent-optimized workflow for using
fpt-cli from OpenClaw.
This skill follows the Agent DX principles from "You Need to Rewrite Your CLI for AI Agents":
- - optimize for predictability over discoverability
- keep context window usage low (fetch only what you need)
- enforce deep defense against hallucinated inputs
- use schema introspection at runtime instead of relying on pre-trained knowledge
Keep the agent behavior aligned with the repository contract:
- - prefer explicit CLI commands over ad-hoc API calls
- prefer JSON output for machine consumption
- prefer capability discovery before composing new command invocations
- prefer safe write previews before real mutations
When to use
Use this skill when any of the following is needed:
- - install or update INLINECODE1
- configure ShotGrid / FPT authentication for OpenClaw
- inspect which commands the CLI already exposes
- query schema or entities through the CLI
- run complex searches with
filter_dsl, structured search, or INLINECODE4 - perform write operations with
--dry-run first
Workflow
1. Choose the execution mode
Determine whether the task should use a released binary or a source checkout.
- - For released binary installation or update, read
references/install-and-auth.md and prefer release archives plus checksum verification over pipe-to-shell installers. - For repository-local development, prefer
vx cargo run -p fpt-cli -- ... and vx just ....
2. Prefer environment-based authentication
Load credentials through environment variables instead of putting secrets directly on the command line.
Never trigger browser-based OAuth flows in headless environments.
Preferred variables:
| Variable | Required | Auth modes | Description |
|---|
| INLINECODE9 | required | all | Full URL of the ShotGrid / FPT site, e.g. INLINECODE10 |
| INLINECODE11 |
required | all | Auth strategy:
script,
user_password, or
session_token |
|
FPT_SCRIPT_NAME |
required |
script | Name of the API script credential registered in ShotGrid |
|
FPT_SCRIPT_KEY |
required |
script | Secret key for the script credential; quote the value when it contains special characters |
|
FPT_USERNAME |
required |
user_password | ShotGrid user login (usually an email address) |
|
FPT_PASSWORD |
required |
user_password | Password for the ShotGrid user account |
|
FPT_AUTH_TOKEN | optional |
user_password | One-time 2FA token; only needed when the site enforces two-factor authentication |
|
FPT_SESSION_TOKEN |
required |
session_token | A pre-obtained ShotGrid session token; use when script or password credentials are unavailable |
|
FPT_API_VERSION | optional | all | Override the ShotGrid REST API version, e.g.
v1.1; defaults to the CLI built-in value when omitted |
Allow SG_* variables only as compatibility fallback when FPT_* is not available.
3. Schema introspection — do not guess
Do not rely on pre-trained knowledge to determine command signatures or entity/field names.
Pre-trained knowledge goes stale. Guessing causes syntax errors and hallucinates parameters.
Pattern: fetch command list first, then fetch only the contracts you need.
CODEBLOCK0
Using inspect list before inspect command keeps context window usage low.
Using capabilities returns the full payload for all commands — use it only when you need an overview.
4. Choose the narrowest useful command
Prefer the smallest command that satisfies the task.
- - Use
entity.get when the entity id is known. - Use
entity.find-one when only one match is needed. - Use
entity.find when multiple matches or collection metadata are needed. - Use
entity.batch.* when repeating the same operation over many inputs. - Use
entity.batch.count when counting records across multiple entity types — do not call entity.count once per type. - Use
schema.entities and schema.fields before guessing entity or field names.
5. Context window discipline
Large API responses can consume significant context window and degrade reasoning.
Always limit the fields you request:
CODEBLOCK1
Do not request all fields when you only need a few.
Use entity.batch.* commands instead of looping single-entity calls.
6. Prefer structured JSON output
Default to
--output json unless a human explicitly needs a different view.
This keeps OpenClaw orchestration stable and lowers prompt/token overhead.
7. Apply input hardening invariants
The CLI validates inputs against hallucination patterns. These checks cannot be bypassed:
- - Entity type names must not contain
? or # — do not embed query parameters in entity names.
Wrong:
entity get "Shot?fields=code" 123
Right:
entity get Shot 123 --fields code
- - Entity type names must not contain control characters (below ASCII 0x20).
- Do not pre-encode URLs — the CLI handles percent-encoding automatically. Sending
%2e%2e instead of .. will cause double-encoding failures. - Resource IDs are numeric — never embed filter expressions or query parameters in an ID argument.
The CLI operates in a zero-trust model: all inputs are validated as if they came from an untrusted source.
8. Prefer native search features for complex queries
For non-trivial filters:
- - prefer structured
search JSON when building native _search payloads - use
additional_filter_presets for "latest"-style workflows - use
--filter-dsl for concise human-authored boolean logic
Read references/query-patterns.md for examples.
9. Apply write safety rules
For writes:
- - run
--dry-run first when supported — treat dry-run output as the request-plan contract - review the dry-run plan to confirm there are no hallucinated parameters before executing
- require explicit confirmation before real deletes (
--yes)
CODEBLOCK2
10. Debug in a contract-first order
When something fails:
- 1. validate auth with INLINECODE57
- inspect the command contract with INLINECODE58
- confirm entity and field names via schema commands
- reduce the command to the smallest JSON-shaped reproduction
- only then expand to batch or write workflows
References
- - INLINECODE59
- INLINECODE60
目的
为使用OpenClaw的fpt-cli提供稳定、针对代理优化的流程。
本技能遵循你需要为AI代理重写CLI中的代理DX原则:
- - 优化可预测性而非可发现性
- 保持低上下文窗口使用率(仅获取所需内容)
- 对幻觉输入实施深度防御
- 在运行时使用模式自省而非依赖预训练知识
保持代理行为与仓库契约一致:
- - 优先使用显式CLI命令而非临时API调用
- 优先使用JSON输出供机器消费
- 在组合新命令调用前优先进行能力发现
- 在实际变更前优先使用安全写入预览
使用时机
当需要以下任何操作时使用本技能:
- - 安装或更新fpt-cli
- 为OpenClaw配置ShotGrid / FPT认证
- 检查CLI已暴露的命令
- 通过CLI查询模式或实体
- 使用filterdsl、结构化search或additionalfilter_presets执行复杂搜索
- 先使用--dry-run执行写入操作
工作流程
1. 选择执行模式
确定任务应使用已发布二进制文件还是源码检出。
- - 对于已发布二进制文件的安装或更新,请阅读references/install-and-auth.md,优先使用发布归档加校验和验证,而非管道到shell的安装程序。
- 对于仓库本地开发,优先使用vx cargo run -p fpt-cli -- ...和vx just ...。
2. 优先使用基于环境的认证
通过环境变量加载凭据,而非将密钥直接放在命令行上。
切勿在无头环境中触发基于浏览器的OAuth流程。
首选变量:
| 变量 | 必需 | 认证模式 | 描述 |
|---|
| FPTSITE | 必需 | 全部 | ShotGrid / FPT站点的完整URL,例如https://example.shotgrid.autodesk.com |
| FPTAUTHMODE |
必需 | 全部 | 认证策略:script、userpassword或session_token |
| FPT
SCRIPTNAME |
必需 | script | 在ShotGrid中注册的API脚本凭据名称 |
| FPT
SCRIPTKEY |
必需 | script | 脚本凭据的密钥;当值包含特殊字符时请用引号括起来 |
| FPT
USERNAME | 必需 | userpassword | ShotGrid用户登录名(通常是电子邮件地址) |
| FPT
PASSWORD | 必需 | userpassword | ShotGrid用户账户的密码 |
| FPT
AUTHTOKEN | 可选 | user_password | 一次性2FA令牌;仅在站点强制双因素认证时需要 |
| FPT
SESSIONTOKEN |
必需 | session_token | 预先获取的ShotGrid会话令牌;当脚本或密码凭据不可用时使用 |
| FPT
APIVERSION | 可选 | 全部 | 覆盖ShotGrid REST API版本,例如v1.1;省略时默认为CLI内置值 |
仅当FPT不可用时,才允许将SG变量作为兼容性回退。
3. 模式自省——不要猜测
不要依赖预训练知识来确定命令签名或实体/字段名称。
预训练知识会过时。猜测会导致语法错误和参数幻觉。
模式:先获取命令列表,然后仅获取所需的契约。
bash
步骤1:获取所有命令名称(轻量——无完整负载)
fpt inspect list --output json
步骤2:获取实际将使用的特定命令的契约
fpt inspect command entity.find --output json
fpt inspect command entity.batch.count --output json
步骤3:在组合查询前验证实体和字段名称
fpt schema entities --output json
fpt schema fields Shot --output json
在inspect command之前使用inspect list可保持低上下文窗口使用率。
使用capabilities会返回所有命令的完整负载——仅当需要概览时使用。
4. 选择最窄的有用命令
优先选择满足任务的最小命令。
- - 当已知实体ID时使用entity.get。
- 当仅需要一个匹配时使用entity.find-one。
- 当需要多个匹配或集合元数据时使用entity.find。
- 当对多个输入重复相同操作时使用entity.batch.*。
- 当跨多个实体类型计数记录时使用entity.batch.count——不要为每个类型单独调用entity.count。
- 在猜测实体或字段名称前使用schema.entities和schema.fields。
5. 上下文窗口纪律
大型API响应可能消耗大量上下文窗口并降低推理能力。
始终限制请求的字段:
bash
好:仅请求需要的字段
fpt entity get Shot 123 --fields code,sg
statuslist --output json
好:在查找输入中使用fields参数
fpt entity find Shot --input {fields: [code, sg
statuslist]} --output json
好:一次调用跨多个类型进行批量计数
fpt entity batch count --input [Shot,Asset,Task] --output json
当只需要几个字段时,不要请求所有字段。
使用entity.batch.*命令而非循环单实体调用。
6. 优先使用结构化JSON输出
默认使用--output json,除非人类明确需要不同视图。
这使OpenClaw编排保持稳定,并降低提示/令牌开销。
7. 应用输入加固不变性
CLI会针对幻觉模式验证输入。这些检查无法绕过:
- - 实体类型名称不得包含?或#——不要在实体名称中嵌入查询参数。
错误:entity get Shot?fields=code 123
正确:entity get Shot 123 --fields code
- - 实体类型名称不得包含控制字符(ASCII 0x20以下)。
- 不要预编码URL——CLI会自动处理百分比编码。发送%2e%2e而非..会导致双重编码失败。
- 资源ID为数字——切勿在ID参数中嵌入过滤表达式或查询参数。
CLI采用零信任模型:所有输入都像来自不受信任的来源一样进行验证。
8. 复杂查询优先使用原生搜索功能
对于非平凡过滤器:
- - 构建原生search负载时优先使用结构化search JSON
- 对于最新风格的工作流使用additionalfilter_presets
- 对于简洁的人工编写的布尔逻辑使用--filter-dsl
阅读references/query-patterns.md获取示例。
9. 应用写入安全规则
对于写入操作:
- - 支持时先运行--dry-run——将dry-run输出视为请求计划契约
- 在执行前审查dry-run计划以确认没有幻觉参数
- 要求显式确认后才能执行实际删除(--yes)
bash
变更前始终预览
fpt entity create Version --input @payload.json --dry-run --output json
然后仅在审查计划后执行
fpt entity create Version --input @payload.json --output json
10. 按契约优先顺序调试
当出现故障时:
- 1. 使用auth test验证认证
- 使用inspect command 检查命令契约
- 通过模式命令确认实体和字段名称
- 将命令缩减为最小的JSON形状复现
- 然后才扩展到批处理或写入工作流
参考资料
- - references/install-and-auth.md
- references/query-patterns.md