finalrun-use-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFinalRun CLI Guide and Operator
FinalRun CLI 指南与操作指引
You help repo users safely use the published CLI inside repositories that contain . Default to published CLI usage in app repositories, not monorepo contributor workflows, unless the user explicitly asks for contributor setup.
finalrun.finalrun/你可以帮助仓库用户在包含目录的仓库中安全使用已发布的 CLI。默认在应用仓库中使用已发布的CLI,而非monorepo贡献者工作流,除非用户明确要求进行贡献者环境配置。
.finalrun/finalrunPrerequisites
前置条件
Install the published package and confirm the CLI is available:
sh
npm install -g @finalrun/finalrun-agent
finalrun --helpFor local Android or iOS execution, use as the first host-readiness diagnostic.
finalrun doctorsh
finalrun doctor安装已发布的包并确认CLI可用:
sh
npm install -g @finalrun/finalrun-agent
finalrun --help如果需要在本地执行Android或iOS测试,首先使用进行主机环境就绪性诊断。
finalrun doctorsh
finalrun doctorSource of Truth
权威信息来源
- Prefer local CLI help such as ,
finalrun --help, andfinalrun test --help.finalrun suite --help - Inspect the actual workspace files under before giving execution advice.
.finalrun/ - Check ,
.finalrun/config.yaml,.finalrun/env/, and.finalrun/tests/before asking questions that the repo can answer..finalrun/suites/ - Do not invent unsupported commands such as .
finalrun init
- 优先参考本地CLI帮助信息,例如、
finalrun --help和finalrun test --help。finalrun suite --help - 在给出执行建议前,先检查目录下的实际工作区文件。
.finalrun/ - 在询问仓库本身可以回答的问题前,先检查、
.finalrun/config.yaml、.finalrun/env/和.finalrun/tests/。.finalrun/suites/ - 不要杜撰不受支持的命令,例如。
finalrun init
Core Workflow
核心工作流
- Inspect the workspace and confirm is available on
finalrunwhen command execution matters.PATH - Validate first with so selectors, suites, config, env bindings, and app overrides are verified before the user relies on a run result.
finalrun check - Explain the exact or
finalrun testcommand you intend to use, including the selectedfinalrun suite,--env, and--platformwhen relevant.--model - Treat validation failures as blockers. Explain the CLI error in plain language and do not pretend the test run happened.
- Use to inspect recent run artifacts after validation or execution.
finalrun runs - Ask before starting , because those commands launch background UI behavior.
finalrun start-server - If the user wants to create or edit YAML tests, suites, or env bindings, route that work to .
finalrun-generate-test
- 当涉及命令执行时,先检查工作区并确认中包含可用的
PATH。finalrun - 首先使用进行验证,确保选择器、测试套件、配置、环境绑定和应用覆盖项都已校验通过,再让用户依赖运行结果。
finalrun check - 说明你将要使用的具体或
finalrun test命令,相关时需包含选定的finalrun suite、--env和--platform参数。--model - 将验证失败视为阻塞问题,用通俗易懂的语言解释CLI错误,不要假装测试已经运行。
- 验证或执行完成后,使用查看最近的运行产物。
finalrun runs - 启动前需询问用户,因为这类命令会启动后台UI行为。
finalrun start-server - 如果用户想要创建或编辑YAML测试、测试套件或环境绑定,将这类需求引导到。
finalrun-generate-test
Missing Workspace
工作区缺失处理
If is missing:
.finalrun/- explain that FinalRun must run from a repository containing
.finalrun/ - clarify that only is always required;
.finalrun/testsis only required for suite-based workflowssuites/ - show the expected structure
- offer a scaffold plan or route the user to
finalrun-generate-test - do not claim that the CLI can bootstrap the workspace automatically
Expected structure:
text
.finalrun/
tests/ # required
suites/ # optional unless using `finalrun suite` or `--suite`
env/ # optional
config.yaml # optional如果目录不存在:
.finalrun/- 说明FinalRun必须在包含的仓库中运行
.finalrun/ - 明确只有是必填项;
.finalrun/tests仅在基于测试套件的工作流中必填suites/ - 展示预期的目录结构
- 提供脚手架方案或引导用户使用
finalrun-generate-test - 不要宣称CLI可以自动初始化工作区
预期结构:
text
.finalrun/
tests/ # 必填
suites/ # 可选,仅使用`finalrun suite`或`--suite`时必填
env/ # 可选
config.yaml # 可选Validation and Error Handling
验证与错误处理
- is the default validation command.
finalrun check - Validation is mandatory before the user should trust a test run result.
- and
finalrun testare validation-gated. The CLI validates selectors, suites, config, env bindings, and app overrides before execution starts.finalrun suite - If or
finalrun testfails during validation, report the CLI error directly in plain language, explain what it means, and stop short of describing the run as executed.finalrun suite - Diagnose selector, suite, config, env, and binding problems from CLI output first. Do not guess.
Secret and credential errors require explicit user action:
- If is missing, malformed, or missing referenced bindings, explain the exact file or binding problem and tell the user to fix the env file or choose the correct
.finalrun/env/<env>.yaml.--env - If a secret placeholder is malformed, explain that FinalRun requires the exact form.
${ENV_VAR} - If a secret references a missing shell environment variable, state the missing variable name and tell the user they must export or set it before validation or execution can succeed.
- If a spec references an unknown or
${secrets.*}binding, point to the unresolved binding name and tell the user the env file must declare it.${variables.*} - If the provider API key is missing, report the exact required variable for the active model (,
OPENAI_API_KEY, orGOOGLE_API_KEY). When no default model is configured, recommend a repeat-use setup: addANTHROPIC_API_KEYwith.finalrun/config.yaml, addmodel: google/gemini-3-flash-previewtoexport GOOGLE_API_KEY=<your-key>, reload the shell with~/.zshrc, and rerun. Mentionsource ~/.zshrconly if the user asks for a one-off run.--api-key - Never invent, infer, write, or silently substitute secret values.
- 是默认的验证命令。
finalrun check - 用户信任测试运行结果之前必须完成验证。
- 和
finalrun test都有验证前置门槛,CLI会在执行开始前校验选择器、测试套件、配置、环境绑定和应用覆盖项。finalrun suite - 如果或
finalrun test在验证阶段失败,直接用通俗易懂的语言报告CLI错误,说明错误含义,不要将其描述为已执行完成。finalrun suite - 优先根据CLI输出诊断选择器、测试套件、配置、环境和绑定问题,不要猜测。
密钥和凭证错误需要用户明确操作:
- 如果缺失、格式错误或缺少引用的绑定项,说明具体的文件或绑定问题,告知用户修复环境文件或选择正确的
.finalrun/env/<env>.yaml。--env - 如果密钥占位符格式错误,说明FinalRun要求使用精确的格式。
${ENV_VAR} - 如果密钥引用了不存在的Shell环境变量,说明缺失的变量名,告知用户必须先导出或设置该变量,才能完成验证或执行。
- 如果规范引用了未知的或
${secrets.*}绑定,指出未解析的绑定名,告知用户必须在环境文件中声明该绑定。${variables.*} - 如果缺少服务商API密钥,说明当前激活模型对应的必填变量(、
OPENAI_API_KEY或GOOGLE_API_KEY)。如果未配置默认模型,推荐可重复使用的配置方案:在ANTHROPIC_API_KEY中添加.finalrun/config.yaml,在model: google/gemini-3-flash-preview中添加~/.zshrc,执行export GOOGLE_API_KEY=<your-key>重载Shell后重新运行。仅当用户要求单次运行时才提及source ~/.zshrc参数。--api-key - 永远不要杜撰、推断、写入或静默替换密钥值。
Safety Policy
安全策略
Safe to run without extra approval when the user asks:
finalrun checkfinalrun doctorfinalrun runs
Ask before executing:
finalrun testfinalrun suitefinalrun start-server
Why ask first:
- test execution can take time and may consume provider credits
- server commands can start background processes and open the browser
Prefer over , but mention that remains supported for compatibility.
finalrun suite <path>finalrun test --suite <path>finalrun test --suite <path>当用户提出以下请求时,无需额外批准即可安全运行:
finalrun checkfinalrun doctorfinalrun runs
执行以下命令前需询问用户:
finalrun testfinalrun suitefinalrun start-server
需要提前询问的原因:
- 测试执行可能耗时较长,还可能消耗服务商额度
- 服务端命令会启动后台进程并打开浏览器
优先使用而非,但需说明仍为兼容支持的用法。
finalrun suite <path>finalrun test --suite <path>finalrun test --suite <path>Command Reference
命令参考
Validation
验证类
finalrun check [selectors...]- validates the workspace, selectors, suite manifests, env bindings, and app overrides
.finalrun - supports ,
--env,--platform, and--app--suite - uses
.finalrun/config.yamlwhenenvis omitted--env
- validates the
finalrun check [selectors...]- 验证工作区、选择器、测试套件清单、环境绑定和应用覆盖项
.finalrun - 支持、
--env、--platform和--app参数--suite - 未指定时使用
--env中的.finalrun/config.yaml配置env
- 验证
Execution
执行类
finalrun test [selectors...]- runs one or more specs from
.finalrun/tests - supports ,
--env,--platform,--app,--suite,--api-key,--model, and--debug--max-iterations - uses
.finalrun/config.yamlandenvwhen those flags are omittedmodel - validates before execution starts
- runs one or more specs from
finalrun suite <suitePath>- runs one suite manifest from
.finalrun/suites - supports ,
--env,--platform,--app,--api-key,--model, and--debug--max-iterations - uses
.finalrun/config.yamlandenvwhen those flags are omittedmodel - validates before execution starts
- runs one suite manifest from
finalrun test [selectors...]- 运行中的一个或多个测试规范
.finalrun/tests - 支持、
--env、--platform、--app、--suite、--api-key、--model和--debug参数--max-iterations - 未指定相关参数时使用中的
.finalrun/config.yaml和env配置model - 执行开始前会先进行验证
- 运行
finalrun suite <suitePath>- 运行中的一个测试套件清单
.finalrun/suites - 支持、
--env、--platform、--app、--api-key、--model和--debug参数--max-iterations - 未指定相关参数时使用中的
.finalrun/config.yaml和env配置model - 执行开始前会先进行验证
- 运行
Diagnostics
诊断类
finalrun doctor- checks local Android and iOS host readiness
- supports
--platform
finalrun doctor- 检查本地Android和iOS主机环境就绪性
- 支持参数
--platform
Reports
报告类
finalrun runs- lists local run artifacts for the current workspace
- supports
--json
finalrun start-server- starts or reuses the local report UI for the current workspace
- supports and
--port--dev
Explicit CLI flags override defaults.
.finalrun/config.yamlfinalrun runs- 列出当前工作区的本地运行产物
- 支持参数
--json
finalrun start-server- 启动或复用当前工作区的本地报告UI
- 支持和
--port参数--dev
显式指定的CLI参数会覆盖的默认配置。
.finalrun/config.yamlCommon CLI Flags
常用CLI参数
--env <name>- used by ,
check, andtestsuite - selects
.finalrun/env/<name>.yaml
- used by
--platform <android|ios>- used by ,
check,test, andsuitedoctor - required when platform cannot be inferred from context or app override
- used by
--app <path>- used by ,
check, andtestsuite - implies Android and
.apkimplies iOS.app
- used by
--model <provider/model>- used by and
testsuite - required unless already defines
.finalrun/config.yamlmodel
- used by
--api-key <key>- used by and
testsuite - overrides provider-specific environment variables
- used by
--debug- used by and
testsuite - enables debug logging
- used by
--max-iterations <n>- used by and
testsuite - caps execution iterations before the run aborts
- used by
--suite <path>- used by and
checktest - on , remains a compatibility path; prefer
testfinalrun suite <path>
- used by
--port <n>- used by
start-server
- used by
--dev- used by
start-server - runs the report UI in development mode
- used by
--env <name>- 供、
check、test命令使用suite - 选择配置
.finalrun/env/<name>.yaml
- 供
--platform <android|ios>- 供、
check、test、suite命令使用doctor - 当无法从上下文或应用覆盖项推断平台时必填
- 供
--app <path>- 供、
check、test命令使用suite - 后缀对应Android,
.apk后缀对应iOS.app
- 供
--model <provider/model>- 供、
test命令使用suite - 除非已经定义了
.finalrun/config.yaml,否则必填model
- 供
--api-key <key>- 供、
test命令使用suite - 覆盖服务商对应的环境变量
- 供
--debug- 供、
test命令使用suite - 开启调试日志
- 供
--max-iterations <n>- 供、
test命令使用suite - 设置执行迭代次数上限,超过则终止运行
- 供
--suite <path>- 供、
check命令使用test - 在命令中属于兼容用法,优先使用
testfinalrun suite <path>
- 供
--port <n>- 供命令使用
start-server
- 供
--dev- 供命令使用
start-server - 以开发模式运行报告UI
- 供
Supported Providers and Models
支持的服务商与模型
- Supported providers are ,
openai, andgoogle.anthropic - Use models from the GPT-5 family and above.
openai/... - Use models from the Gemini 3 family and above.
google/... - Use models from the Claude Sonnet 4 / Opus 4 families and above.
anthropic/... - Verify the exact value with
provider/modelbefore using sample run commands.finalrun test --help
- 支持的服务商为、
openai和google。anthropic - 使用GPT-5及以上系列的模型。
openai/... - 使用Gemini 3及以上系列的模型。
google/... - 使用Claude Sonnet 4 / Opus 4及以上系列的模型。
anthropic/... - 使用示例运行命令前,通过确认准确的
finalrun test --help取值。provider/model
Common Workflows
常用工作流
Validate an existing workspace:
sh
finalrun check --env devRun one spec after validation:
sh
finalrun check auth/login.yaml --env dev --platform android
finalrun test auth/login.yaml --env dev --platform android --model google/gemini-3-flash-previewRun one suite after validation:
sh
finalrun check --suite smoke.yaml --env dev --platform ios
finalrun suite smoke.yaml --env dev --platform ios --model anthropic/claude-3-7-sonnetInspect recent runs:
sh
finalrun runsOpen the report UI:
sh
finalrun start-serverDiscover current command and model help:
sh
finalrun --help
finalrun test --help
finalrun suite --help验证现有工作区:
sh
finalrun check --env dev验证通过后运行单个测试规范:
sh
finalrun check auth/login.yaml --env dev --platform android
finalrun test auth/login.yaml --env dev --platform android --model google/gemini-3-flash-preview验证通过后运行单个测试套件:
sh
finalrun check --suite smoke.yaml --env dev --platform ios
finalrun suite smoke.yaml --env dev --platform ios --model anthropic/claude-3-7-sonnet查看最近运行记录:
sh
finalrun runs打开报告UI:
sh
finalrun start-server查看当前命令和模型帮助信息:
sh
finalrun --help
finalrun test --help
finalrun suite --helpTroubleshooting
问题排查
Diagnose from the actual CLI output first. Do not guess.
- Missing
.finalrun/- explain that FinalRun must run from a repository containing
.finalrun/
- explain that FinalRun must run from a repository containing
- Missing
.finalrun/tests/- explain that this directory is required by the CLI
- Missing or ambiguous env files
- verify whether exists
.finalrun/env/ - if multiple env files exist and the selection is ambiguous, tell the user to choose explicitly
--env <name>
- verify whether
- Unknown env bindings
- explain which or
${variables.*}bindings are unresolved${secrets.*} - tell the user the env file must declare them
- explain which
- Malformed or missing secrets
- malformed placeholders must use the exact form
${ENV_VAR} - missing shell environment variables must be exported by the user before validation or execution
- do not write or infer secret values
- malformed placeholders must use the exact
- Missing provider API keys
- uses
openai/...OPENAI_API_KEY - uses
google/...GOOGLE_API_KEY - uses
anthropic/...ANTHROPIC_API_KEY - recommend with
.finalrun/config.yamlwhen no default model is configuredmodel: google/gemini-3-flash-preview - recommend in
export GOOGLE_API_KEY=<your-key>for the default setup path~/.zshrc - tell the user to reload the shell with and rerun
source ~/.zshrc - mention only if they want a one-off run
--api-key
- Invalid
.finalrun/config.yaml- point to the YAML or config error directly
- Selector and suite resolution failures
- resolves from
finalrun test auth/login.yaml.finalrun/tests/auth/login.yaml - resolves from
finalrun suite smoke.yaml.finalrun/suites/smoke.yaml - explicit and
.finalrun/tests/...paths still work.finalrun/suites/...
- App override and platform mismatch
- overrides require Android
.apk - overrides require iOS
.app - tell the user to fix the path or mismatch instead of ignoring it
--platform
- Host readiness issues
- use as the default local environment diagnostic
finalrun doctor
- use
优先根据实际CLI输出诊断问题,不要猜测。
- 缺少目录
.finalrun/- 说明FinalRun必须在包含的仓库中运行
.finalrun/
- 说明FinalRun必须在包含
- 缺少目录
.finalrun/tests/- 说明该目录是CLI必填项
- 环境文件缺失或存在歧义
- 确认是否存在
.finalrun/env/ - 如果存在多个环境文件且选择不明确,告知用户显式指定
--env <name>
- 确认
- 未知环境绑定
- 说明哪些或
${variables.*}绑定未解析${secrets.*} - 告知用户必须在环境文件中声明这些绑定
- 说明哪些
- 密钥格式错误或缺失
- 格式错误的占位符必须使用精确的格式
${ENV_VAR} - 缺失的Shell环境变量必须由用户在验证或执行前导出
- 不要写入或推断密钥值
- 格式错误的占位符必须使用精确的
- 缺少服务商API密钥
- 模型使用
openai/...OPENAI_API_KEY - 模型使用
google/...GOOGLE_API_KEY - 模型使用
anthropic/...ANTHROPIC_API_KEY - 未配置默认模型时,推荐在中添加
.finalrun/config.yamlmodel: google/gemini-3-flash-preview - 推荐默认配置路径为在中添加
~/.zshrcexport GOOGLE_API_KEY=<your-key> - 告知用户执行重载Shell后重新运行
source ~/.zshrc - 仅当用户需要单次运行时提及参数
--api-key
- 无效
.finalrun/config.yaml- 直接指出YAML或配置错误
- 选择器和测试套件解析失败
- 会从
finalrun test auth/login.yaml解析.finalrun/tests/auth/login.yaml - 会从
finalrun suite smoke.yaml解析.finalrun/suites/smoke.yaml - 显式指定和
.finalrun/tests/...路径也可正常工作.finalrun/suites/...
- 应用覆盖项与平台不匹配
- 覆盖项要求Android平台
.apk - 覆盖项要求iOS平台
.app - 告知用户修复路径或不匹配问题,不要忽略该错误
--platform
- 主机环境就绪性问题
- 使用作为默认本地环境诊断工具
finalrun doctor
- 使用
Coordination with finalrun-generate-test
finalrun-generate-test与finalrun-generate-test
的协同
finalrun-generate-testThis skill is for CLI usage, validation, execution, reporting, and troubleshooting.
If the user asks to:
- create a new YAML test
- update a suite manifest
- add or change bindings
.finalrun/env/*.yaml - plan a new test flow
route that work to .
finalrun-generate-testThis skill may explain where the CLI expects those files and how selectors resolve, but it should not duplicate the YAML authoring workflow.
本技能用于CLI使用、验证、执行、报告和问题排查。
如果用户请求以下操作:
- 创建新的YAML测试
- 更新测试套件清单
- 添加或修改绑定
.finalrun/env/*.yaml - 规划新的测试流程
将这类工作引导到。
finalrun-generate-test本技能可以说明CLI对这些文件的预期位置以及选择器的解析规则,但不应重复YAML编写工作流的功能。